diff --git a/.gitignore b/.gitignore
index 1d9289f..b62ce7d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-SOURCES/libvirt-3.2.0.tar.xz
+SOURCES/libvirt-3.9.0.tar.xz
diff --git a/.libvirt.metadata b/.libvirt.metadata
index e2e8aba..0db550c 100644
--- a/.libvirt.metadata
+++ b/.libvirt.metadata
@@ -1 +1 @@
-47d4b443fdf1e268589529018c436bbc4b413a7c SOURCES/libvirt-3.2.0.tar.xz
+7aae5bfdbc859234833464a7faaa2a1cc0c2775e SOURCES/libvirt-3.9.0.tar.xz
diff --git a/SOURCES/libvirt-Add-VIR_DOMAIN_JOB_OPERATION-typed-parameter.patch b/SOURCES/libvirt-Add-VIR_DOMAIN_JOB_OPERATION-typed-parameter.patch
deleted file mode 100644
index adafe29..0000000
--- a/SOURCES/libvirt-Add-VIR_DOMAIN_JOB_OPERATION-typed-parameter.patch
+++ /dev/null
@@ -1,114 +0,0 @@
-From 16dad808f19120275bc57e952968840417e0d091 Mon Sep 17 00:00:00 2001
-Message-Id: <16dad808f19120275bc57e952968840417e0d091@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 26 Apr 2017 11:59:59 +0200
-Subject: [PATCH] Add VIR_DOMAIN_JOB_OPERATION typed parameter
-
-The parameter is reported by virDomainGetJobStats API and
-VIR_DOMAIN_EVENT_ID_JOB_COMPLETED event and it can be used to identify
-the operation (migration, snapshot, ...) to which the reported
-statistics belong.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441563
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit b1c79d785f9385eb4ebd5e71d1d44e67f744f4d9)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- include/libvirt/libvirt-domain.h | 25 +++++++++++++++++++++++++
- tools/virsh-domain.c             | 29 +++++++++++++++++++++++++++++
- 2 files changed, 54 insertions(+)
-
-diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
-index 501996bc8..c9e96a6c9 100644
---- a/include/libvirt/libvirt-domain.h
-+++ b/include/libvirt/libvirt-domain.h
-@@ -3117,6 +3117,31 @@ int virDomainGetJobStats(virDomainPtr domain,
-                          unsigned int flags);
- int virDomainAbortJob(virDomainPtr dom);
- 
-+typedef enum {
-+    VIR_DOMAIN_JOB_OPERATION_UNKNOWN = 0,
-+    VIR_DOMAIN_JOB_OPERATION_START = 1,
-+    VIR_DOMAIN_JOB_OPERATION_SAVE = 2,
-+    VIR_DOMAIN_JOB_OPERATION_RESTORE = 3,
-+    VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN = 4,
-+    VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT = 5,
-+    VIR_DOMAIN_JOB_OPERATION_SNAPSHOT = 6,
-+    VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_REVERT = 7,
-+    VIR_DOMAIN_JOB_OPERATION_DUMP = 8,
-+
-+# ifdef VIR_ENUM_SENTINELS
-+    VIR_DOMAIN_JOB_OPERATION_LAST
-+# endif
-+} virDomainJobOperation;
-+
-+/**
-+ * VIR_DOMAIN_JOB_OPERATION:
-+ *
-+ * virDomainGetJobStats field: the operation which started the job as
-+ * VIR_TYPED_PARAM_INT. The values correspond to the items in
-+ * virDomainJobOperation enum.
-+ */
-+# define VIR_DOMAIN_JOB_OPERATION                "operation"
-+
- /**
-  * VIR_DOMAIN_JOB_TIME_ELAPSED:
-  *
-diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
-index 4b6c13ce4..bc0ded686 100644
---- a/tools/virsh-domain.c
-+++ b/tools/virsh-domain.c
-@@ -5754,6 +5754,26 @@ virshDomainJobToString(int type)
-     return str ? _(str) : _("unknown");
- }
- 
-+VIR_ENUM_DECL(virshDomainJobOperation);
-+VIR_ENUM_IMPL(virshDomainJobOperation,
-+              VIR_DOMAIN_JOB_OPERATION_LAST,
-+              N_("Unknown"),
-+              N_("Start"),
-+              N_("Save"),
-+              N_("Restore"),
-+              N_("Incoming migration"),
-+              N_("Outgoing migration"),
-+              N_("Snapshot"),
-+              N_("Snapshot revert"),
-+              N_("Dump"))
-+
-+static const char *
-+virshDomainJobOperationToString(int op)
-+{
-+    const char *str = virshDomainJobOperationTypeToString(op);
-+    return str ? _(str) : _("unknown");
-+}
-+
- static bool
- cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
- {
-@@ -5767,6 +5787,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
-     unsigned long long value;
-     unsigned int flags = 0;
-     int ivalue;
-+    int op;
-     int rc;
- 
-     if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
-@@ -5836,6 +5857,14 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
-         goto cleanup;
-     }
- 
-+    op = VIR_DOMAIN_JOB_OPERATION_UNKNOWN;
-+    if ((rc = virTypedParamsGetInt(params, nparams,
-+                                   VIR_DOMAIN_JOB_OPERATION, &op)) < 0)
-+        goto save_error;
-+
-+    vshPrint(ctl, "%-17s %-12s\n", _("Operation:"),
-+             virshDomainJobOperationToString(op));
-+
-     vshPrint(ctl, "%-17s %-12llu ms\n", _("Time elapsed:"), info.timeElapsed);
-     if ((rc = virTypedParamsGetULLong(params, nparams,
-                                       VIR_DOMAIN_JOB_TIME_ELAPSED_NET,
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-Add-support-for-CPU-cache-specification.patch b/SOURCES/libvirt-Add-support-for-CPU-cache-specification.patch
deleted file mode 100644
index 2906ff9..0000000
--- a/SOURCES/libvirt-Add-support-for-CPU-cache-specification.patch
+++ /dev/null
@@ -1,389 +0,0 @@
-From a5cb43154905e2708bf90988bd2aa5f2fca6b935 Mon Sep 17 00:00:00 2001
-Message-Id: <a5cb43154905e2708bf90988bd2aa5f2fca6b935@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Mon, 24 Apr 2017 15:40:07 +0200
-Subject: [PATCH] Add support for CPU cache specification
-
-This patch introduces
-
-    <cache level='N' mode='emulate'/>
-    <cache mode='passthrough'/>
-    <cache mode='disable'/>
-
-sub element of /domain/cpu. Currently only a single <cache> element is
-allowed.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit a646a6016a7c62688988f7cfaa22e1340c2ce761)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1428952
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                          | 35 ++++++++++++
- docs/schemas/cputypes.rng                          | 21 ++++++++
- docs/schemas/domaincommon.rng                      |  3 ++
- src/conf/cpu_conf.c                                | 62 ++++++++++++++++++++++
- src/conf/cpu_conf.h                                | 19 +++++++
- src/libvirt_private.syms                           |  2 +
- .../generic-cpu-cache-disable.xml                  | 20 +++++++
- .../generic-cpu-cache-emulate.xml                  | 20 +++++++
- .../generic-cpu-cache-passthrough.xml              | 20 +++++++
- tests/genericxml2xmltest.c                         |  4 ++
- 10 files changed, 206 insertions(+)
- create mode 100644 tests/genericxml2xmlindata/generic-cpu-cache-disable.xml
- create mode 100644 tests/genericxml2xmlindata/generic-cpu-cache-emulate.xml
- create mode 100644 tests/genericxml2xmlindata/generic-cpu-cache-passthrough.xml
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index aae5e9c07..aee1e1442 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -1198,6 +1198,7 @@
-   &lt;model fallback='allow'&gt;core2duo&lt;/model&gt;
-   &lt;vendor&gt;Intel&lt;/vendor&gt;
-   &lt;topology sockets='1' cores='2' threads='1'/&gt;
-+  &lt;cache level='3' mode='emulate'/&gt;
-   &lt;feature policy='disable' name='lahf_lm'/&gt;
- &lt;/cpu&gt;
- ...</pre>
-@@ -1211,6 +1212,7 @@
- 
- <pre>
- &lt;cpu mode='host-passthrough'&gt;
-+  &lt;cache mode='passthrough'/&gt;
-   &lt;feature policy='disable' name='lahf_lm'/&gt;
- ...</pre>
- 
-@@ -1431,6 +1433,39 @@
-         <span class="since">Since 0.8.5</span> the <code>policy</code>
-         attribute can be omitted and will default to <code>require</code>.
-       </dd>
-+
-+      <dt><code>cache</code></dt>
-+      <dd><span class="since">Since 3.3.0</span> the <code>cache</code>
-+        element describes the virtual CPU cache. If the element is missing,
-+        the hypervisor will use a sensible default.
-+
-+        <dl>
-+          <dt><code>level</code></dt>
-+          <dd>This optional attribute specifies which cache level is described
-+            by the element. Missing attribute means the element describes all
-+            CPU cache levels at once. Mixing <code>cache</code> elements with
-+            the <code>level</code> attribute set and those without the
-+            attribute is forbidden.</dd>
-+
-+          <dt><code>mode</code></dt>
-+          <dd>
-+            The following values are supported:
-+            <dl>
-+              <dt><code>emulate</code></dt>
-+              <dd>The hypervisor will provide a fake CPU cache data.</dd>
-+
-+              <dt><code>passthrough</code></dt>
-+              <dd>The real CPU cache data reported by the host CPU will be
-+                passed through to the virtual CPU.</dd>
-+
-+              <dt><code>disable</code></dt>
-+              <dd>The virtual CPU will report no CPU cache of the specified
-+                level (or no cache at all if the <code>level</code> attribute
-+                is missing).</dd>
-+            </dl>
-+          </dd>
-+        </dl>
-+      </dd>
-     </dl>
- 
-     <p>
-diff --git a/docs/schemas/cputypes.rng b/docs/schemas/cputypes.rng
-index 8189114e3..3eef16abc 100644
---- a/docs/schemas/cputypes.rng
-+++ b/docs/schemas/cputypes.rng
-@@ -142,4 +142,25 @@
-     </data>
-   </define>
- 
-+  <define name="cpuCache">
-+    <element name="cache">
-+      <optional>
-+        <attribute name="level">
-+          <choice>
-+            <value>1</value>
-+            <value>2</value>
-+            <value>3</value>
-+          </choice>
-+        </attribute>
-+      </optional>
-+      <attribute name="mode">
-+        <choice>
-+          <value>emulate</value>
-+          <value>passthrough</value>
-+          <value>disable</value>
-+        </choice>
-+      </attribute>
-+    </element>
-+  </define>
-+
- </grammar>
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index edc225fe5..d5c28ee3c 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -4545,6 +4545,9 @@
-         <optional>
-           <ref name="cpuNuma"/>
-         </optional>
-+        <optional>
-+          <ref name="cpuCache"/>
-+        </optional>
-       </interleave>
-     </element>
-   </define>
-diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
-index 623b1699f..1b098c476 100644
---- a/src/conf/cpu_conf.c
-+++ b/src/conf/cpu_conf.c
-@@ -62,6 +62,12 @@ VIR_ENUM_IMPL(virCPUFeaturePolicy, VIR_CPU_FEATURE_LAST,
-               "disable",
-               "forbid")
- 
-+VIR_ENUM_IMPL(virCPUCacheMode, VIR_CPU_CACHE_MODE_LAST,
-+              "emulate",
-+              "passthrough",
-+              "disable")
-+
-+
- void
- virCPUDefFreeFeatures(virCPUDefPtr def)
- {
-@@ -92,6 +98,7 @@ virCPUDefFree(virCPUDefPtr def)
-         return;
- 
-     virCPUDefFreeModel(def);
-+    VIR_FREE(def->cache);
-     VIR_FREE(def);
- }
- 
-@@ -204,7 +211,18 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu)
-     copy->threads = cpu->threads;
-     copy->arch = cpu->arch;
- 
-+    if (cpu->cache) {
-+        if (VIR_ALLOC(copy->cache) < 0)
-+            goto error;
-+
-+        *copy->cache = *cpu->cache;
-+    }
-+
-     return copy;
-+
-+ error:
-+    virCPUDefFree(copy);
-+    return NULL;
- }
- 
- 
-@@ -489,6 +507,41 @@ virCPUDefParseXML(xmlNodePtr node,
-         def->features[i].policy = policy;
-     }
- 
-+    if (virXPathInt("count(./cache)", ctxt, &n) < 0) {
-+        goto cleanup;
-+    } else if (n > 1) {
-+        virReportError(VIR_ERR_XML_ERROR, "%s",
-+                       _("at most one CPU cache element may be specified"));
-+        goto cleanup;
-+    } else if (n == 1) {
-+        int level = -1;
-+        char *strmode;
-+        int mode;
-+
-+        if (virXPathBoolean("boolean(./cache[1]/@level)", ctxt) == 1 &&
-+            (virXPathInt("string(./cache[1]/@level)", ctxt, &level) < 0 ||
-+             level < 1 || level > 3)) {
-+            virReportError(VIR_ERR_XML_ERROR, "%s",
-+                           _("invalid CPU cache level, must be in range [1,3]"));
-+            goto cleanup;
-+        }
-+
-+        if (!(strmode = virXPathString("string(./cache[1]/@mode)", ctxt)) ||
-+            (mode = virCPUCacheModeTypeFromString(strmode)) < 0) {
-+            VIR_FREE(strmode);
-+            virReportError(VIR_ERR_XML_ERROR, "%s",
-+                           _("missing or invalid CPU cache mode"));
-+            goto cleanup;
-+        }
-+        VIR_FREE(strmode);
-+
-+        if (VIR_ALLOC(def->cache) < 0)
-+            goto cleanup;
-+
-+        def->cache->level = level;
-+        def->cache->mode = mode;
-+    }
-+
-  cleanup:
-     ctxt->node = oldnode;
-     VIR_FREE(fallback);
-@@ -662,6 +715,15 @@ virCPUDefFormatBuf(virBufferPtr buf,
-         virBufferAddLit(buf, "/>\n");
-     }
- 
-+    if (def->cache) {
-+        virBufferAddLit(buf, "<cache ");
-+        if (def->cache->level != -1)
-+            virBufferAsprintf(buf, "level='%d' ", def->cache->level);
-+        virBufferAsprintf(buf, "mode='%s'",
-+                          virCPUCacheModeTypeToString(def->cache->mode));
-+        virBufferAddLit(buf, "/>\n");
-+    }
-+
-     for (i = 0; i < def->nfeatures; i++) {
-         virCPUFeatureDefPtr feature = def->features + i;
- 
-diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
-index 3e02deed4..09438b68b 100644
---- a/src/conf/cpu_conf.h
-+++ b/src/conf/cpu_conf.h
-@@ -103,6 +103,24 @@ struct _virCPUFeatureDef {
- };
- 
- 
-+typedef enum {
-+    VIR_CPU_CACHE_MODE_EMULATE,
-+    VIR_CPU_CACHE_MODE_PASSTHROUGH,
-+    VIR_CPU_CACHE_MODE_DISABLE,
-+
-+    VIR_CPU_CACHE_MODE_LAST
-+} virCPUCacheMode;
-+
-+VIR_ENUM_DECL(virCPUCacheMode);
-+
-+typedef struct _virCPUCacheDef virCPUCacheDef;
-+typedef virCPUCacheDef *virCPUCacheDefPtr;
-+struct _virCPUCacheDef {
-+    int level;          /* -1 for unspecified */
-+    virCPUCacheMode mode;
-+};
-+
-+
- typedef struct _virCPUDef virCPUDef;
- typedef virCPUDef *virCPUDefPtr;
- struct _virCPUDef {
-@@ -121,6 +139,7 @@ struct _virCPUDef {
-     size_t nfeatures;
-     size_t nfeatures_max;
-     virCPUFeatureDefPtr features;
-+    virCPUCacheDefPtr cache;
- };
- 
- 
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index b551cb86a..9a334311d 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -67,6 +67,8 @@ virCapabilitiesSetNetPrefix;
- 
- 
- # conf/cpu_conf.h
-+virCPUCacheModeTypeFromString;
-+virCPUCacheModeTypeToString;
- virCPUDefAddFeature;
- virCPUDefCopy;
- virCPUDefCopyModel;
-diff --git a/tests/genericxml2xmlindata/generic-cpu-cache-disable.xml b/tests/genericxml2xmlindata/generic-cpu-cache-disable.xml
-new file mode 100644
-index 000000000..25f65cc6e
---- /dev/null
-+++ b/tests/genericxml2xmlindata/generic-cpu-cache-disable.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='i686' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-passthrough'>
-+    <cache mode='disable'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/genericxml2xmlindata/generic-cpu-cache-emulate.xml b/tests/genericxml2xmlindata/generic-cpu-cache-emulate.xml
-new file mode 100644
-index 000000000..6ea57cbf6
---- /dev/null
-+++ b/tests/genericxml2xmlindata/generic-cpu-cache-emulate.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='i686' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-passthrough'>
-+    <cache level='3' mode='emulate'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/genericxml2xmlindata/generic-cpu-cache-passthrough.xml b/tests/genericxml2xmlindata/generic-cpu-cache-passthrough.xml
-new file mode 100644
-index 000000000..8d4c186c9
---- /dev/null
-+++ b/tests/genericxml2xmlindata/generic-cpu-cache-passthrough.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='i686' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-passthrough'>
-+    <cache mode='passthrough'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
-index 488190270..ab1ebce9f 100644
---- a/tests/genericxml2xmltest.c
-+++ b/tests/genericxml2xmltest.c
-@@ -100,6 +100,10 @@ mymain(void)
- 
-     DO_TEST("vcpus-individual");
- 
-+    DO_TEST("cpu-cache-emulate");
-+    DO_TEST("cpu-cache-passthrough");
-+    DO_TEST("cpu-cache-disable");
-+
-     virObjectUnref(caps);
-     virObjectUnref(xmlopt);
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-Add-support-for-virtio-net.tx_queue_size.patch b/SOURCES/libvirt-Add-support-for-virtio-net.tx_queue_size.patch
deleted file mode 100644
index 7e04950..0000000
--- a/SOURCES/libvirt-Add-support-for-virtio-net.tx_queue_size.patch
+++ /dev/null
@@ -1,317 +0,0 @@
-From 9b3184784e1243a81a4b8de350fb0434a1ad1f28 Mon Sep 17 00:00:00 2001
-Message-Id: <9b3184784e1243a81a4b8de350fb0434a1ad1f28@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Fri, 18 Aug 2017 09:35:54 +0200
-Subject: [PATCH] Add support for virtio-net.tx_queue_size
-
-RHEL-7.5:   https://bugzilla.redhat.com/show_bug.cgi?id=1462653
-RHEL-7.4.z: https://bugzilla.redhat.com/show_bug.cgi?id=1482514
-
-Just like I've added support for setting rx_queue_size (in
-c56cdf259 and friends), qemu just gained support for setting tx
-ring size.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-(cherry picked from commit 2074ef6cd4a2e033813ec091487d027a85f73509)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-
-Conflicts:
-      src/qemu/qemu_capabilities.c:
-      src/qemu/qemu_capabilities.h: Context because of some caps
-                                    missing
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                                | 15 ++++++++++++++-
- docs/schemas/domaincommon.rng                            |  5 +++++
- src/conf/domain_conf.c                                   | 16 ++++++++++++++++
- src/conf/domain_conf.h                                   |  1 +
- src/qemu/qemu_capabilities.c                             |  2 ++
- src/qemu/qemu_capabilities.h                             |  1 +
- src/qemu/qemu_command.c                                  |  8 ++++++++
- src/qemu/qemu_domain.c                                   | 16 +++++++++++-----
- ...e.args => qemuxml2argv-net-virtio-rxtxqueuesize.args} |  4 ++--
- ...ize.xml => qemuxml2argv-net-virtio-rxtxqueuesize.xml} |  2 +-
- tests/qemuxml2argvtest.c                                 |  5 +++--
- ...e.xml => qemuxml2xmlout-net-virtio-rxtxqueuesize.xml} |  2 +-
- tests/qemuxml2xmltest.c                                  |  2 +-
- 13 files changed, 66 insertions(+), 13 deletions(-)
- rename tests/qemuxml2argvdata/{qemuxml2argv-net-virtio-rxqueuesize.args => qemuxml2argv-net-virtio-rxtxqueuesize.args} (83%)
- rename tests/qemuxml2argvdata/{qemuxml2argv-net-virtio-rxqueuesize.xml => qemuxml2argv-net-virtio-rxtxqueuesize.xml} (93%)
- rename tests/qemuxml2xmloutdata/{qemuxml2xmlout-net-virtio-rxqueuesize.xml => qemuxml2xmlout-net-virtio-rxtxqueuesize.xml} (96%)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index dc8e7d2dc7..024debe862 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -5038,7 +5038,7 @@ qemu-kvm -net nic,model=? /dev/null
-     &lt;source network='default'/&gt;
-     &lt;target dev='vnet1'/&gt;
-     &lt;model type='virtio'/&gt;
--    <b>&lt;driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5' rx_queue_size='256'&gt;
-+    <b>&lt;driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5' rx_queue_size='256' tx_queue_size='256'&gt;
-       &lt;host csum='off' gso='off' tso4='off' tso6='off' ecn='off' ufo='off' mrg_rxbuf='off'/&gt;
-       &lt;guest csum='off' tso4='off' tso6='off' ecn='off' ufo='off'/&gt;
-     &lt;/driver&gt;
-@@ -5168,6 +5168,19 @@ qemu-kvm -net nic,model=? /dev/null
-         <b>In general you should leave this option alone, unless you
-         are very certain you know what you are doing.</b>
-       </dd>
-+      <dt><code>tx_queue_size</code></dt>
-+      <dd>
-+        The optional <code>tx_queue_size</code> attribute controls
-+        the size of virtio ring for each queue as described above.
-+        The default value is hypervisor dependent and may change
-+        across its releases. Moreover, some hypervisors may pose
-+        some restrictions on actual value. For instance, QEMU
-+        v2.9  requires value to be a power of two from [256, 1024] range.
-+        <span class="since">Since 3.7.0 (QEMU and KVM only)</span><br/><br/>
-+
-+        <b>In general you should leave this option alone, unless you
-+        are very certain you know what you are doing.</b>
-+      </dd>
-       <dt>virtio options</dt>
-       <dd>
-         For virtio interfaces,
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index 78023ff4af..bb077ed5a0 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -2619,6 +2619,11 @@
-                   <ref name='positiveInteger'/>
-                 </attribute>
-               </optional>
-+              <optional>
-+                <attribute name='tx_queue_size'>
-+                  <ref name='positiveInteger'/>
-+                </attribute>
-+              </optional>
-               <optional>
-                 <attribute name="txmode">
-                   <choice>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index d8ca25da38..806582fb8f 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -9721,6 +9721,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
-     char *event_idx = NULL;
-     char *queues = NULL;
-     char *rx_queue_size = NULL;
-+    char *tx_queue_size = NULL;
-     char *str = NULL;
-     char *filter = NULL;
-     char *internal = NULL;
-@@ -9894,6 +9895,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
-                 event_idx = virXMLPropString(cur, "event_idx");
-                 queues = virXMLPropString(cur, "queues");
-                 rx_queue_size = virXMLPropString(cur, "rx_queue_size");
-+                tx_queue_size = virXMLPropString(cur, "tx_queue_size");
-             } else if (xmlStrEqual(cur->name, BAD_CAST "filterref")) {
-                 if (filter) {
-                     virReportError(VIR_ERR_XML_ERROR, "%s",
-@@ -10291,6 +10293,16 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
-             }
-             def->driver.virtio.rx_queue_size = q;
-         }
-+        if (tx_queue_size) {
-+            unsigned int q;
-+            if (virStrToLong_uip(tx_queue_size, NULL, 10, &q) < 0) {
-+                virReportError(VIR_ERR_XML_DETAIL,
-+                               _("'tx_queue_size' attribute must be positive number: %s"),
-+                               tx_queue_size);
-+                goto error;
-+            }
-+            def->driver.virtio.tx_queue_size = q;
-+        }
-         if ((str = virXPathString("string(./driver/host/@csum)", ctxt))) {
-             if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
-                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-@@ -10488,6 +10500,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
-     VIR_FREE(event_idx);
-     VIR_FREE(queues);
-     VIR_FREE(rx_queue_size);
-+    VIR_FREE(tx_queue_size);
-     VIR_FREE(str);
-     VIR_FREE(filter);
-     VIR_FREE(type);
-@@ -22264,6 +22277,9 @@ virDomainVirtioNetDriverFormat(char **outstr,
-     if (def->driver.virtio.rx_queue_size)
-         virBufferAsprintf(&buf, " rx_queue_size='%u'",
-                           def->driver.virtio.rx_queue_size);
-+    if (def->driver.virtio.tx_queue_size)
-+        virBufferAsprintf(&buf, " tx_queue_size='%u'",
-+                          def->driver.virtio.tx_queue_size);
- 
-     virDomainVirtioOptionsFormat(&buf, def->virtio);
- 
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 4c33b0d15e..7372a52856 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -967,6 +967,7 @@ struct _virDomainNetDef {
-             virTristateSwitch event_idx;
-             unsigned int queues; /* Multiqueue virtio-net */
-             unsigned int rx_queue_size;
-+            unsigned int tx_queue_size;
-             struct {
-                 virTristateSwitch csum;
-                 virTristateSwitch gso;
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index f22c11941c..6f8b1ac735 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -376,6 +376,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
-               "intel-iommu.device-iotlb", /* 260 */
-               "virtio.iommu_platform",
-               "virtio.ats",
-+              "virtio-net.tx_queue_size",
-     );
- 
- 
-@@ -1642,6 +1643,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioNet[] = {
-     { "tx", QEMU_CAPS_VIRTIO_TX_ALG },
-     { "event_idx", QEMU_CAPS_VIRTIO_NET_EVENT_IDX },
-     { "rx_queue_size", QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE },
-+    { "tx_queue_size", QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE },
-     { "host_mtu", QEMU_CAPS_VIRTIO_NET_HOST_MTU },
- };
- 
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index c28c80d40a..281fe7d483 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -415,6 +415,7 @@ typedef enum {
-     QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB, /* intel-iommu.device-iotlb */
-     QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, /* virtio-*-pci.iommu_platform */
-     QEMU_CAPS_VIRTIO_PCI_ATS, /* virtio-*-pci.ats */
-+    QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE, /* virtio-net-*.tx_queue_size */
- 
-     QEMU_CAPS_LAST /* this must always be the last item */
- } virQEMUCapsFlags;
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index a4184b7378..f16029aa83 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -3788,6 +3788,14 @@ qemuBuildNicDevStr(virDomainDefPtr def,
-         }
-         virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size);
-     }
-+    if (usingVirtio && net->driver.virtio.tx_queue_size) {
-+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE)) {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                           _("virtio tx_queue_size option is not supported with this QEMU binary"));
-+            goto error;
-+        }
-+        virBufferAsprintf(&buf, ",tx_queue_size=%u", net->driver.virtio.tx_queue_size);
-+    }
- 
-     if (usingVirtio && net->mtu) {
-         if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) {
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index c9c668b892..a41657099f 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -3121,11 +3121,17 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
-             goto cleanup;
-         }
- 
--        if (STREQ_NULLABLE(net->model, "virtio") &&
--            net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queue_size - 1)) {
--            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
--                           _("rx_queue_size has to be a power of two"));
--            goto cleanup;
-+        if (STREQ_NULLABLE(net->model, "virtio")) {
-+            if (net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queue_size - 1)) {
-+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                               _("rx_queue_size has to be a power of two"));
-+                goto cleanup;
-+            }
-+            if (net->driver.virtio.tx_queue_size & (net->driver.virtio.tx_queue_size - 1)) {
-+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                               _("tx_queue_size has to be a power of two"));
-+                goto cleanup;
-+            }
-         }
- 
-         if (net->mtu &&
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.args
-similarity index 83%
-rename from tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args
-rename to tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.args
-index 7d275a723d..68b87b4ffe 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.args
-@@ -19,7 +19,7 @@ QEMU_AUDIO_DRV=none \
- -usb \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
- -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
---device virtio-net-pci,rx_queue_size=512,vlan=0,id=net0,mac=00:11:22:33:44:55,\
--bus=pci.0,addr=0x3 \
-+-device virtio-net-pci,rx_queue_size=512,tx_queue_size=1024,vlan=0,id=net0,\
-+mac=00:11:22:33:44:55,bus=pci.0,addr=0x3 \
- -net user,vlan=0,name=hostnet0 \
- -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.xml
-similarity index 93%
-rename from tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml
-rename to tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.xml
-index cfb4742fc6..14d357bba3 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.xml
-@@ -22,7 +22,7 @@
-     <interface type='user'>
-       <mac address='00:11:22:33:44:55'/>
-       <model type='virtio'/>
--      <driver rx_queue_size='512'/>
-+      <driver rx_queue_size='512' tx_queue_size='1024'/>
-     </interface>
-     <memballoon model='virtio'/>
-   </devices>
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 5ca27f105d..827fe90239 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -1145,8 +1145,9 @@ mymain(void)
-             QEMU_CAPS_VIRTIO_S390);
-     DO_TEST("net-virtio-ccw",
-             QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
--    DO_TEST("net-virtio-rxqueuesize",
--            QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE);
-+    DO_TEST("net-virtio-rxtxqueuesize",
-+            QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE,
-+            QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE);
-     DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE);
-     DO_TEST("net-eth", NONE);
-     DO_TEST("net-eth-ifname", NONE);
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxtxqueuesize.xml
-similarity index 96%
-rename from tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml
-rename to tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxtxqueuesize.xml
-index 5b41936063..34e1e40012 100644
---- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxtxqueuesize.xml
-@@ -29,7 +29,7 @@
-     <interface type='user'>
-       <mac address='00:11:22:33:44:55'/>
-       <model type='virtio'/>
--      <driver rx_queue_size='512'/>
-+      <driver rx_queue_size='512' tx_queue_size='1024'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
-     </interface>
-     <input type='mouse' bus='ps2'/>
-diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
-index f2abad00cf..62bce8d240 100644
---- a/tests/qemuxml2xmltest.c
-+++ b/tests/qemuxml2xmltest.c
-@@ -523,7 +523,7 @@ mymain(void)
-     DO_TEST("net-eth-ifname", NONE);
-     DO_TEST("net-eth-hostip", NONE);
-     DO_TEST("net-virtio-network-portgroup", NONE);
--    DO_TEST("net-virtio-rxqueuesize", NONE);
-+    DO_TEST("net-virtio-rxtxqueuesize", NONE);
-     DO_TEST("net-hostdev", NONE);
-     DO_TEST("net-hostdev-vfio", NONE);
-     DO_TEST("net-midonet", NONE);
--- 
-2.14.1
-
diff --git a/SOURCES/libvirt-Add-virtio-related-options-to-controllers.patch b/SOURCES/libvirt-Add-virtio-related-options-to-controllers.patch
deleted file mode 100644
index f494336..0000000
--- a/SOURCES/libvirt-Add-virtio-related-options-to-controllers.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From e0bb36c4d7c60336d2aba94013c2946e1594959b Mon Sep 17 00:00:00 2001
-Message-Id: <e0bb36c4d7c60336d2aba94013c2946e1594959b@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:49:03 +0200
-Subject: [PATCH] Add virtio-related options to controllers
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit c85217cf8a81879d065b9d13e876eec141f63f6f)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                              |  6 ++++++
- docs/schemas/domaincommon.rng                          |  1 +
- src/conf/domain_conf.c                                 | 10 ++++++++++
- src/conf/domain_conf.h                                 |  1 +
- tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml |  2 ++
- 5 files changed, 20 insertions(+)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index bb7a85a1a1..2b26f090cd 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -3597,6 +3597,12 @@
-         <code>iothread</code> value. The <code>iothread</code> value
-         must be within the range 1 to the domain iothreads value.
-       </dd>
-+      <dt>virtio options</dt>
-+      <dd>
-+        For virtio controllers,
-+        <a href="#elementsVirtio">Virtio-specific options</a> can also be
-+        set. (<span class="since">Since 3.5.0</span>)
-+      </dd>
-     </dl>
-     <p>
-       USB companion controllers have an optional
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index f838dc55fd..2108d23df7 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -2019,6 +2019,7 @@
-             <optional>
-               <ref name="driverIOThread"/>
-             </optional>
-+            <ref name="virtioOptions"/>
-           </element>
-         </optional>
-       </interleave>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index a4b4f70855..2e5eeb1172 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -1873,6 +1873,7 @@ void virDomainControllerDefFree(virDomainControllerDefPtr def)
-         return;
- 
-     virDomainDeviceInfoClear(&def->info);
-+    VIR_FREE(def->virtio);
- 
-     VIR_FREE(def);
- }
-@@ -9037,6 +9038,9 @@ virDomainControllerDefParseXML(xmlNodePtr node,
-         cur = cur->next;
-     }
- 
-+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
-+        goto error;
-+
-     /* node is parsed differently from target attributes because
-      * someone thought it should be a subelement instead...
-      */
-@@ -19214,6 +19218,10 @@ virDomainControllerDefCheckABIStability(virDomainControllerDefPtr src,
-         }
-     }
- 
-+    if (src->virtio && dst->virtio &&
-+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
-+        return false;
-+
-     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
-         return false;
- 
-@@ -21504,6 +21512,8 @@ virDomainControllerDriverFormat(virBufferPtr buf,
-     if (def->iothread)
-         virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
- 
-+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
-+
-     if (virBufferUse(&driverBuf)) {
-         virBufferAddLit(buf, "<driver");
-         virBufferAddBuffer(buf, &driverBuf);
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index eac1919175..205c9e27b1 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -813,6 +813,7 @@ struct _virDomainControllerDef {
-         virDomainUSBControllerOpts usbopts;
-     } opts;
-     virDomainDeviceInfo info;
-+    virDomainVirtioOptionsPtr virtio;
- };
- 
- 
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-index 6dd82de648..867e56c107 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-@@ -27,10 +27,12 @@
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
-     </controller>
-     <controller type='scsi' index='0' model='virtio-scsi'>
-+      <driver iommu='on' ats='on'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
-     </controller>
-     <controller type='pci' index='0' model='pci-root'/>
-     <controller type='virtio-serial' index='0'>
-+      <driver iommu='on' ats='on'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
-     </controller>
-     <filesystem type='mount' accessmode='passthrough'>
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-Add-virtio-related-options-to-disks.patch b/SOURCES/libvirt-Add-virtio-related-options-to-disks.patch
deleted file mode 100644
index abd2ba2..0000000
--- a/SOURCES/libvirt-Add-virtio-related-options-to-disks.patch
+++ /dev/null
@@ -1,133 +0,0 @@
-From 51a842ccdf1c02ec00ba96217658b0db31a6addb Mon Sep 17 00:00:00 2001
-Message-Id: <51a842ccdf1c02ec00ba96217658b0db31a6addb@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:49:02 +0200
-Subject: [PATCH] Add virtio-related options to disks
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 1bc2cb3b3205dca7174147ac970e2b82c8af69da)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                              |  5 +++++
- docs/schemas/domaincommon.rng                          |  1 +
- src/conf/domain_conf.c                                 | 15 +++++++++++++++
- src/conf/domain_conf.h                                 |  1 +
- tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml |  2 +-
- 5 files changed, 23 insertions(+), 1 deletion(-)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 2556f383fc..bb7a85a1a1 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -3008,6 +3008,11 @@
-             <code>bus</code> and "pci" or "ccw" <code>address</code> types.
-             <span class='since'>Since 1.2.8 (QEMU 2.1)</span>
-           </li>
-+          <li>
-+          For virtio disks,
-+          <a href="#elementsVirtio">Virtio-specific options</a> can also be
-+          set. (<span class="since">Since 3.5.0</span>)
-+          </li>
-         </ul>
-       </dd>
-       <dt><code>backenddomain</code></dt>
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index f571af6706..f838dc55fd 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -1716,6 +1716,7 @@
-       <optional>
-         <ref name="detect_zeroes"/>
-       </optional>
-+      <ref name="virtioOptions"/>
-       <empty/>
-     </element>
-   </define>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 4768d02029..a4b4f70855 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -1745,6 +1745,7 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
-     VIR_FREE(def->product);
-     VIR_FREE(def->domain_name);
-     VIR_FREE(def->blkdeviotune.group_name);
-+    VIR_FREE(def->virtio);
-     virDomainDeviceInfoClear(&def->info);
-     virObjectUnref(def->privateData);
- 
-@@ -4440,6 +4441,10 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
-             }
-         }
- 
-+        if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO &&
-+            virDomainCheckVirtioOptions(disk->virtio) < 0)
-+            return -1;
-+
-         if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
-             virDomainDiskDefAssignAddress(xmlopt, disk, def) < 0)
-             return -1;
-@@ -8420,6 +8425,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
-         }
-     }
- 
-+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
-+        goto error;
-+
-     /* Disk volume types will have authentication information handled in
-      * virStorageTranslateDiskSourcePool
-      */
-@@ -19146,6 +19154,10 @@ virDomainDiskDefCheckABIStability(virDomainDiskDefPtr src,
-         return false;
-     }
- 
-+    if (src->virtio && dst->virtio &&
-+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
-+        return false;
-+
-     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
-         return false;
- 
-@@ -21307,6 +21319,9 @@ virDomainDiskDefFormat(virBufferPtr buf,
-         virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
-     if (def->detect_zeroes)
-         virBufferAsprintf(&driverBuf, " detect_zeroes='%s'", detect_zeroes);
-+
-+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
-+
-     if (virBufferUse(&driverBuf)) {
-         virBufferAddLit(buf, "<driver");
-         virBufferAddBuffer(buf, &driverBuf);
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index f1f9208b91..eac1919175 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -668,6 +668,7 @@ struct _virDomainDiskDef {
-     unsigned int iothread; /* unused = 0, > 0 specific thread # */
-     int detect_zeroes; /* enum virDomainDiskDetectZeroes */
-     char *domain_name; /* backend domain name */
-+    virDomainVirtioOptionsPtr virtio;
- };
- 
- 
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-index b16a9847fe..6dd82de648 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-@@ -15,7 +15,7 @@
-   <devices>
-     <emulator>/usr/bin/qemu-system-x86_64</emulator>
-     <disk type='file' device='disk'>
--      <driver name='qemu' type='raw'/>
-+      <driver name='qemu' type='raw' iommu='on' ats='on'/>
-       <source file='/var/lib/libvirt/images/img1'/>
-       <target dev='vda' bus='virtio'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-Add-virtio-related-options-to-filesystems.patch b/SOURCES/libvirt-Add-virtio-related-options-to-filesystems.patch
deleted file mode 100644
index 2576cd7..0000000
--- a/SOURCES/libvirt-Add-virtio-related-options-to-filesystems.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-From c828a666c154dece5bce0530c6a53d72d91ca3a1 Mon Sep 17 00:00:00 2001
-Message-Id: <c828a666c154dece5bce0530c6a53d72d91ca3a1@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:49:04 +0200
-Subject: [PATCH] Add virtio-related options to filesystems
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit b10c22d9fa11e2a67eca04592688bd701700f77f)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                              |  5 +++++
- docs/schemas/domaincommon.rng                          |  1 +
- src/conf/domain_conf.c                                 | 10 ++++++++++
- src/conf/domain_conf.h                                 |  1 +
- tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml |  3 ++-
- 5 files changed, 19 insertions(+), 1 deletion(-)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 2b26f090cd..8d3f916a19 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -3293,6 +3293,11 @@
-             or "handle", but no formats. Virtuozzo driver supports
-             a type of "ploop" with a format of "ploop".
-           </li>
-+          <li>
-+          For virtio-backed devices,
-+          <a href="#elementsVirtio">Virtio-specific options</a> can also be
-+          set. (<span class="since">Since 3.5.0</span>)
-+          </li>
-         </ul>
-       </dd>
- 
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index 2108d23df7..5e526b6100 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -2202,6 +2202,7 @@
-           <value>immediate</value>
-         </attribute>
-       </optional>
-+      <ref name='virtioOptions'/>
-       <empty/>
-     </element>
-   </define>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 2e5eeb1172..5c7ffc0419 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -1905,6 +1905,7 @@ void virDomainFSDefFree(virDomainFSDefPtr def)
-     virStorageSourceFree(def->src);
-     VIR_FREE(def->dst);
-     virDomainDeviceInfoClear(&def->info);
-+    VIR_FREE(def->virtio);
- 
-     VIR_FREE(def);
- }
-@@ -9451,6 +9452,9 @@ virDomainFSDefParseXML(xmlNodePtr node,
-             goto error;
-     }
- 
-+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
-+        goto error;
-+
-     def->src->path = source;
-     source = NULL;
-     def->dst = target;
-@@ -19246,6 +19250,10 @@ virDomainFsDefCheckABIStability(virDomainFSDefPtr src,
-         return false;
-     }
- 
-+    if (src->virtio && dst->virtio &&
-+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
-+        return false;
-+
-     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
-         return false;
- 
-@@ -21713,6 +21721,8 @@ virDomainFSDefFormat(virBufferPtr buf,
- 
-     }
- 
-+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
-+
-     if (virBufferUse(&driverBuf)) {
-         virBufferAddLit(buf, "<driver");
-         virBufferAddBuffer(buf, &driverBuf);
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 205c9e27b1..fdd852c29d 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -876,6 +876,7 @@ struct _virDomainFSDef {
-     unsigned long long space_hard_limit; /* in bytes */
-     unsigned long long space_soft_limit; /* in bytes */
-     bool symlinksResolved;
-+    virDomainVirtioOptionsPtr virtio;
- };
- 
- 
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-index 867e56c107..33da214611 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-@@ -36,12 +36,13 @@
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
-     </controller>
-     <filesystem type='mount' accessmode='passthrough'>
-+      <driver iommu='on' ats='on'/>
-       <source dir='/export/fs1'/>
-       <target dir='fs1'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
-     </filesystem>
-     <filesystem type='mount' accessmode='mapped'>
--      <driver type='path' wrpolicy='immediate'/>
-+      <driver type='path' wrpolicy='immediate' iommu='on' ats='on'/>
-       <source dir='/export/fs2'/>
-       <target dir='fs2'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-Add-virtio-related-options-to-input-devices.patch b/SOURCES/libvirt-Add-virtio-related-options-to-input-devices.patch
deleted file mode 100644
index 6e235e0..0000000
--- a/SOURCES/libvirt-Add-virtio-related-options-to-input-devices.patch
+++ /dev/null
@@ -1,153 +0,0 @@
-From 00aaab7312b72b5ef1785793f97849a69f425b83 Mon Sep 17 00:00:00 2001
-Message-Id: <00aaab7312b72b5ef1785793f97849a69f425b83@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:49:07 +0200
-Subject: [PATCH] Add virtio-related options to input devices
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit cc0933d3501229cdc8cf183a52a14c9b1c8de666)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                              |  7 +++++++
- docs/schemas/domaincommon.rng                          |  5 +++++
- src/conf/domain_conf.c                                 | 18 ++++++++++++++++++
- src/conf/domain_conf.h                                 |  1 +
- tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml |  4 ++++
- 5 files changed, 35 insertions(+)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 6be015f866..dc8e7d2dc7 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -5712,6 +5712,13 @@ qemu-kvm -net nic,model=? /dev/null
-       event device passed through to guests. (KVM only)
-     </p>
- 
-+    <p>
-+        The subelement <code>driver</code> can be used to tune the virtio
-+        options of the device:
-+        <a href="#elementsVirtio">Virtio-specific options</a> can also be
-+        set. (<span class="since">Since 3.5.0</span>)
-+    </p>
-+
-     <h4><a name="elementsHub">Hub devices</a></h4>
- 
-     <p>
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index ee49d6eb58..78023ff4af 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -3936,6 +3936,11 @@
- 
-   <define name="input">
-     <element name="input">
-+      <optional>
-+        <element name="driver">
-+          <ref name="virtioOptions"/>
-+        </element>
-+      </optional>
-       <choice>
-         <group>
-           <attribute name="type">
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index a0de639e51..d8ca25da38 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -1400,6 +1400,7 @@ void virDomainInputDefFree(virDomainInputDefPtr def)
- 
-     virDomainDeviceInfoClear(&def->info);
-     VIR_FREE(def->source.evdev);
-+    VIR_FREE(def->virtio);
-     VIR_FREE(def);
- }
- 
-@@ -11587,6 +11588,9 @@ virDomainInputDefParseXML(const virDomainDef *dom,
-         goto error;
-     }
- 
-+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
-+        goto error;
-+
-  cleanup:
-     VIR_FREE(evdev);
-     VIR_FREE(type);
-@@ -19328,6 +19332,10 @@ virDomainInputDefCheckABIStability(virDomainInputDefPtr src,
-         return false;
-     }
- 
-+    if (src->virtio && dst->virtio &&
-+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
-+        return false;
-+
-     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
-         return false;
- 
-@@ -23404,6 +23412,7 @@ virDomainInputDefFormat(virBufferPtr buf,
-     const char *type = virDomainInputTypeToString(def->type);
-     const char *bus = virDomainInputBusTypeToString(def->bus);
-     virBuffer childbuf = VIR_BUFFER_INITIALIZER;
-+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
- 
-     /* don't format keyboard into migratable XML for backward compatibility */
-     if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
-@@ -23427,6 +23436,15 @@ virDomainInputDefFormat(virBufferPtr buf,
-                       type, bus);
- 
-     virBufferAdjustIndent(&childbuf, virBufferGetIndent(buf, false) + 2);
-+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
-+    if (virBufferCheckError(&driverBuf) < 0)
-+        return -1;
-+
-+    if (virBufferUse(&driverBuf)) {
-+        virBufferAddLit(&childbuf, "<driver");
-+        virBufferAddBuffer(&childbuf, &driverBuf);
-+        virBufferAddLit(&childbuf, "/>\n");
-+    }
-     virBufferEscapeString(&childbuf, "<source evdev='%s'/>\n", def->source.evdev);
-     if (virDomainDeviceInfoFormat(&childbuf, &def->info, flags) < 0)
-         return -1;
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index b79fb50c79..4c33b0d15e 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -1282,6 +1282,7 @@ struct _virDomainInputDef {
-         char *evdev;
-     } source;
-     virDomainDeviceInfo info;
-+    virDomainVirtioOptionsPtr virtio;
- };
- 
- typedef enum {
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-index 85d1145263..773038a320 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-@@ -54,15 +54,19 @@
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
-     </interface>
-     <input type='mouse' bus='virtio'>
-+      <driver iommu='on' ats='on'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
-     </input>
-     <input type='keyboard' bus='virtio'>
-+      <driver iommu='on' ats='on'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
-     </input>
-     <input type='tablet' bus='virtio'>
-+      <driver iommu='on' ats='on'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
-     </input>
-     <input type='passthrough' bus='virtio'>
-+      <driver iommu='on' ats='on'/>
-       <source evdev='/dev/input/event1234'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
-     </input>
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-Add-virtio-related-options-to-interfaces.patch b/SOURCES/libvirt-Add-virtio-related-options-to-interfaces.patch
deleted file mode 100644
index fcede1c..0000000
--- a/SOURCES/libvirt-Add-virtio-related-options-to-interfaces.patch
+++ /dev/null
@@ -1,334 +0,0 @@
-From 7667b332ec942112270da554ded58658a78860b9 Mon Sep 17 00:00:00 2001
-Message-Id: <7667b332ec942112270da554ded58658a78860b9@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:49:00 +0200
-Subject: [PATCH] Add virtio-related options to interfaces
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-<interface type='user'>
-  <mac address='52:54:56:5a:5c:5e'/>
-  <model type='virtio'/>
-  <driver iommu='on' ats='on'/>
-</interface>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit fd518643402d8233ceffe4ef28279bcce53284f6)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                          |  19 ++++
- docs/schemas/domaincommon.rng                      |  12 ++
- src/conf/domain_conf.c                             | 121 +++++++++++++++++++++
- src/conf/domain_conf.h                             |  10 ++
- .../qemuxml2argv-virtio-options.xml                |   1 +
- 5 files changed, 163 insertions(+)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index e8a3367bac..23546daae9 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -3448,6 +3448,19 @@
-       </dd>
-     </dl>
- 
-+    <h4><a name="elementsVirtio">Virtio-related options</a></h4>
-+
-+    <p>
-+      QEMU's virtio devices have some attributes related to the virtio transport under
-+      the <code>driver</code> element:
-+      The <code>iommu</code> attribute enables the use of emulated IOMMU
-+      by the device. The attribute <code>ats</code> controls the Address
-+      Translation Service support for PCIe devices. This is needed to make use
-+      of IOTLB support (see <a href="#elementsIommu">IOMMU device</a>).
-+      Possible values are <code>on</code> or <code>off</code>.
-+      <span class="since">Since 3.5.0</span>
-+    </p>
-+
-     <h4><a name="elementsControllers">Controllers</a></h4>
- 
-     <p>
-@@ -5139,6 +5152,12 @@ qemu-kvm -net nic,model=? /dev/null
-         <b>In general you should leave this option alone, unless you
-         are very certain you know what you are doing.</b>
-       </dd>
-+      <dt>virtio options</dt>
-+      <dd>
-+        For virtio interfaces,
-+        <a href="#elementsVirtio">Virtio-specific options</a> can also be
-+        set. (<span class="since">Since 3.5.0</span>)
-+      </dd>
-     </dl>
-     <p>
-       Offloading options for the host and guest can be configured using
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index 1b66362f17..9e68bbc52d 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -2632,6 +2632,7 @@
-               </optional>
-             </group>
-           </choice>
-+          <ref name="virtioOptions"/>
-           <interleave>
-             <optional>
-               <element name='host'>
-@@ -4952,6 +4953,17 @@
-     </element>
-   </define>
- 
-+  <define name="virtioOptions">
-+    <optional>
-+      <attribute name="iommu">
-+        <ref name="virOnOff"/>
-+      </attribute>
-+      <attribute name="ats">
-+        <ref name="virOnOff"/>
-+      </attribute>
-+    </optional>
-+  </define>
-+
-   <define name="usbmaster">
-     <element name="master">
-       <attribute name="startport">
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 4652e1c72b..bba50cf3fd 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -1112,6 +1112,46 @@ virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
-     return &xmlopt->ns;
- }
- 
-+static int
-+virDomainVirtioOptionsParseXML(xmlXPathContextPtr ctxt,
-+                               virDomainVirtioOptionsPtr *virtio)
-+{
-+    char *str = NULL;
-+    int ret = -1;
-+    int val;
-+    virDomainVirtioOptionsPtr res;
-+
-+    if (VIR_ALLOC(*virtio) < 0)
-+        return -1;
-+
-+    res = *virtio;
-+
-+    if ((str = virXPathString("string(./driver/@iommu)", ctxt))) {
-+        if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
-+            virReportError(VIR_ERR_XML_ERROR, "%s",
-+                           _("invalid iommu value"));
-+            goto cleanup;
-+        }
-+        res->iommu = val;
-+    }
-+    VIR_FREE(str);
-+
-+    if ((str = virXPathString("string(./driver/@ats)", ctxt))) {
-+        if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
-+            virReportError(VIR_ERR_XML_ERROR, "%s",
-+                           _("invalid ats value"));
-+            goto cleanup;
-+        }
-+        res->ats = val;
-+    }
-+
-+    ret = 0;
-+
-+ cleanup:
-+    VIR_FREE(str);
-+    return ret;
-+}
-+
- 
- virSaveCookieCallbacksPtr
- virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt)
-@@ -1953,6 +1993,7 @@ virDomainNetDefClear(virDomainNetDefPtr def)
-     VIR_FREE(def->ifname);
-     VIR_FREE(def->ifname_guest);
-     VIR_FREE(def->ifname_guest_actual);
-+    VIR_FREE(def->virtio);
- 
-     virNetDevIPInfoClear(&def->guestIP);
-     virNetDevIPInfoClear(&def->hostIP);
-@@ -4313,6 +4354,28 @@ virDomainHostdevDefPostParse(virDomainHostdevDefPtr dev,
- 
- 
- static int
-+virDomainCheckVirtioOptions(virDomainVirtioOptionsPtr virtio)
-+{
-+    if (!virtio)
-+        return 0;
-+
-+    if (virtio->iommu != VIR_TRISTATE_SWITCH_ABSENT) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                       _("iommu driver option is only supported "
-+                         "for virtio devices"));
-+        return -1;
-+    }
-+    if (virtio->ats != VIR_TRISTATE_SWITCH_ABSENT) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                       _("ats driver option is only supported "
-+                         "for virtio devices"));
-+        return -1;
-+    }
-+    return 0;
-+}
-+
-+
-+static int
- virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
-                                     const virDomainDef *def,
-                                     virCapsPtr caps ATTRIBUTE_UNUSED,
-@@ -4410,6 +4473,13 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
-         }
-     }
- 
-+    if (dev->type == VIR_DOMAIN_DEVICE_NET) {
-+        virDomainNetDefPtr net = dev->data.net;
-+        if (STRNEQ_NULLABLE(net->model, "virtio") &&
-+            virDomainCheckVirtioOptions(net->virtio) < 0)
-+            return -1;
-+    }
-+
-     return 0;
- }
- 
-@@ -5208,6 +5278,24 @@ virDomainDefValidate(virDomainDefPtr def,
- }
- 
- 
-+static void
-+virDomainVirtioOptionsFormat(virBufferPtr buf,
-+                             virDomainVirtioOptionsPtr virtio)
-+{
-+    if (!virtio)
-+        return;
-+
-+    if (virtio->iommu != VIR_TRISTATE_SWITCH_ABSENT) {
-+        virBufferAsprintf(buf, " iommu='%s'",
-+                          virTristateSwitchTypeToString(virtio->iommu));
-+    }
-+    if (virtio->ats != VIR_TRISTATE_SWITCH_ABSENT) {
-+        virBufferAsprintf(buf, " ats='%s'",
-+                          virTristateSwitchTypeToString(virtio->ats));
-+    }
-+}
-+
-+
- /* Generate a string representation of a device address
-  * @info address Device address to stringify
-  */
-@@ -10354,6 +10442,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
-             goto error;
-     }
- 
-+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
-+        goto error;
-+
-  cleanup:
-     ctxt->node = oldnode;
-     VIR_FREE(macaddr);
-@@ -18979,6 +19070,30 @@ virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src,
- 
- 
- static bool
-+virDomainVirtioOptionsCheckABIStability(virDomainVirtioOptionsPtr src,
-+                                        virDomainVirtioOptionsPtr dst)
-+{
-+    if (src->iommu != dst->iommu) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("Target device iommu option '%s' does not "
-+                         "match source '%s'"),
-+                       virTristateSwitchTypeToString(dst->iommu),
-+                       virTristateSwitchTypeToString(src->iommu));
-+        return false;
-+    }
-+    if (src->ats != dst->ats) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("Target device ats option '%s' does not "
-+                         "match source '%s'"),
-+                       virTristateSwitchTypeToString(dst->ats),
-+                       virTristateSwitchTypeToString(src->ats));
-+        return false;
-+    }
-+    return true;
-+}
-+
-+
-+static bool
- virDomainDiskDefCheckABIStability(virDomainDiskDefPtr src,
-                                   virDomainDiskDefPtr dst)
- {
-@@ -19137,6 +19252,10 @@ virDomainNetDefCheckABIStability(virDomainNetDefPtr src,
-         return false;
-     }
- 
-+    if (src->virtio && dst->virtio &&
-+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
-+        return false;
-+
-     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
-         return false;
- 
-@@ -22074,6 +22193,8 @@ virDomainVirtioNetDriverFormat(char **outstr,
-         virBufferAsprintf(&buf, " rx_queue_size='%u'",
-                           def->driver.virtio.rx_queue_size);
- 
-+    virDomainVirtioOptionsFormat(&buf, def->virtio);
-+
-     if (virBufferCheckError(&buf) < 0)
-         return -1;
- 
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index e6c20a9e1e..603d35bd50 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -156,6 +156,9 @@ typedef virDomainTPMDef *virDomainTPMDefPtr;
- typedef struct _virDomainIOMMUDef virDomainIOMMUDef;
- typedef virDomainIOMMUDef *virDomainIOMMUDefPtr;
- 
-+typedef struct _virDomainVirtioOptions virDomainVirtioOptions;
-+typedef virDomainVirtioOptions *virDomainVirtioOptionsPtr;
-+
- /* Flags for the 'type' field in virDomainDeviceDef */
- typedef enum {
-     VIR_DOMAIN_DEVICE_NONE = 0,
-@@ -1040,6 +1043,7 @@ struct _virDomainNetDef {
-     int linkstate;
-     unsigned int mtu;
-     virNetDevCoalescePtr coalesce;
-+    virDomainVirtioOptionsPtr virtio;
- };
- 
- typedef enum {
-@@ -2215,6 +2219,12 @@ struct _virDomainIOMMUDef {
-     virTristateSwitch eim;
-     virTristateSwitch iotlb;
- };
-+
-+struct _virDomainVirtioOptions {
-+    virTristateSwitch iommu;
-+    virTristateSwitch ats;
-+};
-+
- /*
-  * Guest VM main configuration
-  *
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-index c88cf649b1..3357bc6d1b 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-@@ -47,6 +47,7 @@
-     <interface type='user'>
-       <mac address='52:54:56:58:5a:5c'/>
-       <model type='virtio'/>
-+      <driver iommu='on' ats='on'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
-     </interface>
-     <input type='mouse' bus='virtio'>
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-Add-virtio-related-options-to-rng-devices.patch b/SOURCES/libvirt-Add-virtio-related-options-to-rng-devices.patch
deleted file mode 100644
index a2777a9..0000000
--- a/SOURCES/libvirt-Add-virtio-related-options-to-rng-devices.patch
+++ /dev/null
@@ -1,146 +0,0 @@
-From b452148f1570656d9b42efbdbff396cf5cafa9c7 Mon Sep 17 00:00:00 2001
-Message-Id: <b452148f1570656d9b42efbdbff396cf5cafa9c7@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:49:05 +0200
-Subject: [PATCH] Add virtio-related options to rng devices
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit f65db1be1200b656094180ecfdb63f8bd0158cab)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                             | 11 +++++++++++
- docs/schemas/domaincommon.rng                         |  5 +++++
- src/conf/domain_conf.c                                | 19 +++++++++++++++++++
- src/conf/domain_conf.h                                |  1 +
- .../qemuxml2argvdata/qemuxml2argv-virtio-options.xml  |  1 +
- 5 files changed, 37 insertions(+)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 8d3f916a19..2e5c669c4a 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -7061,6 +7061,17 @@ qemu-kvm -net nic,model=? /dev/null
-           </dd>
-         </dl>
-       </dd>
-+      <dt><code>driver</code></dt>
-+      <dd>
-+        The subelement <code>driver</code> can be used to tune the device:
-+        <dl>
-+          <dt>virtio options</dt>
-+          <dd>
-+          <a href="#elementsVirtio">Virtio-specific options</a> can also be
-+          set. (<span class="since">Since 3.5.0</span>)
-+          </dd>
-+        </dl>
-+      </dd>
- 
-     </dl>
- 
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index 5e526b6100..7e80275029 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -4912,6 +4912,11 @@
-       <interleave>
-         <ref name="rng-backend"/>
-         <optional>
-+          <element name="driver">
-+            <ref name="virtioOptions"/>
-+          </element>
-+        </optional>
-+        <optional>
-           <ref name="rng-rate"/>
-         </optional>
-         <optional>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 5c7ffc0419..059c006b69 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -12922,6 +12922,9 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlopt,
-     if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
-         goto error;
- 
-+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
-+        goto error;
-+
-  cleanup:
-     VIR_FREE(model);
-     VIR_FREE(backend);
-@@ -19637,6 +19640,10 @@ virDomainRNGDefCheckABIStability(virDomainRNGDefPtr src,
-         return false;
-     }
- 
-+    if (src->virtio && dst->virtio &&
-+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
-+        return false;
-+
-     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
-         return false;
- 
-@@ -23132,6 +23139,7 @@ virDomainRNGDefFormat(virBufferPtr buf,
- {
-     const char *model = virDomainRNGModelTypeToString(def->model);
-     const char *backend = virDomainRNGBackendTypeToString(def->backend);
-+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
- 
-     virBufferAsprintf(buf, "<rng model='%s'>\n", model);
-     virBufferAdjustIndent(buf, 2);
-@@ -23160,6 +23168,16 @@ virDomainRNGDefFormat(virBufferPtr buf,
-         break;
-     }
- 
-+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
-+    if (virBufferCheckError(&driverBuf) < 0)
-+        return -1;
-+
-+    if (virBufferUse(&driverBuf)) {
-+        virBufferAddLit(buf, "<driver");
-+        virBufferAddBuffer(buf, &driverBuf);
-+        virBufferAddLit(buf, "/>\n");
-+    }
-+
-     if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
-         if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
-             return -1;
-@@ -23188,6 +23206,7 @@ virDomainRNGDefFree(virDomainRNGDefPtr def)
-     }
- 
-     virDomainDeviceInfoClear(&def->info);
-+    VIR_FREE(def->virtio);
-     VIR_FREE(def);
- }
- 
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index fdd852c29d..8cb9d5d0b1 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -2020,6 +2020,7 @@ struct _virDomainRNGDef {
-     } source;
- 
-     virDomainDeviceInfo info;
-+    virDomainVirtioOptionsPtr virtio;
- };
- 
- typedef enum {
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-index 33da214611..b7b95014cd 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-@@ -80,6 +80,7 @@
-     </memballoon>
-     <rng model='virtio'>
-       <backend model='random'>/dev/random</backend>
-+      <driver iommu='on' ats='on'/>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
-     </rng>
-   </devices>
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-Add-virtio-related-options-to-video.patch b/SOURCES/libvirt-Add-virtio-related-options-to-video.patch
deleted file mode 100644
index 1f0f3e4..0000000
--- a/SOURCES/libvirt-Add-virtio-related-options-to-video.patch
+++ /dev/null
@@ -1,189 +0,0 @@
-From 6abf3f12df5173dc12af69827fbee98811f83959 Mon Sep 17 00:00:00 2001
-Message-Id: <6abf3f12df5173dc12af69827fbee98811f83959@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:49:06 +0200
-Subject: [PATCH] Add virtio-related options to video
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit f5384fb4029a59624e728a2e0d37e6a62efbdc52)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                          | 12 ++++++++++
- docs/schemas/domaincommon.rng                      |  5 ++++
- src/conf/domain_conf.c                             | 27 ++++++++++++++++++++--
- src/conf/domain_conf.h                             |  1 +
- .../qemuxml2argv-virtio-options.xml                |  1 +
- 5 files changed, 44 insertions(+), 2 deletions(-)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 2e5c669c4a..6be015f866 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -6133,6 +6133,18 @@ qemu-kvm -net nic,model=? /dev/null
-         The optional <code>address</code> sub-element can be used to
-         tie the video device to a particular PCI slot.
-       </dd>
-+
-+      <dt><code>driver</code></dt>
-+      <dd>
-+        The subelement <code>driver</code> can be used to tune the device:
-+        <dl>
-+          <dt>virtio options</dt>
-+          <dd>
-+          <a href="#elementsVirtio">Virtio-specific options</a> can also be
-+          set. (<span class="since">Since 3.5.0</span>)
-+          </dd>
-+        </dl>
-+      </dd>
-     </dl>
- 
-     <h4><a name="elementsConsole">Consoles, serial, parallel &amp; channel devices</a></h4>
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index 7e80275029..ee49d6eb58 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -3165,6 +3165,11 @@
-   <define name="video">
-     <element name="video">
-       <optional>
-+        <element name="driver">
-+          <ref name="virtioOptions"/>
-+        </element>
-+      </optional>
-+      <optional>
-         <element name="model">
-           <choice>
-             <attribute name="type">
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 059c006b69..a0de639e51 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -2339,6 +2339,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
-     virDomainDeviceInfoClear(&def->info);
- 
-     VIR_FREE(def->accel);
-+    VIR_FREE(def->virtio);
-     VIR_FREE(def);
- }
- 
-@@ -13499,11 +13500,13 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
- 
- static virDomainVideoDefPtr
- virDomainVideoDefParseXML(xmlNodePtr node,
-+                          xmlXPathContextPtr ctxt,
-                           const virDomainDef *dom,
-                           unsigned int flags)
- {
-     virDomainVideoDefPtr def;
-     xmlNodePtr cur;
-+    xmlNodePtr saved = ctxt->node;
-     char *type = NULL;
-     char *heads = NULL;
-     char *vram = NULL;
-@@ -13512,6 +13515,8 @@ virDomainVideoDefParseXML(xmlNodePtr node,
-     char *vgamem = NULL;
-     char *primary = NULL;
- 
-+    ctxt->node = node;
-+
-     if (VIR_ALLOC(def) < 0)
-         return NULL;
- 
-@@ -13613,7 +13618,12 @@ virDomainVideoDefParseXML(xmlNodePtr node,
-     if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
-         goto error;
- 
-+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
-+        goto error;
-+
-  cleanup:
-+    ctxt->node = saved;
-+
-     VIR_FREE(type);
-     VIR_FREE(ram);
-     VIR_FREE(vram);
-@@ -14412,7 +14422,7 @@ virDomainDeviceDefParse(const char *xmlStr,
-             goto error;
-         break;
-     case VIR_DOMAIN_DEVICE_VIDEO:
--        if (!(dev->data.video = virDomainVideoDefParseXML(node, def, flags)))
-+        if (!(dev->data.video = virDomainVideoDefParseXML(node, ctxt, def, flags)))
-             goto error;
-         break;
-     case VIR_DOMAIN_DEVICE_HOSTDEV:
-@@ -18347,7 +18357,7 @@ virDomainDefParseXML(xmlDocPtr xml,
-         virDomainVideoDefPtr video;
-         ssize_t insertAt = -1;
- 
--        if (!(video = virDomainVideoDefParseXML(nodes[i], def, flags)))
-+        if (!(video = virDomainVideoDefParseXML(nodes[i], ctxt, def, flags)))
-             goto error;
- 
-         if (video->primary) {
-@@ -19414,6 +19424,10 @@ virDomainVideoDefCheckABIStability(virDomainVideoDefPtr src,
-         }
-     }
- 
-+    if (src->virtio && dst->virtio &&
-+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
-+        return false;
-+
-     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
-         return false;
- 
-@@ -23332,6 +23346,7 @@ virDomainVideoDefFormat(virBufferPtr buf,
-                         unsigned int flags)
- {
-     const char *model = virDomainVideoTypeToString(def->type);
-+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
- 
-     if (!model) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-@@ -23341,6 +23356,14 @@ virDomainVideoDefFormat(virBufferPtr buf,
- 
-     virBufferAddLit(buf, "<video>\n");
-     virBufferAdjustIndent(buf, 2);
-+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
-+    if (virBufferCheckError(&driverBuf) < 0)
-+        return -1;
-+    if (virBufferUse(&driverBuf)) {
-+        virBufferAddLit(buf, "<driver");
-+        virBufferAddBuffer(buf, &driverBuf);
-+        virBufferAddLit(buf, "/>\n");
-+    }
-     virBufferAsprintf(buf, "<model type='%s'",
-                       model);
-     if (def->ram)
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 8cb9d5d0b1..b79fb50c79 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -1376,6 +1376,7 @@ struct _virDomainVideoDef {
-     bool primary;
-     virDomainVideoAccelDefPtr accel;
-     virDomainDeviceInfo info;
-+    virDomainVirtioOptionsPtr virtio;
- };
- 
- /* graphics console modes */
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-index b7b95014cd..85d1145263 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-@@ -69,6 +69,7 @@
-     <input type='mouse' bus='ps2'/>
-     <input type='keyboard' bus='ps2'/>
-     <video>
-+      <driver iommu='on' ats='on'/>
-       <model type='virtio' heads='1' primary='yes'>
-         <acceleration accel3d='yes'/>
-       </model>
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-Adding-POWER9-cpu-model-to-cpu_map.xml.patch b/SOURCES/libvirt-Adding-POWER9-cpu-model-to-cpu_map.xml.patch
deleted file mode 100644
index 35cdb0e..0000000
--- a/SOURCES/libvirt-Adding-POWER9-cpu-model-to-cpu_map.xml.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From e3d953a8230f0cc4c8955f80c515cede99593d6b Mon Sep 17 00:00:00 2001
-Message-Id: <e3d953a8230f0cc4c8955f80c515cede99593d6b@dist-git>
-From: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
-Date: Wed, 17 May 2017 13:23:33 +0200
-Subject: [PATCH] Adding POWER9 cpu model to cpu_map.xml
-
-As POWER9 model is not available in cpu_map.xml virsh capabilities
-donot display the cpu model and vendor details. This patch
-provides those details
-
-(cherry picked from commit 9cdf3a1c06189b8d0cab9f8f62b5b626cf8a150c)
-
-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1450189
-
-Signed-off-by: Andrea Bolognani <abologna@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/cpu/cpu_map.xml | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
-index 7d5540a73..29b5b596f 100644
---- a/src/cpu/cpu_map.xml
-+++ b/src/cpu/cpu_map.xml
-@@ -1571,6 +1571,11 @@
-       <pvr value='0x004d0000' mask='0xffff0000'/>
-     </model>
- 
-+    <model name='POWER9'>
-+      <vendor name='IBM'/>
-+      <pvr value='0x004e0000' mask='0xffff0000'/>
-+    </model>
-+
-     <!-- Freescale-based CPU models -->
-     <model name='POWERPC_e5500'>
-       <vendor name='Freescale'/>
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch b/SOURCES/libvirt-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch
deleted file mode 100644
index 5c2ab6b..0000000
--- a/SOURCES/libvirt-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From f15202cb5a7429a2618cd4ede95064d8874b64ff Mon Sep 17 00:00:00 2001
-Message-Id: <f15202cb5a7429a2618cd4ede95064d8874b64ff@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Tue, 25 Apr 2017 13:41:21 +0200
-Subject: [PATCH] Define ETHTOOL_[GS]COALESCE when building on older kernels
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1414627
-
-RHEL-only (upstream will have this only when built on kernel that
-supports it).
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/util/virnetdev.c | 19 ++++++++-----------
- 1 file changed, 8 insertions(+), 11 deletions(-)
-
-diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
-index f14286f62..eb97b705e 100644
---- a/src/util/virnetdev.c
-+++ b/src/util/virnetdev.c
-@@ -3082,7 +3082,14 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap ATTRIBUTE_UNUSED,
- # endif
- 
- 
--# if HAVE_DECL_ETHTOOL_SCOALESCE && HAVE_DECL_ETHTOOL_GCOALESCE
-+/* Workaround for binary distributions building on old kernels */
-+# ifndef ETHTOOL_GCOALESCE
-+#  define ETHTOOL_GCOALESCE 0x0000000e
-+# endif
-+# ifndef ETHTOOL_SCOALESCE
-+#  define ETHTOOL_SCOALESCE 0x0000000f
-+# endif
-+
- /**
-  * virNetDevSetCoalesce:
-  * @ifname: interface name to modify
-@@ -3153,16 +3160,6 @@ int virNetDevSetCoalesce(const char *ifname,
-     VIR_FORCE_CLOSE(fd);
-     return ret;
- }
--# else
--int virNetDevSetCoalesce(const char *ifname,
--                         virNetDevCoalescePtr coalesce ATTRIBUTE_UNUSED)
--{
--    virReportSystemError(ENOSYS,
--                         _("Cannot set coalesce info on interface '%s'"),
--                         ifname);
--    return -1;
--}
--# endif
- 
- 
- /**
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-Do-not-release-unreserved-address-in-qemuDomainAttachRNGDevice.patch b/SOURCES/libvirt-Do-not-release-unreserved-address-in-qemuDomainAttachRNGDevice.patch
deleted file mode 100644
index 2f90144..0000000
--- a/SOURCES/libvirt-Do-not-release-unreserved-address-in-qemuDomainAttachRNGDevice.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 595b527d46c885352dce5fd9b2e226a1d17c1ef4 Mon Sep 17 00:00:00 2001
-Message-Id: <595b527d46c885352dce5fd9b2e226a1d17c1ef4@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Mon, 22 May 2017 10:50:56 +0200
-Subject: [PATCH] Do not release unreserved address in
- qemuDomainAttachRNGDevice
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Only set releaseaddr to true after the address has been
-reserved successfully.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1452581
-
-Reviewed-by: John Ferlan <jferlan@redhat.com>
-(cherry picked from commit f25f30aff548636d0c8782d3eaee049c77548dd5)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_hotplug.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index 6e5678f16..5c3660922 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -2090,7 +2090,6 @@ qemuDomainAttachRNGDevice(virConnectPtr conn,
-                                             rng->source.file))
-             goto cleanup;
-     }
--    releaseaddr = true;
- 
-     if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
-         rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
-@@ -2103,6 +2102,7 @@ qemuDomainAttachRNGDevice(virConnectPtr conn,
-                                       !rng->info.addr.ccw.assigned) < 0)
-             goto cleanup;
-     }
-+    releaseaddr = true;
- 
-     if (qemuDomainNamespaceSetupRNG(driver, vm, rng) < 0)
-         goto cleanup;
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-Don-t-leak-str-in-virDomainNetDefCoalesceParseXML.patch b/SOURCES/libvirt-Don-t-leak-str-in-virDomainNetDefCoalesceParseXML.patch
deleted file mode 100644
index 2f1d5d0..0000000
--- a/SOURCES/libvirt-Don-t-leak-str-in-virDomainNetDefCoalesceParseXML.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 8405ec82963c74f0505455fa2be35208dafbf907 Mon Sep 17 00:00:00 2001
-Message-Id: <8405ec82963c74f0505455fa2be35208dafbf907@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Tue, 25 Apr 2017 13:41:19 +0200
-Subject: [PATCH] Don't leak str in virDomainNetDefCoalesceParseXML
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1414627
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-(cherry picked from commit f08e26a19a5ba1cb434627554ee037e5a1b97e83)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index f2801ec84..47022c329 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -6798,6 +6798,7 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node,
-     ret->rx_max_coalesced_frames = tmp;
- 
-  cleanup:
-+    VIR_FREE(str);
-     ctxt->node = save;
-     return ret;
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-Fix-padding-of-encrypted-data.patch b/SOURCES/libvirt-Fix-padding-of-encrypted-data.patch
deleted file mode 100644
index 024b62b..0000000
--- a/SOURCES/libvirt-Fix-padding-of-encrypted-data.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-From 603a58f73e71323294c0d840bbfef4b5d9676e32 Mon Sep 17 00:00:00 2001
-Message-Id: <603a58f73e71323294c0d840bbfef4b5d9676e32@dist-git>
-From: "Daniel P. Berrange" <berrange@redhat.com>
-Date: Wed, 3 May 2017 08:52:13 +0200
-Subject: [PATCH] Fix padding of encrypted data
-
-If we are encoding a block of data that is 16 bytes in length,
-we cannot leave it as 16 bytes, we must pad it out to the next
-block boundary, 32 bytes. Without this padding, the decoder will
-incorrectly treat the last byte of plain text as the padding
-length, as it can't distinguish padded from non-padded data.
-
-The problem exhibited itself when using a 16 byte passphrase
-for a LUKS volume
-
-  $ virsh secret-set-value 55806c7d-8e93-456f-829b-607d8c198367 \
-       $(echo -n 1234567812345678 | base64)
-  Secret value set
-
-  $ virsh start demo
-  error: Failed to start domain demo
-  error: internal error: process exited while connecting to monitor: >>>>>>>>>>Len 16
-  2017-05-02T10:35:40.016390Z qemu-system-x86_64: -object \
-    secret,id=virtio-disk1-luks-secret0,data=SEtNi5vDUeyseMKHwc1c1Q==,\
-    keyid=masterKey0,iv=zm7apUB1A6dPcH53VW960Q==,format=base64: \
-    Incorrect number of padding bytes (56) found on decrypted data
-
-Notice how the padding '56' corresponds to the ordinal value of
-the character '8'.
-
-Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
-(cherry picked from commit 71890992daf37ec78b00b4ce873369421dc99731)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1447297
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/util/vircrypto.c | 10 ++++++++--
- 1 file changed, 8 insertions(+), 2 deletions(-)
-
-diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c
-index 8748e1c4e..48b04fc8c 100644
---- a/src/util/vircrypto.c
-+++ b/src/util/vircrypto.c
-@@ -152,8 +152,14 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg,
-     uint8_t *ciphertext;
-     size_t ciphertextlen;
- 
--    /* Allocate a padded buffer, copy in the data */
--    ciphertextlen = VIR_ROUND_UP(datalen, 16);
-+    /* Allocate a padded buffer, copy in the data.
-+     *
-+     * NB, we must *always* have at least 1 byte of
-+     * padding - we can't skip it on multiples of
-+     * 16, otherwise decoder can't distinguish padded
-+     * data from non-padded data. Hence datalen + 1
-+     */
-+    ciphertextlen = VIR_ROUND_UP(datalen + 1, 16);
-     if (VIR_ALLOC_N(ciphertext, ciphertextlen) < 0)
-         return -1;
-     memcpy(ciphertext, data, datalen);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-Introduce-virDomainDeviceAliasIsUserAlias.patch b/SOURCES/libvirt-Introduce-virDomainDeviceAliasIsUserAlias.patch
new file mode 100644
index 0000000..e9cdd28
--- /dev/null
+++ b/SOURCES/libvirt-Introduce-virDomainDeviceAliasIsUserAlias.patch
@@ -0,0 +1,79 @@
+From c4df501b589eb7d4315c13bfe6ba653321135841 Mon Sep 17 00:00:00 2001
+Message-Id: <c4df501b589eb7d4315c13bfe6ba653321135841@dist-git>
+From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
+Date: Thu, 30 Nov 2017 17:45:57 +0100
+Subject: [PATCH] Introduce virDomainDeviceAliasIsUserAlias
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Allow parts of code outside domain_conf to decide whether the alias
+is user-specified or not.
+
+(cherry picked from commit 309cd46b400d80420615b19adfebf7158492ae3b)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1518148
+
+Signed-off-by: Ján Tomko <jtomko@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c   | 9 ++++++++-
+ src/conf/domain_conf.h   | 2 ++
+ src/libvirt_private.syms | 1 +
+ 3 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 83392a42c0..bd6d851f21 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -6662,6 +6662,13 @@ virDomainDeviceAddressParseXML(xmlNodePtr address,
+ #define USER_ALIAS_CHARS \
+     "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
+ 
++bool
++virDomainDeviceAliasIsUserAlias(const char *aliasStr)
++{
++    return STRPREFIX(aliasStr, USER_ALIAS_PREFIX);
++}
++
++
+ /* Parse the XML definition for a device address
+  * @param node XML nodeset to parse for device address definition
+  */
+@@ -6715,7 +6722,7 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
+ 
+         if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) ||
+             (xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_USER_ALIAS &&
+-             STRPREFIX(aliasStr, USER_ALIAS_PREFIX) &&
++             virDomainDeviceAliasIsUserAlias(aliasStr) &&
+              strspn(aliasStr, USER_ALIAS_CHARS) == strlen(aliasStr)))
+             VIR_STEAL_PTR(info->alias, aliasStr);
+     }
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 0e97f0437e..479a791f29 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -2674,6 +2674,8 @@ int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
+                                            virDomainDeviceDefPtr dev,
+                                            unsigned int flags);
+ 
++bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);
++
+ int virDomainDefValidate(virDomainDefPtr def,
+                          virCapsPtr caps,
+                          unsigned int parseFlags,
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 0449b0185f..19c1ecc408 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -292,6 +292,7 @@ virDomainDefVcpuOrderClear;
+ virDomainDeleteConfig;
+ virDomainDeviceAddressIsValid;
+ virDomainDeviceAddressTypeToString;
++virDomainDeviceAliasIsUserAlias;
+ virDomainDeviceDefCopy;
+ virDomainDeviceDefFree;
+ virDomainDeviceDefParse;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-Introduce-virDomainInputDefGetPath.patch b/SOURCES/libvirt-Introduce-virDomainInputDefGetPath.patch
new file mode 100644
index 0000000..de76e4f
--- /dev/null
+++ b/SOURCES/libvirt-Introduce-virDomainInputDefGetPath.patch
@@ -0,0 +1,112 @@
+From 90aa784ed6ab93eae0a5e555c55bd65bc3240647 Mon Sep 17 00:00:00 2001
+Message-Id: <90aa784ed6ab93eae0a5e555c55bd65bc3240647@dist-git>
+From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
+Date: Mon, 27 Nov 2017 14:20:58 +0100
+Subject: [PATCH] Introduce virDomainInputDefGetPath
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Use it to denadify qemuDomainSetupInput.
+
+(cherry picked from commit cbf4242db7da3727f86934513c417acdec3d1a48)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1509866
+
+Signed-off-by: Ján Tomko <jtomko@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c   | 16 ++++++++++++++++
+ src/conf/domain_conf.h   |  1 +
+ src/libvirt_private.syms |  1 +
+ src/qemu/qemu_domain.c   | 21 ++++-----------------
+ 4 files changed, 22 insertions(+), 17 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 641a978f07..530fae9d9d 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -1397,6 +1397,22 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
+     VIR_FREE(def);
+ }
+ 
++const char *virDomainInputDefGetPath(virDomainInputDefPtr input)
++{
++    switch ((virDomainInputType) input->type) {
++    case VIR_DOMAIN_INPUT_TYPE_MOUSE:
++    case VIR_DOMAIN_INPUT_TYPE_TABLET:
++    case VIR_DOMAIN_INPUT_TYPE_KBD:
++    case VIR_DOMAIN_INPUT_TYPE_LAST:
++        return NULL;
++        break;
++
++    case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
++        return input->source.evdev;
++    }
++    return NULL;
++}
++
+ void virDomainInputDefFree(virDomainInputDefPtr def)
+ {
+     if (!def)
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index f967e603d1..09635763a1 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -2696,6 +2696,7 @@ int virDomainObjWaitUntil(virDomainObjPtr vm,
+ void virDomainPanicDefFree(virDomainPanicDefPtr panic);
+ void virDomainResourceDefFree(virDomainResourceDefPtr resource);
+ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
++const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
+ void virDomainInputDefFree(virDomainInputDefPtr def);
+ virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
+ void virDomainDiskDefFree(virDomainDiskDefPtr def);
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 8d1d4a896b..3e0bc8730c 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -393,6 +393,7 @@ virDomainHypervTypeToString;
+ virDomainInputBusTypeToString;
+ virDomainInputDefFind;
+ virDomainInputDefFree;
++virDomainInputDefGetPath;
+ virDomainIOMMUModelTypeFromString;
+ virDomainIOMMUModelTypeToString;
+ virDomainIOThreadIDAdd;
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 2f987787cd..dbe9ed5e98 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -8977,25 +8977,12 @@ qemuDomainSetupInput(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
+                      virDomainInputDefPtr input,
+                      const struct qemuDomainCreateDeviceData *data)
+ {
+-    int ret = -1;
++    const char *path = virDomainInputDefGetPath(input);
+ 
+-    switch ((virDomainInputType) input->type) {
+-    case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
+-        if (qemuDomainCreateDevice(input->source.evdev, data, false) < 0)
+-            goto cleanup;
+-        break;
++    if (path && qemuDomainCreateDevice(path, data, false) < 0)
++        return -1;
+ 
+-    case VIR_DOMAIN_INPUT_TYPE_MOUSE:
+-    case VIR_DOMAIN_INPUT_TYPE_TABLET:
+-    case VIR_DOMAIN_INPUT_TYPE_KBD:
+-    case VIR_DOMAIN_INPUT_TYPE_LAST:
+-        /* nada */
+-        break;
+-    }
+-
+-    ret = 0;
+- cleanup:
+-    return ret;
++    return 0;
+ }
+ 
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-RHEL-Add-rhel-machine-types-to-qemuDomainMachineNeedsFDC.patch b/SOURCES/libvirt-RHEL-Add-rhel-machine-types-to-qemuDomainMachineNeedsFDC.patch
index b72350b..c3f491d 100644
--- a/SOURCES/libvirt-RHEL-Add-rhel-machine-types-to-qemuDomainMachineNeedsFDC.patch
+++ b/SOURCES/libvirt-RHEL-Add-rhel-machine-types-to-qemuDomainMachineNeedsFDC.patch
@@ -1,5 +1,5 @@
-From 43caa2e812f3329221b875bbef4f0dcd07f8da05 Mon Sep 17 00:00:00 2001
-Message-Id: <43caa2e812f3329221b875bbef4f0dcd07f8da05@dist-git>
+From 6c4cb735843674c4dc3638fd22e222105bfc33ef Mon Sep 17 00:00:00 2001
+Message-Id: <6c4cb735843674c4dc3638fd22e222105bfc33ef@dist-git>
 From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
 Date: Mon, 22 Feb 2016 12:51:51 +0100
 Subject: [PATCH] RHEL: Add rhel machine types to qemuDomainMachineNeedsFDC
@@ -17,10 +17,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  1 file changed, 3 insertions(+)
 
 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 589eb1889..9f165c1da 100644
+index 13e77eedcd..81bfef946e 100644
 --- a/src/qemu/qemu_domain.c
 +++ b/src/qemu/qemu_domain.c
-@@ -5889,6 +5889,9 @@ qemuDomainMachineNeedsFDC(const virDomainDef *def)
+@@ -6833,6 +6833,9 @@ qemuDomainMachineNeedsFDC(const char *machine)
              STRPREFIX(p, "2.2") ||
              STRPREFIX(p, "2.3"))
              return false;
@@ -31,5 +31,5 @@ index 589eb1889..9f165c1da 100644
      }
      return false;
 -- 
-2.12.2
+2.14.3
 
diff --git a/SOURCES/libvirt-RHEL-Add-support-for-QMP-I-O-error-reason.patch b/SOURCES/libvirt-RHEL-Add-support-for-QMP-I-O-error-reason.patch
index 362558d..3651996 100644
--- a/SOURCES/libvirt-RHEL-Add-support-for-QMP-I-O-error-reason.patch
+++ b/SOURCES/libvirt-RHEL-Add-support-for-QMP-I-O-error-reason.patch
@@ -1,5 +1,5 @@
-From d2a647fd2d68114875222614d6b098a96c9d16c3 Mon Sep 17 00:00:00 2001
-Message-Id: <d2a647fd2d68114875222614d6b098a96c9d16c3@dist-git>
+From 039a4ec94aca6cb2226161de49e4b8a7c53f8321 Mon Sep 17 00:00:00 2001
+Message-Id: <039a4ec94aca6cb2226161de49e4b8a7c53f8321@dist-git>
 From: Jiri Denemark <jdenemar@redhat.com>
 Date: Thu, 9 Oct 2014 10:38:39 +0200
 Subject: [PATCH] RHEL: Add support for QMP I/O error reason
@@ -18,10 +18,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  1 file changed, 9 insertions(+), 3 deletions(-)
 
 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
-index 6fcf57cd1..405f79fec 100644
+index e0f942788d..a1fa37e1e9 100644
 --- a/src/qemu/qemu_monitor_json.c
 +++ b/src/qemu/qemu_monitor_json.c
-@@ -646,7 +646,7 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data)
+@@ -641,7 +641,7 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data)
  {
      const char *device;
      const char *action;
@@ -30,7 +30,7 @@ index 6fcf57cd1..405f79fec 100644
      bool nospc = false;
      int actionID;
  
-@@ -662,8 +662,14 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data)
+@@ -657,8 +657,14 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data)
      if ((device = virJSONValueObjectGetString(data, "device")) == NULL)
          VIR_WARN("missing device in disk io error event");
  
@@ -48,5 +48,5 @@ index 6fcf57cd1..405f79fec 100644
      if ((actionID = qemuMonitorIOErrorActionTypeFromString(action)) < 0) {
          VIR_WARN("unknown disk io error action '%s'", action);
 -- 
-2.12.2
+2.14.3
 
diff --git a/SOURCES/libvirt-RHEL-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch b/SOURCES/libvirt-RHEL-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch
new file mode 100644
index 0000000..8649f9f
--- /dev/null
+++ b/SOURCES/libvirt-RHEL-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch
@@ -0,0 +1,62 @@
+From c6e5d4660e094d9377300d76873545ef73886e0a Mon Sep 17 00:00:00 2001
+Message-Id: <c6e5d4660e094d9377300d76873545ef73886e0a@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Tue, 25 Apr 2017 13:41:21 +0200
+Subject: [PATCH] RHEL: Define ETHTOOL_[GS]COALESCE when building on older
+ kernels
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1414627
+
+RHEL-only (upstream will have this only when built on kernel that
+supports it).
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/util/virnetdev.c | 23 ++++++++---------------
+ 1 file changed, 8 insertions(+), 15 deletions(-)
+
+diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
+index 41ef65d882..4a63fe9af9 100644
+--- a/src/util/virnetdev.c
++++ b/src/util/virnetdev.c
+@@ -3350,7 +3350,14 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap ATTRIBUTE_UNUSED,
+ # endif
+ 
+ 
+-# if HAVE_DECL_ETHTOOL_SCOALESCE && HAVE_DECL_ETHTOOL_GCOALESCE
++/* Workaround for binary distributions building on old kernels */
++# ifndef ETHTOOL_GCOALESCE
++#  define ETHTOOL_GCOALESCE 0x0000000e
++# endif
++# ifndef ETHTOOL_SCOALESCE
++#  define ETHTOOL_SCOALESCE 0x0000000f
++# endif
++
+ /**
+  * virNetDevSetCoalesce:
+  * @ifname: interface name to modify
+@@ -3450,20 +3457,6 @@ int virNetDevSetCoalesce(const char *ifname,
+     VIR_FORCE_CLOSE(fd);
+     return ret;
+ }
+-# else
+-int virNetDevSetCoalesce(const char *ifname,
+-                         virNetDevCoalescePtr coalesce,
+-                         bool update)
+-{
+-    if (!coalesce && !update)
+-        return 0;
+-
+-    virReportSystemError(ENOSYS,
+-                         _("Cannot set coalesce info on interface '%s'"),
+-                         ifname);
+-    return -1;
+-}
+-# endif
+ 
+ 
+ /**
+-- 
+2.14.3
+
diff --git a/SOURCES/libvirt-RHEL-Fix-maxvcpus-output.patch b/SOURCES/libvirt-RHEL-Fix-maxvcpus-output.patch
index 6007b17..039c712 100644
--- a/SOURCES/libvirt-RHEL-Fix-maxvcpus-output.patch
+++ b/SOURCES/libvirt-RHEL-Fix-maxvcpus-output.patch
@@ -1,5 +1,5 @@
-From 6ce52a680d7799f1a861f98c50581a74b15d51a1 Mon Sep 17 00:00:00 2001
-Message-Id: <6ce52a680d7799f1a861f98c50581a74b15d51a1@dist-git>
+From e6b3f2c8091afc39840c44add90c0148db365811 Mon Sep 17 00:00:00 2001
+Message-Id: <e6b3f2c8091afc39840c44add90c0148db365811@dist-git>
 From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
 Date: Wed, 17 Sep 2014 19:00:58 +0200
 Subject: [PATCH] RHEL: Fix maxvcpus output
@@ -19,10 +19,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  1 file changed, 5 insertions(+)
 
 diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
-index 02b9fc8eb..20d3a004b 100644
+index c485a97211..bd58aa43df 100644
 --- a/src/util/virhostcpu.c
 +++ b/src/util/virhostcpu.c
-@@ -1166,6 +1166,11 @@ virHostCPUGetKVMMaxVCPUs(void)
+@@ -1178,6 +1178,11 @@ virHostCPUGetKVMMaxVCPUs(void)
          return -1;
      }
  
@@ -35,5 +35,5 @@ index 02b9fc8eb..20d3a004b 100644
      /* at first try KVM_CAP_MAX_VCPUS to determine the maximum count */
      if ((ret = ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS)) > 0)
 -- 
-2.12.2
+2.14.3
 
diff --git a/SOURCES/libvirt-RHEL-Hack-around-changed-Broadwell-Haswell-CPUs.patch b/SOURCES/libvirt-RHEL-Hack-around-changed-Broadwell-Haswell-CPUs.patch
index 897b338..b4c1c99 100644
--- a/SOURCES/libvirt-RHEL-Hack-around-changed-Broadwell-Haswell-CPUs.patch
+++ b/SOURCES/libvirt-RHEL-Hack-around-changed-Broadwell-Haswell-CPUs.patch
@@ -1,5 +1,5 @@
-From 26d33ed184f16a57b412360e4e75dbbcb9807c76 Mon Sep 17 00:00:00 2001
-Message-Id: <26d33ed184f16a57b412360e4e75dbbcb9807c76@dist-git>
+From 01e432517f0a44054a5317cea7f8a1171a3b10c7 Mon Sep 17 00:00:00 2001
+Message-Id: <01e432517f0a44054a5317cea7f8a1171a3b10c7@dist-git>
 From: Jiri Denemark <jdenemar@redhat.com>
 Date: Fri, 27 Mar 2015 12:48:40 +0100
 Subject: [PATCH] RHEL: Hack around changed Broadwell/Haswell CPUs
@@ -18,17 +18,20 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1199446
 
 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
 ---
- src/qemu/qemu_command.c                             | 21 +++++++++++++++++++++
- .../qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args  |  2 +-
- .../qemuxml2argv-cpu-host-model-cmt.args            |  3 ++-
- .../qemuxml2argv-cpu-tsc-frequency.args             |  2 +-
- 4 files changed, 25 insertions(+), 3 deletions(-)
+ src/qemu/qemu_command.c                            | 29 ++++++++++++++++++++++
+ .../qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args |  2 +-
+ .../qemuxml2argv-cpu-host-model-cmt.args           |  3 ++-
+ .../qemuxml2argv-cpu-tsc-frequency.args            |  2 +-
+ .../qemuxml2argv-q35-acpi-nouefi.args              |  2 +-
+ .../qemuxml2argv-q35-acpi-uefi.args                |  2 +-
+ .../qemuxml2argv-q35-noacpi-nouefi.args            |  2 +-
+ 7 files changed, 36 insertions(+), 6 deletions(-)
 
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 64d2d7105..1a2984e56 100644
+index b1cfafa790..365555ca87 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
-@@ -6768,6 +6768,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
+@@ -6857,6 +6857,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
      size_t i;
      virCapsPtr caps = NULL;
      virCPUDefPtr cpu = def->cpu;
@@ -37,7 +40,7 @@ index 64d2d7105..1a2984e56 100644
  
      if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
          goto cleanup;
-@@ -6822,6 +6824,11 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
+@@ -6911,6 +6913,11 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
          virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id);
  
      for (i = 0; i < cpu->nfeatures; i++) {
@@ -49,7 +52,7 @@ index 64d2d7105..1a2984e56 100644
          switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
          case VIR_CPU_FEATURE_FORCE:
          case VIR_CPU_FEATURE_REQUIRE:
-@@ -6845,6 +6852,20 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
+@@ -6934,6 +6941,28 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
          }
      }
  
@@ -61,17 +64,25 @@ index 64d2d7105..1a2984e56 100644
 +     */
 +    if (STREQ_NULLABLE(cpu->model, "Broadwell") ||
 +        STREQ_NULLABLE(cpu->model, "Haswell")) {
-+        if (!rtm)
-+            virBufferAddLit(buf, ",+rtm");
-+        if (!hle)
-+            virBufferAddLit(buf, ",+hle");
++        if (!rtm) {
++            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
++                virBufferAddLit(buf, ",rtm=on");
++            else
++                virBufferAddLit(buf, ",+rtm");
++        }
++        if (!hle) {
++            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
++                virBufferAddLit(buf, ",hle=on");
++            else
++                virBufferAddLit(buf, ",+hle");
++        }
 +    }
 +
      ret = 0;
   cleanup:
      virObjectUnref(caps);
 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
-index ef0e68b14..2e74a6703 100644
+index 06c9eed5b9..553b91c83b 100644
 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
 +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
 @@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
@@ -84,7 +95,7 @@ index ef0e68b14..2e74a6703 100644
  -smp 6,sockets=6,cores=1,threads=1 \
  -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
-index 7ae4ac5ad..e02f996ee 100644
+index ef45d98300..28cdf92782 100644
 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
 +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
 @@ -9,7 +9,8 @@ QEMU_AUDIO_DRV=none \
@@ -98,7 +109,7 @@ index 7ae4ac5ad..e02f996ee 100644
  -smp 6,sockets=6,cores=1,threads=1 \
  -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args
-index 50223fab2..cd9a3ef16 100644
+index 3e2da0f242..53193c6fe2 100644
 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args
 +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args
 @@ -10,7 +10,7 @@ QEMU_AUDIO_DRV=none \
@@ -110,6 +121,45 @@ index 50223fab2..cd9a3ef16 100644
  -m 214 \
  -smp 1,sockets=1,cores=1,threads=1 \
  -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args
+index 503045de6b..5e1d3b4eb0 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args
+@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
+ -name guest \
+ -S \
+ -M q35 \
+--cpu Haswell \
++-cpu Haswell,+rtm,+hle \
+ -m 1024 \
+ -smp 1,sockets=1,cores=1,threads=1 \
+ -uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args
+index fbbbcf9812..40214c69e8 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args
+@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
+ -name guest \
+ -S \
+ -M q35 \
+--cpu Haswell \
++-cpu Haswell,+rtm,+hle \
+ -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,\
+ readonly=on \
+ -drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,\
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args
+index de2a7f30bc..1be5968e02 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args
+@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
+ -name guest \
+ -S \
+ -M q35 \
+--cpu Haswell \
++-cpu Haswell,+rtm,+hle \
+ -m 1024 \
+ -smp 1,sockets=1,cores=1,threads=1 \
+ -uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
 -- 
-2.12.2
+2.14.3
 
diff --git a/SOURCES/libvirt-RHEL-Support-virtio-disk-hotplug-in-JSON-mode.patch b/SOURCES/libvirt-RHEL-Support-virtio-disk-hotplug-in-JSON-mode.patch
index 8347599..0357f85 100644
--- a/SOURCES/libvirt-RHEL-Support-virtio-disk-hotplug-in-JSON-mode.patch
+++ b/SOURCES/libvirt-RHEL-Support-virtio-disk-hotplug-in-JSON-mode.patch
@@ -1,5 +1,5 @@
-From 2d1d83a1d3eeb7cf98972c461842f333f900c1e2 Mon Sep 17 00:00:00 2001
-Message-Id: <2d1d83a1d3eeb7cf98972c461842f333f900c1e2@dist-git>
+From 618632843aeb3a587c2bbfdb7442217ae13b45fe Mon Sep 17 00:00:00 2001
+Message-Id: <618632843aeb3a587c2bbfdb7442217ae13b45fe@dist-git>
 From: Jiri Denemark <jdenemar@redhat.com>
 Date: Tue, 5 Apr 2016 09:14:09 +0200
 Subject: [PATCH] RHEL: Support virtio disk hotplug in JSON mode
@@ -53,14 +53,14 @@ Conflicts:
  src/qemu/qemu_monitor.c      |  12 +++--
  src/qemu/qemu_monitor_json.c | 106 +++++++++++++++++++++++++++++++++++++++++++
  src/qemu/qemu_monitor_json.h |   6 +++
- tests/qemuhotplugtest.c      |  92 ++++++++++++++++++++++++++++++++++++-
- 4 files changed, 210 insertions(+), 6 deletions(-)
+ tests/qemuhotplugtest.c      |  93 ++++++++++++++++++++++++++++++++++++-
+ 4 files changed, 211 insertions(+), 6 deletions(-)
 
 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
-index 8bc00bc1e..488d761fb 100644
+index 3cf23db874..12ad45d340 100644
 --- a/src/qemu/qemu_monitor.c
 +++ b/src/qemu/qemu_monitor.c
-@@ -3073,8 +3073,10 @@ qemuMonitorDriveDel(qemuMonitorPtr mon,
+@@ -3125,8 +3125,10 @@ qemuMonitorDriveDel(qemuMonitorPtr mon,
  
      QEMU_CHECK_MONITOR(mon);
  
@@ -73,7 +73,7 @@ index 8bc00bc1e..488d761fb 100644
  }
  
  
-@@ -3195,8 +3197,10 @@ qemuMonitorAddDrive(qemuMonitorPtr mon,
+@@ -3247,8 +3249,10 @@ qemuMonitorAddDrive(qemuMonitorPtr mon,
  
      QEMU_CHECK_MONITOR(mon);
  
@@ -87,10 +87,10 @@ index 8bc00bc1e..488d761fb 100644
  
  
 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
-index 2010657e3..6fcf57cd1 100644
+index 8a75e0ef7e..e0f942788d 100644
 --- a/src/qemu/qemu_monitor_json.c
 +++ b/src/qemu/qemu_monitor_json.c
-@@ -3807,6 +3807,112 @@ int qemuMonitorJSONDelObject(qemuMonitorPtr mon,
+@@ -3839,6 +3839,112 @@ int qemuMonitorJSONDelObject(qemuMonitorPtr mon,
  }
  
  
@@ -204,10 +204,10 @@ index 2010657e3..6fcf57cd1 100644
                                        const char *alias,
                                        const char *passphrase)
 diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
-index fb697033c..696aaeffc 100644
+index 02a504ab85..f1e818aed2 100644
 --- a/src/qemu/qemu_monitor_json.h
 +++ b/src/qemu/qemu_monitor_json.h
-@@ -233,6 +233,12 @@ int qemuMonitorJSONAddObject(qemuMonitorPtr mon,
+@@ -234,6 +234,12 @@ int qemuMonitorJSONAddObject(qemuMonitorPtr mon,
  int qemuMonitorJSONDelObject(qemuMonitorPtr mon,
                               const char *objalias);
  
@@ -221,10 +221,10 @@ index fb697033c..696aaeffc 100644
                                        const char *alias,
                                        const char *passphrase);
 diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
-index cdeb3f1bf..2e1afeea9 100644
+index bdde7e45f3..7691ad8f0f 100644
 --- a/tests/qemuhotplugtest.c
 +++ b/tests/qemuhotplugtest.c
-@@ -658,6 +658,14 @@ mymain(void)
+@@ -663,6 +663,14 @@ mymain(void)
      "    }"                                                 \
      "}\r\n"
  
@@ -239,7 +239,7 @@ index cdeb3f1bf..2e1afeea9 100644
      DO_TEST_UPDATE("graphics-spice", "graphics-spice-nochange", false, false, NULL);
      DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-nochange", false, false,
                     "set_password", QMP_OK, "expire_password", QMP_OK);
-@@ -678,67 +686,135 @@ mymain(void)
+@@ -683,67 +691,135 @@ mymain(void)
                     "chardev-remove", QMP_OK);
  
      DO_TEST_ATTACH("base-live", "disk-virtio", false, true,
@@ -376,7 +376,7 @@ index cdeb3f1bf..2e1afeea9 100644
                     "human-monitor-command", HMP(""));
  
      DO_TEST_ATTACH_EVENT("base-without-scsi-controller-live", "disk-scsi-2", false, true,
-@@ -747,14 +823,17 @@ mymain(void)
+@@ -752,14 +828,17 @@ mymain(void)
                           "device_add", QMP_OK,
                           "device_add", QMP_OK,
                           "device_add", QMP_OK,
@@ -395,7 +395,7 @@ index cdeb3f1bf..2e1afeea9 100644
                     "human-monitor-command", HMP(""));
  
      DO_TEST_ATTACH("base-live", "qemu-agent", false, true,
-@@ -765,38 +844,47 @@ mymain(void)
+@@ -770,38 +849,47 @@ mymain(void)
                     "chardev-remove", QMP_OK);
  
      DO_TEST_ATTACH("base-ccw-live", "ccw-virtio", false, true,
@@ -443,6 +443,14 @@ index cdeb3f1bf..2e1afeea9 100644
                     "human-monitor-command", HMP("OK\\r\\n"),
                     "device_add", QMP_OK);
  
+@@ -819,6 +907,7 @@ mymain(void)
+                    "object-del", QMP_OK);
+     DO_TEST_ATTACH("base-live+disk-scsi-wwn",
+                    "disk-scsi-duplicate-wwn", false, false,
++                   "__com.redhat_drive_add", QMP_NOT_FOUND,
+                    "human-monitor-command", HMP("OK\\r\\n"),
+                    "device_add", QMP_OK);
+ 
 -- 
-2.12.2
+2.14.3
 
diff --git a/SOURCES/libvirt-RHEL-cpu-Fix-EPYC-IBRS-CPU-model.patch b/SOURCES/libvirt-RHEL-cpu-Fix-EPYC-IBRS-CPU-model.patch
new file mode 100644
index 0000000..2e372c8
--- /dev/null
+++ b/SOURCES/libvirt-RHEL-cpu-Fix-EPYC-IBRS-CPU-model.patch
@@ -0,0 +1,34 @@
+From 111f9cb4bd22a68c50237e52190663c3f43a66ee Mon Sep 17 00:00:00 2001
+Message-Id: <111f9cb4bd22a68c50237e52190663c3f43a66ee@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Fri, 5 Jan 2018 17:40:30 +0100
+Subject: [PATCH] RHEL: cpu: Fix EPYC-IBRS CPU model
+
+It is spelled as EPYC-IBPB in QEMU.
+
+RHEL-only, upstream patches were sent for review with this patch
+squashed in.
+
+CVE-2017-5715
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/cpu/cpu_map.xml | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
+index a7888ec134..4d786f1e0a 100644
+--- a/src/cpu/cpu_map.xml
++++ b/src/cpu/cpu_map.xml
+@@ -1754,7 +1754,7 @@
+       <feature name='xsavec'/>
+       <feature name='xsaveopt'/>
+     </model>
+-    <model name='EPYC-IBRS'>
++    <model name='EPYC-IBPB'>
+       <model name='EPYC'/>
+       <feature name='ibpb'/>
+     </model>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-RHEL-qemu-Add-ability-to-set-sgio-values-for-hostdev.patch b/SOURCES/libvirt-RHEL-qemu-Add-ability-to-set-sgio-values-for-hostdev.patch
index 11db783..ef549ec 100644
--- a/SOURCES/libvirt-RHEL-qemu-Add-ability-to-set-sgio-values-for-hostdev.patch
+++ b/SOURCES/libvirt-RHEL-qemu-Add-ability-to-set-sgio-values-for-hostdev.patch
@@ -1,5 +1,5 @@
-From 5ed5c2acfb240683c3b1d7ec2e63b3c2571d707f Mon Sep 17 00:00:00 2001
-Message-Id: <5ed5c2acfb240683c3b1d7ec2e63b3c2571d707f@dist-git>
+From c696e4c1071b6a386d8c8428836eeb146886b644 Mon Sep 17 00:00:00 2001
+Message-Id: <c696e4c1071b6a386d8c8428836eeb146886b644@dist-git>
 From: John Ferlan <jferlan@redhat.com>
 Date: Thu, 9 Jul 2015 08:28:57 -0400
 Subject: [PATCH] RHEL: qemu: Add ability to set sgio values for hostdev
@@ -18,10 +18,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  1 file changed, 9 insertions(+), 7 deletions(-)
 
 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
-index 3b33e37bb..9137a69f8 100644
+index ec61c9c526..f1c142efb6 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
-@@ -1458,6 +1458,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
+@@ -1570,6 +1570,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
      virDomainDiskDefPtr disk = NULL;
      virDomainHostdevDefPtr hostdev = NULL;
      char *sysfs_path = NULL;
@@ -29,7 +29,7 @@ index 3b33e37bb..9137a69f8 100644
      const char *path = NULL;
      int val = -1;
      int ret = -1;
-@@ -1479,14 +1480,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
+@@ -1591,14 +1592,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
          if (!qemuIsSharedHostdev(hostdev))
              return 0;
  
@@ -46,7 +46,7 @@ index 3b33e37bb..9137a69f8 100644
      } else {
          return 0;
      }
-@@ -1495,7 +1492,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
+@@ -1607,7 +1604,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
          goto cleanup;
  
      /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0.  */
@@ -59,7 +59,7 @@ index 3b33e37bb..9137a69f8 100644
  
      /* Do not do anything if unpriv_sgio is not supported by the kernel and the
       * whitelist is enabled.  But if requesting unfiltered access, always call
-@@ -1508,6 +1509,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
+@@ -1620,6 +1621,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
      ret = 0;
  
   cleanup:
@@ -68,5 +68,5 @@ index 3b33e37bb..9137a69f8 100644
      return ret;
  }
 -- 
-2.12.2
+2.14.3
 
diff --git a/SOURCES/libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch b/SOURCES/libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch
index 6d23430..fe9f6da 100644
--- a/SOURCES/libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch
+++ b/SOURCES/libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch
@@ -1,5 +1,5 @@
-From d331ff38d1f088b7cbdaec27b57ebbb81b3ff3d0 Mon Sep 17 00:00:00 2001
-Message-Id: <d331ff38d1f088b7cbdaec27b57ebbb81b3ff3d0@dist-git>
+From aa370aac88baeea6a35558f3c22a9206cc667eb9 Mon Sep 17 00:00:00 2001
+Message-Id: <aa370aac88baeea6a35558f3c22a9206cc667eb9@dist-git>
 From: John Ferlan <jferlan@redhat.com>
 Date: Thu, 9 Jul 2015 08:28:58 -0400
 Subject: [PATCH] RHEL: qemu: Add check for unpriv sgio for SCSI generic host
@@ -22,10 +22,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  1 file changed, 15 insertions(+)
 
 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
-index 9137a69f8..7324c9c41 100644
+index f1c142efb6..4e5b33b788 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
-@@ -1298,6 +1298,8 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver,
+@@ -1410,6 +1410,8 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver,
  {
      char *dev_path = NULL;
      char *key = NULL;
@@ -34,7 +34,7 @@ index 9137a69f8..7324c9c41 100644
      int ret = -1;
  
      if (!qemuIsSharedHostdev(hostdev))
-@@ -1306,6 +1308,19 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver,
+@@ -1418,6 +1420,19 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver,
      if (!(dev_path = qemuGetHostdevPath(hostdev)))
          goto cleanup;
  
@@ -55,5 +55,5 @@ index 9137a69f8..7324c9c41 100644
          goto cleanup;
  
 -- 
-2.12.2
+2.14.3
 
diff --git a/SOURCES/libvirt-RHEL-qemu-Report-full-stats-for-completed-migration.patch b/SOURCES/libvirt-RHEL-qemu-Report-full-stats-for-completed-migration.patch
deleted file mode 100644
index b9f4830..0000000
--- a/SOURCES/libvirt-RHEL-qemu-Report-full-stats-for-completed-migration.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From c92e3fa956308c0b8be42a412b6f6ea2b9ff27ce Mon Sep 17 00:00:00 2001
-Message-Id: <c92e3fa956308c0b8be42a412b6f6ea2b9ff27ce@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 19 Jan 2018 13:51:51 +0100
-Subject: [PATCH] RHEL: qemu: Report full stats for completed migration
-
-RHEL-only: caused by improper adjustment of a backported patch
-
-When backporting patches (specifically upstream commit 3f2d6d829e, which
-was backported to 7.4.z as commit 547c0e17e6) for BZ 1530130 I
-intentionally skipped several refactoring commits because they were not
-trivial and resolving conflicts could cause more problems than skipping
-them. The commits were done upstream to support reporting statistics
-from NBD migration.
-
-The refactors moved qemuMigrationFetchJobStatus (hidden in
-qemuMigrationUpdateJobStatus in RHEL-7.4) out of
-qemuMigrationCheckJobStatus. Because of this, the upstream version of
-qemuMigrationCheckJobStatus didn't have to do anything special for the
-QEMU_DOMAIN_JOB_STATUS_COMPLETED switch branch. But downstream called
-qemuMigrationUpdateJobStatus in this branch and thus
-QEMU_DOMAIN_JOB_STATUS_COMPLETED should have been replaced with
-QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED to make sure the migration
-statistics are properly fetched from QEMU once migration completes.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530130
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 2b1e8dd9fd..ab5398f5ea 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -1452,7 +1452,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
-                        qemuMigrationJobName(vm), _("canceled by client"));
-         return -1;
- 
--    case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
-+    case QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED:
-         /* Fetch statistics of a completed migration */
-         if (events && updateJobStats &&
-             qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0)
-@@ -1461,7 +1461,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
- 
-     case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
-     case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
--    case QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED:
-+    case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
-     case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
-         break;
-     }
--- 
-2.16.0
-
diff --git a/SOURCES/libvirt-RHEL-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch b/SOURCES/libvirt-RHEL-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch
index 3611f76..cf534ed 100644
--- a/SOURCES/libvirt-RHEL-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch
+++ b/SOURCES/libvirt-RHEL-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch
@@ -1,5 +1,5 @@
-From 8e998fbb777e15718145899a60cd3d65accf68c9 Mon Sep 17 00:00:00 2001
-Message-Id: <8e998fbb777e15718145899a60cd3d65accf68c9@dist-git>
+From 569531d2a63be9a2e4d3c234b22391e7fcd8e5cc Mon Sep 17 00:00:00 2001
+Message-Id: <569531d2a63be9a2e4d3c234b22391e7fcd8e5cc@dist-git>
 From: Martin Kletzander <mkletzan@redhat.com>
 Date: Mon, 23 Nov 2015 12:46:36 +0100
 Subject: [PATCH] RHEL: qemu: Support vhost-user-multiqueue with QEMU 2.3
@@ -16,10 +16,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  1 file changed, 5 insertions(+), 2 deletions(-)
 
 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 629fc8a9b..83ebcd020 100644
+index 10ec0d4bb9..37a58b3640 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
-@@ -4548,8 +4548,11 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
+@@ -4761,8 +4761,11 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
          virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_AARCH64_OFF);
  
      /* vhost-user supports multi-queue from v2.4.0 onwards,
@@ -34,5 +34,5 @@ index 629fc8a9b..83ebcd020 100644
  
      /* smm option is supported from v2.4.0 */
 -- 
-2.12.2
+2.14.3
 
diff --git a/SOURCES/libvirt-RHEL-qemu-support-relative-backing-for-RHEL-7.0.z-qemu.patch b/SOURCES/libvirt-RHEL-qemu-support-relative-backing-for-RHEL-7.0.z-qemu.patch
index b03fb90..418c241 100644
--- a/SOURCES/libvirt-RHEL-qemu-support-relative-backing-for-RHEL-7.0.z-qemu.patch
+++ b/SOURCES/libvirt-RHEL-qemu-support-relative-backing-for-RHEL-7.0.z-qemu.patch
@@ -1,5 +1,5 @@
-From e57574f1c3a506267da6676a0036bc35dbd923b3 Mon Sep 17 00:00:00 2001
-Message-Id: <e57574f1c3a506267da6676a0036bc35dbd923b3@dist-git>
+From 9c0e9d27d742f8150378cb228a64662d9c4984d4 Mon Sep 17 00:00:00 2001
+Message-Id: <9c0e9d27d742f8150378cb228a64662d9c4984d4@dist-git>
 From: Eric Blake <eblake@redhat.com>
 Date: Tue, 7 Oct 2014 17:06:17 -0600
 Subject: [PATCH] RHEL: qemu: support relative backing for RHEL 7.0.z qemu
@@ -25,10 +25,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  1 file changed, 1 insertion(+)
 
 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index b1245ad5d..629fc8a9b 100644
+index 7cb091056b..10ec0d4bb9 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
-@@ -1480,6 +1480,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {
+@@ -1555,6 +1555,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {
      { "add-fd", QEMU_CAPS_ADD_FD },
      { "nbd-server-start", QEMU_CAPS_NBD_SERVER },
      { "change-backing-file", QEMU_CAPS_CHANGE_BACKING_FILE },
@@ -37,5 +37,5 @@ index b1245ad5d..629fc8a9b 100644
      { "migrate-incoming", QEMU_CAPS_INCOMING_DEFER },
      { "query-hotpluggable-cpus", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS },
 -- 
-2.12.2
+2.14.3
 
diff --git a/SOURCES/libvirt-RHEL-screenshot-Implement-multiple-screen-support.patch b/SOURCES/libvirt-RHEL-screenshot-Implement-multiple-screen-support.patch
index 14cd198..dc3cb8d 100644
--- a/SOURCES/libvirt-RHEL-screenshot-Implement-multiple-screen-support.patch
+++ b/SOURCES/libvirt-RHEL-screenshot-Implement-multiple-screen-support.patch
@@ -1,5 +1,5 @@
-From 647ae3f777d7b2b20e6e0caa4603c0b162cca9ec Mon Sep 17 00:00:00 2001
-Message-Id: <647ae3f777d7b2b20e6e0caa4603c0b162cca9ec@dist-git>
+From e326d80a0b1ff2606e16e6fabea8a1914a5cd1d2 Mon Sep 17 00:00:00 2001
+Message-Id: <e326d80a0b1ff2606e16e6fabea8a1914a5cd1d2@dist-git>
 From: Michal Privoznik <mprivozn@redhat.com>
 Date: Fri, 26 Aug 2011 16:41:17 +0800
 Subject: [PATCH] RHEL: screenshot: Implement multiple screen support
@@ -34,10 +34,10 @@ Conflicts:
  5 files changed, 57 insertions(+), 10 deletions(-)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 3cc4f4d66..3f3eca440 100644
+index 1dff53441b..82c60e6ef1 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
-@@ -3791,6 +3791,8 @@ qemuDomainScreenshot(virDomainPtr dom,
+@@ -3999,6 +3999,8 @@ qemuDomainScreenshot(virDomainPtr dom,
      char *ret = NULL;
      bool unlink_tmp = false;
      virQEMUDriverConfigPtr cfg = NULL;
@@ -46,7 +46,7 @@ index 3cc4f4d66..3f3eca440 100644
  
      virCheckFlags(0, NULL);
  
-@@ -3812,12 +3814,15 @@ qemuDomainScreenshot(virDomainPtr dom,
+@@ -4020,12 +4022,15 @@ qemuDomainScreenshot(virDomainPtr dom,
          goto endjob;
      }
  
@@ -68,7 +68,7 @@ index 3cc4f4d66..3f3eca440 100644
          goto endjob;
      }
  
-@@ -3832,8 +3837,11 @@ qemuDomainScreenshot(virDomainPtr dom,
+@@ -4040,8 +4045,11 @@ qemuDomainScreenshot(virDomainPtr dom,
  
      qemuSecuritySetSavedStateLabel(driver->securityManager, vm->def, tmp);
  
@@ -82,10 +82,10 @@ index 3cc4f4d66..3f3eca440 100644
          goto endjob;
      }
 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
-index a4fa6eca6..8bc00bc1e 100644
+index dd9d64a207..3cf23db874 100644
 --- a/src/qemu/qemu_monitor.c
 +++ b/src/qemu/qemu_monitor.c
-@@ -3409,12 +3409,22 @@ qemuMonitorSendKey(qemuMonitorPtr mon,
+@@ -3461,12 +3461,22 @@ qemuMonitorSendKey(qemuMonitorPtr mon,
  
  int
  qemuMonitorScreendump(qemuMonitorPtr mon,
@@ -111,10 +111,10 @@ index a4fa6eca6..8bc00bc1e 100644
          return qemuMonitorJSONScreendump(mon, file);
      else
 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
-index 91ab9057e..c1506b0fc 100644
+index bc8494faee..7e20e96116 100644
 --- a/src/qemu/qemu_monitor.h
 +++ b/src/qemu/qemu_monitor.h
-@@ -876,7 +876,8 @@ int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
+@@ -888,7 +888,8 @@ int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
  int qemuMonitorInjectNMI(qemuMonitorPtr mon);
  
  int qemuMonitorScreendump(qemuMonitorPtr mon,
@@ -125,10 +125,10 @@ index 91ab9057e..c1506b0fc 100644
  int qemuMonitorSendKey(qemuMonitorPtr mon,
                         unsigned int holdtime,
 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
-index aeb777d37..2010657e3 100644
+index 05cc634d20..8a75e0ef7e 100644
 --- a/src/qemu/qemu_monitor_json.c
 +++ b/src/qemu/qemu_monitor_json.c
-@@ -4262,6 +4262,30 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
+@@ -4294,6 +4294,30 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
      return ret;
  }
  
@@ -160,10 +160,10 @@ index aeb777d37..2010657e3 100644
                                const char *file)
  {
 diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
-index d090d5709..fb697033c 100644
+index 739a99293c..02a504ab85 100644
 --- a/src/qemu/qemu_monitor_json.h
 +++ b/src/qemu/qemu_monitor_json.h
-@@ -291,6 +291,10 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
+@@ -292,6 +292,10 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
                             unsigned int *keycodes,
                             unsigned int nkeycodes);
  
@@ -175,5 +175,5 @@ index d090d5709..fb697033c 100644
                                const char *file);
  
 -- 
-2.12.2
+2.14.3
 
diff --git a/SOURCES/libvirt-Remove-pointless-check-for-ret-in-virDomainNetDefCoalesceParseXML.patch b/SOURCES/libvirt-Remove-pointless-check-for-ret-in-virDomainNetDefCoalesceParseXML.patch
deleted file mode 100644
index b45264f..0000000
--- a/SOURCES/libvirt-Remove-pointless-check-for-ret-in-virDomainNetDefCoalesceParseXML.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From 25fbc5c619a4277086b0bce0e3a55dd4099d4ab2 Mon Sep 17 00:00:00 2001
-Message-Id: <25fbc5c619a4277086b0bce0e3a55dd4099d4ab2@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Tue, 25 Apr 2017 13:41:20 +0200
-Subject: [PATCH] Remove pointless check for !ret in
- virDomainNetDefCoalesceParseXML
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1414627
-
-It was left there after removing a macro it was part of in first
-version or so.  Now it will always be NULL.
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-(cherry picked from commit b2763f189c5b306a685021b4fede9e2cee8528de)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 47022c329..2d5d00cf2 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -6776,7 +6776,7 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node,
-     if (!str)
-         goto cleanup;
- 
--    if (!ret && VIR_ALLOC(ret) < 0)
-+    if (VIR_ALLOC(ret) < 0)
-         goto cleanup;
- 
-     if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) {
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-Rename-virResctrlInfo-to-virResctrlInfoPerCache.patch b/SOURCES/libvirt-Rename-virResctrlInfo-to-virResctrlInfoPerCache.patch
new file mode 100644
index 0000000..bb00ca1
--- /dev/null
+++ b/SOURCES/libvirt-Rename-virResctrlInfo-to-virResctrlInfoPerCache.patch
@@ -0,0 +1,97 @@
+From f8604e5cb29526fa7374b1a6690ac3b285720c3f Mon Sep 17 00:00:00 2001
+Message-Id: <f8604e5cb29526fa7374b1a6690ac3b285720c3f@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:24 +0100
+Subject: [PATCH] Rename virResctrlInfo to virResctrlInfoPerCache
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Just to ease the review of following patches.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit b2211a9e5492879be5f3c6ab9ed2d0dba849c964)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/conf/capabilities.c | 2 +-
+ src/conf/capabilities.h | 2 +-
+ src/util/virresctrl.c   | 4 ++--
+ src/util/virresctrl.h   | 8 ++++----
+ 4 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
+index 798c9bdaea..e93eaed2f0 100644
+--- a/src/conf/capabilities.c
++++ b/src/conf/capabilities.c
+@@ -904,7 +904,7 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
+         virBufferSetChildIndent(&controlBuf, buf);
+         for (j = 0; j < bank->ncontrols; j++) {
+             const char *min_unit;
+-            virResctrlInfoPtr controls = bank->controls[j];
++            virResctrlInfoPerCachePtr controls = bank->controls[j];
+             unsigned long long gran_short_size = controls->granularity;
+             unsigned long long min_short_size = controls->min;
+ 
+diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
+index 5048fa819d..27b88cb5ed 100644
+--- a/src/conf/capabilities.h
++++ b/src/conf/capabilities.h
+@@ -148,7 +148,7 @@ struct _virCapsHostCacheBank {
+     virCacheType type;  /* Data, Instruction or Unified */
+     virBitmapPtr cpus;  /* All CPUs that share this bank */
+     size_t ncontrols;
+-    virResctrlInfoPtr *controls;
++    virResctrlInfoPerCachePtr *controls;
+ };
+ 
+ typedef struct _virCapsHost virCapsHost;
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index 2a11825a52..050a08178e 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -59,7 +59,7 @@ int
+ virResctrlGetCacheInfo(unsigned int level,
+                        unsigned long long size,
+                        virCacheType scope,
+-                       virResctrlInfoPtr **controls,
++                       virResctrlInfoPerCachePtr **controls,
+                        size_t *ncontrols)
+ {
+     int ret = -1;
+@@ -69,7 +69,7 @@ virResctrlGetCacheInfo(unsigned int level,
+     char *type_upper = NULL;
+     unsigned int bits = 0;
+     unsigned int min_cbm_bits = 0;
+-    virResctrlInfoPtr control;
++    virResctrlInfoPerCachePtr control;
+ 
+     if (VIR_ALLOC(control) < 0)
+         goto cleanup;
+diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
+index 848b13e98a..42e8527803 100644
+--- a/src/util/virresctrl.h
++++ b/src/util/virresctrl.h
+@@ -36,9 +36,9 @@ typedef enum {
+ VIR_ENUM_DECL(virCache);
+ 
+ 
+-typedef struct _virResctrlInfo virResctrlInfo;
+-typedef virResctrlInfo *virResctrlInfoPtr;
+-struct _virResctrlInfo {
++typedef struct _virResctrlInfoPerCache virResctrlInfoPerCache;
++typedef virResctrlInfoPerCache *virResctrlInfoPerCachePtr;
++struct _virResctrlInfoPerCache {
+     /* Smallest possible increase of the allocation size in bytes */
+     unsigned long long granularity;
+     /* Minimal allocatable size in bytes (if different from granularity) */
+@@ -54,7 +54,7 @@ int
+ virResctrlGetCacheInfo(unsigned int level,
+                        unsigned long long size,
+                        virCacheType scope,
+-                       virResctrlInfoPtr **controls,
++                       virResctrlInfoPerCachePtr **controls,
+                        size_t *ncontrols);
+ 
+ int
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-Revert-qemu-monitor-do-not-report-error-on-shutdown.patch b/SOURCES/libvirt-Revert-qemu-monitor-do-not-report-error-on-shutdown.patch
new file mode 100644
index 0000000..5e23027
--- /dev/null
+++ b/SOURCES/libvirt-Revert-qemu-monitor-do-not-report-error-on-shutdown.patch
@@ -0,0 +1,69 @@
+From be2ee0f5055cff0fd449ce972935f1af8ebfee84 Mon Sep 17 00:00:00 2001
+Message-Id: <be2ee0f5055cff0fd449ce972935f1af8ebfee84@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Fri, 19 Jan 2018 14:35:17 +0100
+Subject: [PATCH] Revert "qemu: monitor: do not report error on shutdown"
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1536461
+
+This reverts commit aeda1b8c56dc58b0a413acc61bbea938b40499e1.
+
+Problem is that we need mon->lastError to be set because it's
+used all over the place. Also, there's nothing wrong with
+reporting error if one occurred. I mean, if there's a thread
+executing an API and which currently is talking on monitor it
+definitely wants the error reported.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+(cherry picked from commit 72adaf2f10509c3682f2c65ffad4176e00e5a2fb)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_monitor.c | 10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
+index 12ad45d340..b6af209a83 100644
+--- a/src/qemu/qemu_monitor.c
++++ b/src/qemu/qemu_monitor.c
+@@ -69,7 +69,6 @@ struct _qemuMonitor {
+      * < 0: an error occurred during the registration of @fd */
+     int watch;
+     int hasSendFD;
+-    int willhangup;
+ 
+     virDomainObjPtr vm;
+ 
+@@ -701,10 +700,8 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque)
+         if (events & VIR_EVENT_HANDLE_HANGUP) {
+             hangup = true;
+             if (!error) {
+-                if (!mon->willhangup) {
+-                    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+-                                   _("End of file from qemu monitor"));
+-                }
++                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                               _("End of file from qemu monitor"));
+                 eof = true;
+                 events &= ~VIR_EVENT_HANDLE_HANGUP;
+             }
+@@ -743,7 +740,7 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque)
+         if (mon->lastError.code != VIR_ERR_OK) {
+             /* Already have an error, so clear any new error */
+             virResetLastError();
+-        } else if (!mon->willhangup) {
++        } else {
+             virErrorPtr err = virGetLastError();
+             if (!err)
+                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+@@ -1337,7 +1334,6 @@ qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest)
+ {
+     int ret = -1;
+     VIR_DEBUG("mon=%p guest=%u", mon, guest);
+-    mon->willhangup = 1;
+ 
+     QEMU_MONITOR_CALLBACK(mon, ret, domainShutdown, mon->vm, guest);
+     return ret;
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-Revert-qemu-propagate-bridge-MTU-into-qemu-host_mtu-option.patch b/SOURCES/libvirt-Revert-qemu-propagate-bridge-MTU-into-qemu-host_mtu-option.patch
deleted file mode 100644
index 644df32..0000000
--- a/SOURCES/libvirt-Revert-qemu-propagate-bridge-MTU-into-qemu-host_mtu-option.patch
+++ /dev/null
@@ -1,204 +0,0 @@
-From b36260c361f9d8a854c4d5e9c7309aed7cb99834 Mon Sep 17 00:00:00 2001
-Message-Id: <b36260c361f9d8a854c4d5e9c7309aed7cb99834@dist-git>
-From: Laine Stump <laine@laine.org>
-Date: Tue, 23 May 2017 13:02:42 -0400
-Subject: [PATCH] Revert "qemu: propagate bridge MTU into qemu "host_mtu"
- option"
-
-This reverts commit 2841e675.
-
-It turns out that adding the host_mtu field to the PCI capabilities in
-the guest bumps the length of PCI capabilities beyond the 32 byte
-boundary, so the virtio-net device gets 64 bytes of ioport space
-instead of 32, which offsets the address of all the other following
-devices. Migration doesn't work very well when the location and length
-of PCI capabilities of devices is changed between source and
-destination.
-
-This means that we need to make sure that the absence/presence of
-host_mtu on the qemu commandline always matches between source and
-destination, which means that we need to make setting of host_mtu an
-opt-in thing (it can't happen automatically when the bridge being used
-has a non-default MTU, which is what commit 2841e675 implemented).
-
-I do want to re-implement this feature with an <mtu auto='on'/>
-setting, but probably won't backport that to any stable branches, so
-I'm first reverting the original commit, and that revert can be pushed
-to the few releases that have been made since the original (3.1.0 -
-3.3.0)
-
-Resolves: https://bugzilla.redhat.com/1449346
-(cherry picked from commit 77780a29edace958a1f931d3281b962be4f5290e)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_command.c   | 32 ++++++++++----------------------
- src/qemu/qemu_command.h   |  3 +--
- src/qemu/qemu_hotplug.c   |  5 ++---
- src/qemu/qemu_interface.c |  5 ++---
- src/qemu/qemu_interface.h |  3 +--
- 5 files changed, 16 insertions(+), 32 deletions(-)
-
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 30feef1de..4d3a3d8ca 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -3633,8 +3633,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
-                    int vlan,
-                    unsigned int bootindex,
-                    size_t vhostfdSize,
--                   virQEMUCapsPtr qemuCaps,
--                   unsigned int mtu)
-+                   virQEMUCapsPtr qemuCaps)
- {
-     virBuffer buf = VIR_BUFFER_INITIALIZER;
-     const char *nic = net->model;
-@@ -3758,23 +3757,13 @@ qemuBuildNicDevStr(virDomainDefPtr def,
-         virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size);
-     }
- 
--    if (usingVirtio && mtu) {
--        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) {
--
--            virBufferAsprintf(&buf, ",host_mtu=%u", mtu);
--
--        } else {
--            /* log an error if mtu was requested specifically for this
--             * interface, otherwise, if it's just what was reported by
--             * the attached network, ignore it.
--             */
--            if (net->mtu) {
--                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
--                               _("setting MTU is not supported with "
--                                 "this QEMU binary"));
--                goto error;
--            }
-+    if (usingVirtio && net->mtu) {
-+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                           _("setting MTU is not supported with this QEMU binary"));
-+            goto error;
-         }
-+        virBufferAsprintf(&buf, ",host_mtu=%u", net->mtu);
-     }
- 
-     if (vlan == -1)
-@@ -8275,7 +8264,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
-     VIR_FREE(netdev);
- 
-     if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex,
--                                   queues, qemuCaps, net->mtu))) {
-+                                   queues, qemuCaps))) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-                        "%s", _("Error generating NIC -device string"));
-         goto error;
-@@ -8321,7 +8310,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
-     virDomainNetType actualType = virDomainNetGetActualType(net);
-     virNetDevBandwidthPtr actualBandwidth;
-     size_t i;
--    unsigned int mtu = net->mtu;
- 
- 
-     if (!bootindex)
-@@ -8376,7 +8364,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
-         memset(tapfd, -1, tapfdSize * sizeof(tapfd[0]));
- 
-         if (qemuInterfaceBridgeConnect(def, driver, net,
--                                       tapfd, &tapfdSize, &mtu) < 0)
-+                                       tapfd, &tapfdSize) < 0)
-             goto cleanup;
-         break;
- 
-@@ -8556,7 +8544,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
-     }
-     if (qemuDomainSupportsNicdev(def, net)) {
-         if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
--                                       vhostfdSize, qemuCaps, mtu)))
-+                                       vhostfdSize, qemuCaps)))
-             goto cleanup;
-         virCommandAddArgList(cmd, "-device", nic, NULL);
-     } else {
-diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
-index 7da92c8c9..09cb00ee9 100644
---- a/src/qemu/qemu_command.h
-+++ b/src/qemu/qemu_command.h
-@@ -101,8 +101,7 @@ char *qemuBuildNicDevStr(virDomainDefPtr def,
-                          int vlan,
-                          unsigned int bootindex,
-                          size_t vhostfdSize,
--                         virQEMUCapsPtr qemuCaps,
--                         unsigned int mtu);
-+                         virQEMUCapsPtr qemuCaps);
- 
- char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);
- 
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index 5c3660922..cdeb0617a 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -968,7 +968,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
-     bool charDevPlugged = false;
-     bool netdevPlugged = false;
-     bool hostPlugged = false;
--    unsigned int mtu = net->mtu;
- 
-     /* preallocate new slot for device */
-     if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0)
-@@ -1025,7 +1024,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
-             goto cleanup;
-         memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize);
-         if (qemuInterfaceBridgeConnect(vm->def, driver, net,
--                                       tapfd, &tapfdSize, &mtu) < 0)
-+                                       tapfd, &tapfdSize) < 0)
-             goto cleanup;
-         iface_connected = true;
-         if (qemuInterfaceOpenVhostNet(vm->def, net, priv->qemuCaps,
-@@ -1239,7 +1238,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
-         VIR_FORCE_CLOSE(vhostfd[i]);
- 
-     if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
--                                      queueSize, priv->qemuCaps, mtu)))
-+                                      queueSize, priv->qemuCaps)))
-         goto try_remove;
- 
-     qemuDomainObjEnterMonitor(driver, vm);
-diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
-index c643b76ec..e11d69c3e 100644
---- a/src/qemu/qemu_interface.c
-+++ b/src/qemu/qemu_interface.c
-@@ -503,8 +503,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
-                            virQEMUDriverPtr driver,
-                            virDomainNetDefPtr net,
-                            int *tapfd,
--                           size_t *tapfdSize,
--                           unsigned int *mtu)
-+                           size_t *tapfdSize)
- {
-     const char *brname;
-     int ret = -1;
-@@ -545,7 +544,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
-                                            def->uuid, tunpath, tapfd, *tapfdSize,
-                                            virDomainNetGetActualVirtPortProfile(net),
-                                            virDomainNetGetActualVlan(net),
--                                           net->coalesce, net->mtu, mtu,
-+                                           net->coalesce, 0, NULL,
-                                            tap_create_flags) < 0) {
-             virDomainAuditNetDevice(def, net, tunpath, false);
-             goto cleanup;
-diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h
-index ba74ac2cf..a7faa0b3d 100644
---- a/src/qemu/qemu_interface.h
-+++ b/src/qemu/qemu_interface.h
-@@ -51,8 +51,7 @@ int qemuInterfaceBridgeConnect(virDomainDefPtr def,
-                                virQEMUDriverPtr driver,
-                                virDomainNetDefPtr net,
-                                int *tapfd,
--                               size_t *tapfdSize,
--                               unsigned int *mtu)
-+                               size_t *tapfdSize)
-     ATTRIBUTE_NONNULL(2);
- 
- int qemuInterfaceOpenVhostNet(virDomainDefPtr def,
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-Revert-virNetDevSupportBandwidth-Enable-QoS-for-vhostuser.patch b/SOURCES/libvirt-Revert-virNetDevSupportBandwidth-Enable-QoS-for-vhostuser.patch
new file mode 100644
index 0000000..c75d21b
--- /dev/null
+++ b/SOURCES/libvirt-Revert-virNetDevSupportBandwidth-Enable-QoS-for-vhostuser.patch
@@ -0,0 +1,39 @@
+From 9d000db886030a45b1d8d016dd884db6b61419de Mon Sep 17 00:00:00 2001
+Message-Id: <9d000db886030a45b1d8d016dd884db6b61419de@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Mon, 13 Nov 2017 14:26:00 +0100
+Subject: [PATCH] Revert "virNetDevSupportBandwidth: Enable QoS for vhostuser"
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1497410
+
+This reverts commit bc8a99ef06417a2303ccab455f9f045e2a617916.
+
+The vhostuser is not a TAP. Therefore our QoS code is not able to
+set any bandwidth. I don't really understand what I was thinking.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+(cherry picked from commit 676768edeb28689c48f8fe9b6923003c1ed39584)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/netdev_bandwidth_conf.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/conf/netdev_bandwidth_conf.h b/src/conf/netdev_bandwidth_conf.h
+index c378280654..30f988953c 100644
+--- a/src/conf/netdev_bandwidth_conf.h
++++ b/src/conf/netdev_bandwidth_conf.h
+@@ -46,9 +46,9 @@ static inline bool virNetDevSupportBandwidth(virDomainNetType type)
+     case VIR_DOMAIN_NET_TYPE_NETWORK:
+     case VIR_DOMAIN_NET_TYPE_DIRECT:
+     case VIR_DOMAIN_NET_TYPE_ETHERNET:
+-    case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+         return true;
+     case VIR_DOMAIN_NET_TYPE_USER:
++    case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+     case VIR_DOMAIN_NET_TYPE_SERVER:
+     case VIR_DOMAIN_NET_TYPE_CLIENT:
+     case VIR_DOMAIN_NET_TYPE_MCAST:
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-Set-coalesce-settings-for-domain-interfaces.patch b/SOURCES/libvirt-Set-coalesce-settings-for-domain-interfaces.patch
deleted file mode 100644
index 745263f..0000000
--- a/SOURCES/libvirt-Set-coalesce-settings-for-domain-interfaces.patch
+++ /dev/null
@@ -1,142 +0,0 @@
-From 7fadd91380ce1000f3aa5b6e5c4b928f883fbb33 Mon Sep 17 00:00:00 2001
-Message-Id: <7fadd91380ce1000f3aa5b6e5c4b928f883fbb33@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Tue, 25 Apr 2017 13:41:17 +0200
-Subject: [PATCH] Set coalesce settings for domain interfaces
-
-This patch makes use of the virNetDevSetCoalesce() function to make
-appropriate settings effective for devices that support them.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1414627
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-(cherry picked from commit fcef44728dff9cb708d00d17f5e0b44aa513f27b)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/bhyve/bhyve_command.c   | 2 +-
- src/network/bridge_driver.c | 2 +-
- src/qemu/qemu_interface.c   | 2 +-
- src/uml/uml_conf.c          | 2 +-
- src/util/virnetdevtap.c     | 5 +++++
- src/util/virnetdevtap.h     | 2 ++
- tests/bhyvexml2argvmock.c   | 1 +
- 7 files changed, 12 insertions(+), 4 deletions(-)
-
-diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
-index e0528ed77..e9c072b9f 100644
---- a/src/bhyve/bhyve_command.c
-+++ b/src/bhyve/bhyve_command.c
-@@ -100,7 +100,7 @@ bhyveBuildNetArgStr(virConnectPtr conn,
-                                            def->uuid, NULL, NULL, 0,
-                                            virDomainNetGetActualVirtPortProfile(net),
-                                            virDomainNetGetActualVlan(net),
--                                           0, NULL,
-+                                           NULL, 0, NULL,
-                                            VIR_NETDEV_TAP_CREATE_IFUP | VIR_NETDEV_TAP_CREATE_PERSIST) < 0) {
-             goto cleanup;
-         }
-diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
-index 41bce794a..b0026ab17 100644
---- a/src/network/bridge_driver.c
-+++ b/src/network/bridge_driver.c
-@@ -2315,7 +2315,7 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver,
-         if (virNetDevTapCreateInBridgePort(network->def->bridge,
-                                            &macTapIfName, &network->def->mac,
-                                            NULL, NULL, &tapfd, 1, NULL, NULL,
--                                           network->def->mtu, NULL,
-+                                           NULL, network->def->mtu, NULL,
-                                            VIR_NETDEV_TAP_CREATE_USE_MAC_FOR_BRIDGE |
-                                            VIR_NETDEV_TAP_CREATE_IFUP |
-                                            VIR_NETDEV_TAP_CREATE_PERSIST) < 0) {
-diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
-index c5dca60f1..2057ac929 100644
---- a/src/qemu/qemu_interface.c
-+++ b/src/qemu/qemu_interface.c
-@@ -545,7 +545,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
-                                            def->uuid, tunpath, tapfd, *tapfdSize,
-                                            virDomainNetGetActualVirtPortProfile(net),
-                                            virDomainNetGetActualVlan(net),
--                                           net->mtu, mtu,
-+                                           net->coalesce, net->mtu, mtu,
-                                            tap_create_flags) < 0) {
-             virDomainAuditNetDevice(def, net, tunpath, false);
-             goto cleanup;
-diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
-index 871653c5a..bdef78324 100644
---- a/src/uml/uml_conf.c
-+++ b/src/uml/uml_conf.c
-@@ -125,7 +125,7 @@ umlConnectTapDevice(virDomainDefPtr vm,
-                                        vm->uuid, net->backend.tap, &tapfd, 1,
-                                        virDomainNetGetActualVirtPortProfile(net),
-                                        virDomainNetGetActualVlan(net),
--                                       0, NULL,
-+                                       NULL, 0, NULL,
-                                        VIR_NETDEV_TAP_CREATE_IFUP |
-                                        VIR_NETDEV_TAP_CREATE_PERSIST) < 0) {
-         if (template_ifname)
-diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
-index 93002b929..c8dacfe27 100644
---- a/src/util/virnetdevtap.c
-+++ b/src/util/virnetdevtap.c
-@@ -584,6 +584,7 @@ virNetDevTapAttachBridge(const char *tapname,
-  * @tapfd: array of file descriptor return value for the new tap device
-  * @tapfdSize: number of file descriptors in @tapfd
-  * @virtPortProfile: bridge/port specific configuration
-+ * @coalesce: optional coalesce parameters
-  * @mtu: requested MTU for port (or 0 for "default")
-  * @actualMTU: MTU actually set for port (after accounting for bridge's MTU)
-  * @flags: OR of virNetDevTapCreateFlags:
-@@ -616,6 +617,7 @@ int virNetDevTapCreateInBridgePort(const char *brname,
-                                    size_t tapfdSize,
-                                    virNetDevVPortProfilePtr virtPortProfile,
-                                    virNetDevVlanPtr virtVlan,
-+                                   virNetDevCoalescePtr coalesce,
-                                    unsigned int mtu,
-                                    unsigned int *actualMTU,
-                                    unsigned int flags)
-@@ -661,6 +663,9 @@ int virNetDevTapCreateInBridgePort(const char *brname,
-     if (virNetDevSetOnline(*ifname, !!(flags & VIR_NETDEV_TAP_CREATE_IFUP)) < 0)
-         goto error;
- 
-+    if (virNetDevSetCoalesce(*ifname, coalesce) < 0)
-+        goto error;
-+
-     return 0;
- 
-  error:
-diff --git a/src/util/virnetdevtap.h b/src/util/virnetdevtap.h
-index 6bb3b8891..bd5ec14d4 100644
---- a/src/util/virnetdevtap.h
-+++ b/src/util/virnetdevtap.h
-@@ -24,6 +24,7 @@
- # define __VIR_NETDEV_TAP_H__
- 
- # include "internal.h"
-+# include "virnetdev.h"
- # include "virnetdevvportprofile.h"
- # include "virnetdevvlan.h"
- 
-@@ -83,6 +84,7 @@ int virNetDevTapCreateInBridgePort(const char *brname,
-                                    size_t tapfdSize,
-                                    virNetDevVPortProfilePtr virtPortProfile,
-                                    virNetDevVlanPtr virtVlan,
-+                                   virNetDevCoalescePtr coalesce,
-                                    unsigned int mtu,
-                                    unsigned int *actualMTU,
-                                    unsigned int flags)
-diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c
-index fd714694f..7afa0e34c 100644
---- a/tests/bhyvexml2argvmock.c
-+++ b/tests/bhyvexml2argvmock.c
-@@ -28,6 +28,7 @@ int virNetDevTapCreateInBridgePort(const char *brname ATTRIBUTE_UNUSED,
-                                    size_t tapfdSize ATTRIBUTE_UNUSED,
-                                    virNetDevVPortProfilePtr virtPortProfile ATTRIBUTE_UNUSED,
-                                    virNetDevVlanPtr virtVlan ATTRIBUTE_UNUSED,
-+                                   virNetDevCoalescePtr coalesce ATTRIBUTE_UNUSED,
-                                    unsigned int mtu ATTRIBUTE_UNUSED,
-                                    unsigned int *actualMTU ATTRIBUTE_UNUSED,
-                                    unsigned int fakeflags ATTRIBUTE_UNUSED)
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-Split-out-virDomainIOMMUDefFormat.patch b/SOURCES/libvirt-Split-out-virDomainIOMMUDefFormat.patch
deleted file mode 100644
index 5df4c85..0000000
--- a/SOURCES/libvirt-Split-out-virDomainIOMMUDefFormat.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-From 0823b17d4ddc02a0bfca9fece7ff5ae3fd106a91 Mon Sep 17 00:00:00 2001
-Message-Id: <0823b17d4ddc02a0bfca9fece7ff5ae3fd106a91@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:49 +0200
-Subject: [PATCH] Split out virDomainIOMMUDefFormat
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Make adding subelements easier.
-
-(cherry picked from commit d34ac94351255721ae86eba561cd2ba1d620ab7b)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 15 +++++++++++----
- 1 file changed, 11 insertions(+), 4 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index a918ecd59..4096b9caf 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -24068,6 +24068,15 @@ virDomainDefIothreadShouldFormat(virDomainDefPtr def)
- }
- 
- 
-+static void
-+virDomainIOMMUDefFormat(virBufferPtr buf,
-+                        const virDomainIOMMUDef *iommu)
-+{
-+    virBufferAsprintf(buf, "<iommu model='%s'/>\n",
-+                      virDomainIOMMUModelTypeToString(iommu->model));
-+}
-+
-+
- /* This internal version appends to an existing buffer
-  * (possibly with auto-indent), rather than flattening
-  * to string.
-@@ -24814,10 +24823,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
-             goto error;
-     }
- 
--    if (def->iommu) {
--        virBufferAsprintf(buf, "<iommu model='%s'/>\n",
--                          virDomainIOMMUModelTypeToString(def->iommu->model));
--    }
-+    if (def->iommu)
-+        virDomainIOMMUDefFormat(buf, def->iommu);
- 
-     virBufferAdjustIndent(buf, -2);
-     virBufferAddLit(buf, "</devices>\n");
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-Use-a-separate-buffer-for-controller-driver.patch b/SOURCES/libvirt-Use-a-separate-buffer-for-controller-driver.patch
deleted file mode 100644
index 8c44da7..0000000
--- a/SOURCES/libvirt-Use-a-separate-buffer-for-controller-driver.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From 4e32b3e8ab394aaf1f94b1166d7c5e38cec8ede4 Mon Sep 17 00:00:00 2001
-Message-Id: <4e32b3e8ab394aaf1f94b1166d7c5e38cec8ede4@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:48:53 +0200
-Subject: [PATCH] Use a separate buffer for <controller><driver>
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Make adding new attributes easier.
-
-(cherry picked from commit 5e5fc766257b05979c37593434d28cc9eb7e0cf0)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 39 ++++++++++++++++++++-------------------
- 1 file changed, 20 insertions(+), 19 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index d5c5a7030b..242a79a7e7 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -21332,6 +21332,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
-     const char *model = NULL;
-     const char *modelName = NULL;
-     bool pcihole64 = false, pciModel = false, pciTarget = false;
-+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
- 
-     if (!type) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-@@ -21436,26 +21437,26 @@ virDomainControllerDefFormat(virBufferPtr buf,
-             }
-         }
- 
--        if (def->queues || def->cmd_per_lun ||
--            def->max_sectors || def->ioeventfd || def->iothread) {
-+        if (def->queues)
-+            virBufferAsprintf(&driverBuf, " queues='%u'", def->queues);
-+
-+        if (def->cmd_per_lun)
-+            virBufferAsprintf(&driverBuf, " cmd_per_lun='%u'", def->cmd_per_lun);
-+
-+        if (def->max_sectors)
-+            virBufferAsprintf(&driverBuf, " max_sectors='%u'", def->max_sectors);
-+
-+        if (def->ioeventfd) {
-+            virBufferAsprintf(&driverBuf, " ioeventfd='%s'",
-+                              virTristateSwitchTypeToString(def->ioeventfd));
-+        }
-+
-+        if (def->iothread)
-+            virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
-+
-+        if (virBufferUse(&driverBuf)) {
-             virBufferAddLit(buf, "<driver");
--            if (def->queues)
--                virBufferAsprintf(buf, " queues='%u'", def->queues);
--
--            if (def->cmd_per_lun)
--                virBufferAsprintf(buf, " cmd_per_lun='%u'", def->cmd_per_lun);
--
--            if (def->max_sectors)
--                virBufferAsprintf(buf, " max_sectors='%u'", def->max_sectors);
--
--            if (def->ioeventfd) {
--                virBufferAsprintf(buf, " ioeventfd='%s'",
--                                  virTristateSwitchTypeToString(def->ioeventfd));
--            }
--
--            if (def->iothread)
--                virBufferAsprintf(buf, " iothread='%u'", def->iothread);
--
-+            virBufferAddBuffer(buf, &driverBuf);
-             virBufferAddLit(buf, "/>\n");
-         }
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-Use-a-separate-buffer-for-disk-driver.patch b/SOURCES/libvirt-Use-a-separate-buffer-for-disk-driver.patch
deleted file mode 100644
index d623c15..0000000
--- a/SOURCES/libvirt-Use-a-separate-buffer-for-disk-driver.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 0f6008b1fa9b236f673163a123b71aeebb6b4454 Mon Sep 17 00:00:00 2001
-Message-Id: <0f6008b1fa9b236f673163a123b71aeebb6b4454@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:48:52 +0200
-Subject: [PATCH] Use a separate buffer for <disk><driver>
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Eliminate the big condition at the start.
-Instead use a buffer and only format the element if the buffer
-is non-empty.
-
-(cherry picked from commit d89803d27c3088aff6f4d062a578fc9938a80e04)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 55 +++++++++++++++++++++++++-------------------------
- 1 file changed, 27 insertions(+), 28 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 4228cad610..d5c5a7030b 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -21088,6 +21088,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
-     const char *sgio = virDomainDeviceSGIOTypeToString(def->sgio);
-     const char *discard = virDomainDiskDiscardTypeToString(def->discard);
-     const char *detect_zeroes = virDomainDiskDetectZeroesTypeToString(def->detect_zeroes);
-+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
- 
-     if (!type || !def->src->type) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-@@ -21139,35 +21140,33 @@ virDomainDiskDefFormat(virBufferPtr buf,
-     virBufferAddLit(buf, ">\n");
-     virBufferAdjustIndent(buf, 2);
- 
--    if (def->src->driverName || def->src->format > 0 || def->cachemode ||
--        def->error_policy || def->rerror_policy || def->iomode ||
--        def->ioeventfd || def->event_idx || def->copy_on_read ||
--        def->discard || def->iothread || def->detect_zeroes) {
-+    virBufferEscapeString(&driverBuf, " name='%s'", def->src->driverName);
-+    if (def->src->format > 0)
-+        virBufferAsprintf(&driverBuf, " type='%s'",
-+                          virStorageFileFormatTypeToString(def->src->format));
-+    if (def->cachemode)
-+        virBufferAsprintf(&driverBuf, " cache='%s'", cachemode);
-+    if (def->error_policy)
-+        virBufferAsprintf(&driverBuf, " error_policy='%s'", error_policy);
-+    if (def->rerror_policy)
-+        virBufferAsprintf(&driverBuf, " rerror_policy='%s'", rerror_policy);
-+    if (def->iomode)
-+        virBufferAsprintf(&driverBuf, " io='%s'", iomode);
-+    if (def->ioeventfd)
-+        virBufferAsprintf(&driverBuf, " ioeventfd='%s'", ioeventfd);
-+    if (def->event_idx)
-+        virBufferAsprintf(&driverBuf, " event_idx='%s'", event_idx);
-+    if (def->copy_on_read)
-+        virBufferAsprintf(&driverBuf, " copy_on_read='%s'", copy_on_read);
-+    if (def->discard)
-+        virBufferAsprintf(&driverBuf, " discard='%s'", discard);
-+    if (def->iothread)
-+        virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
-+    if (def->detect_zeroes)
-+        virBufferAsprintf(&driverBuf, " detect_zeroes='%s'", detect_zeroes);
-+    if (virBufferUse(&driverBuf)) {
-         virBufferAddLit(buf, "<driver");
--        virBufferEscapeString(buf, " name='%s'", def->src->driverName);
--        if (def->src->format > 0)
--            virBufferAsprintf(buf, " type='%s'",
--                              virStorageFileFormatTypeToString(def->src->format));
--        if (def->cachemode)
--            virBufferAsprintf(buf, " cache='%s'", cachemode);
--        if (def->error_policy)
--            virBufferAsprintf(buf, " error_policy='%s'", error_policy);
--        if (def->rerror_policy)
--            virBufferAsprintf(buf, " rerror_policy='%s'", rerror_policy);
--        if (def->iomode)
--            virBufferAsprintf(buf, " io='%s'", iomode);
--        if (def->ioeventfd)
--            virBufferAsprintf(buf, " ioeventfd='%s'", ioeventfd);
--        if (def->event_idx)
--            virBufferAsprintf(buf, " event_idx='%s'", event_idx);
--        if (def->copy_on_read)
--            virBufferAsprintf(buf, " copy_on_read='%s'", copy_on_read);
--        if (def->discard)
--            virBufferAsprintf(buf, " discard='%s'", discard);
--        if (def->iothread)
--            virBufferAsprintf(buf, " iothread='%u'", def->iothread);
--        if (def->detect_zeroes)
--            virBufferAsprintf(buf, " detect_zeroes='%s'", detect_zeroes);
-+        virBufferAddBuffer(buf, &driverBuf);
-         virBufferAddLit(buf, "/>\n");
-     }
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-Use-a-separate-buffer-for-filesystem-driver.patch b/SOURCES/libvirt-Use-a-separate-buffer-for-filesystem-driver.patch
deleted file mode 100644
index e1d6b72..0000000
--- a/SOURCES/libvirt-Use-a-separate-buffer-for-filesystem-driver.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From 71aa3b75eb2f6e01c0c8e0d1bc5c0d29e310d3fd Mon Sep 17 00:00:00 2001
-Message-Id: <71aa3b75eb2f6e01c0c8e0d1bc5c0d29e310d3fd@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:48:54 +0200
-Subject: [PATCH] Use a separate buffer for <filesystem><driver>
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Format the attributes in a separate buffer and only
-print the element if it's not empty.
-
-(cherry picked from commit 8d704e6cf7da60156a0b25b165d4780e99a0fa2f)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 12 +++++++++---
- 1 file changed, 9 insertions(+), 3 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 242a79a7e7..e004559f9f 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -21504,6 +21504,7 @@ virDomainFSDefFormat(virBufferPtr buf,
-     const char *fsdriver = virDomainFSDriverTypeToString(def->fsdriver);
-     const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy);
-     const char *src = def->src->path;
-+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
- 
-     if (!type) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-@@ -21523,16 +21524,21 @@ virDomainFSDefFormat(virBufferPtr buf,
-                       type, accessmode);
-     virBufferAdjustIndent(buf, 2);
-     if (def->fsdriver) {
--        virBufferAsprintf(buf, "<driver type='%s'", fsdriver);
-+        virBufferAsprintf(&driverBuf, " type='%s'", fsdriver);
- 
-         if (def->format)
--            virBufferAsprintf(buf, " format='%s'",
-+            virBufferAsprintf(&driverBuf, " format='%s'",
-                               virStorageFileFormatTypeToString(def->format));
- 
-         /* Don't generate anything if wrpolicy is set to default */
-         if (def->wrpolicy)
--            virBufferAsprintf(buf, " wrpolicy='%s'", wrpolicy);
-+            virBufferAsprintf(&driverBuf, " wrpolicy='%s'", wrpolicy);
- 
-+    }
-+
-+    if (virBufferUse(&driverBuf)) {
-+        virBufferAddLit(buf, "<driver");
-+        virBufferAddBuffer(buf, &driverBuf);
-         virBufferAddLit(buf, "/>\n");
-     }
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-Use-a-separate-buffer-for-input-subelements.patch b/SOURCES/libvirt-Use-a-separate-buffer-for-input-subelements.patch
deleted file mode 100644
index 89dd9e0..0000000
--- a/SOURCES/libvirt-Use-a-separate-buffer-for-input-subelements.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From c8fc71708382f37cfc7437b15f58e3d5ab1f2cb1 Mon Sep 17 00:00:00 2001
-Message-Id: <c8fc71708382f37cfc7437b15f58e3d5ab1f2cb1@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:48:51 +0200
-Subject: [PATCH] Use a separate buffer for <input> subelements
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Instead of figuring out upfront whether <input> will be a single
-or a pair element, format the subelements into a separate buffer
-and close <input/> early if this buffer is empty.
-
-(cherry picked from commit 51219e11b8c57c7a9755eedd72986269b78ccfb7)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 21 +++++++++++----------
- 1 file changed, 11 insertions(+), 10 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index b473ce6b1e..4228cad610 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -23152,6 +23152,7 @@ virDomainInputDefFormat(virBufferPtr buf,
- {
-     const char *type = virDomainInputTypeToString(def->type);
-     const char *bus = virDomainInputBusTypeToString(def->bus);
-+    virBuffer childbuf = VIR_BUFFER_INITIALIZER;
- 
-     /* don't format keyboard into migratable XML for backward compatibility */
-     if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
-@@ -23174,17 +23175,17 @@ virDomainInputDefFormat(virBufferPtr buf,
-     virBufferAsprintf(buf, "<input type='%s' bus='%s'",
-                       type, bus);
- 
--    if (virDomainDeviceInfoNeedsFormat(&def->info, flags) ||
--        def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) {
--        virBufferAddLit(buf, ">\n");
--        virBufferAdjustIndent(buf, 2);
--        virBufferEscapeString(buf, "<source evdev='%s'/>\n", def->source.evdev);
--        if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
--            return -1;
--        virBufferAdjustIndent(buf, -2);
--        virBufferAddLit(buf, "</input>\n");
--    } else {
-+    virBufferAdjustIndent(&childbuf, virBufferGetIndent(buf, false) + 2);
-+    virBufferEscapeString(&childbuf, "<source evdev='%s'/>\n", def->source.evdev);
-+    if (virDomainDeviceInfoFormat(&childbuf, &def->info, flags) < 0)
-+        return -1;
-+
-+    if (!virBufferUse(&childbuf)) {
-         virBufferAddLit(buf, "/>\n");
-+    } else {
-+        virBufferAddLit(buf, ">\n");
-+        virBufferAddBuffer(buf, &childbuf);
-+        virBufferAddLit(buf, "</input>\n");
-     }
- 
-     return 0;
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-add-virtio-related-options-to-memballoon.patch b/SOURCES/libvirt-add-virtio-related-options-to-memballoon.patch
deleted file mode 100644
index 8204d2b..0000000
--- a/SOURCES/libvirt-add-virtio-related-options-to-memballoon.patch
+++ /dev/null
@@ -1,147 +0,0 @@
-From f9a338cd5d0477291a0001a527d0add941f7ea37 Mon Sep 17 00:00:00 2001
-Message-Id: <f9a338cd5d0477291a0001a527d0add941f7ea37@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:49:01 +0200
-Subject: [PATCH] add virtio-related options to memballoon
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 82223f9364a9f47a39b7c66c241b82ae62f9fb4b)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                          |  7 +++++++
- docs/schemas/domaincommon.rng                      |  5 +++++
- src/conf/domain_conf.c                             | 24 ++++++++++++++++++++++
- src/conf/domain_conf.h                             |  1 +
- .../qemuxml2argv-virtio-options.xml                |  1 +
- 5 files changed, 38 insertions(+)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 23546daae9..2556f383fc 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -6913,6 +6913,7 @@ qemu-kvm -net nic,model=? /dev/null
-     &lt;memballoon model='virtio'&gt;
-       &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/&gt;
-       &lt;stats period='10'/&gt;
-+      &lt;driver iommu='on' ats='on'/&gt;
-     &lt;/memballoon&gt;
-   &lt;/devices&gt;
- &lt;/domain&gt;</pre>
-@@ -6957,6 +6958,12 @@ qemu-kvm -net nic,model=? /dev/null
-           <span class='since'>Since 1.1.1, requires QEMU 1.5</span>
-         </p>
-       </dd>
-+      <dt><code>driver</code></dt>
-+      <dd>
-+        For model <code>virtio</code> memballoon,
-+        <a href="#elementsVirtio">Virtio-specific options</a> can also be
-+        set. (<span class="since">Since 3.5.0</span>)
-+      </dd>
-     </dl>
-     <h4><a name="elementsRng">Random number generator device</a></h4>
- 
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index 9e68bbc52d..f571af6706 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -3730,6 +3730,11 @@
-             </attribute>
-           </element>
-         </optional>
-+        <optional>
-+          <element name="driver">
-+            <ref name="virtioOptions"/>
-+          </element>
-+        </optional>
-       </interleave>
-     </element>
-   </define>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index bba50cf3fd..4768d02029 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -2292,6 +2292,7 @@ void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def)
-         return;
- 
-     virDomainDeviceInfoClear(&def->info);
-+    VIR_FREE(def->virtio);
- 
-     VIR_FREE(def);
- }
-@@ -12970,6 +12971,9 @@ virDomainMemballoonDefParseXML(xmlNodePtr node,
-     else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
-         goto error;
- 
-+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
-+        goto error;
-+
-  cleanup:
-     VIR_FREE(model);
-     VIR_FREE(deflate);
-@@ -19582,6 +19586,10 @@ virDomainMemballoonDefCheckABIStability(virDomainMemballoonDefPtr src,
-         return false;
-     }
- 
-+    if (src->virtio && dst->virtio &&
-+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
-+        return false;
-+
-     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
-         return false;
- 
-@@ -22934,6 +22942,22 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
-         return -1;
-     }
- 
-+    if (def->virtio) {
-+        virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
-+
-+        virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
-+
-+        if (virBufferCheckError(&driverBuf) < 0) {
-+            virBufferFreeAndReset(&childrenBuf);
-+            return -1;
-+        }
-+        if (virBufferUse(&driverBuf)) {
-+            virBufferAddLit(&childrenBuf, "<driver");
-+            virBufferAddBuffer(&childrenBuf, &driverBuf);
-+            virBufferAddLit(&childrenBuf, "/>\n");
-+        }
-+    }
-+
-     if (!virBufferUse(&childrenBuf)) {
-         virBufferAddLit(buf, "/>\n");
-     } else {
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 603d35bd50..f1f9208b91 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -1609,6 +1609,7 @@ struct _virDomainMemballoonDef {
-     virDomainDeviceInfo info;
-     int period; /* seconds between collections */
-     int autodeflate; /* enum virTristateSwitch */
-+    virDomainVirtioOptionsPtr virtio;
- };
- 
- struct _virDomainNVRAMDef {
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-index 3357bc6d1b..b16a9847fe 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-@@ -73,6 +73,7 @@
-     </video>
-     <memballoon model='virtio'>
-       <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
-+      <driver iommu='on' ats='on'/>
-     </memballoon>
-     <rng model='virtio'>
-       <backend model='random'>/dev/random</backend>
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-audit-Fix-the-output-message-for-shmem.patch b/SOURCES/libvirt-audit-Fix-the-output-message-for-shmem.patch
deleted file mode 100644
index c3e819a..0000000
--- a/SOURCES/libvirt-audit-Fix-the-output-message-for-shmem.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-From c71f920357ffb17cd13aaf9a12e8d77d1b29b08c Mon Sep 17 00:00:00 2001
-Message-Id: <c71f920357ffb17cd13aaf9a12e8d77d1b29b08c@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Mon, 5 Jun 2017 17:02:03 +0200
-Subject: [PATCH] audit: Fix the output message for shmem
-
-After some discussion on and off the linux-audit mailing list, we
-should use different fields for the audit messages.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1218603
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-(cherry picked from commit 6d12a1cb2fb0e0152a19518423dceafa7cf088fb)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_audit.c | 24 +++++++++++++-----------
- 1 file changed, 13 insertions(+), 11 deletions(-)
-
-diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
-index 2d9ff5e3ff..1e667af73c 100644
---- a/src/conf/domain_audit.c
-+++ b/src/conf/domain_audit.c
-@@ -983,15 +983,13 @@ virDomainAuditShmem(virDomainObjPtr vm,
-     char uuidstr[VIR_UUID_STRING_BUFLEN];
-     char *vmname = virAuditEncode("vm", vm->def->name);
-     const char *srcpath = virDomainAuditChardevPath(&def->server.chr);
--    char *src = virAuditEncode("server", VIR_AUDIT_STR(srcpath));
--    char *shmem = virAuditEncode("shmem", VIR_AUDIT_STR(def->name));
-     const char *virt = virDomainVirtTypeToString(vm->def->virtType);
--    char *size = NULL;
-+    char *shmpath = NULL;
- 
-     virUUIDFormat(vm->def->uuid, uuidstr);
- 
--    if (!vmname || !src || !shmem ||
--        virAsprintfQuiet(&size, "%llu", def->size) < 0) {
-+    if (!vmname ||
-+        virAsprintfQuiet(&shmpath, "/dev/shm/%s", def->name) < 0) {
-         VIR_WARN("OOM while encoding audit message");
-         goto cleanup;
-     }
-@@ -1002,14 +1000,18 @@ virDomainAuditShmem(virDomainObjPtr vm,
-         virt = "?";
-     }
- 
--    VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
--              "virt=%s resrc=shmem reason=%s %s uuid=%s size=%s %s %s",
--              virt, reason, vmname, uuidstr, size, shmem, src);
-+    if (def->server.enabled) {
-+        VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
-+                  "virt=%s resrc=ivshmem-socket reason=%s %s uuid=%s path=%s",
-+                  virt, reason, vmname, uuidstr, VIR_AUDIT_STR(srcpath));
-+    } else {
-+        VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
-+                  "virt=%s resrc=shmem reason=%s %s uuid=%s size=%llu path=%s",
-+                  virt, reason, vmname, uuidstr, def->size, VIR_AUDIT_STR(shmpath));
-+   }
- 
-  cleanup:
-     VIR_FREE(vmname);
--    VIR_FREE(src);
--    VIR_FREE(size);
--    VIR_FREE(shmem);
-+    VIR_FREE(shmpath);
-     return;
- }
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-conf-Add-check-for-non-scsi_host-parent-during-vport-delete.patch b/SOURCES/libvirt-conf-Add-check-for-non-scsi_host-parent-during-vport-delete.patch
deleted file mode 100644
index 66afa80..0000000
--- a/SOURCES/libvirt-conf-Add-check-for-non-scsi_host-parent-during-vport-delete.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From aa337656da6b3e44ccaae85ec64538dee80000cf Mon Sep 17 00:00:00 2001
-Message-Id: <aa337656da6b3e44ccaae85ec64538dee80000cf@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Thu, 13 Apr 2017 10:38:35 -0400
-Subject: [PATCH] conf: Add check for non scsi_host parent during vport delete
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1420740
-
-If the parent is not a scsi_host, then we can just happily return since
-we won't be removing a vport.
-
-Fixes a bug with the following output:
-
-$ virsh pool-destroy host4_hba_pool
-error: Failed to destroy pool host4_hba_pool
-error: internal error: Invalid adapter name 'pci_0000_10_00_1' for SCSI pool
-
-$
-
-(cherry picked from commit 84f178bdc7ab38011cc1f76759b0a41335285a4f)
-Signed-off-by: John Ferlan <jferlan@redhat.com>
----
- src/conf/node_device_conf.c | 7 +++++++
- 1 file changed, 7 insertions(+)
-
-diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
-index 7d0baa9d1..cc3fad8b9 100644
---- a/src/conf/node_device_conf.c
-+++ b/src/conf/node_device_conf.c
-@@ -2074,6 +2074,13 @@ virNodeDeviceDeleteVport(virConnectPtr conn,
-         if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name)))
-             goto cleanup;
- 
-+        /* If the parent is not a scsi_host, then this is a pool backed
-+         * directly to an HBA and there's no vHBA to remove - so we're done */
-+        if (!STRPREFIX(vhba_parent, "scsi_host")) {
-+            ret = 0;
-+            goto cleanup;
-+        }
-+
-         if (virSCSIHostGetNumber(vhba_parent, &parent_host) < 0)
-             goto cleanup;
-     }
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-conf-Add-infrastructure-for-disk-source-private-data-XML.patch b/SOURCES/libvirt-conf-Add-infrastructure-for-disk-source-private-data-XML.patch
new file mode 100644
index 0000000..2015326
--- /dev/null
+++ b/SOURCES/libvirt-conf-Add-infrastructure-for-disk-source-private-data-XML.patch
@@ -0,0 +1,510 @@
+From 996dfd6322782e72583384381ffebf91ef1d3e27 Mon Sep 17 00:00:00 2001
+Message-Id: <996dfd6322782e72583384381ffebf91ef1d3e27@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 14 Dec 2017 14:31:51 +0100
+Subject: [PATCH] conf: Add infrastructure for disk source private data XML
+
+VM drivers may need to store additional private data to the status XML
+so that it can be restored after libvirtd restart. Since not everything
+is needed add a callback infrastructure, where VM drivers can add only
+stuff they need.
+
+Note that the private data is formatted as a <privateData> sub-element
+of the <disk> or <backingStore> <source> sub-element. This is done since
+storing it out of band (in the VM private data) would require a complex
+matching process to allow to put the data into correct place.
+
+(cherry picked from commit aed3d038a6565f3b0e916bdb004ca90b302b200d)
+
+ Conflicts:
+	tests/qemublocktest.c: This file does not exist downstream yet.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1523261
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c      | 136 ++++++++++++++++++++++++++++++++++----------
+ src/conf/domain_conf.h      |  17 +++++-
+ src/conf/snapshot_conf.c    |  18 +++---
+ src/network/bridge_driver.c |   2 +-
+ src/qemu/qemu_domain.c      |   2 +-
+ tests/virstoragetest.c      |   2 +-
+ 6 files changed, 134 insertions(+), 43 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 2d54037b71..ad9c16a1e0 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -8550,11 +8550,43 @@ virDomainDiskSourceEncryptionParse(xmlNodePtr node,
+ }
+ 
+ 
++static int
++virDomainDiskSourcePrivateDataParse(xmlXPathContextPtr ctxt,
++                                    virStorageSourcePtr src,
++                                    unsigned int flags,
++                                    virDomainXMLOptionPtr xmlopt)
++{
++    xmlNodePtr saveNode = ctxt->node;
++    xmlNodePtr node;
++    int ret = -1;
++
++    if (!(flags & VIR_DOMAIN_DEF_PARSE_STATUS) ||
++        !xmlopt || !xmlopt->privateData.storageParse)
++        return 0;
++
++    if (!(node = virXPathNode("./privateData", ctxt)))
++        return 0;
++
++    ctxt->node = node;
++
++    if (xmlopt->privateData.storageParse(ctxt, src) < 0)
++        goto cleanup;
++
++    ret = 0;
++
++ cleanup:
++    ctxt->node = saveNode;
++
++    return ret;
++}
++
++
+ int
+ virDomainDiskSourceParse(xmlNodePtr node,
+                          xmlXPathContextPtr ctxt,
+                          virStorageSourcePtr src,
+-                         unsigned int flags)
++                         unsigned int flags,
++                         virDomainXMLOptionPtr xmlopt)
+ {
+     int ret = -1;
+     xmlNodePtr saveNode = ctxt->node;
+@@ -8593,6 +8625,9 @@ virDomainDiskSourceParse(xmlNodePtr node,
+     if (virDomainDiskSourceEncryptionParse(node, &src->encryption) < 0)
+         goto cleanup;
+ 
++    if (virDomainDiskSourcePrivateDataParse(ctxt, src, flags, xmlopt) < 0)
++        goto cleanup;
++
+     /* People sometimes pass a bogus '' source path when they mean to omit the
+      * source element completely (e.g. CDROM without media). This is just a
+      * little compatibility check to help those broken apps */
+@@ -8610,7 +8645,8 @@ virDomainDiskSourceParse(xmlNodePtr node,
+ static int
+ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
+                                virStorageSourcePtr src,
+-                               unsigned int flags)
++                               unsigned int flags,
++                               virDomainXMLOptionPtr xmlopt)
+ {
+     virStorageSourcePtr backingStore = NULL;
+     xmlNodePtr save_ctxt = ctxt->node;
+@@ -8668,8 +8704,8 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
+         goto cleanup;
+     }
+ 
+-    if (virDomainDiskSourceParse(source, ctxt, backingStore, flags) < 0 ||
+-        virDomainDiskBackingStoreParse(ctxt, backingStore, flags) < 0)
++    if (virDomainDiskSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
++        virDomainDiskBackingStoreParse(ctxt, backingStore, flags, xmlopt) < 0)
+         goto cleanup;
+ 
+     VIR_STEAL_PTR(src->backingStore, backingStore);
+@@ -8771,7 +8807,8 @@ static int
+ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
+                             xmlNodePtr cur,
+                             xmlXPathContextPtr ctxt,
+-                            unsigned int flags)
++                            unsigned int flags,
++                            virDomainXMLOptionPtr xmlopt)
+ {
+     xmlNodePtr mirrorNode;
+     char *mirrorFormat = NULL;
+@@ -8809,7 +8846,8 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
+             goto cleanup;
+         }
+ 
+-        if (virDomainDiskSourceParse(mirrorNode, ctxt, def->mirror, flags) < 0)
++        if (virDomainDiskSourceParse(mirrorNode, ctxt, def->mirror,
++                                     flags, xmlopt) < 0)
+             goto cleanup;
+     } else {
+         /* For back-compat reasons, we handle a file name
+@@ -9235,7 +9273,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
+         if (!source && virXMLNodeNameEqual(cur, "source")) {
+             sourceNode = cur;
+ 
+-            if (virDomainDiskSourceParse(cur, ctxt, def->src, flags) < 0)
++            if (virDomainDiskSourceParse(cur, ctxt, def->src, flags, xmlopt) < 0)
+                 goto error;
+ 
+             /* If we've already found an <auth> as a child of <disk> and
+@@ -9316,7 +9354,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
+         } else if (!def->mirror &&
+                    virXMLNodeNameEqual(cur, "mirror") &&
+                    !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) {
+-            if (virDomainDiskDefMirrorParse(def, cur, ctxt, flags) < 0)
++            if (virDomainDiskDefMirrorParse(def, cur, ctxt, flags, xmlopt) < 0)
+                 goto error;
+         } else if (!authdef &&
+                    virXMLNodeNameEqual(cur, "auth")) {
+@@ -9587,7 +9625,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
+     product = NULL;
+ 
+     if (!(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) {
+-        if (virDomainDiskBackingStoreParse(ctxt, def->src, flags) < 0)
++        if (virDomainDiskBackingStoreParse(ctxt, def->src, flags, xmlopt) < 0)
+             goto error;
+     }
+ 
+@@ -22349,12 +22387,43 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
+ }
+ 
+ 
++static int
++virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
++                                     virStorageSourcePtr src,
++                                     unsigned int flags,
++                                     virDomainXMLOptionPtr xmlopt)
++{
++    virBuffer childBuf = VIR_BUFFER_INITIALIZER;
++    int ret = -1;
++
++    if (!(flags & VIR_DOMAIN_DEF_FORMAT_STATUS) ||
++        !xmlopt || !xmlopt->privateData.storageFormat)
++        return 0;
++
++    virBufferSetChildIndent(&childBuf, buf);
++
++    if (xmlopt->privateData.storageFormat(src, &childBuf) < 0)
++        goto cleanup;
++
++    if (virXMLFormatElement(buf, "privateData", NULL, &childBuf) < 0)
++        goto cleanup;
++
++    ret = 0;
++
++ cleanup:
++    virBufferFreeAndReset(&childBuf);
++
++    return ret;
++}
++
++
+ static int
+ virDomainDiskSourceFormatInternal(virBufferPtr buf,
+                                   virStorageSourcePtr src,
+                                   int policy,
+                                   unsigned int flags,
+-                                  bool skipSeclabels)
++                                  bool skipSeclabels,
++                                  virDomainXMLOptionPtr xmlopt)
+ {
+     const char *startupPolicy = NULL;
+     virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
+@@ -22436,6 +22505,9 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
+             virStorageEncryptionFormat(&childBuf, src->encryption) < 0)
+             return -1;
+ 
++        if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0)
++            return -1;
++
+         if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0)
+             goto error;
+     }
+@@ -22453,15 +22525,18 @@ int
+ virDomainDiskSourceFormat(virBufferPtr buf,
+                           virStorageSourcePtr src,
+                           int policy,
+-                          unsigned int flags)
++                          unsigned int flags,
++                          virDomainXMLOptionPtr xmlopt)
+ {
+-    return virDomainDiskSourceFormatInternal(buf, src, policy, flags, false);
++    return virDomainDiskSourceFormatInternal(buf, src, policy, flags, false, xmlopt);
+ }
+ 
+ 
+ static int
+ virDomainDiskBackingStoreFormat(virBufferPtr buf,
+-                                virStorageSourcePtr backingStore)
++                                virStorageSourcePtr backingStore,
++                                virDomainXMLOptionPtr xmlopt,
++                                unsigned int flags)
+ {
+     const char *format;
+ 
+@@ -22490,9 +22565,9 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
+ 
+     virBufferAsprintf(buf, "<format type='%s'/>\n", format);
+     /* We currently don't output seclabels for backing chain element */
+-    if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, 0, true) < 0 ||
+-        virDomainDiskBackingStoreFormat(buf,
+-                                        backingStore->backingStore) < 0)
++    if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, flags, true, xmlopt) < 0 ||
++        virDomainDiskBackingStoreFormat(buf, backingStore->backingStore,
++                                        xmlopt, flags) < 0)
+         return -1;
+ 
+     virBufferAdjustIndent(buf, -2);
+@@ -22510,7 +22585,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
+ static int
+ virDomainDiskDefFormat(virBufferPtr buf,
+                        virDomainDiskDefPtr def,
+-                       unsigned int flags)
++                       unsigned int flags,
++                       virDomainXMLOptionPtr xmlopt)
+ {
+     const char *type = virStorageTypeToString(def->src->type);
+     const char *device = virDomainDiskDeviceTypeToString(def->device);
+@@ -22623,13 +22699,14 @@ virDomainDiskDefFormat(virBufferPtr buf,
+     }
+ 
+     if (virDomainDiskSourceFormat(buf, def->src, def->startupPolicy,
+-                                  flags) < 0)
++                                  flags, xmlopt) < 0)
+         return -1;
+ 
+     /* Don't format backingStore to inactive XMLs until the code for
+      * persistent storage of backing chains is ready. */
+     if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
+-        virDomainDiskBackingStoreFormat(buf, def->src->backingStore) < 0)
++        virDomainDiskBackingStoreFormat(buf, def->src->backingStore,
++                                        xmlopt, flags) < 0)
+         return -1;
+ 
+     virBufferEscapeString(buf, "<backenddomain name='%s'/>\n", def->domain_name);
+@@ -22666,7 +22743,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
+         virBufferAddLit(buf, ">\n");
+         virBufferAdjustIndent(buf, 2);
+         virBufferEscapeString(buf, "<format type='%s'/>\n", formatStr);
+-        if (virDomainDiskSourceFormat(buf, def->mirror, 0, 0) < 0)
++        if (virDomainDiskSourceFormat(buf, def->mirror, 0, 0, xmlopt) < 0)
+             return -1;
+         virBufferAdjustIndent(buf, -2);
+         virBufferAddLit(buf, "</mirror>\n");
+@@ -25897,7 +25974,8 @@ int
+ virDomainDefFormatInternal(virDomainDefPtr def,
+                            virCapsPtr caps,
+                            unsigned int flags,
+-                           virBufferPtr buf)
++                           virBufferPtr buf,
++                           virDomainXMLOptionPtr xmlopt)
+ {
+     unsigned char *uuid;
+     char uuidstr[VIR_UUID_STRING_BUFLEN];
+@@ -25952,10 +26030,10 @@ virDomainDefFormatInternal(virDomainDefPtr def,
+          * but no leading indentation before the starting element.
+          * Thankfully, libxml maps what looks like globals into
+          * thread-local uses, so we are thread-safe.  */
+-        xmlIndentTreeOutput = 1;
+-        xmlbuf = xmlBufferCreate();
+-        if (xmlNodeDump(xmlbuf, def->metadata->doc, def->metadata,
+-                        virBufferGetIndent(buf, false) / 2, 1) < 0) {
++            xmlIndentTreeOutput = 1;
++            xmlbuf = xmlBufferCreate();
++            if (xmlNodeDump(xmlbuf, def->metadata->doc, def->metadata,
++                            virBufferGetIndent(buf, false) / 2, 1) < 0) {
+             xmlBufferFree(xmlbuf);
+             xmlIndentTreeOutput = oldIndentTreeOutput;
+             goto error;
+@@ -26528,7 +26606,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
+                           def->emulator);
+ 
+     for (n = 0; n < def->ndisks; n++)
+-        if (virDomainDiskDefFormat(buf, def->disks[n], flags) < 0)
++        if (virDomainDiskDefFormat(buf, def->disks[n], flags, xmlopt) < 0)
+             goto error;
+ 
+     for (n = 0; n < def->ncontrollers; n++)
+@@ -26715,7 +26793,7 @@ virDomainDefFormat(virDomainDefPtr def, virCapsPtr caps, unsigned int flags)
+     virBuffer buf = VIR_BUFFER_INITIALIZER;
+ 
+     virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS, NULL);
+-    if (virDomainDefFormatInternal(def, caps, flags, &buf) < 0)
++    if (virDomainDefFormatInternal(def, caps, flags, &buf, NULL) < 0)
+         return NULL;
+ 
+     return virBufferContentAndReset(&buf);
+@@ -26750,7 +26828,7 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
+         xmlopt->privateData.format(&buf, obj) < 0)
+         goto error;
+ 
+-    if (virDomainDefFormatInternal(obj->def, caps, flags, &buf) < 0)
++    if (virDomainDefFormatInternal(obj->def, caps, flags, &buf, xmlopt) < 0)
+         goto error;
+ 
+     virBufferAdjustIndent(&buf, -2);
+@@ -27704,7 +27782,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
+ 
+     switch ((virDomainDeviceType) src->type) {
+     case VIR_DOMAIN_DEVICE_DISK:
+-        rc = virDomainDiskDefFormat(&buf, src->data.disk, flags);
++        rc = virDomainDiskDefFormat(&buf, src->data.disk, flags, xmlopt);
+         break;
+     case VIR_DOMAIN_DEVICE_LEASE:
+         rc = virDomainLeaseDefFormat(&buf, src->data.lease);
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 698d3280fe..5e67c9a9c1 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -2626,6 +2626,12 @@ typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
+                                                 virDomainObjPtr,
+                                                 virDomainDefParserConfigPtr);
+ 
++typedef int (*virDomainXMLPrivateDataStorageSourceParseFunc)(xmlXPathContextPtr ctxt,
++                                                             virStorageSourcePtr src);
++typedef int (*virDomainXMLPrivateDataStorageSourceFormatFunc)(virStorageSourcePtr src,
++                                                              virBufferPtr buf);
++
++
+ typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
+ typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
+ struct _virDomainXMLPrivateDataCallbacks {
+@@ -2639,6 +2645,8 @@ struct _virDomainXMLPrivateDataCallbacks {
+     virDomainXMLPrivateDataNewFunc    chrSourceNew;
+     virDomainXMLPrivateDataFormatFunc format;
+     virDomainXMLPrivateDataParseFunc  parse;
++    virDomainXMLPrivateDataStorageSourceParseFunc storageParse;
++    virDomainXMLPrivateDataStorageSourceFormatFunc storageFormat;
+ };
+ 
+ typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src,
+@@ -2963,12 +2971,14 @@ char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
+ int virDomainDefFormatInternal(virDomainDefPtr def,
+                                virCapsPtr caps,
+                                unsigned int flags,
+-                               virBufferPtr buf);
++                               virBufferPtr buf,
++                               virDomainXMLOptionPtr xmlopt);
+ 
+ int virDomainDiskSourceFormat(virBufferPtr buf,
+                               virStorageSourcePtr src,
+                               int policy,
+-                              unsigned int flags);
++                              unsigned int flags,
++                              virDomainXMLOptionPtr xmlopt);
+ 
+ int virDomainNetDefFormat(virBufferPtr buf,
+                           virDomainNetDefPtr def,
+@@ -3017,7 +3027,8 @@ virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
+ int virDomainDiskSourceParse(xmlNodePtr node,
+                              xmlXPathContextPtr ctxt,
+                              virStorageSourcePtr src,
+-                             unsigned int flags);
++                             unsigned int flags,
++                             virDomainXMLOptionPtr xmlopt);
+ 
+ int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
+ virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
+diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
+index f0e852c92b..d7b086242b 100644
+--- a/src/conf/snapshot_conf.c
++++ b/src/conf/snapshot_conf.c
+@@ -110,7 +110,8 @@ static int
+ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
+                                  xmlXPathContextPtr ctxt,
+                                  virDomainSnapshotDiskDefPtr def,
+-                                 unsigned int flags)
++                                 unsigned int flags,
++                                 virDomainXMLOptionPtr xmlopt)
+ {
+     int ret = -1;
+     char *snapshot = NULL;
+@@ -155,7 +156,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
+     }
+ 
+     if ((cur = virXPathNode("./source", ctxt)) &&
+-        virDomainDiskSourceParse(cur, ctxt, def->src, flags) < 0)
++        virDomainDiskSourceParse(cur, ctxt, def->src, flags, xmlopt) < 0)
+         goto cleanup;
+ 
+     if ((driver = virXPathString("string(./driver/@type)", ctxt))) {
+@@ -348,8 +349,8 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
+             goto cleanup;
+         def->ndisks = n;
+         for (i = 0; i < def->ndisks; i++) {
+-            if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt,
+-                                                 &def->disks[i], flags) < 0)
++            if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt, &def->disks[i],
++                                                 flags, xmlopt) < 0)
+                 goto cleanup;
+         }
+         VIR_FREE(nodes);
+@@ -663,7 +664,8 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
+ 
+ static void
+ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
+-                               virDomainSnapshotDiskDefPtr disk)
++                               virDomainSnapshotDiskDefPtr disk,
++                               virDomainXMLOptionPtr xmlopt)
+ {
+     int type = disk->src->type;
+ 
+@@ -686,7 +688,7 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
+     if (disk->src->format > 0)
+         virBufferEscapeString(buf, "<driver type='%s'/>\n",
+                               virStorageFileFormatTypeToString(disk->src->format));
+-    virDomainDiskSourceFormat(buf, disk->src, 0, 0);
++    virDomainDiskSourceFormat(buf, disk->src, 0, 0, xmlopt);
+ 
+     virBufferAdjustIndent(buf, -2);
+     virBufferAddLit(buf, "</disk>\n");
+@@ -740,13 +742,13 @@ virDomainSnapshotDefFormat(const char *domain_uuid,
+         virBufferAddLit(&buf, "<disks>\n");
+         virBufferAdjustIndent(&buf, 2);
+         for (i = 0; i < def->ndisks; i++)
+-            virDomainSnapshotDiskDefFormat(&buf, &def->disks[i]);
++            virDomainSnapshotDiskDefFormat(&buf, &def->disks[i], xmlopt);
+         virBufferAdjustIndent(&buf, -2);
+         virBufferAddLit(&buf, "</disks>\n");
+     }
+ 
+     if (def->dom) {
+-        if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0)
++        if (virDomainDefFormatInternal(def->dom, caps, flags, &buf, xmlopt) < 0)
+             goto error;
+     } else if (domain_uuid) {
+         virBufferAddLit(&buf, "<domain>\n");
+diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
+index fcaa66df91..334da7a85d 100644
+--- a/src/network/bridge_driver.c
++++ b/src/network/bridge_driver.c
+@@ -233,7 +233,7 @@ networkRunHook(virNetworkObjPtr obj,
+             goto cleanup;
+         if (virNetworkDefFormatBuf(&buf, def, 0) < 0)
+             goto cleanup;
+-        if (dom && virDomainDefFormatInternal(dom, NULL, 0, &buf) < 0)
++        if (dom && virDomainDefFormatInternal(dom, NULL, 0, &buf, NULL) < 0)
+             goto cleanup;
+ 
+         virBufferAdjustIndent(&buf, -2);
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 9dd9db049b..625bcb20d5 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -5245,7 +5245,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
+  format:
+     ret = virDomainDefFormatInternal(def, caps,
+                                      virDomainDefFormatConvertXMLFlags(flags),
+-                                     buf);
++                                     buf, driver->xmlopt);
+ 
+  cleanup:
+     virDomainDefFree(copy);
+diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
+index e1d8751728..bdd0829c21 100644
+--- a/tests/virstoragetest.c
++++ b/tests/virstoragetest.c
+@@ -693,7 +693,7 @@ testBackingParse(const void *args)
+         goto cleanup;
+     }
+ 
+-    if (virDomainDiskSourceFormat(&buf, src, 0, 0) < 0 ||
++    if (virDomainDiskSourceFormat(&buf, src, 0, 0, NULL) < 0 ||
+         !(xml = virBufferContentAndReset(&buf))) {
+         fprintf(stderr, "failed to format disk source xml\n");
+         goto cleanup;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Add-save-cookie-callbacks-to-xmlopt.patch b/SOURCES/libvirt-conf-Add-save-cookie-callbacks-to-xmlopt.patch
deleted file mode 100644
index d7101a8..0000000
--- a/SOURCES/libvirt-conf-Add-save-cookie-callbacks-to-xmlopt.patch
+++ /dev/null
@@ -1,427 +0,0 @@
-From 7cf2eee78e7e0e08eb1203f7fdb5705aba6b0e42 Mon Sep 17 00:00:00 2001
-Message-Id: <7cf2eee78e7e0e08eb1203f7fdb5705aba6b0e42@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 2 Jun 2017 00:44:46 +0200
-Subject: [PATCH] conf: Add save cookie callbacks to xmlopt
-
-virDomainXMLOption gains driver specific callbacks for parsing and
-formatting save cookies.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 25af7e950a9e35a6cffeed32bbcdd95dd7e01035)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/bhyve/bhyve_domain.c      |  2 +-
- src/conf/domain_conf.c        | 16 +++++++++++++++-
- src/conf/domain_conf.h        |  7 ++++++-
- src/conf/snapshot_conf.c      | 11 ++++++++++-
- src/conf/snapshot_conf.h      |  2 ++
- src/libvirt_private.syms      |  1 +
- src/libxl/libxl_conf.c        |  2 +-
- src/lxc/lxc_conf.c            |  2 +-
- src/openvz/openvz_driver.c    |  2 +-
- src/phyp/phyp_driver.c        |  2 +-
- src/qemu/qemu_capabilities.c  |  2 +-
- src/qemu/qemu_conf.c          |  3 ++-
- src/security/virt-aa-helper.c |  2 +-
- src/test/test_driver.c        |  2 +-
- src/uml/uml_driver.c          |  2 +-
- src/vbox/vbox_common.c        |  2 +-
- src/vmware/vmware_driver.c    |  3 ++-
- src/vmx/vmx.c                 |  2 +-
- src/vz/vz_driver.c            |  2 +-
- src/xen/xen_driver.c          |  2 +-
- src/xenapi/xenapi_driver.c    |  2 +-
- tests/bhyveargv2xmltest.c     |  2 +-
- tests/testutils.c             |  2 +-
- 23 files changed, 54 insertions(+), 21 deletions(-)
-
-diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
-index 0a99550afa..20c82937b5 100644
---- a/src/bhyve/bhyve_domain.c
-+++ b/src/bhyve/bhyve_domain.c
-@@ -144,7 +144,7 @@ virBhyveDriverCreateXMLConf(bhyveConnPtr driver)
-     virBhyveDriverDomainDefParserConfig.priv = driver;
-     return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
-                                  &virBhyveDriverPrivateDataCallbacks,
--                                 NULL, NULL);
-+                                 NULL, NULL, NULL);
- }
- 
- virDomainDefParserConfig virBhyveDriverDomainDefParserConfig = {
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 395dcc0531..b473ce6b1e 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -79,6 +79,9 @@ struct _virDomainXMLOption {
- 
-     /* ABI stability callbacks */
-     virDomainABIStability abi;
-+
-+    /* Private data for save image stored in snapshot XML */
-+    virSaveCookieCallbacks saveCookie;
- };
- 
- #define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS             \
-@@ -1054,7 +1057,8 @@ virDomainXMLOptionPtr
- virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
-                       virDomainXMLPrivateDataCallbacksPtr priv,
-                       virDomainXMLNamespacePtr xmlns,
--                      virDomainABIStabilityPtr abi)
-+                      virDomainABIStabilityPtr abi,
-+                      virSaveCookieCallbacksPtr saveCookie)
- {
-     virDomainXMLOptionPtr xmlopt;
- 
-@@ -1076,6 +1080,9 @@ virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
-     if (abi)
-         xmlopt->abi = *abi;
- 
-+    if (saveCookie)
-+        xmlopt->saveCookie = *saveCookie;
-+
-     /* Technically this forbids to use one of Xerox's MAC address prefixes in
-      * our hypervisor drivers. This shouldn't ever be a problem.
-      *
-@@ -1106,6 +1113,13 @@ virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
- }
- 
- 
-+virSaveCookieCallbacksPtr
-+virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt)
-+{
-+    return &xmlopt->saveCookie;
-+}
-+
-+
- void
- virBlkioDeviceArrayClear(virBlkioDevicePtr devices,
-                          int ndevices)
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index d64ef1b6e9..706d106ad9 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -55,6 +55,7 @@
- # include "virgic.h"
- # include "virperf.h"
- # include "virtypedparam.h"
-+# include "virsavecookie.h"
- 
- /* forward declarations of all device types, required by
-  * virDomainDeviceDef
-@@ -2549,7 +2550,11 @@ struct _virDomainABIStability {
- virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
-                                             virDomainXMLPrivateDataCallbacksPtr priv,
-                                             virDomainXMLNamespacePtr xmlns,
--                                            virDomainABIStabilityPtr abi);
-+                                            virDomainABIStabilityPtr abi,
-+                                            virSaveCookieCallbacksPtr saveCookie);
-+
-+virSaveCookieCallbacksPtr
-+virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
- 
- void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);
- 
-diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
-index e3bba985d7..6330f7d1f9 100644
---- a/src/conf/snapshot_conf.c
-+++ b/src/conf/snapshot_conf.c
-@@ -102,6 +102,7 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def)
-         virDomainSnapshotDiskDefClear(&def->disks[i]);
-     VIR_FREE(def->disks);
-     virDomainDefFree(def->dom);
-+    virObjectUnref(def->cookie);
-     VIR_FREE(def);
- }
- 
-@@ -214,6 +215,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
-     char *memorySnapshot = NULL;
-     char *memoryFile = NULL;
-     bool offline = !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE);
-+    virSaveCookieCallbacksPtr saveCookie = virDomainXMLOptionGetSaveCookie(xmlopt);
- 
-     if (VIR_ALLOC(def) < 0)
-         goto cleanup;
-@@ -365,6 +367,9 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
-         def->current = active != 0;
-     }
- 
-+    if (!offline && virSaveCookieParse(ctxt, &def->cookie, saveCookie) < 0)
-+        goto cleanup;
-+
-     ret = def;
- 
-  cleanup:
-@@ -691,7 +696,7 @@ char *
- virDomainSnapshotDefFormat(const char *domain_uuid,
-                            virDomainSnapshotDefPtr def,
-                            virCapsPtr caps,
--                           virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
-+                           virDomainXMLOptionPtr xmlopt,
-                            unsigned int flags,
-                            int internal)
- {
-@@ -751,6 +756,10 @@ virDomainSnapshotDefFormat(const char *domain_uuid,
-         virBufferAddLit(&buf, "</domain>\n");
-     }
- 
-+    if (virSaveCookieFormatBuf(&buf, def->cookie,
-+                               virDomainXMLOptionGetSaveCookie(xmlopt)) < 0)
-+        goto error;
-+
-     if (internal)
-         virBufferAsprintf(&buf, "<active>%d</active>\n", def->current);
- 
-diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
-index 2ce526fa6b..1d663c77bc 100644
---- a/src/conf/snapshot_conf.h
-+++ b/src/conf/snapshot_conf.h
-@@ -76,6 +76,8 @@ struct _virDomainSnapshotDef {
- 
-     virDomainDefPtr dom;
- 
-+    virObjectPtr cookie;
-+
-     /* Internal use.  */
-     bool current; /* At most one snapshot in the list should have this set */
- };
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index b4769080e8..88e3f4b8ac 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -533,6 +533,7 @@ virDomainWatchdogActionTypeToString;
- virDomainWatchdogModelTypeFromString;
- virDomainWatchdogModelTypeToString;
- virDomainXMLOptionGetNamespace;
-+virDomainXMLOptionGetSaveCookie;
- virDomainXMLOptionNew;
- 
- 
-diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
-index dd345c22cf..28d31db158 100644
---- a/src/libxl/libxl_conf.c
-+++ b/src/libxl/libxl_conf.c
-@@ -2147,5 +2147,5 @@ libxlCreateXMLConf(void)
- {
-     return virDomainXMLOptionNew(&libxlDomainDefParserConfig,
-                                  &libxlDomainXMLPrivateDataCallbacks,
--                                 NULL, NULL);
-+                                 NULL, NULL, NULL);
- }
-diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
-index b46fbc58ff..8adc408c32 100644
---- a/src/lxc/lxc_conf.c
-+++ b/src/lxc/lxc_conf.c
-@@ -213,7 +213,7 @@ lxcDomainXMLConfInit(void)
-     return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
-                                  &virLXCDriverPrivateDataCallbacks,
-                                  &virLXCDriverDomainXMLNamespace,
--                                 NULL);
-+                                 NULL, NULL);
- }
- 
- 
-diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
-index 44a6631a99..4392aa64c0 100644
---- a/src/openvz/openvz_driver.c
-+++ b/src/openvz/openvz_driver.c
-@@ -1493,7 +1493,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
-         goto cleanup;
- 
-     if (!(driver->xmlopt = virDomainXMLOptionNew(&openvzDomainDefParserConfig,
--                                                 NULL, NULL, NULL)))
-+                                                 NULL, NULL, NULL, NULL)))
-         goto cleanup;
- 
-     if (openvzLoadDomains(driver) < 0)
-diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
-index e85f66ffab..32cb681c75 100644
---- a/src/phyp/phyp_driver.c
-+++ b/src/phyp/phyp_driver.c
-@@ -1199,7 +1199,7 @@ phypConnectOpen(virConnectPtr conn,
-         goto failure;
- 
-     if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(&virPhypDriverDomainDefParserConfig,
--                                                      NULL, NULL, NULL)))
-+                                                      NULL, NULL, NULL, NULL)))
-         goto failure;
- 
-     conn->privateData = phyp_driver;
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 72d3f25763..29bb9949af 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -5027,7 +5027,7 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd,
-         goto ignore;
-     }
- 
--    if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL)) ||
-+    if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) ||
-         !(cmd->vm = virDomainObjNew(xmlopt)))
-         goto cleanup;
- 
-diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
-index 76eed25277..96956b7779 100644
---- a/src/qemu/qemu_conf.c
-+++ b/src/qemu/qemu_conf.c
-@@ -908,7 +908,8 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver)
-     return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig,
-                                  &virQEMUDriverPrivateDataCallbacks,
-                                  &virQEMUDriverDomainXMLNamespace,
--                                 &virQEMUDriverDomainABIStability);
-+                                 &virQEMUDriverDomainABIStability,
-+                                 NULL);
- }
- 
- 
-diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
-index 48201d5b8c..97436e5dc7 100644
---- a/src/security/virt-aa-helper.c
-+++ b/src/security/virt-aa-helper.c
-@@ -667,7 +667,7 @@ get_definition(vahControl * ctl, const char *xmlStr)
-         goto exit;
-     }
- 
--    if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL))) {
-+    if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL))) {
-         vah_error(ctl, 0, _("Failed to create XML config object"));
-         goto exit;
-     }
-diff --git a/src/test/test_driver.c b/src/test/test_driver.c
-index c8085dd797..4fd14ddee6 100644
---- a/src/test/test_driver.c
-+++ b/src/test/test_driver.c
-@@ -414,7 +414,7 @@ testDriverNew(void)
-         goto error;
-     }
- 
--    if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL)) ||
-+    if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL, NULL)) ||
-         !(ret->eventState = virObjectEventStateNew()) ||
-         !(ret->domains = virDomainObjListNew()) ||
-         !(ret->networks = virNetworkObjListNew()))
-diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
-index ae75daa596..f91ee2961e 100644
---- a/src/uml/uml_driver.c
-+++ b/src/uml/uml_driver.c
-@@ -533,7 +533,7 @@ umlStateInitialize(bool privileged,
-         goto out_of_memory;
- 
-     if (!(uml_driver->xmlopt = virDomainXMLOptionNew(&umlDriverDomainDefParserConfig,
--                                                     &privcb, NULL, NULL)))
-+                                                     &privcb, NULL, NULL, NULL)))
-         goto error;
- 
-     if ((uml_driver->inotifyFD = inotify_init()) < 0) {
-diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
-index c739031660..4a79c43a1a 100644
---- a/src/vbox/vbox_common.c
-+++ b/src/vbox/vbox_common.c
-@@ -139,7 +139,7 @@ vboxDriverObjNew(void)
- 
-     if (!(driver->caps = vboxCapsInit()) ||
-         !(driver->xmlopt = virDomainXMLOptionNew(&vboxDomainDefParserConfig,
--                                                 NULL, NULL, NULL)))
-+                                                 NULL, NULL, NULL, NULL)))
-         goto cleanup;
- 
-     return driver;
-diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
-index 24e97a4969..525c85edc8 100644
---- a/src/vmware/vmware_driver.c
-+++ b/src/vmware/vmware_driver.c
-@@ -114,7 +114,8 @@ vmwareDomainXMLConfigInit(void)
-     virDomainXMLPrivateDataCallbacks priv = { .alloc = vmwareDataAllocFunc,
-                                               .free = vmwareDataFreeFunc };
- 
--    return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv, NULL, NULL);
-+    return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv,
-+                                 NULL, NULL, NULL);
- }
- 
- static virDrvOpenStatus
-diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
-index 3289a20026..96507f10f3 100644
---- a/src/vmx/vmx.c
-+++ b/src/vmx/vmx.c
-@@ -591,7 +591,7 @@ virDomainXMLOptionPtr
- virVMXDomainXMLConfInit(void)
- {
-     return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL,
--                                 &virVMXDomainXMLNamespace, NULL);
-+                                 &virVMXDomainXMLNamespace, NULL, NULL);
- }
- 
- char *
-diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
-index f0b6722a6e..532a6841f3 100644
---- a/src/vz/vz_driver.c
-+++ b/src/vz/vz_driver.c
-@@ -326,7 +326,7 @@ vzDriverObjNew(void)
-     if (!(driver->caps = vzBuildCapabilities()) ||
-         !(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
-                                                  &vzDomainXMLPrivateDataCallbacksPtr,
--                                                 NULL, NULL)) ||
-+                                                 NULL, NULL, NULL)) ||
-         !(driver->domains = virDomainObjListNew()) ||
-         !(driver->domainEventState = virObjectEventStateNew()) ||
-         (vzInitVersion(driver) < 0) ||
-diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
-index 0c160f8370..ab74ba9928 100644
---- a/src/xen/xen_driver.c
-+++ b/src/xen/xen_driver.c
-@@ -401,7 +401,7 @@ virDomainXMLOptionPtr
- xenDomainXMLConfInit(void)
- {
-     return virDomainXMLOptionNew(&xenDomainDefParserConfig,
--                                 NULL, NULL, NULL);
-+                                 NULL, NULL, NULL, NULL);
- }
- 
- 
-diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
-index 5623ddb507..c94fd422f9 100644
---- a/src/xenapi/xenapi_driver.c
-+++ b/src/xenapi/xenapi_driver.c
-@@ -200,7 +200,7 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
-     }
- 
-     if (!(privP->xmlopt = virDomainXMLOptionNew(&xenapiDomainDefParserConfig,
--                                                NULL, NULL, NULL))) {
-+                                                NULL, NULL, NULL, NULL))) {
-         xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
-                                   _("Failed to create XML conf object"));
-         goto error;
-diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c
-index 5d7261a45b..43ef76a594 100644
---- a/tests/bhyveargv2xmltest.c
-+++ b/tests/bhyveargv2xmltest.c
-@@ -131,7 +131,7 @@ mymain(void)
-         return EXIT_FAILURE;
- 
-     if ((driver.xmlopt = virDomainXMLOptionNew(NULL, NULL,
--                                               NULL, NULL)) == NULL)
-+                                               NULL, NULL, NULL)) == NULL)
-         return EXIT_FAILURE;
- 
- # define DO_TEST_FULL(name, flags)                            \
-diff --git a/tests/testutils.c b/tests/testutils.c
-index b7dc8d8408..0823469068 100644
---- a/tests/testutils.c
-+++ b/tests/testutils.c
-@@ -1136,7 +1136,7 @@ virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void)
- {
-     return virDomainXMLOptionNew(&virTestGenericDomainDefParserConfig,
-                                  &virTestGenericPrivateDataCallbacks,
--                                 NULL, NULL);
-+                                 NULL, NULL, NULL);
- }
- 
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-conf-Add-support-for-cputune-cachetune.patch b/SOURCES/libvirt-conf-Add-support-for-cputune-cachetune.patch
new file mode 100644
index 0000000..5ff1f1b
--- /dev/null
+++ b/SOURCES/libvirt-conf-Add-support-for-cputune-cachetune.patch
@@ -0,0 +1,794 @@
+From ba1ce05bd6e49217cd8c89b75e741e518d2b9292 Mon Sep 17 00:00:00 2001
+Message-Id: <ba1ce05bd6e49217cd8c89b75e741e518d2b9292@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:30 +0100
+Subject: [PATCH] conf: Add support for cputune/cachetune
+
+More info in the documentation, this is basically the XML parsing/formatting
+support, schemas, tests and documentation for the new cputune/cachetune element
+that will get used by following patches.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 7387e3fea44e28118e1f72841d79503849e15985)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Downstream changes:
+
+- Rename test XML files due to ab7a2fe230bb742cc4bc7f8d1475201b97fe49ab
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ docs/formatdomain.html.in                          |  54 ++++
+ docs/schemas/domaincommon.rng                      |  32 +++
+ src/conf/domain_conf.c                             | 295 ++++++++++++++++++++-
+ src/conf/domain_conf.h                             |  13 +
+ .../genericxml2xmlindata/generic-cachetune-cdp.xml |  36 +++
+ .../generic-cachetune-colliding-allocs.xml         |  30 +++
+ .../generic-cachetune-colliding-tunes.xml          |  32 +++
+ .../generic-cachetune-colliding-types.xml          |  30 +++
+ .../generic-cachetune-small.xml                    |  29 ++
+ tests/genericxml2xmlindata/generic-cachetune.xml   |  33 +++
+ tests/genericxml2xmltest.c                         |  10 +
+ 11 files changed, 592 insertions(+), 2 deletions(-)
+ create mode 100644 tests/genericxml2xmlindata/generic-cachetune-cdp.xml
+ create mode 100644 tests/genericxml2xmlindata/generic-cachetune-colliding-allocs.xml
+ create mode 100644 tests/genericxml2xmlindata/generic-cachetune-colliding-tunes.xml
+ create mode 100644 tests/genericxml2xmlindata/generic-cachetune-colliding-types.xml
+ create mode 100644 tests/genericxml2xmlindata/generic-cachetune-small.xml
+ create mode 100644 tests/genericxml2xmlindata/generic-cachetune.xml
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index 0cfbf051b7..f33261d05c 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -689,6 +689,10 @@
+     &lt;iothread_quota&gt;-1&lt;/iothread_quota&gt;
+     &lt;vcpusched vcpus='0-4,^3' scheduler='fifo' priority='1'/&gt;
+     &lt;iothreadsched iothreads='2' scheduler='batch'/&gt;
++    &lt;cachetune vcpus='0-3'&gt;
++      &lt;cache id='0' level='3' type='both' size='3' unit='MiB'/&gt;
++      &lt;cache id='1' level='3' type='both' size='3' unit='MiB'/&gt;
++    &lt;/cachetune&gt;
+   &lt;/cputune&gt;
+   ...
+ &lt;/domain&gt;
+@@ -834,6 +838,56 @@
+         <span class="since">Since 1.2.13</span>
+       </dd>
+ 
++      <dt><code>cachetune</code><span class="since">Since 4.1.0</span></dt>
++      <dd>
++        Optional <code>cachetune</code> element can control allocations for CPU
++        caches using the resctrl on the host. Whether or not is this supported
++        can be gathered from capabilities where some limitations like minimum
++        size and required granularity are reported as well. The required
++        attribute <code>vcpus</code> specifies to which vCPUs this allocation
++        applies. A vCPU can only be member of one <code>cachetune</code> element
++        allocations. Supported subelements are:
++        <dl>
++          <dt><code>cache</code></dt>
++          <dd>
++            This element controls the allocation of CPU cache and has the
++            following attributes:
++            <dl>
++              <dt><code>level</code></dt>
++              <dd>
++                Host cache level from which to allocate.
++              </dd>
++              <dt><code>id</code></dt>
++              <dd>
++                Host cache id from which to allocate.
++              </dd>
++              <dt><code>type</code></dt>
++              <dd>
++                Type of allocation. Can be <code>code</code> for code
++                (instructions), <code>data</code> for data or <code>both</code>
++                for both code and data (unified). Currently the allocation can
++                be done only with the same type as the host supports, meaning
++                you cannot request <code>both</code> for host with CDP
++                (code/data prioritization) enabled.
++              </dd>
++              <dt><code>size</code></dt>
++              <dd>
++                The size of the region to allocate. The value by default is in
++                bytes, but the <code>unit</code> attribute can be used to scale
++                the value.
++              </dd>
++              <dt><code>unit</code> (optional)</dt>
++              <dd>
++                If specified it is the unit such as KiB, MiB, GiB, or TiB
++                (described in the <code>memory</code> element
++                for <a href="#elementsMemoryAllocation">Memory Allocation</a>)
++                in which <code>size</code> is specified, defaults to bytes.
++              </dd>
++            </dl>
++          </dd>
++        </dl>
++
++      </dd>
+     </dl>
+ 
+ 
+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
+index 05709afc0c..564674b659 100644
+--- a/docs/schemas/domaincommon.rng
++++ b/docs/schemas/domaincommon.rng
+@@ -900,6 +900,38 @@
+             <ref name="schedparam"/>
+           </element>
+         </zeroOrMore>
++        <zeroOrMore>
++          <element name="cachetune">
++            <attribute name="vcpus">
++              <ref name='cpuset'/>
++            </attribute>
++            <oneOrMore>
++              <element name="cache">
++                <attribute name="id">
++                  <ref name='unsignedInt'/>
++                </attribute>
++                <attribute name="level">
++                  <ref name='unsignedInt'/>
++                </attribute>
++                <attribute name="type">
++                  <choice>
++                    <value>both</value>
++                    <value>code</value>
++                    <value>data</value>
++                  </choice>
++                </attribute>
++                <attribute name="size">
++                  <ref name='unsignedLong'/>
++                </attribute>
++                <optional>
++                  <attribute name='unit'>
++                    <ref name='unit'/>
++                  </attribute>
++                </optional>
++              </element>
++            </oneOrMore>
++          </element>
++        </zeroOrMore>
+       </interleave>
+     </element>
+   </define>
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index ad9c16a1e0..181b035647 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -2886,6 +2886,19 @@ virDomainLoaderDefFree(virDomainLoaderDefPtr loader)
+     VIR_FREE(loader);
+ }
+ 
++
++static void
++virDomainCachetuneDefFree(virDomainCachetuneDefPtr cachetune)
++{
++    if (!cachetune)
++        return;
++
++    virObjectUnref(cachetune->alloc);
++    virBitmapFree(cachetune->vcpus);
++    VIR_FREE(cachetune);
++}
++
++
+ void virDomainDefFree(virDomainDefPtr def)
+ {
+     size_t i;
+@@ -3058,6 +3071,10 @@ void virDomainDefFree(virDomainDefPtr def)
+         virDomainShmemDefFree(def->shmems[i]);
+     VIR_FREE(def->shmems);
+ 
++    for (i = 0; i < def->ncachetunes; i++)
++        virDomainCachetuneDefFree(def->cachetunes[i]);
++    VIR_FREE(def->cachetunes);
++
+     VIR_FREE(def->keywrap);
+ 
+     if (def->namespaceData && def->ns.free)
+@@ -18233,6 +18250,194 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
+ }
+ 
+ 
++static int
++virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt,
++                                xmlNodePtr node,
++                                virResctrlAllocPtr alloc)
++{
++    xmlNodePtr oldnode = ctxt->node;
++    unsigned int level;
++    unsigned int cache;
++    int type;
++    unsigned long long size;
++    char *tmp = NULL;
++    int ret = -1;
++
++    ctxt->node = node;
++
++    tmp = virXMLPropString(node, "id");
++    if (!tmp) {
++        virReportError(VIR_ERR_XML_ERROR, "%s",
++                       _("Missing cachetune attribute 'id'"));
++        goto cleanup;
++    }
++    if (virStrToLong_uip(tmp, NULL, 10, &cache) < 0) {
++        virReportError(VIR_ERR_XML_ERROR,
++                       _("Invalid cachetune attribute 'id' value '%s'"),
++                       tmp);
++        goto cleanup;
++    }
++    VIR_FREE(tmp);
++
++    tmp = virXMLPropString(node, "level");
++    if (!tmp) {
++        virReportError(VIR_ERR_XML_ERROR, "%s",
++                       _("Missing cachetune attribute 'level'"));
++        goto cleanup;
++    }
++    if (virStrToLong_uip(tmp, NULL, 10, &level) < 0) {
++        virReportError(VIR_ERR_XML_ERROR,
++                       _("Invalid cachetune attribute 'level' value '%s'"),
++                       tmp);
++        goto cleanup;
++    }
++    VIR_FREE(tmp);
++
++    tmp = virXMLPropString(node, "type");
++    if (!tmp) {
++        virReportError(VIR_ERR_XML_ERROR, "%s",
++                       _("Missing cachetune attribute 'type'"));
++        goto cleanup;
++    }
++    type = virCacheTypeFromString(tmp);
++    if (type < 0) {
++        virReportError(VIR_ERR_XML_ERROR,
++                       _("Invalid cachetune attribute 'type' value '%s'"),
++                       tmp);
++        goto cleanup;
++    }
++    VIR_FREE(tmp);
++
++    if (virDomainParseScaledValue("./@size", "./@unit",
++                                  ctxt, &size, 1024,
++                                  ULLONG_MAX, true) < 0)
++        goto cleanup;
++
++    if (virResctrlAllocSetSize(alloc, level, type, cache, size) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    ctxt->node = oldnode;
++    VIR_FREE(tmp);
++    return ret;
++}
++
++
++static int
++virDomainCachetuneDefParse(virDomainDefPtr def,
++                           xmlXPathContextPtr ctxt,
++                           xmlNodePtr node,
++                           unsigned int flags)
++{
++    xmlNodePtr oldnode = ctxt->node;
++    xmlNodePtr *nodes = NULL;
++    virBitmapPtr vcpus = NULL;
++    virResctrlAllocPtr alloc = virResctrlAllocNew();
++    virDomainCachetuneDefPtr tmp_cachetune = NULL;
++    char *tmp = NULL;
++    char *vcpus_str = NULL;
++    char *alloc_id = NULL;
++    ssize_t i = 0;
++    int n;
++    int ret = -1;
++
++    ctxt->node = node;
++
++    if (!alloc)
++        goto cleanup;
++
++    if (VIR_ALLOC(tmp_cachetune) < 0)
++        goto cleanup;
++
++    vcpus_str = virXMLPropString(node, "vcpus");
++    if (!vcpus_str) {
++        virReportError(VIR_ERR_XML_ERROR, "%s",
++                       _("Missing cachetune attribute 'vcpus'"));
++        goto cleanup;
++    }
++    if (virBitmapParse(vcpus_str, &vcpus, VIR_DOMAIN_CPUMASK_LEN) < 0) {
++        virReportError(VIR_ERR_XML_ERROR,
++                       _("Invalid cachetune attribute 'vcpus' value '%s'"),
++                       vcpus_str);
++        goto cleanup;
++    }
++
++    /* We need to limit the bitmap to number of vCPUs.  If there's nothing left,
++     * then we can just clean up and return 0 immediately */
++    virBitmapShrink(vcpus, def->maxvcpus);
++    if (virBitmapIsAllClear(vcpus)) {
++        ret = 0;
++        goto cleanup;
++    }
++
++    if ((n = virXPathNodeSet("./cache", ctxt, &nodes)) < 0) {
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("Cannot extract cache nodes under cachetune"));
++        goto cleanup;
++    }
++
++    for (i = 0; i < n; i++) {
++        if (virDomainCachetuneDefParseCache(ctxt, nodes[i], alloc) < 0)
++            goto cleanup;
++    }
++
++    if (virResctrlAllocIsEmpty(alloc)) {
++        ret = 0;
++        goto cleanup;
++    }
++
++    for (i = 0; i < def->ncachetunes; i++) {
++        if (virBitmapOverlaps(def->cachetunes[i]->vcpus, vcpus)) {
++            virReportError(VIR_ERR_XML_ERROR, "%s",
++                           _("Overlapping vcpus in cachetunes"));
++            goto cleanup;
++        }
++    }
++
++    /* We need to format it back because we need to be consistent in the naming
++     * even when users specify some "sub-optimal" string there. */
++    VIR_FREE(vcpus_str);
++    vcpus_str = virBitmapFormat(vcpus);
++    if (!vcpus_str)
++        goto cleanup;
++
++    if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
++        alloc_id = virXMLPropString(node, "id");
++
++    if (!alloc_id) {
++        /* The number of allocations is limited and the directory structure is flat,
++         * not hierarchical, so we need to have all same allocations in one
++         * directory, so it's nice to have it named appropriately.  For now it's
++         * 'vcpus_...' but it's designed in order for it to be changeable in the
++         * future (it's part of the status XML). */
++        if (virAsprintf(&alloc_id, "vcpus_%s", vcpus_str) < 0)
++            goto cleanup;
++    }
++
++    if (virResctrlAllocSetID(alloc, alloc_id) < 0)
++        goto cleanup;
++
++    VIR_STEAL_PTR(tmp_cachetune->vcpus, vcpus);
++    VIR_STEAL_PTR(tmp_cachetune->alloc, alloc);
++
++    if (VIR_APPEND_ELEMENT(def->cachetunes, def->ncachetunes, tmp_cachetune) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    ctxt->node = oldnode;
++    virDomainCachetuneDefFree(tmp_cachetune);
++    virObjectUnref(alloc);
++    virBitmapFree(vcpus);
++    VIR_FREE(alloc_id);
++    VIR_FREE(vcpus_str);
++    VIR_FREE(nodes);
++    VIR_FREE(tmp);
++    return ret;
++}
++
++
+ static virDomainDefPtr
+ virDomainDefParseXML(xmlDocPtr xml,
+                      xmlNodePtr root,
+@@ -18785,6 +18990,18 @@ virDomainDefParseXML(xmlDocPtr xml,
+     }
+     VIR_FREE(nodes);
+ 
++    if ((n = virXPathNodeSet("./cputune/cachetune", ctxt, &nodes)) < 0) {
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("cannot extract cachetune nodes"));
++        goto error;
++    }
++
++    for (i = 0; i < n; i++) {
++        if (virDomainCachetuneDefParse(def, ctxt, nodes[i], flags) < 0)
++            goto error;
++    }
++    VIR_FREE(nodes);
++
+     if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &def->cpu) < 0)
+         goto error;
+ 
+@@ -25736,9 +25953,80 @@ virDomainSchedulerFormat(virBufferPtr buf,
+ }
+ 
+ 
++static int
++virDomainCachetuneDefFormatHelper(unsigned int level,
++                                  virCacheType type,
++                                  unsigned int cache,
++                                  unsigned long long size,
++                                  void *opaque)
++{
++    const char *unit;
++    virBufferPtr buf = opaque;
++    unsigned long long short_size = virFormatIntPretty(size, &unit);
++
++    virBufferAsprintf(buf,
++                      "<cache id='%u' level='%u' type='%s' "
++                      "size='%llu' unit='%s'/>\n",
++                      cache, level, virCacheTypeToString(type),
++                      short_size, unit);
++
++    return 0;
++}
++
++
++static int
++virDomainCachetuneDefFormat(virBufferPtr buf,
++                            virDomainCachetuneDefPtr cachetune,
++                            unsigned int flags)
++{
++    virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
++    char *vcpus = NULL;
++    int ret = -1;
++
++    virBufferSetChildIndent(&childrenBuf, buf);
++    virResctrlAllocForeachSize(cachetune->alloc,
++                               virDomainCachetuneDefFormatHelper,
++                               &childrenBuf);
++
++
++    if (virBufferCheckError(&childrenBuf) < 0)
++        goto cleanup;
++
++    if (!virBufferUse(&childrenBuf)) {
++        ret = 0;
++        goto cleanup;
++    }
++
++    vcpus = virBitmapFormat(cachetune->vcpus);
++    if (!vcpus)
++        goto cleanup;
++
++    virBufferAsprintf(buf, "<cachetune vcpus='%s'", vcpus);
++
++    if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
++        const char *alloc_id = virResctrlAllocGetID(cachetune->alloc);
++        if (!alloc_id)
++            goto cleanup;
++
++        virBufferAsprintf(buf, " id='%s'", alloc_id);
++    }
++    virBufferAddLit(buf, ">\n");
++
++    virBufferAddBuffer(buf, &childrenBuf);
++    virBufferAddLit(buf, "</cachetune>\n");
++
++    ret = 0;
++ cleanup:
++    virBufferFreeAndReset(&childrenBuf);
++    VIR_FREE(vcpus);
++    return ret;
++}
++
++
+ static int
+ virDomainCputuneDefFormat(virBufferPtr buf,
+-                          virDomainDefPtr def)
++                          virDomainDefPtr def,
++                          unsigned int flags)
+ {
+     size_t i;
+     virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
+@@ -25837,6 +26125,9 @@ virDomainCputuneDefFormat(virBufferPtr buf,
+                                  def->iothreadids[i]->iothread_id);
+     }
+ 
++    for (i = 0; i < def->ncachetunes; i++)
++        virDomainCachetuneDefFormat(&childrenBuf, def->cachetunes[i], flags);
++
+     if (virBufferCheckError(&childrenBuf) < 0)
+         return -1;
+ 
+@@ -26174,7 +26465,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
+         }
+     }
+ 
+-    if (virDomainCputuneDefFormat(buf, def) < 0)
++    if (virDomainCputuneDefFormat(buf, def, flags) < 0)
+         goto error;
+ 
+     if (virDomainNumatuneFormatXML(buf, def->numa) < 0)
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 5e67c9a9c1..ed7b587bed 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -56,6 +56,7 @@
+ # include "virperf.h"
+ # include "virtypedparam.h"
+ # include "virsavecookie.h"
++# include "virresctrl.h"
+ 
+ /* forward declarations of all device types, required by
+  * virDomainDeviceDef
+@@ -2190,6 +2191,15 @@ struct _virDomainCputune {
+ };
+ 
+ 
++typedef struct _virDomainCachetuneDef virDomainCachetuneDef;
++typedef virDomainCachetuneDef *virDomainCachetuneDefPtr;
++
++struct _virDomainCachetuneDef {
++    virBitmapPtr vcpus;
++    virResctrlAllocPtr alloc;
++};
++
++
+ typedef struct _virDomainVcpuDef virDomainVcpuDef;
+ typedef virDomainVcpuDef *virDomainVcpuDefPtr;
+ 
+@@ -2318,6 +2328,9 @@ struct _virDomainDef {
+ 
+     virDomainCputune cputune;
+ 
++    virDomainCachetuneDefPtr *cachetunes;
++    size_t ncachetunes;
++
+     virDomainNumaPtr numa;
+     virDomainResourceDefPtr resource;
+     virDomainIdMapDef idmap;
+diff --git a/tests/genericxml2xmlindata/generic-cachetune-cdp.xml b/tests/genericxml2xmlindata/generic-cachetune-cdp.xml
+new file mode 100644
+index 0000000000..9718f06098
+--- /dev/null
++++ b/tests/genericxml2xmlindata/generic-cachetune-cdp.xml
+@@ -0,0 +1,36 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219136</memory>
++  <currentMemory unit='KiB'>219136</currentMemory>
++  <vcpu placement='static'>4</vcpu>
++  <cputune>
++    <cachetune vcpus='0-1'>
++      <cache id='0' level='3' type='code' size='7680' unit='KiB'/>
++      <cache id='1' level='3' type='data' size='3840' unit='KiB'/>
++    </cachetune>
++    <cachetune vcpus='2'>
++      <cache id='1' level='3' type='code' size='6' unit='MiB'/>
++    </cachetune>
++    <cachetune vcpus='3'>
++      <cache id='1' level='3' type='data' size='6912' unit='KiB'/>
++    </cachetune>
++  </cputune>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <controller type='usb' index='0'/>
++    <controller type='ide' index='0'/>
++    <controller type='pci' index='0' model='pci-root'/>
++    <input type='mouse' bus='ps2'/>
++    <input type='keyboard' bus='ps2'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/genericxml2xmlindata/generic-cachetune-colliding-allocs.xml b/tests/genericxml2xmlindata/generic-cachetune-colliding-allocs.xml
+new file mode 100644
+index 0000000000..82c9176cba
+--- /dev/null
++++ b/tests/genericxml2xmlindata/generic-cachetune-colliding-allocs.xml
+@@ -0,0 +1,30 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219136</memory>
++  <currentMemory unit='KiB'>219136</currentMemory>
++  <vcpu placement='static'>4</vcpu>
++  <cputune>
++    <cachetune vcpus='0'>
++      <cache id='0' level='3' type='code' size='12' unit='KiB'/>
++      <cache id='0' level='3' type='code' size='18' unit='KiB'/>
++    </cachetune>
++  </cputune>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <controller type='usb' index='0'/>
++    <controller type='ide' index='0'/>
++    <controller type='pci' index='0' model='pci-root'/>
++    <input type='mouse' bus='ps2'/>
++    <input type='keyboard' bus='ps2'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/genericxml2xmlindata/generic-cachetune-colliding-tunes.xml b/tests/genericxml2xmlindata/generic-cachetune-colliding-tunes.xml
+new file mode 100644
+index 0000000000..a0f37028c9
+--- /dev/null
++++ b/tests/genericxml2xmlindata/generic-cachetune-colliding-tunes.xml
+@@ -0,0 +1,32 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219136</memory>
++  <currentMemory unit='KiB'>219136</currentMemory>
++  <vcpu placement='static'>4</vcpu>
++  <cputune>
++    <cachetune vcpus='0'>
++      <cache id='0' level='3' type='code' size='12' unit='KiB'/>
++    </cachetune>
++    <cachetune vcpus='0'>
++      <cache id='0' level='3' type='data' size='18' unit='KiB'/>
++    </cachetune>
++  </cputune>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <controller type='usb' index='0'/>
++    <controller type='ide' index='0'/>
++    <controller type='pci' index='0' model='pci-root'/>
++    <input type='mouse' bus='ps2'/>
++    <input type='keyboard' bus='ps2'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/genericxml2xmlindata/generic-cachetune-colliding-types.xml b/tests/genericxml2xmlindata/generic-cachetune-colliding-types.xml
+new file mode 100644
+index 0000000000..c229eccee4
+--- /dev/null
++++ b/tests/genericxml2xmlindata/generic-cachetune-colliding-types.xml
+@@ -0,0 +1,30 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219136</memory>
++  <currentMemory unit='KiB'>219136</currentMemory>
++  <vcpu placement='static'>4</vcpu>
++  <cputune>
++    <cachetune vcpus='0-1'>
++      <cache id='0' level='3' type='both' size='12' unit='KiB'/>
++      <cache id='0' level='3' type='code' size='6' unit='KiB'/>
++    </cachetune>
++  </cputune>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <controller type='usb' index='0'/>
++    <controller type='ide' index='0'/>
++    <controller type='pci' index='0' model='pci-root'/>
++    <input type='mouse' bus='ps2'/>
++    <input type='keyboard' bus='ps2'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/genericxml2xmlindata/generic-cachetune-small.xml b/tests/genericxml2xmlindata/generic-cachetune-small.xml
+new file mode 100644
+index 0000000000..ab2d9cf885
+--- /dev/null
++++ b/tests/genericxml2xmlindata/generic-cachetune-small.xml
+@@ -0,0 +1,29 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219136</memory>
++  <currentMemory unit='KiB'>219136</currentMemory>
++  <vcpu placement='static'>4</vcpu>
++  <cputune>
++    <cachetune vcpus='0-1'>
++      <cache id='0' level='3' type='both' size='768' unit='KiB'/>
++    </cachetune>
++  </cputune>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <controller type='usb' index='0'/>
++    <controller type='ide' index='0'/>
++    <controller type='pci' index='0' model='pci-root'/>
++    <input type='mouse' bus='ps2'/>
++    <input type='keyboard' bus='ps2'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/genericxml2xmlindata/generic-cachetune.xml b/tests/genericxml2xmlindata/generic-cachetune.xml
+new file mode 100644
+index 0000000000..645cab7771
+--- /dev/null
++++ b/tests/genericxml2xmlindata/generic-cachetune.xml
+@@ -0,0 +1,33 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219136</memory>
++  <currentMemory unit='KiB'>219136</currentMemory>
++  <vcpu placement='static'>4</vcpu>
++  <cputune>
++    <cachetune vcpus='0-1'>
++      <cache id='0' level='3' type='both' size='3' unit='MiB'/>
++      <cache id='1' level='3' type='both' size='3' unit='MiB'/>
++    </cachetune>
++    <cachetune vcpus='3'>
++      <cache id='0' level='3' type='both' size='3' unit='MiB'/>
++    </cachetune>
++  </cputune>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <controller type='usb' index='0'/>
++    <controller type='ide' index='0'/>
++    <controller type='pci' index='0' model='pci-root'/>
++    <input type='mouse' bus='ps2'/>
++    <input type='keyboard' bus='ps2'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
+index 0377a05e9c..4ced5c349c 100644
+--- a/tests/genericxml2xmltest.c
++++ b/tests/genericxml2xmltest.c
+@@ -130,6 +130,16 @@ mymain(void)
+     DO_TEST_FULL("chardev-reconnect-invalid-mode", 0, false,
+                  TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
+ 
++    DO_TEST("cachetune");
++    DO_TEST("cachetune-small");
++    DO_TEST("cachetune-cdp");
++    DO_TEST_FULL("cachetune-colliding-allocs", false, true,
++                 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
++    DO_TEST_FULL("cachetune-colliding-tunes", false, true,
++                 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
++    DO_TEST_FULL("cachetune-colliding-types", false, true,
++                 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
++
+     virObjectUnref(caps);
+     virObjectUnref(xmlopt);
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-conf-Add-target-type-and-model-for-pl011.patch b/SOURCES/libvirt-conf-Add-target-type-and-model-for-pl011.patch
new file mode 100644
index 0000000..fd6612b
--- /dev/null
+++ b/SOURCES/libvirt-conf-Add-target-type-and-model-for-pl011.patch
@@ -0,0 +1,952 @@
+From 623a617e8199a9c7abd1903399fdbeccf4e85add Mon Sep 17 00:00:00 2001
+Message-Id: <623a617e8199a9c7abd1903399fdbeccf4e85add@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:14 +0100
+Subject: [PATCH] conf: Add target type and model for pl011
+
+We can finally introduce a specific target model for the pl011 device
+used by mach-virt guests, which means isa-serial will no longer show
+up to confuse users.
+
+We make sure migration works in both directions by interpreting the
+isa-serial target type, or the lack of target type, appropriately
+when parsing the guest XML, and skipping the newly-introduced type
+when formatting if for migration. We also verify that pl011 is not
+used for non-mach-virt guests and add a bunch of test cases.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit eccdcb81fcfd1641960d397c82986b4517841794)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/formatdomain.html.in                          | 13 ++++---
+ docs/schemas/domaincommon.rng                      |  2 +
+ src/conf/domain_conf.c                             |  3 ++
+ src/conf/domain_conf.h                             |  2 +
+ src/qemu/qemu_command.c                            |  9 ++++-
+ src/qemu/qemu_domain.c                             | 26 +++++++++++++
+ src/qemu/qemu_domain_address.c                     |  1 +
+ .../qemuxml2argv-mach-virt-console-native.args     |  1 +
+ .../qemuxml2argv-mach-virt-console-native.xml      | 17 +++++++++
+ .../qemuxml2argv-mach-virt-console-virtio.args     | 24 ++++++++++++
+ .../qemuxml2argv-mach-virt-console-virtio.xml      | 19 ++++++++++
+ ...muxml2argv-mach-virt-serial+console-native.args |  1 +
+ ...emuxml2argv-mach-virt-serial+console-native.xml | 18 +++++++++
+ .../qemuxml2argv-mach-virt-serial-compat.args      |  1 +
+ .../qemuxml2argv-mach-virt-serial-compat.xml       | 19 ++++++++++
+ ...muxml2argv-mach-virt-serial-invalid-machine.xml | 21 +++++++++++
+ .../qemuxml2argv-mach-virt-serial-native.args      | 23 +++++++++++
+ .../qemuxml2argv-mach-virt-serial-native.xml       | 16 ++++++++
+ .../qemuxml2argv-mach-virt-serial-pci.args         | 26 +++++++++++++
+ .../qemuxml2argv-mach-virt-serial-pci.xml          | 18 +++++++++
+ .../qemuxml2argv-mach-virt-serial-usb.args         | 27 +++++++++++++
+ .../qemuxml2argv-mach-virt-serial-usb.xml          | 21 +++++++++++
+ tests/qemuxml2argvtest.c                           | 27 +++++++++++++
+ .../qemuxml2xmlout-aarch64-virtio-pci-default.xml  |  4 +-
+ .../qemuxml2xmlout-mach-virt-console-native.xml    |  1 +
+ .../qemuxml2xmlout-mach-virt-console-virtio.xml    | 27 +++++++++++++
+ ...uxml2xmlout-mach-virt-serial+console-native.xml |  1 +
+ .../qemuxml2xmlout-mach-virt-serial-compat.xml     | 31 +++++++++++++++
+ .../qemuxml2xmlout-mach-virt-serial-native.xml     |  1 +
+ .../qemuxml2xmlout-mach-virt-serial-pci.xml        | 44 ++++++++++++++++++++++
+ .../qemuxml2xmlout-mach-virt-serial-usb.xml        | 41 ++++++++++++++++++++
+ tests/qemuxml2xmltest.c                            | 26 +++++++++++++
+ 32 files changed, 503 insertions(+), 8 deletions(-)
+ create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.xml
+ create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.xml
+ create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-invalid-machine.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.xml
+ create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-native.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-virtio.xml
+ create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial+console-native.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-compat.xml
+ create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-native.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-pci.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-usb.xml
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index 0634f3396a..87389f4e73 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -6463,8 +6463,9 @@ qemu-kvm -net nic,model=? /dev/null
+       with x86 guests), <code>usb-serial</code> (usable whenever USB support
+       is available) and <code>pci-serial</code> (usable whenever PCI support
+       is available); <span class="since">since 3.10.0</span>,
+-      <code>spapr-vio-serial</code> (usable with ppc64/pseries guests)
+-      is available as well.
++      <code>spapr-vio-serial</code> (usable with ppc64/pseries guests) and
++      <code>system-serial</code> (usable with aarch64/virt guests) are
++      available as well.
+     </p>
+ 
+     <p>
+@@ -6476,7 +6477,8 @@ qemu-kvm -net nic,model=? /dev/null
+       target type); <code>pci-serial</code>
+       (usable with the <code>pci-serial</code> target type);
+       <code>spapr-vty</code> (usable with the <code>spapr-vio-serial</code>
+-      target type).
++      target type); <code>pl011</code> (usable with the
++      <code>system-serial</code> target type).
+     </p>
+ 
+     <p>
+@@ -6485,12 +6487,13 @@ qemu-kvm -net nic,model=? /dev/null
+     </p>
+ 
+     <p>
+-      All of the target types support configuring the guest-visible device
++      Most target types support configuring the guest-visible device
+       address as <a href="#elementsAddress">documented above</a>; more
+       specifically, acceptable address types are <code>isa</code> (for
+       <code>isa-serial</code>), <code>usb</code> (for <code>usb-serial</code>),
+       <code>pci</code> (for <code>pci-serial</code>) and <code>spapr-vio</code>
+-      (for <code>spapr-vio-serial</code>).
++      (for <code>spapr-vio-serial</code>). The <code>system-serial</code>
++      target type doesn't support specifying an address.
+     </p>
+ 
+     <p>
+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
+index 027d9ae7a1..957eae2832 100644
+--- a/docs/schemas/domaincommon.rng
++++ b/docs/schemas/domaincommon.rng
+@@ -3572,6 +3572,7 @@
+         <value>usb-serial</value>
+         <value>pci-serial</value>
+         <value>spapr-vio-serial</value>
++        <value>system-serial</value>
+       </choice>
+     </attribute>
+   </define>
+@@ -3584,6 +3585,7 @@
+           <value>usb-serial</value>
+           <value>pci-serial</value>
+           <value>spapr-vty</value>
++          <value>pl011</value>
+         </choice>
+       </attribute>
+     </element>
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 97c7a66b5b..32089df3c2 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -446,6 +446,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget,
+               "usb-serial",
+               "pci-serial",
+               "spapr-vio-serial",
++              "system-serial",
+ );
+ 
+ VIR_ENUM_IMPL(virDomainChrChannelTarget,
+@@ -474,6 +475,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTargetModel,
+               "usb-serial",
+               "pci-serial",
+               "spapr-vty",
++              "pl011",
+ );
+ 
+ VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST,
+@@ -4063,6 +4065,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def)
+         switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) {
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: {
+ 
+             /* Create a stub console to match the serial port.
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 979e8cca00..d6febf3059 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -1078,6 +1078,7 @@ typedef enum {
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM,
+ 
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
+ } virDomainChrSerialTargetType;
+@@ -1111,6 +1112,7 @@ typedef enum {
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011,
+ 
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
+ } virDomainChrSerialTargetModel;
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 056dafea39..483eee6056 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9230,6 +9230,7 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel)
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
+         return QEMU_CAPS_DEVICE_SPAPR_VTY;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+         break;
+@@ -9261,10 +9262,13 @@ qemuChrIsPlatformDevice(const virDomainDef *def,
+                         virDomainChrDefPtr chr)
+ {
+     if (def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) {
+-        /* TARGET_TYPE_ISA here really means 'the default platform device' */
++
++        /* pl011 (used on mach-virt) is a platform device */
+         if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+-            chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA)
++            chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM &&
++            chr->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011) {
+             return true;
++        }
+     }
+ 
+     /* If we got all the way here and we're still stuck with the default
+@@ -10365,6 +10369,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+         break;
+ 
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+         /* Except from _LAST, which is just a guard value and will never
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 17c898896d..2fc173fa45 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3468,6 +3468,7 @@ qemuDomainChrSerialTargetTypeToAddressType(int targetType)
+         return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
+         return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         break;
+@@ -3489,6 +3490,8 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel)
+         return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
+         return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
++        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+         break;
+@@ -3525,6 +3528,16 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr)
+             }
+             break;
+ 
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
++            if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                               _("Target type '%s' cannot have an "
++                                 "associated address"),
++                               virDomainChrSerialTargetTypeToString(chr->targetType));
++                return -1;
++            }
++            break;
++
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+             break;
+@@ -3536,6 +3549,7 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr)
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
+ 
+             expected = qemuDomainChrSerialTargetModelToTargetType(chr->targetModel);
+ 
+@@ -3592,6 +3606,12 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev,
+             isCompatible = false;
+         }
+ 
++        if (!qemuDomainIsVirt(def) &&
++            (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM ||
++             dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011)) {
++            isCompatible = false;
++        }
++
+         if (!isCompatible) {
+             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                            _("Serial device with target type '%s' and "
+@@ -4243,6 +4263,8 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
+             chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
+         } else if (qemuDomainIsPSeries(def)) {
+             chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO;
++        } else if (qemuDomainIsVirt(def)) {
++            chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM;
+         }
+     }
+ 
+@@ -4262,6 +4284,9 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
+             chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY;
+             break;
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
++            chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011;
++            break;
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+             /* Nothing to do */
+@@ -5178,6 +5203,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
+             if (flags & VIR_DOMAIN_XML_MIGRATABLE) {
+                 switch ((virDomainChrSerialTargetType) serial->targetType) {
+                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
++                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
+                     serial->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
+                     serial->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE;
+                     break;
+diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
+index f62bb2f97e..db9656a3a5 100644
+--- a/src/qemu/qemu_domain_address.c
++++ b/src/qemu/qemu_domain_address.c
+@@ -784,6 +784,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+             return 0;
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.args
+new file mode 120000
+index 0000000000..1a90484d3b
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.args
+@@ -0,0 +1 @@
++qemuxml2argv-mach-virt-serial-native.args
+\ No newline at end of file
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.xml
+new file mode 100644
+index 0000000000..6aba864d0b
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.xml
+@@ -0,0 +1,17 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- The <console> element being present should result in a matching
++         <serial> element being created -->
++    <console type='pty'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.args
+new file mode 100644
+index 0000000000..2a862bff18
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.args
+@@ -0,0 +1,24 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-aarch64 \
++-name guest \
++-S \
++-M virt \
++-m 512 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-no-acpi \
++-boot c \
++-device virtio-serial,id=virtio-serial0 \
++-chardev pty,id=charconsole0 \
++-device virtconsole,chardev=charconsole0,id=console0
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.xml
+new file mode 100644
+index 0000000000..92704504c8
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.xml
+@@ -0,0 +1,19 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- The <console> element being present should *not* result in a
++         matching <serial> element being created -->
++    <console type='pty'>
++      <target type='virtio'/>
++    </console>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.args
+new file mode 120000
+index 0000000000..1a90484d3b
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.args
+@@ -0,0 +1 @@
++qemuxml2argv-mach-virt-serial-native.args
+\ No newline at end of file
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.xml
+new file mode 100644
+index 0000000000..549b764e98
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.xml
+@@ -0,0 +1,18 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- When both the <serial> and <console> elements are present, they will
++         be matched and end up representing the same native serial console -->
++    <serial type='pty'/>
++    <console type='pty'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.args
+new file mode 120000
+index 0000000000..1a90484d3b
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.args
+@@ -0,0 +1 @@
++qemuxml2argv-mach-virt-serial-native.args
+\ No newline at end of file
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.xml
+new file mode 100644
+index 0000000000..9e6be3ffeb
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.xml
+@@ -0,0 +1,19 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- isa-serial has to be accepted for backwards compatibility reasons,
++         but should get converted to the proper type (pl011) -->
++    <serial type='pty'>
++      <target type='isa-serial'/>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-invalid-machine.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-invalid-machine.xml
+new file mode 100644
+index 0000000000..a8de76abf9
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-invalid-machine.xml
+@@ -0,0 +1,21 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='x86_64' machine='pc'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-x86_64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- The pl011 serial console can only be used for mach-virt guests,
++         so this should be rejected -->
++    <serial type='pty'>
++      <target type='system-serial'>
++        <model name='pl011'/>
++      </target>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.args
+new file mode 100644
+index 0000000000..f4bfce376a
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.args
+@@ -0,0 +1,23 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-aarch64 \
++-name guest \
++-S \
++-M virt \
++-m 512 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-no-acpi \
++-boot c \
++-chardev pty,id=charserial0 \
++-serial chardev:charserial0
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.xml
+new file mode 100644
+index 0000000000..817f606eea
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.xml
+@@ -0,0 +1,16 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- This will use the pl011 target type -->
++    <serial type='pty'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.args
+new file mode 100644
+index 0000000000..334194efe1
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.args
+@@ -0,0 +1,26 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-aarch64 \
++-name guest \
++-S \
++-M virt \
++-m 512 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-no-acpi \
++-boot c \
++-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1 \
++-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
++-device pcie-root-port,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \
++-chardev pty,id=charserial0 \
++-device pci-serial,chardev=charserial0,id=serial0,bus=pci.2,addr=0x1
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.xml
+new file mode 100644
+index 0000000000..29aa7664b1
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.xml
+@@ -0,0 +1,18 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- This will be assigned a PCI address -->
++    <serial type='pty'>
++      <target type='pci-serial'/>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.args
+new file mode 100644
+index 0000000000..44c4027acc
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.args
+@@ -0,0 +1,27 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-aarch64 \
++-name guest \
++-S \
++-M virt \
++-m 512 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-no-acpi \
++-boot c \
++-device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\
++addr=0x1 \
++-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
++-device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
++-chardev pty,id=charserial0 \
++-device usb-serial,chardev=charserial0,id=serial0,bus=usb.0,port=1
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.xml
+new file mode 100644
+index 0000000000..35f192a3e5
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.xml
+@@ -0,0 +1,21 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' model='qemu-xhci'/>
++    <!-- This should be assigned a USB address. You'll not be able to find it
++         in the file generated by qemuxml2xmltest due to limitations in the
++         test suite, but it will be there when actually running libvirt;
++         moreover, the USB address will be present in the .args file -->
++    <serial type='pty'>
++      <target type='usb-serial'/>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 2b3bbd1b8b..656b8c0995 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -1898,6 +1898,33 @@ mymain(void)
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);
+ 
++    DO_TEST("mach-virt-serial-native",
++            QEMU_CAPS_NODEFCONFIG);
++    DO_TEST("mach-virt-serial+console-native",
++            QEMU_CAPS_NODEFCONFIG);
++    DO_TEST("mach-virt-serial-compat",
++            QEMU_CAPS_NODEFCONFIG);
++    DO_TEST("mach-virt-serial-pci",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_OBJECT_GPEX,
++            QEMU_CAPS_PCI_MULTIFUNCTION,
++            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
++            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
++            QEMU_CAPS_DEVICE_PCI_BRIDGE,
++            QEMU_CAPS_DEVICE_PCI_SERIAL);
++    DO_TEST("mach-virt-serial-usb",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_OBJECT_GPEX,
++            QEMU_CAPS_PCI_MULTIFUNCTION,
++            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
++            QEMU_CAPS_DEVICE_QEMU_XHCI,
++            QEMU_CAPS_DEVICE_USB_SERIAL);
++    DO_TEST("mach-virt-console-native",
++            QEMU_CAPS_NODEFCONFIG);
++    DO_TEST("mach-virt-console-virtio",
++            QEMU_CAPS_NODEFCONFIG);
++    DO_TEST_PARSE_ERROR("mach-virt-serial-invalid-machine", NONE);
++
+     DO_TEST("disk-ide-drive-split",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_IDE_CD);
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
+index e5496424b3..9796d7f637 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
+@@ -71,7 +71,9 @@
+       <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='system-serial' port='0'>
++        <model name='pl011'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-native.xml
+new file mode 120000
+index 0000000000..a4768fcf86
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-native.xml
+@@ -0,0 +1 @@
++qemuxml2xmlout-mach-virt-serial-compat.xml
+\ No newline at end of file
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-virtio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-virtio.xml
+new file mode 100644
+index 0000000000..3e46cd2012
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-virtio.xml
+@@ -0,0 +1,27 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <currentMemory unit='KiB'>524288</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <features>
++    <gic version='2'/>
++  </features>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' index='0' model='none'/>
++    <controller type='virtio-serial' index='0'/>
++    <console type='pty'>
++      <target type='virtio' port='0'/>
++    </console>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial+console-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial+console-native.xml
+new file mode 120000
+index 0000000000..a4768fcf86
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial+console-native.xml
+@@ -0,0 +1 @@
++qemuxml2xmlout-mach-virt-serial-compat.xml
+\ No newline at end of file
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-compat.xml
+new file mode 100644
+index 0000000000..3d7325a8db
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-compat.xml
+@@ -0,0 +1,31 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <currentMemory unit='KiB'>524288</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <features>
++    <gic version='2'/>
++  </features>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' index='0' model='none'/>
++    <serial type='pty'>
++      <target type='system-serial' port='0'>
++        <model name='pl011'/>
++      </target>
++    </serial>
++    <console type='pty'>
++      <target type='serial' port='0'/>
++    </console>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-native.xml
+new file mode 120000
+index 0000000000..a4768fcf86
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-native.xml
+@@ -0,0 +1 @@
++qemuxml2xmlout-mach-virt-serial-compat.xml
+\ No newline at end of file
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-pci.xml
+new file mode 100644
+index 0000000000..4bcf69a3d1
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-pci.xml
+@@ -0,0 +1,44 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <currentMemory unit='KiB'>524288</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <features>
++    <gic version='2'/>
++  </features>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' index='0' model='none'/>
++    <controller type='pci' index='0' model='pcie-root'/>
++    <controller type='pci' index='1' model='dmi-to-pci-bridge'>
++      <model name='i82801b11-bridge'/>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
++    </controller>
++    <controller type='pci' index='2' model='pci-bridge'>
++      <model name='pci-bridge'/>
++      <target chassisNr='2'/>
++      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
++    </controller>
++    <controller type='pci' index='3' model='pcie-root-port'>
++      <model name='pcie-root-port'/>
++      <target chassis='3' port='0x10'/>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
++    </controller>
++    <serial type='pty'>
++      <target type='pci-serial' port='0'>
++        <model name='pci-serial'/>
++      </target>
++      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-usb.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-usb.xml
+new file mode 100644
+index 0000000000..01c2a52555
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-usb.xml
+@@ -0,0 +1,41 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <currentMemory unit='KiB'>524288</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='aarch64' machine='virt'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <features>
++    <gic version='2'/>
++  </features>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-aarch64</emulator>
++    <controller type='usb' index='0' model='qemu-xhci'>
++      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
++    </controller>
++    <controller type='pci' index='0' model='pcie-root'/>
++    <controller type='pci' index='1' model='pcie-root-port'>
++      <model name='pcie-root-port'/>
++      <target chassis='1' port='0x8'/>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
++    </controller>
++    <controller type='pci' index='2' model='pcie-root-port'>
++      <model name='pcie-root-port'/>
++      <target chassis='2' port='0x9'/>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
++    </controller>
++    <serial type='pty'>
++      <target type='usb-serial' port='0'>
++        <model name='usb-serial'/>
++      </target>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
+index f76bd5a68d..bd18507bb6 100644
+--- a/tests/qemuxml2xmltest.c
++++ b/tests/qemuxml2xmltest.c
+@@ -788,6 +788,32 @@ mymain(void)
+     DO_TEST("pseries-console-virtio",
+             QEMU_CAPS_NODEFCONFIG);
+ 
++    DO_TEST("mach-virt-serial-native",
++            QEMU_CAPS_NODEFCONFIG);
++    DO_TEST("mach-virt-serial+console-native",
++            QEMU_CAPS_NODEFCONFIG);
++    DO_TEST("mach-virt-serial-compat",
++            QEMU_CAPS_NODEFCONFIG);
++    DO_TEST("mach-virt-serial-pci",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_OBJECT_GPEX,
++            QEMU_CAPS_PCI_MULTIFUNCTION,
++            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
++            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
++            QEMU_CAPS_DEVICE_PCI_BRIDGE,
++            QEMU_CAPS_DEVICE_PCI_SERIAL);
++    DO_TEST("mach-virt-serial-usb",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_OBJECT_GPEX,
++            QEMU_CAPS_PCI_MULTIFUNCTION,
++            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
++            QEMU_CAPS_DEVICE_QEMU_XHCI,
++            QEMU_CAPS_DEVICE_USB_SERIAL);
++    DO_TEST("mach-virt-console-native",
++            QEMU_CAPS_NODEFCONFIG);
++    DO_TEST("mach-virt-console-virtio",
++            QEMU_CAPS_NODEFCONFIG);
++
+     DO_TEST("balloon-device-auto", NONE);
+     DO_TEST("balloon-device-period", NONE);
+     DO_TEST("channel-virtio-auto", NONE);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Add-target-type-and-model-for-spapr-vty.patch b/SOURCES/libvirt-conf-Add-target-type-and-model-for-spapr-vty.patch
new file mode 100644
index 0000000..610c5a2
--- /dev/null
+++ b/SOURCES/libvirt-conf-Add-target-type-and-model-for-spapr-vty.patch
@@ -0,0 +1,1042 @@
+From fd981b46a6729b5d5dac4923b860f888b0c193b9 Mon Sep 17 00:00:00 2001
+Message-Id: <fd981b46a6729b5d5dac4923b860f888b0c193b9@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:12 +0100
+Subject: [PATCH] conf: Add target type and model for spapr-vty
+
+We can finally introduce a specific target model for the spapr-vty
+device used by pSeries guests, which means isa-serial will no longer
+show up to confuse users.
+
+We make sure migration works in both directions by interpreting the
+isa-serial target type, or the lack of target type, appropriately
+when parsing the guest XML, and skipping the newly-introduced type
+when formatting if for migration. We also verify that spapr-vty is
+not used for non-pSeries guests and add a bunch of test cases.
+
+This commit is best viewed with 'git show -w'.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit c498a8921e447715189c8c6d22b7ca24cc810830)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/formatdomain.html.in                          | 13 ++--
+ docs/schemas/domaincommon.rng                      |  2 +
+ src/conf/domain_conf.c                             |  6 +-
+ src/conf/domain_conf.h                             |  2 +
+ src/qemu/qemu_command.c                            | 67 +++++++++------------
+ src/qemu/qemu_domain.c                             | 69 ++++++++++++++++++----
+ src/qemu/qemu_domain_address.c                     |  1 +
+ .../qemuxml2argv-pseries-basic.args                |  2 +-
+ .../qemuxml2argv-pseries-console-native.args       |  1 +
+ .../qemuxml2argv-pseries-console-native.xml        | 17 ++++++
+ .../qemuxml2argv-pseries-console-virtio.args       | 23 ++++++++
+ .../qemuxml2argv-pseries-console-virtio.xml        | 19 ++++++
+ .../qemuxml2argv-pseries-cpu-compat-power9.args    |  2 +-
+ .../qemuxml2argv-pseries-cpu-compat.args           |  2 +-
+ .../qemuxml2argv-pseries-cpu-exact.args            |  2 +-
+ .../qemuxml2argv-pseries-cpu-le.args               |  2 +-
+ .../qemuxml2argv-pseries-panic-missing.args        |  2 +-
+ .../qemuxml2argv-pseries-panic-no-address.args     |  2 +-
+ ...qemuxml2argv-pseries-serial+console-native.args |  1 +
+ .../qemuxml2argv-pseries-serial+console-native.xml | 18 ++++++
+ .../qemuxml2argv-pseries-serial-compat.args        |  1 +
+ .../qemuxml2argv-pseries-serial-compat.xml         | 19 ++++++
+ ...qemuxml2argv-pseries-serial-invalid-machine.xml | 19 ++++++
+ .../qemuxml2argv-pseries-serial-native.args        | 22 +++++++
+ .../qemuxml2argv-pseries-serial-native.xml         | 16 +++++
+ .../qemuxml2argv-pseries-usb-default.args          |  2 +-
+ .../qemuxml2argv-pseries-usb-kbd.args              |  2 +-
+ .../qemuxml2argv-pseries-usb-multi.args            |  2 +-
+ .../qemuxml2argv-pseries-vio-user-assigned.args    |  4 +-
+ .../qemuxml2argvdata/qemuxml2argv-pseries-vio.args |  4 +-
+ tests/qemuxml2argvtest.c                           | 16 +++++
+ .../qemuxml2xmlout-panic-pseries.xml               |  4 +-
+ .../qemuxml2xmlout-pseries-console-native.xml      |  1 +
+ .../qemuxml2xmlout-pseries-console-virtio.xml      | 31 ++++++++++
+ .../qemuxml2xmlout-pseries-cpu-compat-power9.xml   |  4 +-
+ .../qemuxml2xmlout-pseries-cpu-compat.xml          |  4 +-
+ .../qemuxml2xmlout-pseries-cpu-exact.xml           |  4 +-
+ .../qemuxml2xmlout-pseries-panic-missing.xml       |  4 +-
+ .../qemuxml2xmlout-pseries-panic-no-address.xml    |  4 +-
+ ...emuxml2xmlout-pseries-serial+console-native.xml |  1 +
+ .../qemuxml2xmlout-pseries-serial-compat.xml       |  1 +
+ .../qemuxml2xmlout-pseries-serial-native.xml       | 35 +++++++++++
+ tests/qemuxml2xmltest.c                            | 15 +++++
+ 43 files changed, 386 insertions(+), 82 deletions(-)
+ create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml
+ create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml
+ create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml
+ create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml
+ create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml
+ create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index cf1167b9c6..0634f3396a 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -6462,7 +6462,9 @@ qemu-kvm -net nic,model=? /dev/null
+       <span class="since">since 1.0.2</span>, <code>isa-serial</code> (usable
+       with x86 guests), <code>usb-serial</code> (usable whenever USB support
+       is available) and <code>pci-serial</code> (usable whenever PCI support
+-      is available).
++      is available); <span class="since">since 3.10.0</span>,
++      <code>spapr-vio-serial</code> (usable with ppc64/pseries guests)
++      is available as well.
+     </p>
+ 
+     <p>
+@@ -6472,7 +6474,9 @@ qemu-kvm -net nic,model=? /dev/null
+       <code>isa-serial</code> (usable with the <code>isa-serial</code> target
+       type); <code>usb-serial</code> (usable with the <code>usb-serial</code>
+       target type); <code>pci-serial</code>
+-      (usable with the <code>pci-serial</code> target type).
++      (usable with the <code>pci-serial</code> target type);
++      <code>spapr-vty</code> (usable with the <code>spapr-vio-serial</code>
++      target type).
+     </p>
+ 
+     <p>
+@@ -6484,8 +6488,9 @@ qemu-kvm -net nic,model=? /dev/null
+       All of the target types support configuring the guest-visible device
+       address as <a href="#elementsAddress">documented above</a>; more
+       specifically, acceptable address types are <code>isa</code> (for
+-      <code>isa-serial</code>), <code>usb</code> (for <code>usb-serial</code>)
+-      and <code>pci</code> (for <code>pci-serial</code>).
++      <code>isa-serial</code>), <code>usb</code> (for <code>usb-serial</code>),
++      <code>pci</code> (for <code>pci-serial</code>) and <code>spapr-vio</code>
++      (for <code>spapr-vio-serial</code>).
+     </p>
+ 
+     <p>
+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
+index 3630e539e6..027d9ae7a1 100644
+--- a/docs/schemas/domaincommon.rng
++++ b/docs/schemas/domaincommon.rng
+@@ -3571,6 +3571,7 @@
+         <value>isa-serial</value>
+         <value>usb-serial</value>
+         <value>pci-serial</value>
++        <value>spapr-vio-serial</value>
+       </choice>
+     </attribute>
+   </define>
+@@ -3582,6 +3583,7 @@
+           <value>isa-serial</value>
+           <value>usb-serial</value>
+           <value>pci-serial</value>
++          <value>spapr-vty</value>
+         </choice>
+       </attribute>
+     </element>
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 692b9d9414..97c7a66b5b 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -444,7 +444,9 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget,
+               "none",
+               "isa-serial",
+               "usb-serial",
+-              "pci-serial")
++              "pci-serial",
++              "spapr-vio-serial",
++);
+ 
+ VIR_ENUM_IMPL(virDomainChrChannelTarget,
+               VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,
+@@ -471,6 +473,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTargetModel,
+               "isa-serial",
+               "usb-serial",
+               "pci-serial",
++              "spapr-vty",
+ );
+ 
+ VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST,
+@@ -4059,6 +4062,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def)
+ 
+         switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) {
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: {
+ 
+             /* Create a stub console to match the serial port.
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 9dfe9388cd..979e8cca00 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -1077,6 +1077,7 @@ typedef enum {
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
+ 
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
+ } virDomainChrSerialTargetType;
+@@ -1109,6 +1110,7 @@ typedef enum {
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY,
+ 
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
+ } virDomainChrSerialTargetModel;
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index f8d5d317cd..91083dc73d 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9227,6 +9227,8 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel)
+         return QEMU_CAPS_DEVICE_USB_SERIAL;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
+         return QEMU_CAPS_DEVICE_PCI_SERIAL;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
++        return QEMU_CAPS_DEVICE_SPAPR_VTY;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+@@ -10354,52 +10356,39 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+     virBuffer cmd = VIR_BUFFER_INITIALIZER;
+     virQEMUCapsFlags caps;
+ 
+-    if (qemuDomainIsPSeries(def)) {
+-        if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+-            serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) {
+-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_VTY)) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("spapr-vty not supported in this QEMU binary"));
+-                goto error;
+-            }
++    switch ((virDomainChrSerialTargetModel) serial->targetModel) {
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
+ 
+-            virBufferAsprintf(&cmd, "spapr-vty,chardev=char%s",
+-                              serial->info.alias);
+-        }
+-    } else {
+-        switch ((virDomainChrSerialTargetModel) serial->targetModel) {
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
++        caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
+ 
+-            caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
+-
+-            if (caps && !virQEMUCapsGet(qemuCaps, caps)) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+-                               _("'%s' is not supported in this QEMU binary"),
+-                               virDomainChrSerialTargetModelTypeToString(serial->targetModel));
+-                goto error;
+-            }
+-            break;
+-
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+-            break;
+-
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+-            /* Except from _LAST, which is just a guard value and will never
+-             * be used, all of the above are platform devices, which means
+-             * qemuBuildSerialCommandLine() will have taken the appropriate
+-             * branch and we will not have ended up here. */
+-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+-                           _("Invalid target model for serial device"));
++        if (caps && !virQEMUCapsGet(qemuCaps, caps)) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                           _("'%s' is not supported in this QEMU binary"),
++                           virDomainChrSerialTargetModelTypeToString(serial->targetModel));
+             goto error;
+         }
++        break;
+ 
+-        virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s",
+-                          virDomainChrSerialTargetModelTypeToString(serial->targetModel),
+-                          serial->info.alias, serial->info.alias);
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
++        break;
++
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
++        /* Except from _LAST, which is just a guard value and will never
++         * be used, all of the above are platform devices, which means
++         * qemuBuildSerialCommandLine() will have taken the appropriate
++         * branch and we will not have ended up here. */
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("Invalid target model for serial device"));
++        goto error;
+     }
+ 
++    virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s",
++                      virDomainChrSerialTargetModelTypeToString(serial->targetModel),
++                      serial->info.alias, serial->info.alias);
++
+     if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0)
+         goto error;
+ 
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 7b5bc97de6..17c898896d 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3466,6 +3466,8 @@ qemuDomainChrSerialTargetTypeToAddressType(int targetType)
+         return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
+         return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
++        return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         break;
+@@ -3485,6 +3487,8 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel)
+         return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
+         return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
++        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+         break;
+@@ -3495,8 +3499,7 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel)
+ 
+ 
+ static int
+-qemuDomainChrTargetDefValidate(const virDomainDef *def,
+-                               const virDomainChrDef *chr)
++qemuDomainChrTargetDefValidate(const virDomainChrDef *chr)
+ {
+     int expected;
+ 
+@@ -3508,11 +3511,7 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def,
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
+-
+-            /* Hack required until we have a proper type for pSeries
+-             * serial consoles */
+-            if (qemuDomainIsPSeries(def))
+-                return 0;
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
+ 
+             expected = qemuDomainChrSerialTargetTypeToAddressType(chr->targetType);
+ 
+@@ -3536,6 +3535,7 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def,
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
+ 
+             expected = qemuDomainChrSerialTargetModelToTargetType(chr->targetModel);
+ 
+@@ -3573,7 +3573,7 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev,
+     if (qemuDomainChrSourceDefValidate(dev->source) < 0)
+         return -1;
+ 
+-    if (qemuDomainChrTargetDefValidate(def, dev) < 0)
++    if (qemuDomainChrTargetDefValidate(dev) < 0)
+         return -1;
+ 
+     if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL &&
+@@ -3583,6 +3583,26 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev,
+             return -1;
+     }
+ 
++    if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
++        bool isCompatible = true;
++
++        if (!qemuDomainIsPSeries(def) &&
++            (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO ||
++             dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY)) {
++            isCompatible = false;
++        }
++
++        if (!isCompatible) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                           _("Serial device with target type '%s' and "
++                             "target model '%s' not compatible with guest "
++                             "architecture or machine type"),
++                           virDomainChrSerialTargetTypeToString(dev->targetType),
++                           virDomainChrSerialTargetModelTypeToString(dev->targetModel));
++            return -1;
++        }
++    }
++
+     return 0;
+ }
+ 
+@@ -4222,10 +4242,7 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
+         if (ARCH_IS_X86(def->os.arch)) {
+             chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
+         } else if (qemuDomainIsPSeries(def)) {
+-            /* Setting TYPE_ISA here is just a temporary hack to reduce test
+-             * suite churn. Later on we will have a proper serial type for
+-             * pSeries and this line will be updated accordingly. */
+-            chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
++            chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO;
+         }
+     }
+ 
+@@ -4242,6 +4259,9 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
+             chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL;
+             break;
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
++            chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY;
++            break;
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+             /* Nothing to do */
+@@ -5147,6 +5167,31 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
+                 goto cleanup;
+         }
+ 
++        for (i = 0; i < def->nserials; i++) {
++            virDomainChrDefPtr serial = def->serials[i];
++
++            /* Historically, the native console type for some machine types
++             * was not set at all, which means it defaulted to ISA even
++             * though that was not even remotely accurate. To ensure migration
++             * towards older libvirt versions works for such guests, we switch
++             * it back to the default here */
++            if (flags & VIR_DOMAIN_XML_MIGRATABLE) {
++                switch ((virDomainChrSerialTargetType) serial->targetType) {
++                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
++                    serial->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
++                    serial->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE;
++                    break;
++                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
++                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
++                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
++                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
++                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
++                    /* Nothing to do */
++                    break;
++                }
++            }
++        }
++
+         /* Replace the CPU definition updated according to QEMU with the one
+          * used for starting the domain. The updated def will be sent
+          * separately for backward compatibility.
+diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
+index 989c0e6c93..2319e503eb 100644
+--- a/src/qemu/qemu_domain_address.c
++++ b/src/qemu/qemu_domain_address.c
+@@ -782,6 +782,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
+ 
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+             return 0;
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args
+index 97a7057ba0..789d9f679e 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args
+@@ -20,4 +20,4 @@ server,nowait \
+ -boot c \
+ -usb \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args
+new file mode 120000
+index 0000000000..d6c830ecdf
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args
+@@ -0,0 +1 @@
++qemuxml2argv-pseries-serial-native.args
+\ No newline at end of file
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml
+new file mode 100644
+index 0000000000..9f37bf0dec
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml
+@@ -0,0 +1,17 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- The <console> element being present should result in a matching
++         <serial> element being created -->
++    <console type='pty'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args
+new file mode 100644
+index 0000000000..343018fb3e
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args
+@@ -0,0 +1,23 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-ppc64 \
++-name guest \
++-S \
++-M pseries \
++-m 512 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-boot c \
++-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x1 \
++-chardev pty,id=charconsole0 \
++-device virtconsole,chardev=charconsole0,id=console0
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml
+new file mode 100644
+index 0000000000..0190ab63ac
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml
+@@ -0,0 +1,19 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- The <console> element being present should *not* result in a
++         matching <serial> element being created -->
++    <console type='pty'>
++      <target type='virtio'/>
++    </console>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
+index af93d63dc9..9bb375aeba 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
+@@ -21,4 +21,4 @@ server,nowait \
+ -boot c \
+ -usb \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
+index 7740e2f5a9..5174aa760e 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
+@@ -21,4 +21,4 @@ server,nowait \
+ -boot c \
+ -usb \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args
+index d2c99a7fa3..3790deca8c 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args
+@@ -21,4 +21,4 @@ server,nowait \
+ -boot c \
+ -usb \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args
+index 97a7057ba0..789d9f679e 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args
+@@ -20,4 +20,4 @@ server,nowait \
+ -boot c \
+ -usb \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
+index 97a7057ba0..789d9f679e 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
+@@ -20,4 +20,4 @@ server,nowait \
+ -boot c \
+ -usb \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args
+index 97a7057ba0..789d9f679e 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args
+@@ -20,4 +20,4 @@ server,nowait \
+ -boot c \
+ -usb \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args
+new file mode 120000
+index 0000000000..d6c830ecdf
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args
+@@ -0,0 +1 @@
++qemuxml2argv-pseries-serial-native.args
+\ No newline at end of file
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml
+new file mode 100644
+index 0000000000..2733baa980
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml
+@@ -0,0 +1,18 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- When both the <serial> and <console> elements are present, they will
++         be matched and end up representing the same native serial console -->
++    <serial type='pty'/>
++    <console type='pty'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args
+new file mode 120000
+index 0000000000..d6c830ecdf
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args
+@@ -0,0 +1 @@
++qemuxml2argv-pseries-serial-native.args
+\ No newline at end of file
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml
+new file mode 100644
+index 0000000000..2e182edbd0
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml
+@@ -0,0 +1,19 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- isa-serial has to be accepted for backwards compatibility reasons,
++         but should get converted to the proper type (spapr-vty-serial) -->
++    <serial type='pty'>
++      <target type='isa-serial'/>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml
+new file mode 100644
+index 0000000000..5482146a57
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml
+@@ -0,0 +1,19 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='x86_64' machine='pc'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-x86_64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- The spapr-vio-serial target type can only be used for pSeries
++         guests, so this should be rejected -->
++    <serial type='pty'>
++      <target type='spapr-vio-serial'/>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args
+new file mode 100644
+index 0000000000..f72b8b6259
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args
+@@ -0,0 +1,22 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-ppc64 \
++-name guest \
++-S \
++-M pseries \
++-m 512 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-boot c \
++-chardev pty,id=charserial0 \
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml
+new file mode 100644
+index 0000000000..6cec4bc9d3
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml
+@@ -0,0 +1,16 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- This will use the spapr-vty-serial target type -->
++    <serial type='pty'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
+index a92b1e01b1..37c0594032 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
+@@ -20,4 +20,4 @@ server,nowait \
+ -boot c \
+ -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
+index caaccdbb8e..838b80453a 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
+@@ -20,5 +20,5 @@ server,nowait \
+ -boot c \
+ -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000 \
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \
+ -device usb-kbd,id=input0,bus=usb.0,port=1
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
+index b9bd905a5d..56bc1d67ef 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
+@@ -21,4 +21,4 @@ server,nowait \
+ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1 \
+ -device pci-ohci,id=usb1,bus=pci.0,addr=0x2 \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args
+index 63cf3c1830..0fcfbe3796 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args
+@@ -25,6 +25,6 @@ server,nowait \
+ -device scsi-disk,bus=scsi1.0,channel=0,scsi-id=0,lun=0,\
+ drive=drive-scsi1-0-0-0,id=scsi1-0-0-0 \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x20000000 \
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x20000000 \
+ -chardev pty,id=charserial1 \
+--device spapr-vty,chardev=charserial1,reg=0x30001000
++-device spapr-vty,chardev=charserial1,id=serial1,reg=0x30001000
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args
+index 0294067bc8..8a9bdcc4cd 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args
+@@ -25,6 +25,6 @@ server,nowait \
+ -device scsi-disk,bus=scsi1.0,channel=0,scsi-id=0,lun=0,\
+ drive=drive-scsi1-0-0-0,id=scsi1-0-0-0 \
+ -chardev pty,id=charserial0 \
+--device spapr-vty,chardev=charserial0,reg=0x30000000 \
++-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \
+ -chardev pty,id=charserial1 \
+--device spapr-vty,chardev=charserial1,reg=0x30001000
++-device spapr-vty,chardev=charserial1,id=serial1,reg=0x30001000
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 747ad24663..4b63dd141d 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -1875,6 +1875,22 @@ mymain(void)
+                         QEMU_CAPS_MACHINE_OPT,
+                         QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
+ 
++    DO_TEST("pseries-serial-native",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_SPAPR_VTY);
++    DO_TEST("pseries-serial+console-native",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_SPAPR_VTY);
++    DO_TEST("pseries-serial-compat",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_SPAPR_VTY);
++    DO_TEST("pseries-console-native",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_SPAPR_VTY);
++    DO_TEST("pseries-console-virtio",
++            QEMU_CAPS_NODEFCONFIG);
++    DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);
++
+     DO_TEST("disk-ide-drive-split",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_IDE_CD);
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
+index 496df0696c..484fe4cfa6 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
+@@ -22,8 +22,8 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'>
+-        <model name='isa-serial'/>
++      <target type='spapr-vio-serial' port='0'>
++        <model name='spapr-vty'/>
+       </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml
+new file mode 120000
+index 0000000000..b0e645fc03
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml
+@@ -0,0 +1 @@
++qemuxml2xmlout-pseries-serial-native.xml
+\ No newline at end of file
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml
+new file mode 100644
+index 0000000000..48760f2824
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml
+@@ -0,0 +1,31 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <currentMemory unit='KiB'>524288</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' index='0' model='none'/>
++    <controller type='pci' index='0' model='pci-root'>
++      <model name='spapr-pci-host-bridge'/>
++      <target index='0'/>
++    </controller>
++    <controller type='virtio-serial' index='0'>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
++    </controller>
++    <console type='pty'>
++      <target type='virtio' port='0'/>
++    </console>
++    <memballoon model='none'/>
++    <panic model='pseries'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
+index 9d4c5efe67..404bb0c768 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
+@@ -25,8 +25,8 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'>
+-        <model name='isa-serial'/>
++      <target type='spapr-vio-serial' port='0'>
++        <model name='spapr-vty'/>
+       </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
+index 6059859abd..1891fa5f48 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
+@@ -25,8 +25,8 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'>
+-        <model name='isa-serial'/>
++      <target type='spapr-vio-serial' port='0'>
++        <model name='spapr-vty'/>
+       </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
+index f3216523ed..f08f3e005f 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
+@@ -26,8 +26,8 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'>
+-        <model name='isa-serial'/>
++      <target type='spapr-vio-serial' port='0'>
++        <model name='spapr-vty'/>
+       </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
+index 496df0696c..484fe4cfa6 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
+@@ -22,8 +22,8 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'>
+-        <model name='isa-serial'/>
++      <target type='spapr-vio-serial' port='0'>
++        <model name='spapr-vty'/>
+       </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
+index 496df0696c..484fe4cfa6 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
+@@ -22,8 +22,8 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'>
+-        <model name='isa-serial'/>
++      <target type='spapr-vio-serial' port='0'>
++        <model name='spapr-vty'/>
+       </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml
+new file mode 120000
+index 0000000000..b0e645fc03
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml
+@@ -0,0 +1 @@
++qemuxml2xmlout-pseries-serial-native.xml
+\ No newline at end of file
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml
+new file mode 120000
+index 0000000000..b0e645fc03
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml
+@@ -0,0 +1 @@
++qemuxml2xmlout-pseries-serial-native.xml
+\ No newline at end of file
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml
+new file mode 100644
+index 0000000000..fae7c54d5b
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml
+@@ -0,0 +1,35 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <currentMemory unit='KiB'>524288</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' index='0' model='none'/>
++    <controller type='pci' index='0' model='pci-root'>
++      <model name='spapr-pci-host-bridge'/>
++      <target index='0'/>
++    </controller>
++    <serial type='pty'>
++      <target type='spapr-vio-serial' port='0'>
++        <model name='spapr-vty'/>
++      </target>
++      <address type='spapr-vio' reg='0x30000000'/>
++    </serial>
++    <console type='pty'>
++      <target type='serial' port='0'/>
++      <address type='spapr-vio' reg='0x30000000'/>
++    </console>
++    <memballoon model='none'/>
++    <panic model='pseries'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
+index 6687997900..ad429ead4d 100644
+--- a/tests/qemuxml2xmltest.c
++++ b/tests/qemuxml2xmltest.c
+@@ -766,6 +766,21 @@ mymain(void)
+             QEMU_CAPS_MACHINE_OPT,
+             QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
+ 
++    DO_TEST("pseries-serial-native",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_SPAPR_VTY);
++    DO_TEST("pseries-serial+console-native",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_SPAPR_VTY);
++    DO_TEST("pseries-serial-compat",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_SPAPR_VTY);
++    DO_TEST("pseries-console-native",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_SPAPR_VTY);
++    DO_TEST("pseries-console-virtio",
++            QEMU_CAPS_NODEFCONFIG);
++
+     DO_TEST("balloon-device-auto", NONE);
+     DO_TEST("balloon-device-period", NONE);
+     DO_TEST("channel-virtio-auto", NONE);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Check-CPU-cache-for-ABI-stability.patch b/SOURCES/libvirt-conf-Check-CPU-cache-for-ABI-stability.patch
deleted file mode 100644
index 13fcb60..0000000
--- a/SOURCES/libvirt-conf-Check-CPU-cache-for-ABI-stability.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From b768a8cb9fbd84a96f576d1dd7468f664200683f Mon Sep 17 00:00:00 2001
-Message-Id: <b768a8cb9fbd84a96f576d1dd7468f664200683f@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 10 May 2017 13:05:16 +0200
-Subject: [PATCH] conf: Check CPU cache for ABI stability
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
-(cherry picked from commit 1e9cf6e09ce242c94731bd21707dd3bcd41f854f)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1449595
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/cpu_conf.c | 10 ++++++++++
- 1 file changed, 10 insertions(+)
-
-diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
-index 1b098c476..a4be5742e 100644
---- a/src/conf/cpu_conf.c
-+++ b/src/conf/cpu_conf.c
-@@ -915,6 +915,16 @@ virCPUDefIsEqual(virCPUDefPtr src,
-         }
-     }
- 
-+    if ((src->cache && !dst->cache) ||
-+        (!src->cache && dst->cache) ||
-+        (src->cache && dst->cache &&
-+         (src->cache->level != dst->cache->level ||
-+          src->cache->mode != dst->cache->mode))) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                       _("Target CPU cache does not match source"));
-+        goto cleanup;
-+    }
-+
-     identical = true;
- 
-  cleanup:
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-conf-Check-virDomainChrSourceDefFormat-return-value.patch b/SOURCES/libvirt-conf-Check-virDomainChrSourceDefFormat-return-value.patch
new file mode 100644
index 0000000..0193671
--- /dev/null
+++ b/SOURCES/libvirt-conf-Check-virDomainChrSourceDefFormat-return-value.patch
@@ -0,0 +1,123 @@
+From 73650fdd9de90d6f5a6f4a3c6c19d60368411b07 Mon Sep 17 00:00:00 2001
+Message-Id: <73650fdd9de90d6f5a6f4a3c6c19d60368411b07@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:02 +0100
+Subject: [PATCH] conf: Check virDomainChrSourceDefFormat() return value
+
+The function can fail, but none of the caller were accounting
+for that.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 2cd323e382b4abfffda52fe49d1b50a087716e01)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c | 34 ++++++++++++++++++++++++----------
+ 1 file changed, 24 insertions(+), 10 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index cf1bd030a0..346edaa6bd 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -24045,7 +24045,9 @@ virDomainChrDefFormat(virBufferPtr buf,
+     if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0)
+         return -1;
+     virBufferAddLit(buf, ">\n");
+-    virDomainChrSourceDefFormat(buf, def->source, flags);
++
++    if (virDomainChrSourceDefFormat(buf, def->source, flags) < 0)
++        return -1;
+ 
+     if (virDomainChrTargetDefFormat(buf, def, flags) < 0)
+         return -1;
+@@ -24066,13 +24068,14 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
+     const char *mode = virDomainSmartcardTypeToString(def->type);
+     virBuffer childBuf = VIR_BUFFER_INITIALIZER;
+     size_t i;
++    int ret = -1;
+ 
+     virBufferSetChildIndent(&childBuf, buf);
+ 
+     if (!mode) {
+         virReportError(VIR_ERR_INTERNAL_ERROR,
+                        _("unexpected smartcard type %d"), def->type);
+-        return -1;
++        goto cleanup;
+     }
+ 
+     switch (def->type) {
+@@ -24089,23 +24092,25 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
+         break;
+ 
+     case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
+-        virDomainChrSourceDefFormat(&childBuf, def->data.passthru, flags);
++        if (virDomainChrSourceDefFormat(&childBuf, def->data.passthru, flags) < 0)
++            goto cleanup;
+         break;
+ 
+     default:
+         virReportError(VIR_ERR_INTERNAL_ERROR,
+                        _("unexpected smartcard type %d"), def->type);
+-        return -1;
++        goto cleanup;
+     }
+     virDomainDeviceInfoFormat(&childBuf, &def->info, flags);
+ 
+     if (virBufferCheckError(&childBuf) < 0)
+-        return -1;
++        goto cleanup;
+ 
+     virBufferAsprintf(buf, "<smartcard mode='%s'", mode);
+     if (def->type == VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH &&
+-        virDomainChrAttrsDefFormat(buf, def->data.passthru, false) < 0)
+-        return -1;
++        virDomainChrAttrsDefFormat(buf, def->data.passthru, false) < 0) {
++        goto cleanup;
++    }
+ 
+     if (virBufferUse(&childBuf)) {
+         virBufferAddLit(buf, ">\n");
+@@ -24114,7 +24119,12 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
+     } else {
+         virBufferAddLit(buf, "/>\n");
+     }
+-    return 0;
++
++    ret = 0;
++
++ cleanup:
++    virBufferFreeAndReset(&childBuf);
++    return ret;
+ }
+ 
+ static int
+@@ -24416,7 +24426,8 @@ virDomainRNGDefFormat(virBufferPtr buf,
+             return -1;
+         virBufferAddLit(buf, ">\n");
+         virBufferAdjustIndent(buf, 2);
+-        virDomainChrSourceDefFormat(buf, def->source.chardev, flags);
++        if (virDomainChrSourceDefFormat(buf, def->source.chardev, flags) < 0)
++            return -1;
+         virBufferAdjustIndent(buf, -2);
+         virBufferAddLit(buf, "</backend>\n");
+ 
+@@ -25261,7 +25272,10 @@ virDomainRedirdevDefFormat(virBufferPtr buf,
+         return -1;
+     virBufferAddLit(buf, ">\n");
+     virBufferAdjustIndent(buf, 2);
+-    virDomainChrSourceDefFormat(buf, def->source, flags);
++
++    if (virDomainChrSourceDefFormat(buf, def->source, flags) < 0)
++        return -1;
++
+     virDomainDeviceInfoFormat(buf, &def->info,
+                               flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT);
+     virBufferAdjustIndent(buf, -2);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Don-t-assign-value-from-.TypeFromString-directly-to-enum.patch b/SOURCES/libvirt-conf-Don-t-assign-value-from-.TypeFromString-directly-to-enum.patch
deleted file mode 100644
index 6d2a136..0000000
--- a/SOURCES/libvirt-conf-Don-t-assign-value-from-.TypeFromString-directly-to-enum.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From 8c00ca78eed4ffdb9238b89b58eb5975baf5e339 Mon Sep 17 00:00:00 2001
-Message-Id: <8c00ca78eed4ffdb9238b89b58eb5975baf5e339@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Fri, 19 May 2017 12:24:11 +0200
-Subject: [PATCH] conf: Don't assign value from ..TypeFromString directly to
- enum
-
-Enums are unsigned, so it's impossible to check whether the helper
-returned -1 for invalid conversions.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1452454
-(cherry picked from commit 85d62624c5d02c38e00a275dc2b2957584454908)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 15 +++++++++------
- 1 file changed, 9 insertions(+), 6 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 1653aa61d..a918ecd59 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -14065,6 +14065,7 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
-     xmlNodePtr save = ctxt->node;
-     xmlNodePtr node;
-     virDomainMemoryDefPtr def;
-+    int val;
- 
-     ctxt->node = memdevNode;
- 
-@@ -14084,12 +14085,14 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
-     }
-     VIR_FREE(tmp);
- 
--    tmp = virXMLPropString(memdevNode, "access");
--    if (tmp &&
--        (def->access = virDomainMemoryAccessTypeFromString(tmp)) <= 0) {
--        virReportError(VIR_ERR_XML_ERROR,
--                       _("invalid access mode '%s'"), tmp);
--        goto error;
-+    if ((tmp = virXMLPropString(memdevNode, "access"))) {
-+        if ((val = virDomainMemoryAccessTypeFromString(tmp)) <= 0) {
-+            virReportError(VIR_ERR_XML_ERROR,
-+                           _("invalid access mode '%s'"), tmp);
-+            goto error;
-+        }
-+
-+        def->access = val;
-     }
-     VIR_FREE(tmp);
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-conf-Don-t-inline-virDomainNetTypeSharesHostView.patch b/SOURCES/libvirt-conf-Don-t-inline-virDomainNetTypeSharesHostView.patch
new file mode 100644
index 0000000..76a771b
--- /dev/null
+++ b/SOURCES/libvirt-conf-Don-t-inline-virDomainNetTypeSharesHostView.patch
@@ -0,0 +1,136 @@
+From 0597400171b44e0d180196b2c04da72f8b1f225f Mon Sep 17 00:00:00 2001
+Message-Id: <0597400171b44e0d180196b2c04da72f8b1f225f@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Thu, 2 Nov 2017 19:58:00 +0100
+Subject: [PATCH] conf: Don't inline virDomainNetTypeSharesHostView
+
+When coverage build is enabled, gcc complains about it:
+
+In file included from qemu/qemu_agent.h:29:0,
+                 from qemu/qemu_driver.c:47:
+qemu/qemu_driver.c: In function 'qemuDomainSetInterfaceParameters':
+./conf/domain_conf.h:3397:1: error: inlining failed in call to
+'virDomainNetTypeSharesHostView': call is unlikely and code size would
+grow [-Werror=inline]
+ virDomainNetTypeSharesHostView(const virDomainNetDef *net)
+ ^
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+(cherry picked from commit bce925dadaf8fe4693abee88fb68aa7ede9d209e)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1472263
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c   | 36 ++++++++++++++++++++++++++++++++++++
+ src/conf/domain_conf.h   | 37 +++----------------------------------
+ src/libvirt_private.syms |  1 +
+ 3 files changed, 40 insertions(+), 34 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 77c20c6972..394afb0d80 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -28082,3 +28082,39 @@ virDomainGenerateMachineName(const char *drivername,
+     virBufferCheckError(&buf);
+     return virBufferContentAndReset(&buf);
+ }
++
++
++/**
++ * virDomainNetTypeSharesHostView:
++ * @net: interface
++ *
++ * Some types of interfaces "share" the host view. For instance,
++ * for macvtap interface, every domain RX is the host RX too. And
++ * every domain TX is host TX too. IOW, for some types of
++ * interfaces guest and host are on the same side of RX/TX
++ * barrier. This is important so that we set up QoS correctly and
++ * report proper stats.
++ */
++bool
++virDomainNetTypeSharesHostView(const virDomainNetDef *net)
++{
++    virDomainNetType actualType = virDomainNetGetActualType(net);
++    switch (actualType) {
++    case VIR_DOMAIN_NET_TYPE_DIRECT:
++    case VIR_DOMAIN_NET_TYPE_ETHERNET:
++        return true;
++    case VIR_DOMAIN_NET_TYPE_USER:
++    case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
++    case VIR_DOMAIN_NET_TYPE_SERVER:
++    case VIR_DOMAIN_NET_TYPE_CLIENT:
++    case VIR_DOMAIN_NET_TYPE_MCAST:
++    case VIR_DOMAIN_NET_TYPE_NETWORK:
++    case VIR_DOMAIN_NET_TYPE_BRIDGE:
++    case VIR_DOMAIN_NET_TYPE_INTERNAL:
++    case VIR_DOMAIN_NET_TYPE_HOSTDEV:
++    case VIR_DOMAIN_NET_TYPE_UDP:
++    case VIR_DOMAIN_NET_TYPE_LAST:
++        break;
++    }
++    return false;
++}
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 38de70b154..171f340785 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -3382,40 +3382,9 @@ virDomainGenerateMachineName(const char *drivername,
+                              int id,
+                              const char *name,
+                              bool privileged);
+-/**
+- * virDomainNetTypeSharesHostView:
+- * @net: interface
+- *
+- * Some types of interfaces "share" the host view. For instance,
+- * for macvtap interface, every domain RX is the host RX too. And
+- * every domain TX is host TX too. IOW, for some types of
+- * interfaces guest and host are on the same side of RX/TX
+- * barrier. This is important so that we set up QoS correctly and
+- * report proper stats.
+- */
+-static inline bool
+-virDomainNetTypeSharesHostView(const virDomainNetDef *net)
+-{
+-    virDomainNetType actualType = virDomainNetGetActualType(net);
+-    switch (actualType) {
+-    case VIR_DOMAIN_NET_TYPE_DIRECT:
+-    case VIR_DOMAIN_NET_TYPE_ETHERNET:
+-        return true;
+-    case VIR_DOMAIN_NET_TYPE_USER:
+-    case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+-    case VIR_DOMAIN_NET_TYPE_SERVER:
+-    case VIR_DOMAIN_NET_TYPE_CLIENT:
+-    case VIR_DOMAIN_NET_TYPE_MCAST:
+-    case VIR_DOMAIN_NET_TYPE_NETWORK:
+-    case VIR_DOMAIN_NET_TYPE_BRIDGE:
+-    case VIR_DOMAIN_NET_TYPE_INTERNAL:
+-    case VIR_DOMAIN_NET_TYPE_HOSTDEV:
+-    case VIR_DOMAIN_NET_TYPE_UDP:
+-    case VIR_DOMAIN_NET_TYPE_LAST:
+-        break;
+-    }
+-    return false;
+-}
++
++bool
++virDomainNetTypeSharesHostView(const virDomainNetDef *net);
+ 
+ bool
+ virDomainDefLifecycleActionAllowed(virDomainLifecycle type,
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 448d962b2d..811d9053e6 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -444,6 +444,7 @@ virDomainNetInsert;
+ virDomainNetRemove;
+ virDomainNetRemoveHostdev;
+ virDomainNetTypeFromString;
++virDomainNetTypeSharesHostView;
+ virDomainNetTypeToString;
+ virDomainNostateReasonTypeFromString;
+ virDomainNostateReasonTypeToString;
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-conf-Drop-virDomainChrDeviceType.targetTypeAttr.patch b/SOURCES/libvirt-conf-Drop-virDomainChrDeviceType.targetTypeAttr.patch
new file mode 100644
index 0000000..ecce040
--- /dev/null
+++ b/SOURCES/libvirt-conf-Drop-virDomainChrDeviceType.targetTypeAttr.patch
@@ -0,0 +1,737 @@
+From 77bc396146f85ba8f767fd51f0238037cb9784cc Mon Sep 17 00:00:00 2001
+Message-Id: <77bc396146f85ba8f767fd51f0238037cb9784cc@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:22:59 +0100
+Subject: [PATCH] conf: Drop virDomainChrDeviceType.targetTypeAttr
+
+This attribute was used to decide whether to format the type
+attribute of the <target> element, but the logic didn't take into
+account all possible cases and as such could lead to unexpected
+results. Moreover, it's one more thing to keep track of, and can
+easily fall out of sync with other attributes.
+
+Now that we have VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE, we can
+use that value to signal that no specific target type has been
+configured for the serial device and as such the attribute should
+not be formatted at all. All other values are now formatted.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 4fb8ff9987b7e34d331c4af8f573db11579a0e88)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c                                        | 11 ++++-------
+ src/conf/domain_conf.h                                        |  1 -
+ src/vz/vz_sdk.c                                               |  3 +--
+ tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml        |  2 +-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml            |  2 +-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml           |  2 +-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml           |  4 ++--
+ tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml            |  2 +-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml     |  2 +-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml            |  2 +-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml            |  4 ++--
+ tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml           |  2 +-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml             |  2 +-
+ .../qemuhotplug-console-compat-2-live+console-virtio.xml      |  4 ++--
+ .../qemuhotplug-console-compat-2-live.xml                     |  4 ++--
+ .../qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml         |  4 ++--
+ tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml          |  4 ++--
+ .../qemuxml2xmlout-bios-nvram-os-interleave.xml               |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml     |  4 ++--
+ .../qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml    |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml   |  2 +-
+ .../qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml  |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml  |  4 ++--
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml     |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml    |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml      |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml           |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml     |  2 +-
+ .../qemuxml2xmlout-pseries-cpu-compat-power9.xml              |  2 +-
+ .../qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml  |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml |  2 +-
+ .../qemuxml2xmlout-pseries-panic-missing.xml                  |  2 +-
+ .../qemuxml2xmlout-pseries-panic-no-address.xml               |  2 +-
+ .../qemuxml2xmlout-q35-virt-manager-basic.xml                 |  2 +-
+ .../qemuxml2xmlout-serial-spiceport-nospice.xml               |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml  |  2 +-
+ .../qemuxml2xmlout-serial-target-port-auto.xml                |  6 +++---
+ .../qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml             |  4 ++--
+ .../qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml         |  2 +-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml      |  2 +-
+ 43 files changed, 56 insertions(+), 61 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 3a5ecd3a9d..586a840672 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -11499,8 +11499,7 @@ virDomainChrDefaultTargetType(int devtype)
+ }
+ 
+ static int
+-virDomainChrTargetTypeFromString(virDomainChrDefPtr def,
+-                                 int devtype,
++virDomainChrTargetTypeFromString(int devtype,
+                                  const char *targetType)
+ {
+     int ret = -1;
+@@ -11528,8 +11527,6 @@ virDomainChrTargetTypeFromString(virDomainChrDefPtr def,
+         break;
+     }
+ 
+-    def->targetTypeAttr = true;
+-
+     return ret;
+ }
+ 
+@@ -11546,7 +11543,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
+     char *stateStr = NULL;
+ 
+     if ((def->targetType =
+-         virDomainChrTargetTypeFromString(def, def->deviceType,
++         virDomainChrTargetTypeFromString(def->deviceType,
+                                           targetType)) < 0) {
+         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                        _("unknown target type '%s' specified for character device"),
+@@ -16466,7 +16463,7 @@ virDomainChrEquals(virDomainChrDefPtr src,
+         break;
+ 
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
+-        if (src->targetTypeAttr != tgt->targetTypeAttr)
++        if (src->targetType != tgt->targetType)
+             return false;
+ 
+         ATTRIBUTE_FALLTHROUGH;
+@@ -24026,7 +24023,7 @@ virDomainChrDefFormat(virBufferPtr buf,
+         break;
+ 
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
+-        if (def->targetTypeAttr) {
++        if (def->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) {
+             virBufferAsprintf(buf,
+                               "<target type='%s' port='%d'/>\n",
+                               virDomainChrTargetTypeToString(def->deviceType,
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 9502573b34..bbb056cf21 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -1199,7 +1199,6 @@ struct _virDomainChrSourceDef {
+ struct _virDomainChrDef {
+     int deviceType; /* enum virDomainChrDeviceType */
+ 
+-    bool targetTypeAttr;
+     int targetType; /* enum virDomainChrConsoleTargetType ||
+                        enum virDomainChrChannelTargetType ||
+                        enum virDomainChrSerialTargetType according to deviceType */
+diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
+index 3910deeb3a..c8de1b9598 100644
+--- a/src/vz/vz_sdk.c
++++ b/src/vz/vz_sdk.c
+@@ -1191,7 +1191,6 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDefPtr chr)
+     int ret = -1;
+ 
+     chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+-    chr->targetTypeAttr = false;
+     pret = PrlVmDev_GetIndex(serialPort, &serialPortIndex);
+     prlsdkCheckRetGoto(pret, cleanup);
+     chr->target.port = serialPortIndex;
+@@ -2864,7 +2863,7 @@ static int prlsdkCheckSerialUnsupportedParams(virDomainChrDefPtr chr)
+         return -1;
+     }
+ 
+-    if (chr->targetTypeAttr) {
++    if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) {
+         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                        _("Specified character device target type is not "
+                          "supported by vz driver."));
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml b/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml
+index f512844427..7c106f145c 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml
+@@ -28,7 +28,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+     </controller>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml
+index aac814d59f..e76d0211dc 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml
+@@ -29,7 +29,7 @@
+     </controller>
+     <serial type='dev'>
+       <source path='/dev/ttyS2'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='dev'>
+       <source path='/dev/ttyS2'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml
+index 64819a48ae..ed67ada0d8 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml
+@@ -29,7 +29,7 @@
+     </controller>
+     <serial type='file'>
+       <source path='/tmp/serial.log'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='file'>
+       <source path='/tmp/serial.log'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml
+index e00afe317f..420771dc9c 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml
+@@ -28,11 +28,11 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+     </controller>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <serial type='file'>
+       <source path='/tmp/serial.log'/>
+-      <target port='1'/>
++      <target type='isa-serial' port='1'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml
+index f512844427..7c106f145c 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml
+@@ -28,7 +28,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+     </controller>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml
+index c35a4ca73a..3fe61ffa05 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml
+@@ -30,7 +30,7 @@
+     <serial type='tcp'>
+       <source mode='bind' host='127.0.0.1' service='9999'/>
+       <protocol type='telnet'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='tcp'>
+       <source mode='bind' host='127.0.0.1' service='9999'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml
+index 0d218f5482..3fc9fd39b0 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml
+@@ -30,7 +30,7 @@
+     <serial type='tcp'>
+       <source mode='connect' host='127.0.0.1' service='9999'/>
+       <protocol type='raw'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='tcp'>
+       <source mode='connect' host='127.0.0.1' service='9999'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml
+index f7069d541f..5b4af3fe95 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml
+@@ -30,11 +30,11 @@
+     <serial type='udp'>
+       <source mode='bind' host='127.0.0.1' service='9999'/>
+       <source mode='connect' host='127.0.0.1' service='9998'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <serial type='udp'>
+       <source mode='connect' service='9999'/>
+-      <target port='1'/>
++      <target type='isa-serial' port='1'/>
+     </serial>
+     <console type='udp'>
+       <source mode='bind' host='127.0.0.1' service='9999'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml
+index 14fc8fc7c9..6bb291ff7f 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml
+@@ -29,7 +29,7 @@
+     </controller>
+     <serial type='unix'>
+       <source mode='connect' path='/tmp/serial.sock'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='unix'>
+       <source mode='connect' path='/tmp/serial.sock'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml
+index 95aa1c7b9b..41954fc85d 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml
+@@ -28,7 +28,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+     </controller>
+     <serial type='vc'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='vc'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml
+index 4e1dd49c22..427f431cce 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml
+@@ -72,13 +72,13 @@
+       <alias name='serial0'/>
+     </serial>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+       <alias name='serial1'/>
+     </serial>
+     <serial type='tcp'>
+       <source mode='bind' host='0.0.0.0' service='2445'/>
+       <protocol type='raw'/>
+-      <target port='1'/>
++      <target type='isa-serial' port='1'/>
+       <alias name='serial2'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml
+index c56d13ef4a..144f6eff7a 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml
+@@ -72,13 +72,13 @@
+       <alias name='serial0'/>
+     </serial>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+       <alias name='serial1'/>
+     </serial>
+     <serial type='tcp'>
+       <source mode='bind' host='0.0.0.0' service='2445'/>
+       <protocol type='raw'/>
+-      <target port='1'/>
++      <target type='isa-serial' port='1'/>
+       <alias name='serial2'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml
+index a95e29ad8a..e6c4adb6f3 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml
++++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml
+@@ -29,12 +29,12 @@
+     <serial type='udp'>
+       <source mode='bind' host='127.0.0.1' service='1111'/>
+       <source mode='connect' host='127.0.0.1' service='2222'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <serial type='tcp'>
+       <source mode='connect' host='127.0.0.1' service='5555' tls='no'/>
+       <protocol type='raw'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='udp'>
+       <source mode='bind' host='127.0.0.1' service='1111'/>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
+index c760098fe0..f9724d320e 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
++++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
+@@ -110,10 +110,10 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <serial type='pty'>
+-      <target port='1'/>
++      <target type='isa-serial' port='1'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml
+index 033e86d3a3..5ee73b527e 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml
+@@ -33,7 +33,7 @@
+     </controller>
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml
+index 840bf69f61..ad77f62d9e 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml
+@@ -25,13 +25,13 @@
+       <source path='/tmp/serial.file'>
+         <seclabel model='dac' relabel='no'/>
+       </source>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <serial type='unix'>
+       <source mode='connect' path='/tmp/serial.sock'>
+         <seclabel model='dac' relabel='no'/>
+       </source>
+-      <target port='1'/>
++      <target type='isa-serial' port='1'/>
+     </serial>
+     <console type='file'>
+       <source path='/tmp/serial.file'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
+index e76f857aee..cd9d75c4b7 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
+@@ -27,7 +27,7 @@
+     </controller>
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml
+index 8dc361dfc6..0c0bd7b348 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml
+@@ -28,7 +28,7 @@
+     </controller>
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml
+index 858b2c6750..305c53eab7 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml
+@@ -31,7 +31,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+     </controller>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml
+index f9f9abd2df..b38b3ce987 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml
+@@ -30,7 +30,7 @@
+     </controller>
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml
+index 1c55017678..06192fbb4a 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml
+@@ -47,7 +47,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml
+index 95b6e2df1a..a6eaa38079 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml
+@@ -104,10 +104,10 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <serial type='pty'>
+-      <target port='1'/>
++      <target type='isa-serial' port='1'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml
+index 7fe69bd6cb..e6ad234240 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml
+@@ -55,7 +55,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml
+index b631e5b515..66448ec3dd 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml
+@@ -44,7 +44,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml
+index fd5fdbece5..b1240b8ed1 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml
+@@ -57,7 +57,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml
+index 4571b6a829..4f7ad323ed 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml
+@@ -54,7 +54,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
+index 7fb49feb0f..a563b6dddf 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
+@@ -22,7 +22,7 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
+index f020056219..59587b3c32 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
+@@ -25,7 +25,7 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
+index 3cbce9fe6a..a39e1fd015 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
+@@ -25,7 +25,7 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
+index d69b387686..666eede1a5 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
+@@ -26,7 +26,7 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
+index 7fb49feb0f..a563b6dddf 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
+@@ -22,7 +22,7 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
+index 7fb49feb0f..a563b6dddf 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
+@@ -22,7 +22,7 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
+index c4ccd98aac..27baaa3f14 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
+@@ -79,7 +79,7 @@
+       <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml
+index 79c4ebc734..63462e6f94 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml
+@@ -28,7 +28,7 @@
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='spiceport'>
+       <source channel='org.qemu.console.serial.0'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='spiceport'>
+       <source channel='org.qemu.console.serial.0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml
+index 9527b2d15f..c90bbeb7d5 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml
+@@ -28,7 +28,7 @@
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='spiceport'>
+       <source channel='org.qemu.console.serial.0'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='spiceport'>
+       <source channel='org.qemu.console.serial.0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
+index 71516a31a9..a8790b5098 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
+@@ -27,13 +27,13 @@
+     </controller>
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <serial type='null'>
+-      <target port='1'/>
++      <target type='isa-serial' port='1'/>
+     </serial>
+     <serial type='stdio'>
+-      <target port='2'/>
++      <target type='isa-serial' port='2'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml
+index 18f51e5383..a8af87b53b 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml
+@@ -29,12 +29,12 @@
+     <serial type='udp'>
+       <source mode='bind' host='127.0.0.1' service='1111'/>
+       <source mode='connect' host='127.0.0.1' service='2222'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <serial type='tcp'>
+       <source mode='connect' host='127.0.0.1' service='5555'/>
+       <protocol type='raw'/>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='udp'>
+       <source mode='bind' host='127.0.0.1' service='1111'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml
+index 3a95b6088c..6d847de3a2 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml
+@@ -40,7 +40,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml
+index 759b844395..30989658f4 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml
+@@ -47,7 +47,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml
+index 8c27470ddf..72cbcc4cb5 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml
+@@ -46,7 +46,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target port='0'/>
++      <target type='isa-serial' port='0'/>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Fix-memory-leak-for-distances-in-virDomainNumaFree.patch b/SOURCES/libvirt-conf-Fix-memory-leak-for-distances-in-virDomainNumaFree.patch
new file mode 100644
index 0000000..3747582
--- /dev/null
+++ b/SOURCES/libvirt-conf-Fix-memory-leak-for-distances-in-virDomainNumaFree.patch
@@ -0,0 +1,35 @@
+From 8e0151c7b6ce80dc8145511848155e6170ce2bf6 Mon Sep 17 00:00:00 2001
+Message-Id: <8e0151c7b6ce80dc8145511848155e6170ce2bf6@dist-git>
+From: John Ferlan <jferlan@redhat.com>
+Date: Mon, 4 Dec 2017 13:38:53 +0100
+Subject: [PATCH] conf: Fix memory leak for distances in virDomainNumaFree
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1454889
+
+Commit id '74119a03f' neglected to clean up @distances when
+the numa definition is cleaned up.
+
+(cherry picked from commit 9f0ccc717ba9026c30ce38951a354dd66fa12e3b)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/numa_conf.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
+index 8fc3b0a196..466b64d5fa 100644
+--- a/src/conf/numa_conf.c
++++ b/src/conf/numa_conf.c
+@@ -362,6 +362,9 @@ virDomainNumaFree(virDomainNumaPtr numa)
+     for (i = 0; i < numa->nmem_nodes; i++) {
+         virBitmapFree(numa->mem_nodes[i].cpumask);
+         virBitmapFree(numa->mem_nodes[i].nodeset);
++
++        if (numa->mem_nodes[i].ndistances > 0)
++            VIR_FREE(numa->mem_nodes[i].distances);
+     }
+     VIR_FREE(numa->mem_nodes);
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Fix-message-when-maximum-vCPU-count-is-less-than-current.patch b/SOURCES/libvirt-conf-Fix-message-when-maximum-vCPU-count-is-less-than-current.patch
new file mode 100644
index 0000000..69ef6d6
--- /dev/null
+++ b/SOURCES/libvirt-conf-Fix-message-when-maximum-vCPU-count-is-less-than-current.patch
@@ -0,0 +1,37 @@
+From 73e3efc5dae126514b00a8538664609810cadbc4 Mon Sep 17 00:00:00 2001
+Message-Id: <73e3efc5dae126514b00a8538664609810cadbc4@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Mon, 13 Nov 2017 13:48:09 +0100
+Subject: [PATCH] conf: Fix message when maximum vCPU count is less than
+ current
+
+Reword the message and drop the numbers (which were reversed) from it
+so that it actually makes sense.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1509151
+(cherry picked from commit 50712e14f40ffdac8a71ce9ef091e4e7bd822585)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 3b337d1a64..ca5d0bcc54 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -1505,9 +1505,9 @@ virDomainDefSetVcpus(virDomainDefPtr def,
+     size_t i;
+ 
+     if (vcpus > def->maxvcpus) {
+-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+-                       _("maxvcpus must not be less than current vcpus (%u < %zu)"),
+-                       vcpus, def->maxvcpus);
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                       _("maximum vCPU count must not be less than current "
++                         "vCPU count"));
+         return -1;
+     }
+ 
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-conf-Format-cache-banks-in-capabilities-with-virFormatIntPretty.patch b/SOURCES/libvirt-conf-Format-cache-banks-in-capabilities-with-virFormatIntPretty.patch
new file mode 100644
index 0000000..a1d532b
--- /dev/null
+++ b/SOURCES/libvirt-conf-Format-cache-banks-in-capabilities-with-virFormatIntPretty.patch
@@ -0,0 +1,166 @@
+From 5a978253cced5135a6dd01c730faea2fd21a5dc9 Mon Sep 17 00:00:00 2001
+Message-Id: <5a978253cced5135a6dd01c730faea2fd21a5dc9@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:18 +0100
+Subject: [PATCH] conf: Format cache banks in capabilities with
+ virFormatIntPretty
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 63d95a19cc72d120d40092c1e97235d7b9d4eb29)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/conf/capabilities.c                            | 50 ++++++++++++++--------
+ tests/vircaps2xmldata/vircaps-x86_64-caches.xml    |  2 +-
+ .../vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml |  4 +-
+ .../vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml |  4 +-
+ tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml   |  4 +-
+ 5 files changed, 39 insertions(+), 25 deletions(-)
+
+diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
+index 1f7d8cdb31..798c9bdaea 100644
+--- a/src/conf/capabilities.c
++++ b/src/conf/capabilities.c
+@@ -883,7 +883,8 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
+     for (i = 0; i < ncaches; i++) {
+         virCapsHostCacheBankPtr bank = caches[i];
+         char *cpus_str = virBitmapFormat(bank->cpus);
+-        bool kilos = !(bank->size % 1024);
++        const char *unit = NULL;
++        unsigned long long short_size = virFormatIntPretty(bank->size, &unit);
+ 
+         if (!cpus_str)
+             return -1;
+@@ -897,34 +898,47 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
+                           "size='%llu' unit='%s' cpus='%s'",
+                           bank->id, bank->level,
+                           virCacheTypeToString(bank->type),
+-                          bank->size >> (kilos * 10),
+-                          kilos ? "KiB" : "B",
+-                          cpus_str);
++                          short_size, unit, cpus_str);
+         VIR_FREE(cpus_str);
+ 
+         virBufferSetChildIndent(&controlBuf, buf);
+         for (j = 0; j < bank->ncontrols; j++) {
+-            bool min_kilos = !(bank->controls[j]->granularity % 1024);
++            const char *min_unit;
++            virResctrlInfoPtr controls = bank->controls[j];
++            unsigned long long gran_short_size = controls->granularity;
++            unsigned long long min_short_size = controls->min;
+ 
+-            /* Only use KiB if both values are divisible */
+-            if (bank->controls[j]->min)
+-                min_kilos = min_kilos && !(bank->controls[j]->min % 1024);
++            gran_short_size = virFormatIntPretty(gran_short_size, &unit);
++            min_short_size = virFormatIntPretty(min_short_size, &min_unit);
+ 
+-            virBufferAsprintf(&controlBuf,
+-                              "<control granularity='%llu'",
+-                              bank->controls[j]->granularity >> (min_kilos * 10));
++            /* Only use the smaller unit if they are different */
++            if (min_short_size) {
++                unsigned long long gran_div;
++                unsigned long long min_div;
+ 
+-            if (bank->controls[j]->min) {
+-                virBufferAsprintf(&controlBuf,
+-                                  " min='%llu'",
+-                                  bank->controls[j]->min >> (min_kilos * 10));
++                gran_div = controls->granularity / gran_short_size;
++                min_div = controls->min / min_short_size;
++
++                if (min_div > gran_div) {
++                    min_short_size *= min_div / gran_div;
++                } else if (min_div < gran_div) {
++                    unit = min_unit;
++                    gran_short_size *= gran_div / min_div;
++                }
+             }
+ 
++            virBufferAsprintf(&controlBuf,
++                              "<control granularity='%llu'",
++                              gran_short_size);
++
++            if (min_short_size)
++                virBufferAsprintf(&controlBuf, " min='%llu'", min_short_size);
++
+             virBufferAsprintf(&controlBuf,
+                               " unit='%s' type='%s' maxAllocs='%u'/>\n",
+-                              min_kilos ? "KiB" : "B",
+-                              virCacheTypeToString(bank->controls[j]->scope),
+-                              bank->controls[j]->max_allocation);
++                              unit,
++                              virCacheTypeToString(controls->scope),
++                              controls->max_allocation);
+         }
+ 
+         if (virBufferCheckError(&controlBuf) < 0)
+diff --git a/tests/vircaps2xmldata/vircaps-x86_64-caches.xml b/tests/vircaps2xmldata/vircaps-x86_64-caches.xml
+index fe0be6d08f..0c6f3769a2 100644
+--- a/tests/vircaps2xmldata/vircaps-x86_64-caches.xml
++++ b/tests/vircaps2xmldata/vircaps-x86_64-caches.xml
+@@ -29,7 +29,7 @@
+       </cells>
+     </topology>
+     <cache>
+-      <bank id='0' level='3' type='both' size='8192' unit='KiB' cpus='0-7'/>
++      <bank id='0' level='3' type='both' size='8' unit='MiB' cpus='0-7'/>
+     </cache>
+   </host>
+ 
+diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
+index 7361537bfb..443917c62d 100644
+--- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
++++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
+@@ -41,11 +41,11 @@
+       </cells>
+     </topology>
+     <cache>
+-      <bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'>
++      <bank id='0' level='3' type='both' size='15' unit='MiB' cpus='0-5'>
+         <control granularity='768' unit='KiB' type='code' maxAllocs='8'/>
+         <control granularity='768' unit='KiB' type='data' maxAllocs='8'/>
+       </bank>
+-      <bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'>
++      <bank id='1' level='3' type='both' size='15' unit='MiB' cpus='6-11'>
+         <control granularity='768' unit='KiB' type='code' maxAllocs='8'/>
+         <control granularity='768' unit='KiB' type='data' maxAllocs='8'/>
+       </bank>
+diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml
+index 4e91c87de3..0cd25e59a9 100644
+--- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml
++++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml
+@@ -22,8 +22,8 @@
+       </cells>
+     </topology>
+     <cache>
+-      <bank id='0' level='3' type='both' size='33792' unit='KiB' cpus='0'>
+-        <control granularity='3072' unit='KiB' type='both' maxAllocs='16'/>
++      <bank id='0' level='3' type='both' size='33' unit='MiB' cpus='0'>
++        <control granularity='3' unit='MiB' type='both' maxAllocs='16'/>
+       </bank>
+     </cache>
+   </host>
+diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
+index eb02ad3322..7629259294 100644
+--- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
++++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
+@@ -41,10 +41,10 @@
+       </cells>
+     </topology>
+     <cache>
+-      <bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'>
++      <bank id='0' level='3' type='both' size='15' unit='MiB' cpus='0-5'>
+         <control granularity='768' min='1536' unit='KiB' type='both' maxAllocs='4'/>
+       </bank>
+-      <bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'>
++      <bank id='1' level='3' type='both' size='15' unit='MiB' cpus='6-11'>
+         <control granularity='768' min='1536' unit='KiB' type='both' maxAllocs='4'/>
+       </bank>
+     </cache>
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-conf-Improve-error-handling-in-virDomainChrDefFormat.patch b/SOURCES/libvirt-conf-Improve-error-handling-in-virDomainChrDefFormat.patch
new file mode 100644
index 0000000..d3f07fc
--- /dev/null
+++ b/SOURCES/libvirt-conf-Improve-error-handling-in-virDomainChrDefFormat.patch
@@ -0,0 +1,54 @@
+From f2dd85b3b81cd5c0842ffb55554c1a9cb5e8764b Mon Sep 17 00:00:00 2001
+Message-Id: <f2dd85b3b81cd5c0842ffb55554c1a9cb5e8764b@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:01 +0100
+Subject: [PATCH] conf: Improve error handling in virDomainChrDefFormat()
+
+We don't need to store the return value since we never modify it.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit be956c4e38770dd61998815bbea4b7c2fc38a7d6)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index d68a5f415c..cf1bd030a0 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -24028,8 +24028,6 @@ virDomainChrDefFormat(virBufferPtr buf,
+     const char *elementName = virDomainChrDeviceTypeToString(def->deviceType);
+     bool tty_compat;
+ 
+-    int ret = 0;
+-
+     if (!elementName) {
+         virReportError(VIR_ERR_INTERNAL_ERROR,
+                        _("unexpected char device type %d"),
+@@ -24050,14 +24048,14 @@ virDomainChrDefFormat(virBufferPtr buf,
+     virDomainChrSourceDefFormat(buf, def->source, flags);
+ 
+     if (virDomainChrTargetDefFormat(buf, def, flags) < 0)
+-       return -1;
++        return -1;
+ 
+     virDomainDeviceInfoFormat(buf, &def->info, flags);
+ 
+     virBufferAdjustIndent(buf, -2);
+     virBufferAsprintf(buf, "</%s>\n", elementName);
+ 
+-    return ret;
++    return 0;
+ }
+ 
+ static int
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Improve-virDomainChrTargetDefFormat.patch b/SOURCES/libvirt-conf-Improve-virDomainChrTargetDefFormat.patch
new file mode 100644
index 0000000..5d75d47
--- /dev/null
+++ b/SOURCES/libvirt-conf-Improve-virDomainChrTargetDefFormat.patch
@@ -0,0 +1,89 @@
+From 6e8cb0e122f7c269d1252ed7d55a7c82ae0062eb Mon Sep 17 00:00:00 2001
+Message-Id: <6e8cb0e122f7c269d1252ed7d55a7c82ae0062eb@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:03 +0100
+Subject: [PATCH] conf: Improve virDomainChrTargetDefFormat()
+
+Make the switch statement type-aware, avoid calling
+virDomainChrTargetTypeToString() more than once and check its
+return value before using it.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 46084f2aa1e9188709fcd7abc5c41fe165b2b19b)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c | 29 ++++++++++++++++++++++-------
+ 1 file changed, 22 insertions(+), 7 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 346edaa6bd..2489705d6b 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -23945,7 +23945,7 @@ virDomainChrTargetDefFormat(virBufferPtr buf,
+     const char *targetType = virDomainChrTargetTypeToString(def->deviceType,
+                                                             def->targetType);
+ 
+-    switch (def->deviceType) {
++    switch ((virDomainChrDeviceType) def->deviceType) {
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: {
+         if (!targetType) {
+             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+@@ -23992,28 +23992,43 @@ virDomainChrTargetDefFormat(virBufferPtr buf,
+     }
+ 
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
++        if (!targetType) {
++            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                           _("Could not format console target type"));
++            return -1;
++        }
++
+         virBufferAsprintf(buf,
+                           "<target type='%s' port='%d'/>\n",
+-                          virDomainChrTargetTypeToString(def->deviceType,
+-                                                         def->targetType),
+-                          def->target.port);
++                          targetType, def->target.port);
+         break;
+ 
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
++        if (!targetType) {
++            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                           _("Could not format serial target type"));
++            return -1;
++        }
++
+         if (def->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) {
+             virBufferAsprintf(buf,
+                               "<target type='%s' port='%d'/>\n",
+-                              virDomainChrTargetTypeToString(def->deviceType,
+-                                                             def->targetType),
++                              targetType,
+                               def->target.port);
+             break;
+         }
+         ATTRIBUTE_FALLTHROUGH;
+ 
+-    default:
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
+         virBufferAsprintf(buf, "<target port='%d'/>\n",
+                           def->target.port);
+         break;
++
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
++        virReportError(VIR_ERR_INTERNAL_ERROR,
++                       _("unexpected char device type %d"),
++                       def->deviceType);
++        return -1;
+     }
+ 
+     return 0;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Introduce-VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE.patch b/SOURCES/libvirt-conf-Introduce-VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE.patch
new file mode 100644
index 0000000..18c006d
--- /dev/null
+++ b/SOURCES/libvirt-conf-Introduce-VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE.patch
@@ -0,0 +1,159 @@
+From 4f4db541098163a2061cd63ce6bfb83ce2ed38b5 Mon Sep 17 00:00:00 2001
+Message-Id: <4f4db541098163a2061cd63ce6bfb83ce2ed38b5@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:22:58 +0100
+Subject: [PATCH] conf: Introduce VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE
+
+This is the first step in getting rid of the assumption that
+isa-serial is the default target type for serial devices.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 6385c8c14233388d929ed62717684e7352543416)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c         |  8 +++++---
+ src/conf/domain_conf.h         |  3 ++-
+ src/qemu/qemu_command.c        | 13 +++++++++++++
+ src/qemu/qemu_domain.c         | 21 +++++++++++++++++++++
+ src/qemu/qemu_domain_address.c |  1 +
+ 5 files changed, 42 insertions(+), 4 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 41674a85af..3a5ecd3a9d 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -441,6 +441,7 @@ VIR_ENUM_IMPL(virDomainChrDeviceState, VIR_DOMAIN_CHR_DEVICE_STATE_LAST,
+ 
+ VIR_ENUM_IMPL(virDomainChrSerialTarget,
+               VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST,
++              "none",
+               "isa-serial",
+               "usb-serial",
+               "pci-serial")
+@@ -4025,7 +4026,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def)
+ 
+             /* modify it to be a serial port */
+             def->serials[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+-            def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
++            def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
+             def->serials[0]->target.port = 0;
+         } else {
+             /* if the console source doesn't match */
+@@ -4049,7 +4050,8 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def)
+                def->serials[0]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
+ 
+         switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) {
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: {
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: {
+ 
+             /* Create a stub console to match the serial port.
+              * console[0] either does not exist
+@@ -11485,7 +11487,7 @@ virDomainChrDefaultTargetType(int devtype)
+         return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE;
+ 
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
+-        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
++        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
+ 
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 09635763a1..9502573b34 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -1073,7 +1073,8 @@ typedef enum {
+ } virDomainChrDeviceType;
+ 
+ typedef enum {
+-    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA = 0,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE = 0,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
+ 
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 3d970ed9d1..d593e60198 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9255,6 +9255,14 @@ qemuChrIsPlatformDevice(const virDomainDef *def,
+             return true;
+     }
+ 
++    /* If we got all the way here and we're still stuck with the default
++     * target type for a serial device, it means we have no clue what kind of
++     * device we're talking about and we must treat it as a platform device. */
++    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
++        chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) {
++        return true;
++    }
++
+     return false;
+ }
+ 
+@@ -10378,7 +10386,12 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+             }
+             break;
+ 
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
++            /* Except from _LAST, which is just a guard value and will never
++             * be used, all of the above are platform devices, which means
++             * qemuBuildSerialCommandLine() will have taken the appropriate
++             * branch and we will not have ended up here. */
+             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                            _("Invalid target type for serial device"));
+             goto error;
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index b15d994774..e43f7496c2 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -4095,6 +4095,27 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
+         chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
+     }
+ 
++    /* Historically, isa-serial and the default matched, so in order to
++     * maintain backwards compatibility we map them here. The actual default
++     * will be picked below based on the architecture and machine type. */
++    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
++        chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA) {
++        chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
++    }
++
++    /* Set the default serial type */
++    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
++        chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) {
++        if (ARCH_IS_X86(def->os.arch)) {
++            chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
++        } else if (qemuDomainIsPSeries(def)) {
++            /* Setting TYPE_ISA here is just a temporary hack to reduce test
++             * suite churn. Later on we will have a proper serial type for
++             * pSeries and this line will be updated accordingly. */
++            chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
++        }
++    }
++
+     /* clear auto generated unix socket path for inactive definitions */
+     if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
+         if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0)
+diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
+index 7f4ac0f45a..989c0e6c93 100644
+--- a/src/qemu/qemu_domain_address.c
++++ b/src/qemu/qemu_domain_address.c
+@@ -782,6 +782,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
+ 
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+             return 0;
+         }
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Introduce-virCPUDefFindFeature.patch b/SOURCES/libvirt-conf-Introduce-virCPUDefFindFeature.patch
deleted file mode 100644
index 2ffc775..0000000
--- a/SOURCES/libvirt-conf-Introduce-virCPUDefFindFeature.patch
+++ /dev/null
@@ -1,114 +0,0 @@
-From 2d9d40cfec0aa5db556ca62395671dc340b6bf93 Mon Sep 17 00:00:00 2001
-Message-Id: <2d9d40cfec0aa5db556ca62395671dc340b6bf93@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Mon, 9 Oct 2017 16:20:43 +0200
-Subject: [PATCH] conf: Introduce virCPUDefFindFeature
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 3276416904393a06df664c5d849ee805d07688d8)
-
-Conflicts:
-	src/conf/cpu_conf.h - context, two more new function prototypes
-            in the header file upstream
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1508549
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/cpu_conf.c      | 40 +++++++++++++++++++++++++++-------------
- src/conf/cpu_conf.h      |  4 ++++
- src/libvirt_private.syms |  1 +
- 3 files changed, 32 insertions(+), 13 deletions(-)
-
-diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
-index da40e9ba97..e570dffcd2 100644
---- a/src/conf/cpu_conf.c
-+++ b/src/conf/cpu_conf.c
-@@ -773,24 +773,22 @@ virCPUDefUpdateFeatureInternal(virCPUDefPtr def,
-                                int policy,
-                                bool update)
- {
--    size_t i;
-+    virCPUFeatureDefPtr feat;
- 
-     if (def->type == VIR_CPU_TYPE_HOST)
-         policy = -1;
- 
--    for (i = 0; i < def->nfeatures; i++) {
--        if (STREQ(name, def->features[i].name)) {
--            if (update) {
--                def->features[i].policy = policy;
--                return 0;
--            }
--
--            virReportError(VIR_ERR_INTERNAL_ERROR,
--                           _("CPU feature '%s' specified more than once"),
--                           name);
--
--            return -1;
-+    if ((feat = virCPUDefFindFeature(def, name))) {
-+        if (update) {
-+            feat->policy = policy;
-+            return 0;
-         }
-+
-+        virReportError(VIR_ERR_INTERNAL_ERROR,
-+                       _("CPU feature '%s' specified more than once"),
-+                       name);
-+
-+        return -1;
-     }
- 
-     if (VIR_RESIZE_N(def->features, def->nfeatures_max,
-@@ -822,6 +820,22 @@ virCPUDefAddFeature(virCPUDefPtr def,
-     return virCPUDefUpdateFeatureInternal(def, name, policy, false);
- }
- 
-+
-+virCPUFeatureDefPtr
-+virCPUDefFindFeature(virCPUDefPtr def,
-+                     const char *name)
-+{
-+    size_t i;
-+
-+    for (i = 0; i < def->nfeatures; i++) {
-+        if (STREQ(name, def->features[i].name))
-+            return def->features + i;
-+    }
-+
-+    return NULL;
-+}
-+
-+
- bool
- virCPUDefIsEqual(virCPUDefPtr src,
-                  virCPUDefPtr dst,
-diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
-index b44974f47e..1978814d36 100644
---- a/src/conf/cpu_conf.h
-+++ b/src/conf/cpu_conf.h
-@@ -218,4 +218,8 @@ virCPUDefUpdateFeature(virCPUDefPtr cpu,
-                        const char *name,
-                        int policy);
- 
-+virCPUFeatureDefPtr
-+virCPUDefFindFeature(virCPUDefPtr def,
-+                     const char *name);
-+
- #endif /* __VIR_CPU_CONF_H__ */
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 9c596e3f1c..62ebb8180e 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -74,6 +74,7 @@ virCPUDefCopy;
- virCPUDefCopyModel;
- virCPUDefCopyModelFilter;
- virCPUDefCopyWithoutModel;
-+virCPUDefFindFeature;
- virCPUDefFormat;
- virCPUDefFormatBuf;
- virCPUDefFormatBufFull;
--- 
-2.15.0
-
diff --git a/SOURCES/libvirt-conf-Introduce-virDomainChrTargetDefFormat.patch b/SOURCES/libvirt-conf-Introduce-virDomainChrTargetDefFormat.patch
new file mode 100644
index 0000000..b4d2573
--- /dev/null
+++ b/SOURCES/libvirt-conf-Introduce-virDomainChrTargetDefFormat.patch
@@ -0,0 +1,115 @@
+From 10d833e6bb2798e23beb01ac50d6588bec15b8ad Mon Sep 17 00:00:00 2001
+Message-Id: <10d833e6bb2798e23beb01ac50d6588bec15b8ad@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:00 +0100
+Subject: [PATCH] conf: Introduce virDomainChrTargetDefFormat()
+
+Move formatting of the <target/> element for char devices out of
+virDomainChrDefFormat() and into its own function.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 00b7f81fa8f4e32a722ee2ccbb1862f03be062c0)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c | 67 ++++++++++++++++++++++++++++++--------------------
+ 1 file changed, 40 insertions(+), 27 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 586a840672..d68a5f415c 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -23936,38 +23936,15 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
+     return -1;
+ }
+ 
++
+ static int
+-virDomainChrDefFormat(virBufferPtr buf,
+-                      virDomainChrDefPtr def,
+-                      unsigned int flags)
++virDomainChrTargetDefFormat(virBufferPtr buf,
++                            const virDomainChrDef *def,
++                            unsigned int flags)
+ {
+-    const char *elementName = virDomainChrDeviceTypeToString(def->deviceType);
+     const char *targetType = virDomainChrTargetTypeToString(def->deviceType,
+                                                             def->targetType);
+-    bool tty_compat;
+ 
+-    int ret = 0;
+-
+-    if (!elementName) {
+-        virReportError(VIR_ERR_INTERNAL_ERROR,
+-                       _("unexpected char device type %d"),
+-                       def->deviceType);
+-        return -1;
+-    }
+-
+-    virBufferAsprintf(buf, "<%s", elementName);
+-    virBufferAdjustIndent(buf, 2);
+-    tty_compat = (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+-                  def->target.port == 0 &&
+-                  def->source->type == VIR_DOMAIN_CHR_TYPE_PTY &&
+-                  !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
+-                  def->source->data.file.path);
+-    if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0)
+-        return -1;
+-    virBufferAddLit(buf, ">\n");
+-    virDomainChrSourceDefFormat(buf, def->source, flags);
+-
+-    /* Format <target> block */
+     switch (def->deviceType) {
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: {
+         if (!targetType) {
+@@ -24039,6 +24016,42 @@ virDomainChrDefFormat(virBufferPtr buf,
+         break;
+     }
+ 
++    return 0;
++}
++
++
++static int
++virDomainChrDefFormat(virBufferPtr buf,
++                      virDomainChrDefPtr def,
++                      unsigned int flags)
++{
++    const char *elementName = virDomainChrDeviceTypeToString(def->deviceType);
++    bool tty_compat;
++
++    int ret = 0;
++
++    if (!elementName) {
++        virReportError(VIR_ERR_INTERNAL_ERROR,
++                       _("unexpected char device type %d"),
++                       def->deviceType);
++        return -1;
++    }
++
++    virBufferAsprintf(buf, "<%s", elementName);
++    virBufferAdjustIndent(buf, 2);
++    tty_compat = (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
++                  def->target.port == 0 &&
++                  def->source->type == VIR_DOMAIN_CHR_TYPE_PTY &&
++                  !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
++                  def->source->data.file.path);
++    if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0)
++        return -1;
++    virBufferAddLit(buf, ">\n");
++    virDomainChrSourceDefFormat(buf, def->source, flags);
++
++    if (virDomainChrTargetDefFormat(buf, def, flags) < 0)
++       return -1;
++
+     virDomainDeviceInfoFormat(buf, &def->info, flags);
+ 
+     virBufferAdjustIndent(buf, -2);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Introduce-virSaveCookie.patch b/SOURCES/libvirt-conf-Introduce-virSaveCookie.patch
deleted file mode 100644
index fedfc8b..0000000
--- a/SOURCES/libvirt-conf-Introduce-virSaveCookie.patch
+++ /dev/null
@@ -1,290 +0,0 @@
-From 5785b4ff7c33f5e2eb16530f20b6b45d8809aae7 Mon Sep 17 00:00:00 2001
-Message-Id: <5785b4ff7c33f5e2eb16530f20b6b45d8809aae7@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 2 Jun 2017 00:44:06 +0200
-Subject: [PATCH] conf: Introduce virSaveCookie
-
-The code will be used by snapshots and domain save/restore code to store
-additional data for a saved running domain. It is analogous to migration
-cookies, but simple and one way only.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit e37daa1fb69ec30042cbc38d489217edb656bc30)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- po/POTFILES.in           |   1 +
- src/Makefile.am          |   1 +
- src/conf/virsavecookie.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++
- src/conf/virsavecookie.h |  62 ++++++++++++++++++++
- src/libvirt_private.syms |   7 +++
- 5 files changed, 215 insertions(+)
- create mode 100644 src/conf/virsavecookie.c
- create mode 100644 src/conf/virsavecookie.h
-
-diff --git a/po/POTFILES.in b/po/POTFILES.in
-index 064abd5bbb..cf64115719 100644
---- a/po/POTFILES.in
-+++ b/po/POTFILES.in
-@@ -47,6 +47,7 @@ src/conf/virdomainobjlist.c
- src/conf/virinterfaceobj.c
- src/conf/virnodedeviceobj.c
- src/conf/virnwfilterobj.c
-+src/conf/virsavecookie.c
- src/conf/virsecretobj.c
- src/conf/virstorageobj.c
- src/cpu/cpu.c
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 75e4344198..53550280bf 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -336,6 +336,7 @@ DOMAIN_CONF_SOURCES =						\
- 		conf/domain_conf.c conf/domain_conf.h		\
- 		conf/domain_audit.c conf/domain_audit.h		\
- 		conf/domain_nwfilter.c conf/domain_nwfilter.h	\
-+		conf/virsavecookie.c conf/virsavecookie.h	\
- 		conf/snapshot_conf.c conf/snapshot_conf.h	\
- 		conf/numa_conf.c conf/numa_conf.h	\
- 		conf/virdomainobjlist.c conf/virdomainobjlist.h
-diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c
-new file mode 100644
-index 0000000000..502c04d0f4
---- /dev/null
-+++ b/src/conf/virsavecookie.c
-@@ -0,0 +1,144 @@
-+/**
-+ * virsavecookie.c: Save cookie handling
-+ *
-+ * Copyright (C) 2017 Red Hat, Inc.
-+ *
-+ * This library is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU Lesser General Public
-+ * License as published by the Free Software Foundation; either
-+ * version 2.1 of the License, or (at your option) any later version.
-+ *
-+ * This library 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
-+ * Lesser General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU Lesser General Public
-+ * License along with this library.  If not, see
-+ * <http://www.gnu.org/licenses/>.
-+ */
-+
-+#include <config.h>
-+
-+#include "virerror.h"
-+#include "virlog.h"
-+#include "virobject.h"
-+#include "virbuffer.h"
-+#include "virxml.h"
-+#include "virsavecookie.h"
-+
-+#define VIR_FROM_THIS VIR_FROM_CONF
-+
-+VIR_LOG_INIT("conf.savecookie");
-+
-+
-+static int
-+virSaveCookieParseNode(xmlXPathContextPtr ctxt,
-+                       virObjectPtr *obj,
-+                       virSaveCookieCallbacksPtr saveCookie)
-+{
-+    *obj = NULL;
-+
-+    if (!xmlStrEqual(ctxt->node->name, BAD_CAST "cookie")) {
-+        virReportError(VIR_ERR_XML_ERROR, "%s",
-+                       _("XML does not contain expected 'cookie' element"));
-+        return -1;
-+    }
-+
-+    if (!saveCookie || !saveCookie->parse)
-+        return 0;
-+
-+    return saveCookie->parse(ctxt, obj);
-+}
-+
-+
-+int
-+virSaveCookieParse(xmlXPathContextPtr ctxt,
-+                   virObjectPtr *obj,
-+                   virSaveCookieCallbacksPtr saveCookie)
-+{
-+    xmlNodePtr node = ctxt->node;
-+    int ret = -1;
-+
-+    *obj = NULL;
-+
-+    if (!(ctxt->node = virXPathNode("./cookie", ctxt))) {
-+        ret = 0;
-+        goto cleanup;
-+    }
-+
-+    ret = virSaveCookieParseNode(ctxt, obj, saveCookie);
-+
-+ cleanup:
-+    ctxt->node = node;
-+    return ret;
-+}
-+
-+
-+int
-+virSaveCookieParseString(const char *xml,
-+                         virObjectPtr *obj,
-+                         virSaveCookieCallbacksPtr saveCookie)
-+{
-+    xmlDocPtr doc = NULL;
-+    xmlXPathContextPtr ctxt = NULL;
-+    int ret = -1;
-+
-+    *obj = NULL;
-+
-+    if (!xml) {
-+        ret = 0;
-+        goto cleanup;
-+    }
-+
-+    if (!(doc = virXMLParseStringCtxt(xml, _("(save cookie)"), &ctxt)))
-+        goto cleanup;
-+
-+    ret = virSaveCookieParseNode(ctxt, obj, saveCookie);
-+
-+ cleanup:
-+    xmlXPathFreeContext(ctxt);
-+    xmlFreeDoc(doc);
-+    return ret;
-+}
-+
-+
-+int
-+virSaveCookieFormatBuf(virBufferPtr buf,
-+                       virObjectPtr obj,
-+                       virSaveCookieCallbacksPtr saveCookie)
-+{
-+    if (!obj || !saveCookie || !saveCookie->format)
-+        return 0;
-+
-+    virBufferAddLit(buf, "<cookie>\n");
-+    virBufferAdjustIndent(buf, 2);
-+
-+    if (saveCookie->format(buf, obj) < 0)
-+        return -1;
-+
-+    virBufferAdjustIndent(buf, -2);
-+    virBufferAddLit(buf, "</cookie>\n");
-+
-+    return 0;
-+}
-+
-+
-+char *
-+virSaveCookieFormat(virObjectPtr obj,
-+                    virSaveCookieCallbacksPtr saveCookie)
-+{
-+    virBuffer buf = VIR_BUFFER_INITIALIZER;
-+
-+    if (virSaveCookieFormatBuf(&buf, obj, saveCookie) < 0)
-+        goto error;
-+
-+    if (virBufferCheckError(&buf) < 0)
-+        goto error;
-+
-+    return virBufferContentAndReset(&buf);
-+
-+ error:
-+    virBufferFreeAndReset(&buf);
-+    return NULL;
-+}
-diff --git a/src/conf/virsavecookie.h b/src/conf/virsavecookie.h
-new file mode 100644
-index 0000000000..4aed18466c
---- /dev/null
-+++ b/src/conf/virsavecookie.h
-@@ -0,0 +1,62 @@
-+/**
-+ * virsavecookie.h: Save cookie handling
-+ *
-+ * Copyright (C) 2017 Red Hat, Inc.
-+ *
-+ * This library is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU Lesser General Public
-+ * License as published by the Free Software Foundation; either
-+ * version 2.1 of the License, or (at your option) any later version.
-+ *
-+ * This library 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
-+ * Lesser General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU Lesser General Public
-+ * License along with this library.  If not, see
-+ * <http://www.gnu.org/licenses/>.
-+ */
-+#ifndef __VIR_SAVE_COOKIE_H__
-+# define __VIR_SAVE_COOKIE_H__
-+
-+# include <libxml/xpath.h>
-+
-+# include "internal.h"
-+# include "virobject.h"
-+# include "virbuffer.h"
-+
-+
-+typedef int (*virSaveCookieParseFunc)(xmlXPathContextPtr ctxt,
-+                                      virObjectPtr *obj);
-+typedef int (*virSaveCookieFormatFunc)(virBufferPtr buf,
-+                                       virObjectPtr obj);
-+
-+typedef struct _virSaveCookieCallbacks virSaveCookieCallbacks;
-+typedef virSaveCookieCallbacks *virSaveCookieCallbacksPtr;
-+struct _virSaveCookieCallbacks {
-+    virSaveCookieParseFunc parse;
-+    virSaveCookieFormatFunc format;
-+};
-+
-+
-+int
-+virSaveCookieParse(xmlXPathContextPtr ctxt,
-+                   virObjectPtr *obj,
-+                   virSaveCookieCallbacksPtr saveCookie);
-+
-+int
-+virSaveCookieParseString(const char *xml,
-+                         virObjectPtr *obj,
-+                         virSaveCookieCallbacksPtr saveCookie);
-+
-+int
-+virSaveCookieFormatBuf(virBufferPtr buf,
-+                       virObjectPtr obj,
-+                       virSaveCookieCallbacksPtr saveCookie);
-+
-+char *
-+virSaveCookieFormat(virObjectPtr obj,
-+                    virSaveCookieCallbacksPtr saveCookie);
-+
-+#endif /*__VIR_SAVE_COOKIE_H__ */
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index a578dfba34..b4769080e8 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -971,6 +971,13 @@ virNWFilterObjTestUnassignDef;
- virNWFilterObjUnlock;
- 
- 
-+# conf/virsavecookie.h
-+virSaveCookieFormat;
-+virSaveCookieFormatBuf;
-+virSaveCookieParse;
-+virSaveCookieParseString;
-+
-+
- # conf/virsecretobj.h
- virSecretLoadAllConfigs;
- virSecretObjDeleteConfig;
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-conf-Make-error-reporting-in-virCPUDefIsEqual-optional.patch b/SOURCES/libvirt-conf-Make-error-reporting-in-virCPUDefIsEqual-optional.patch
deleted file mode 100644
index 7e24d8f..0000000
--- a/SOURCES/libvirt-conf-Make-error-reporting-in-virCPUDefIsEqual-optional.patch
+++ /dev/null
@@ -1,213 +0,0 @@
-From c1ad40f4ad3813ff3013efba80983f62113fc092 Mon Sep 17 00:00:00 2001
-Message-Id: <c1ad40f4ad3813ff3013efba80983f62113fc092@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 31 May 2017 16:42:42 +0200
-Subject: [PATCH] conf: Make error reporting in virCPUDefIsEqual optional
-
-The function will be used in paths where mismatching CPU defs are not an
-error.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 25ec7f6fe959f2811bb014a8c1f0c92bdf9ca13d)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/cpu_conf.c    | 83 +++++++++++++++++++++++---------------------------
- src/conf/cpu_conf.h    |  3 +-
- src/conf/domain_conf.c |  2 +-
- 3 files changed, 41 insertions(+), 47 deletions(-)
-
-diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
-index a4be5742e3..ffb2e83d67 100644
---- a/src/conf/cpu_conf.c
-+++ b/src/conf/cpu_conf.c
-@@ -811,7 +811,8 @@ virCPUDefAddFeature(virCPUDefPtr def,
- 
- bool
- virCPUDefIsEqual(virCPUDefPtr src,
--                 virCPUDefPtr dst)
-+                 virCPUDefPtr dst,
-+                 bool reportError)
- {
-     bool identical = false;
-     size_t i;
-@@ -819,98 +820,89 @@ virCPUDefIsEqual(virCPUDefPtr src,
-     if (!src && !dst)
-         return true;
- 
-+#define MISMATCH(fmt, ...)                                              \
-+    if (reportError)                                                    \
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, fmt, __VA_ARGS__)
-+
-     if ((src && !dst) || (!src && dst)) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
--                       _("Target CPU does not match source"));
-+        MISMATCH("%s", _("Target CPU does not match source"));
-         goto cleanup;
-     }
- 
-     if (src->type != dst->type) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target CPU type %s does not match source %s"),
--                       virCPUTypeToString(dst->type),
--                       virCPUTypeToString(src->type));
-+        MISMATCH(_("Target CPU type %s does not match source %s"),
-+                 virCPUTypeToString(dst->type),
-+                 virCPUTypeToString(src->type));
-         goto cleanup;
-     }
- 
-     if (src->mode != dst->mode) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target CPU mode %s does not match source %s"),
--                       virCPUModeTypeToString(dst->mode),
--                       virCPUModeTypeToString(src->mode));
-+        MISMATCH(_("Target CPU mode %s does not match source %s"),
-+                 virCPUModeTypeToString(dst->mode),
-+                 virCPUModeTypeToString(src->mode));
-         goto cleanup;
-     }
- 
-     if (src->arch != dst->arch) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target CPU arch %s does not match source %s"),
--                       virArchToString(dst->arch),
--                       virArchToString(src->arch));
-+        MISMATCH(_("Target CPU arch %s does not match source %s"),
-+                 virArchToString(dst->arch),
-+                 virArchToString(src->arch));
-         goto cleanup;
-     }
- 
-     if (STRNEQ_NULLABLE(src->model, dst->model)) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target CPU model %s does not match source %s"),
--                       NULLSTR(dst->model), NULLSTR(src->model));
-+        MISMATCH(_("Target CPU model %s does not match source %s"),
-+                 NULLSTR(dst->model), NULLSTR(src->model));
-         goto cleanup;
-     }
- 
-     if (STRNEQ_NULLABLE(src->vendor, dst->vendor)) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target CPU vendor %s does not match source %s"),
--                       NULLSTR(dst->vendor), NULLSTR(src->vendor));
-+        MISMATCH(_("Target CPU vendor %s does not match source %s"),
-+                 NULLSTR(dst->vendor), NULLSTR(src->vendor));
-         goto cleanup;
-     }
- 
-     if (STRNEQ_NULLABLE(src->vendor_id, dst->vendor_id)) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target CPU vendor id %s does not match source %s"),
--                       NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id));
-+        MISMATCH(_("Target CPU vendor id %s does not match source %s"),
-+                 NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id));
-         goto cleanup;
-     }
- 
-     if (src->sockets != dst->sockets) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target CPU sockets %d does not match source %d"),
--                       dst->sockets, src->sockets);
-+        MISMATCH(_("Target CPU sockets %d does not match source %d"),
-+                 dst->sockets, src->sockets);
-         goto cleanup;
-     }
- 
-     if (src->cores != dst->cores) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target CPU cores %d does not match source %d"),
--                       dst->cores, src->cores);
-+        MISMATCH(_("Target CPU cores %d does not match source %d"),
-+                 dst->cores, src->cores);
-         goto cleanup;
-     }
- 
-     if (src->threads != dst->threads) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target CPU threads %d does not match source %d"),
--                       dst->threads, src->threads);
-+        MISMATCH(_("Target CPU threads %d does not match source %d"),
-+                 dst->threads, src->threads);
-         goto cleanup;
-     }
- 
-     if (src->nfeatures != dst->nfeatures) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target CPU feature count %zu does not match source %zu"),
--                       dst->nfeatures, src->nfeatures);
-+        MISMATCH(_("Target CPU feature count %zu does not match source %zu"),
-+                 dst->nfeatures, src->nfeatures);
-         goto cleanup;
-     }
- 
-     for (i = 0; i < src->nfeatures; i++) {
-         if (STRNEQ(src->features[i].name, dst->features[i].name)) {
--            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                           _("Target CPU feature %s does not match source %s"),
--                           dst->features[i].name, src->features[i].name);
-+            MISMATCH(_("Target CPU feature %s does not match source %s"),
-+                     dst->features[i].name, src->features[i].name);
-             goto cleanup;
-         }
- 
-         if (src->features[i].policy != dst->features[i].policy) {
--            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                           _("Target CPU feature policy %s does not match source %s"),
--                           virCPUFeaturePolicyTypeToString(dst->features[i].policy),
--                           virCPUFeaturePolicyTypeToString(src->features[i].policy));
-+            MISMATCH(_("Target CPU feature policy %s does not match source %s"),
-+                     virCPUFeaturePolicyTypeToString(dst->features[i].policy),
-+                     virCPUFeaturePolicyTypeToString(src->features[i].policy));
-             goto cleanup;
-         }
-     }
-@@ -920,11 +912,12 @@ virCPUDefIsEqual(virCPUDefPtr src,
-         (src->cache && dst->cache &&
-          (src->cache->level != dst->cache->level ||
-           src->cache->mode != dst->cache->mode))) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
--                       _("Target CPU cache does not match source"));
-+        MISMATCH("%s", _("Target CPU cache does not match source"));
-         goto cleanup;
-     }
- 
-+#undef MISMATCH
-+
-     identical = true;
- 
-  cleanup:
-diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
-index 09438b68b4..b0d891552a 100644
---- a/src/conf/cpu_conf.h
-+++ b/src/conf/cpu_conf.h
-@@ -189,7 +189,8 @@ virCPUDefParseXML(xmlNodePtr node,
- 
- bool
- virCPUDefIsEqual(virCPUDefPtr src,
--                 virCPUDefPtr dst);
-+                 virCPUDefPtr dst,
-+                 bool reportError);
- 
- char *
- virCPUDefFormat(virCPUDefPtr def,
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index bab85c6362..2197330a22 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -20042,7 +20042,7 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
-             goto error;
-     }
- 
--    if (!virCPUDefIsEqual(src->cpu, dst->cpu))
-+    if (!virCPUDefIsEqual(src->cpu, dst->cpu, true))
-         goto error;
- 
-     if (!virSysinfoIsEqual(src->sysinfo, dst->sysinfo))
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-conf-Make-virDomainSnapshotDefFormat-easier-to-read.patch b/SOURCES/libvirt-conf-Make-virDomainSnapshotDefFormat-easier-to-read.patch
deleted file mode 100644
index 5ed7558..0000000
--- a/SOURCES/libvirt-conf-Make-virDomainSnapshotDefFormat-easier-to-read.patch
+++ /dev/null
@@ -1,113 +0,0 @@
-From d1adb920ad7f460e32b1cc68e68120b3c655bc18 Mon Sep 17 00:00:00 2001
-Message-Id: <d1adb920ad7f460e32b1cc68e68120b3c655bc18@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Thu, 1 Jun 2017 15:57:55 +0200
-Subject: [PATCH] conf: Make virDomainSnapshotDefFormat easier to read
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 00968dca967f4bf9d4f496e5c971bff3f8147ed8)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/snapshot_conf.c | 30 +++++++++++++++++++++---------
- 1 file changed, 21 insertions(+), 9 deletions(-)
-
-diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
-index b6cba5ac38..7daa9b22ad 100644
---- a/src/conf/snapshot_conf.c
-+++ b/src/conf/snapshot_conf.c
-@@ -686,11 +686,13 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
-     virBufferAddLit(buf, "</disk>\n");
- }
- 
--char *virDomainSnapshotDefFormat(const char *domain_uuid,
--                                 virDomainSnapshotDefPtr def,
--                                 virCapsPtr caps,
--                                 unsigned int flags,
--                                 int internal)
-+
-+char *
-+virDomainSnapshotDefFormat(const char *domain_uuid,
-+                           virDomainSnapshotDefPtr def,
-+                           virCapsPtr caps,
-+                           unsigned int flags,
-+                           int internal)
- {
-     virBuffer buf = VIR_BUFFER_INITIALIZER;
-     size_t i;
-@@ -702,12 +704,14 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
- 
-     virBufferAddLit(&buf, "<domainsnapshot>\n");
-     virBufferAdjustIndent(&buf, 2);
-+
-     virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
-     if (def->description)
-         virBufferEscapeString(&buf, "<description>%s</description>\n",
-                               def->description);
-     virBufferAsprintf(&buf, "<state>%s</state>\n",
-                       virDomainSnapshotStateTypeToString(def->state));
-+
-     if (def->parent) {
-         virBufferAddLit(&buf, "<parent>\n");
-         virBufferAdjustIndent(&buf, 2);
-@@ -715,14 +719,17 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
-         virBufferAdjustIndent(&buf, -2);
-         virBufferAddLit(&buf, "</parent>\n");
-     }
-+
-     virBufferAsprintf(&buf, "<creationTime>%lld</creationTime>\n",
-                       def->creationTime);
-+
-     if (def->memory) {
-         virBufferAsprintf(&buf, "<memory snapshot='%s'",
-                           virDomainSnapshotLocationTypeToString(def->memory));
-         virBufferEscapeString(&buf, " file='%s'", def->file);
-         virBufferAddLit(&buf, "/>\n");
-     }
-+
-     if (def->ndisks) {
-         virBufferAddLit(&buf, "<disks>\n");
-         virBufferAdjustIndent(&buf, 2);
-@@ -731,11 +738,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
-         virBufferAdjustIndent(&buf, -2);
-         virBufferAddLit(&buf, "</disks>\n");
-     }
-+
-     if (def->dom) {
--        if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0) {
--            virBufferFreeAndReset(&buf);
--            return NULL;
--        }
-+        if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0)
-+            goto error;
-     } else if (domain_uuid) {
-         virBufferAddLit(&buf, "<domain>\n");
-         virBufferAdjustIndent(&buf, 2);
-@@ -743,8 +749,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
-         virBufferAdjustIndent(&buf, -2);
-         virBufferAddLit(&buf, "</domain>\n");
-     }
-+
-     if (internal)
-         virBufferAsprintf(&buf, "<active>%d</active>\n", def->current);
-+
-     virBufferAdjustIndent(&buf, -2);
-     virBufferAddLit(&buf, "</domainsnapshot>\n");
- 
-@@ -752,6 +760,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
-         return NULL;
- 
-     return virBufferContentAndReset(&buf);
-+
-+ error:
-+    virBufferFreeAndReset(&buf);
-+    return NULL;
- }
- 
- /* Snapshot Obj functions */
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-conf-Parse-and-format-virDomainChrSerialTargetModel.patch b/SOURCES/libvirt-conf-Parse-and-format-virDomainChrSerialTargetModel.patch
new file mode 100644
index 0000000..560296f
--- /dev/null
+++ b/SOURCES/libvirt-conf-Parse-and-format-virDomainChrSerialTargetModel.patch
@@ -0,0 +1,253 @@
+From f39b12fb966c2dfe7841a299f00ff5c6fa68095e Mon Sep 17 00:00:00 2001
+Message-Id: <f39b12fb966c2dfe7841a299f00ff5c6fa68095e@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:07 +0100
+Subject: [PATCH] conf: Parse and format virDomainChrSerialTargetModel
+
+This information will be used to select, and store in the guest
+configuration in order to guarantee ABI stability, the concrete
+(hypervisor-specific) model for serial devices.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 5ad9d9afd4738ea716a6f820bbb53eecf5604a2f)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/formatdomain.html.in     | 16 ++++++++--
+ docs/schemas/domaincommon.rng | 15 +++++++++
+ src/conf/domain_conf.c        | 72 ++++++++++++++++++++++++++++++++++++++++++-
+ src/conf/domain_conf.h        | 12 ++++++++
+ 4 files changed, 112 insertions(+), 3 deletions(-)
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index f57a124056..cf1167b9c6 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -6447,7 +6447,9 @@ qemu-kvm -net nic,model=? /dev/null
+ &lt;devices&gt;
+   &lt;!-- USB serial port --&gt;
+   &lt;serial type='pty'&gt;
+-    &lt;target type='usb-serial' port='0'/&gt;
++    &lt;target type='usb-serial' port='0'&gt;
++      &lt;model name='usb-serial'/&gt;
++    &lt;/target&gt;
+     &lt;address type='usb' bus='0' port='1'/&gt;
+   &lt;/serial&gt;
+ &lt;/devices&gt;
+@@ -6463,6 +6465,16 @@ qemu-kvm -net nic,model=? /dev/null
+       is available).
+     </p>
+ 
++    <p>
++      <span class="since">Since 3.10.0</span>, the <code>target</code>
++      element can have an optional <code>model</code> subelement;
++      valid values for its <code>name</code> attribute are:
++      <code>isa-serial</code> (usable with the <code>isa-serial</code> target
++      type); <code>usb-serial</code> (usable with the <code>usb-serial</code>
++      target type); <code>pci-serial</code>
++      (usable with the <code>pci-serial</code> target type).
++    </p>
++
+     <p>
+       If any of the attributes is not specified by the user, libvirt will
+       choose a value suitable for most users.
+@@ -6489,7 +6501,7 @@ qemu-kvm -net nic,model=? /dev/null
+   &lt;!-- Serial console --&gt;
+   &lt;console type='pty'&gt;
+     &lt;source path='/dev/pts/2'/&gt;
+-    &lt;target type='serial' port='0'/&gt;
++   &lt;target type='serial' port='0'/&gt;
+   &lt;/console&gt;
+ &lt;/devices&gt;
+ ...</pre>
+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
+index 367861c1ea..3630e539e6 100644
+--- a/docs/schemas/domaincommon.rng
++++ b/docs/schemas/domaincommon.rng
+@@ -3575,6 +3575,18 @@
+     </attribute>
+   </define>
+ 
++  <define name='qemucdevSerialTgtModel'>
++    <element name='model'>
++      <attribute name='name'>
++        <choice>
++          <value>isa-serial</value>
++          <value>usb-serial</value>
++          <value>pci-serial</value>
++        </choice>
++      </attribute>
++    </element>
++  </define>
++
+   <define  name="qemucdevTgtDef">
+     <element name="target">
+       <interleave>
+@@ -3589,6 +3601,9 @@
+         <optional>
+           <attribute name="port"/>
+         </optional>
++        <optional>
++          <ref name="qemucdevSerialTgtModel"/>
++        </optional>
+       </interleave>
+     </element>
+   </define>
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 44d9bbe01d..692b9d9414 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -465,6 +465,14 @@ VIR_ENUM_IMPL(virDomainChrConsoleTarget,
+               "sclp",
+               "sclplm")
+ 
++VIR_ENUM_IMPL(virDomainChrSerialTargetModel,
++              VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST,
++              "none",
++              "isa-serial",
++              "usb-serial",
++              "pci-serial",
++);
++
+ VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST,
+               "parallel",
+               "serial",
+@@ -11530,14 +11538,42 @@ virDomainChrTargetTypeFromString(int devtype,
+     return ret;
+ }
+ 
++static int
++virDomainChrTargetModelFromString(int devtype,
++                                  const char *targetModel)
++{
++    int ret = -1;
++
++    if (!targetModel)
++        return 0;
++
++    switch ((virDomainChrDeviceType) devtype) {
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
++        ret = virDomainChrSerialTargetModelTypeFromString(targetModel);
++        break;
++
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
++        /* Target model not supported yet */
++        ret = 0;
++        break;
++    }
++
++    return ret;
++}
++
+ static int
+ virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
+                               xmlNodePtr cur,
+                               unsigned int flags)
+ {
+     int ret = -1;
++    xmlNodePtr child;
+     unsigned int port;
+     char *targetType = virXMLPropString(cur, "type");
++    char *targetModel = NULL;
+     char *addrStr = NULL;
+     char *portStr = NULL;
+     char *stateStr = NULL;
+@@ -11551,6 +11587,24 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
+         goto error;
+     }
+ 
++    child = cur->children;
++    while (child != NULL) {
++        if (child->type == XML_ELEMENT_NODE &&
++            virXMLNodeNameEqual(child, "model")) {
++            targetModel = virXMLPropString(child, "name");
++        }
++        child = child->next;
++    }
++
++    if ((def->targetModel =
++         virDomainChrTargetModelFromString(def->deviceType,
++                                           targetModel)) < 0) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("unknown target model '%s' specified for character device"),
++                       targetModel);
++        goto error;
++    }
++
+     switch (def->deviceType) {
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
+         switch (def->targetType) {
+@@ -11639,6 +11693,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
+     ret = 0;
+  error:
+     VIR_FREE(targetType);
++    VIR_FREE(targetModel);
+     VIR_FREE(addrStr);
+     VIR_FREE(portStr);
+     VIR_FREE(stateStr);
+@@ -24019,8 +24074,23 @@ virDomainChrTargetDefFormat(virBufferPtr buf,
+         }
+ 
+         virBufferAsprintf(buf,
+-                          "port='%d'/>\n",
++                          "port='%d'",
+                           def->target.port);
++
++        if (def->targetModel != VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE) {
++            virBufferAddLit(buf, ">\n");
++
++            virBufferAdjustIndent(buf, 2);
++            virBufferAsprintf(buf,
++                              "<model name='%s'/>\n",
++                              virDomainChrSerialTargetModelTypeToString(def->targetModel));
++            virBufferAdjustIndent(buf, -2);
++
++            virBufferAddLit(buf, "</target>\n");
++        } else {
++            virBufferAddLit(buf, "/>\n");
++        }
++
+         break;
+ 
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index bbb056cf21..9dfe9388cd 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -1104,6 +1104,17 @@ typedef enum {
+     VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
+ } virDomainChrConsoleTargetType;
+ 
++typedef enum {
++    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE = 0,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL,
++
++    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
++} virDomainChrSerialTargetModel;
++
++VIR_ENUM_DECL(virDomainChrSerialTargetModel);
++
+ typedef enum {
+     VIR_DOMAIN_CHR_TYPE_NULL,
+     VIR_DOMAIN_CHR_TYPE_VC,
+@@ -1202,6 +1213,7 @@ struct _virDomainChrDef {
+     int targetType; /* enum virDomainChrConsoleTargetType ||
+                        enum virDomainChrChannelTargetType ||
+                        enum virDomainChrSerialTargetType according to deviceType */
++    int targetModel; /* enum virDomainChrSerialTargetModel */
+ 
+     union {
+         int port; /* parallel, serial, console */
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Pass-xmlopt-to-virDomainSnapshotDefFormat.patch b/SOURCES/libvirt-conf-Pass-xmlopt-to-virDomainSnapshotDefFormat.patch
deleted file mode 100644
index d546c53..0000000
--- a/SOURCES/libvirt-conf-Pass-xmlopt-to-virDomainSnapshotDefFormat.patch
+++ /dev/null
@@ -1,251 +0,0 @@
-From 49f9421cddc176e39cbb062f26e80ec93341ef0d Mon Sep 17 00:00:00 2001
-Message-Id: <49f9421cddc176e39cbb062f26e80ec93341ef0d@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 2 Jun 2017 00:27:33 +0200
-Subject: [PATCH] conf: Pass xmlopt to virDomainSnapshotDefFormat
-
-This will be used later when a save cookie will become part of the
-snapshot XML using new driver specific parser/formatter functions.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 957cd268a98043fe061227a8e829c622a6fb4b86)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/snapshot_conf.c          |  1 +
- src/conf/snapshot_conf.h          |  1 +
- src/esx/esx_driver.c              |  2 +-
- src/qemu/qemu_domain.c            |  4 +++-
- src/qemu/qemu_domain.h            |  1 +
- src/qemu/qemu_driver.c            | 16 ++++++++++++----
- src/test/test_driver.c            |  1 +
- src/vbox/vbox_common.c            |  4 ++--
- src/vz/vz_driver.c                |  1 +
- tests/domainsnapshotxml2xmltest.c |  1 +
- 10 files changed, 24 insertions(+), 8 deletions(-)
-
-diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
-index 7daa9b22ad..e3bba985d7 100644
---- a/src/conf/snapshot_conf.c
-+++ b/src/conf/snapshot_conf.c
-@@ -691,6 +691,7 @@ char *
- virDomainSnapshotDefFormat(const char *domain_uuid,
-                            virDomainSnapshotDefPtr def,
-                            virCapsPtr caps,
-+                           virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
-                            unsigned int flags,
-                            int internal)
- {
-diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
-index da904f9460..2ce526fa6b 100644
---- a/src/conf/snapshot_conf.h
-+++ b/src/conf/snapshot_conf.h
-@@ -114,6 +114,7 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
- char *virDomainSnapshotDefFormat(const char *domain_uuid,
-                                  virDomainSnapshotDefPtr def,
-                                  virCapsPtr caps,
-+                                 virDomainXMLOptionPtr xmlopt,
-                                  unsigned int flags,
-                                  int internal);
- int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot,
-diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
-index 166d4bcfcc..c4e1f58a0b 100644
---- a/src/esx/esx_driver.c
-+++ b/src/esx/esx_driver.c
-@@ -4282,7 +4282,7 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
- 
-     virUUIDFormat(snapshot->domain->uuid, uuid_string);
- 
--    xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps,
-+    xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps, priv->xmlopt,
-                                      virDomainDefFormatConvertXMLFlags(flags),
-                                      0);
- 
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 11be085801..09903bdd5f 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -4794,6 +4794,7 @@ int
- qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
-                                 virDomainSnapshotObjPtr snapshot,
-                                 virCapsPtr caps,
-+                                virDomainXMLOptionPtr xmlopt,
-                                 char *snapshotDir)
- {
-     char *newxml = NULL;
-@@ -4804,7 +4805,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
- 
-     virUUIDFormat(vm->def->uuid, uuidstr);
-     newxml = virDomainSnapshotDefFormat(
--        uuidstr, snapshot->def, caps,
-+        uuidstr, snapshot->def, caps, xmlopt,
-         virDomainDefFormatConvertXMLFlags(QEMU_DOMAIN_FORMAT_LIVE_FLAGS),
-         1);
-     if (newxml == NULL)
-@@ -4965,6 +4966,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
-             } else {
-                 parentsnap->def->current = true;
-                 if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, driver->caps,
-+                                                    driver->xmlopt,
-                                                     cfg->snapshotDir) < 0) {
-                     VIR_WARN("failed to set parent snapshot '%s' as current",
-                              snap->def->parent);
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 2994398a9e..4db92fac8a 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -557,6 +557,7 @@ const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
- int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
-                                     virDomainSnapshotObjPtr snapshot,
-                                     virCapsPtr caps,
-+                                    virDomainXMLOptionPtr xmlopt,
-                                     char *snapshotDir);
- 
- int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 354329fe64..2688c3eec7 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -14650,7 +14650,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
-         if (update_current) {
-             vm->current_snapshot->def->current = false;
-             if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
--                                                driver->caps,
-+                                                driver->caps, driver->xmlopt,
-                                                 cfg->snapshotDir) < 0)
-                 goto endjob;
-             vm->current_snapshot = NULL;
-@@ -14700,6 +14700,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
-  endjob:
-     if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
-         if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
-+                                            driver->xmlopt,
-                                             cfg->snapshotDir) < 0) {
-             /* if writing of metadata fails, error out rather than trying
-              * to silently carry on without completing the snapshot */
-@@ -15037,7 +15038,8 @@ qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
- 
-     virUUIDFormat(snapshot->domain->uuid, uuidstr);
- 
--    xml = virDomainSnapshotDefFormat(uuidstr, snap->def, driver->caps,
-+    xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
-+                                     driver->caps, driver->xmlopt,
-                                      virDomainDefFormatConvertXMLFlags(flags),
-                                      0);
- 
-@@ -15219,7 +15221,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-     if (vm->current_snapshot) {
-         vm->current_snapshot->def->current = false;
-         if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
--                                            driver->caps, cfg->snapshotDir) < 0)
-+                                            driver->caps, driver->xmlopt,
-+                                            cfg->snapshotDir) < 0)
-             goto endjob;
-         vm->current_snapshot = NULL;
-         /* XXX Should we restore vm->current_snapshot after this point
-@@ -15459,6 +15462,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-  cleanup:
-     if (ret == 0) {
-         if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
-+                                            driver->xmlopt,
-                                             cfg->snapshotDir) < 0)
-             ret = -1;
-         else
-@@ -15495,6 +15499,7 @@ struct _virQEMUSnapReparent {
-     virDomainSnapshotObjPtr parent;
-     virDomainObjPtr vm;
-     virCapsPtr caps;
-+    virDomainXMLOptionPtr xmlopt;
-     int err;
-     virDomainSnapshotObjPtr last;
- };
-@@ -15523,7 +15528,8 @@ qemuDomainSnapshotReparentChildren(void *payload,
-     if (!snap->sibling)
-         rep->last = snap;
- 
--    rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap, rep->caps,
-+    rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap,
-+                                               rep->caps, rep->xmlopt,
-                                                rep->cfg->snapshotDir);
-     return 0;
- }
-@@ -15594,6 +15600,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
-             if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) {
-                 snap->def->current = true;
-                 if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps,
-+                                                    driver->xmlopt,
-                                                     cfg->snapshotDir) < 0) {
-                     virReportError(VIR_ERR_INTERNAL_ERROR,
-                                    _("failed to set snapshot '%s' as current"),
-@@ -15611,6 +15618,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
-         rep.err = 0;
-         rep.last = NULL;
-         rep.caps = driver->caps;
-+        rep.xmlopt = driver->xmlopt;
-         virDomainSnapshotForEachChild(snap,
-                                       qemuDomainSnapshotReparentChildren,
-                                       &rep);
-diff --git a/src/test/test_driver.c b/src/test/test_driver.c
-index 39df646260..c8085dd797 100644
---- a/src/test/test_driver.c
-+++ b/src/test/test_driver.c
-@@ -6348,6 +6348,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
-     virUUIDFormat(snapshot->domain->uuid, uuidstr);
- 
-     xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->caps,
-+                                     privconn->xmlopt,
-                                      virDomainDefFormatConvertXMLFlags(flags),
-                                      0);
- 
-diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
-index dcc64b579c..c739031660 100644
---- a/src/vbox/vbox_common.c
-+++ b/src/vbox/vbox_common.c
-@@ -5115,7 +5115,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
-         VIR_FREE(currentSnapshotXmlFilePath);
-         if (virAsprintf(&currentSnapshotXmlFilePath, "%s%s.xml", machineLocationPath, snapshotMachineDesc->currentSnapshot) < 0)
-             goto cleanup;
--        char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, data->caps, VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
-+        char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, data->caps, data->xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
-         if (snapshotContent == NULL) {
-             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                            _("Unable to get snapshot content"));
-@@ -6037,7 +6037,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
- 
-     virUUIDFormat(dom->uuid, uuidstr);
-     memcpy(def->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
--    ret = virDomainSnapshotDefFormat(uuidstr, def, data->caps,
-+    ret = virDomainSnapshotDefFormat(uuidstr, def, data->caps, data->xmlopt,
-                                       virDomainDefFormatConvertXMLFlags(flags),
-                                       0);
- 
-diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
-index 26c4f48459..f0b6722a6e 100644
---- a/src/vz/vz_driver.c
-+++ b/src/vz/vz_driver.c
-@@ -2309,6 +2309,7 @@ vzDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, unsigned int flags)
-     virUUIDFormat(snapshot->domain->uuid, uuidstr);
- 
-     xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->driver->caps,
-+                                     privconn->driver->xmlopt,
-                                      virDomainDefFormatConvertXMLFlags(flags),
-                                      0);
- 
-diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
-index f5fec47520..df204f9f16 100644
---- a/tests/domainsnapshotxml2xmltest.c
-+++ b/tests/domainsnapshotxml2xmltest.c
-@@ -101,6 +101,7 @@ testCompareXMLToXMLFiles(const char *inxml,
-         goto cleanup;
- 
-     if (!(actual = virDomainSnapshotDefFormat(uuid, def, driver.caps,
-+                                              driver.xmlopt,
-                                               VIR_DOMAIN_DEF_FORMAT_SECURE,
-                                               internal)))
-         goto cleanup;
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-conf-Properly-parse-backingStore.patch b/SOURCES/libvirt-conf-Properly-parse-backingStore.patch
new file mode 100644
index 0000000..5e9b08e
--- /dev/null
+++ b/SOURCES/libvirt-conf-Properly-parse-backingStore.patch
@@ -0,0 +1,200 @@
+From fee89d5de8520422225dc06fa95cc2dad66d7ebe Mon Sep 17 00:00:00 2001
+Message-Id: <fee89d5de8520422225dc06fa95cc2dad66d7ebe@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Mon, 13 Nov 2017 13:25:01 +0100
+Subject: [PATCH] conf: Properly parse <backingStore/>
+
+The terminator would not be parsed properly since the XPath selector was
+looking for an populated element, and also the code did not bother
+assigning the terminating virStorageSourcePtr to the backingStore
+property of the parent.
+
+Some tests would catch it if there wasn't bigger fallout from the change
+to backing store termination in a693fdba0111. Fix them properly now.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1509110
+(cherry picked from commit 19448a2561699807c075e071a45df292efd01f6b)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c                                 | 18 ++++++++----------
+ ...base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml |  1 +
+ .../qemuxml2xmlout-disk-active-commit.xml              |  1 +
+ .../qemuxml2xmlout-disk-backing-chains-active.xml      |  3 +++
+ .../qemuxml2xmlout-disk-mirror-active.xml              |  4 ++++
+ .../qemuxml2xmlout-disk-mirror-old.xml                 |  4 ++++
+ .../qemuxml2xmlout-seclabel-static-labelskip.xml       |  1 +
+ 7 files changed, 22 insertions(+), 10 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 27cfecffda..3b337d1a64 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -8539,16 +8539,7 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
+     char *idx = NULL;
+     int ret = -1;
+ 
+-    if (!(ctxt->node = virXPathNode("./backingStore[*]", ctxt))) {
+-        ret = 0;
+-        goto cleanup;
+-    }
+-
+-    if (!(type = virXMLPropString(ctxt->node, "type"))) {
+-        /* terminator does not have a type */
+-        if (VIR_ALLOC(backingStore) < 0)
+-            goto cleanup;
+-
++    if (!(ctxt->node = virXPathNode("./backingStore", ctxt))) {
+         ret = 0;
+         goto cleanup;
+     }
+@@ -8556,6 +8547,13 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
+     if (VIR_ALLOC(backingStore) < 0)
+         goto cleanup;
+ 
++    /* terminator does not have a type */
++    if (!(type = virXMLPropString(ctxt->node, "type"))) {
++        VIR_STEAL_PTR(src->backingStore, backingStore);
++        ret = 0;
++        goto cleanup;
++    }
++
+     if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
+         (idx = virXMLPropString(ctxt->node, "index")) &&
+         virStrToLong_uip(idx, NULL, 10, &backingStore->id) < 0) {
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
+index 9482b6794a..16caeb3542 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
+@@ -22,6 +22,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='sdf' bus='scsi'/>
+       <readonly/>
+       <shareable/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml
+index 5766e4aea8..cc26af1096 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml
+@@ -20,6 +20,7 @@
+       <backingStore type='block' index='1'>
+         <format type='raw'/>
+         <source dev='/dev/HostVG/QEMUGuest1'/>
++        <backingStore/>
+       </backingStore>
+       <mirror type='block' job='active-commit'>
+         <format type='raw'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml
+index 828defcc25..d1fd2442c3 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml
+@@ -49,6 +49,7 @@
+                 <backingStore type='file' index='6'>
+                   <format type='raw'/>
+                   <source file='/tmp/Fedora-17-x86_64-Live-KDE.iso'/>
++                  <backingStore/>
+                 </backingStore>
+               </backingStore>
+             </backingStore>
+@@ -63,6 +64,7 @@
+       <source protocol='gluster' name='Volume1/Image'>
+         <host name='example.org' port='6000'/>
+       </source>
++      <backingStore/>
+       <target dev='vdc' bus='virtio'/>
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+     </disk>
+@@ -79,6 +81,7 @@
+       <backingStore type='file' index='1'>
+         <format type='qcow2'/>
+         <source file='/tmp/image.qcow'/>
++        <backingStore/>
+       </backingStore>
+       <target dev='vdd' bus='virtio'/>
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml
+index 252bde3389..c1e8a33ec1 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml
+@@ -16,6 +16,7 @@
+     <emulator>/usr/bin/qemu-system-i686</emulator>
+     <disk type='block' device='disk'>
+       <source dev='/dev/HostVG/QEMUGuest1'/>
++      <backingStore/>
+       <mirror type='block' job='copy' ready='yes'>
+         <source dev='/dev/HostVG/QEMUGuest1Copy'/>
+       </mirror>
+@@ -24,12 +25,14 @@
+     </disk>
+     <disk type='block' device='cdrom'>
+       <source dev='/dev/HostVG/QEMUGuest2'/>
++      <backingStore/>
+       <target dev='hdc' bus='ide'/>
+       <readonly/>
+       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+     </disk>
+     <disk type='file' device='disk'>
+       <source file='/tmp/data.img'/>
++      <backingStore/>
+       <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'>
+         <format type='qcow2'/>
+         <source file='/tmp/copy.img'/>
+@@ -39,6 +42,7 @@
+     </disk>
+     <disk type='file' device='disk'>
+       <source file='/tmp/logs.img'/>
++      <backingStore/>
+       <mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'>
+         <format type='qcow2'/>
+         <source file='/tmp/logcopy.img'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
+index f4bd39a580..e390bc02f2 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
+@@ -16,6 +16,7 @@
+     <emulator>/usr/bin/qemu-system-i686</emulator>
+     <disk type='block' device='disk'>
+       <source dev='/dev/HostVG/QEMUGuest1'/>
++      <backingStore/>
+       <mirror type='file' file='/dev/HostVG/QEMUGuest1Copy' job='copy' ready='yes'>
+         <source file='/dev/HostVG/QEMUGuest1Copy'/>
+       </mirror>
+@@ -24,12 +25,14 @@
+     </disk>
+     <disk type='block' device='cdrom'>
+       <source dev='/dev/HostVG/QEMUGuest2'/>
++      <backingStore/>
+       <target dev='hdc' bus='ide'/>
+       <readonly/>
+       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+     </disk>
+     <disk type='file' device='disk'>
+       <source file='/tmp/data.img'/>
++      <backingStore/>
+       <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'>
+         <format type='qcow2'/>
+         <source file='/tmp/copy.img'/>
+@@ -39,6 +42,7 @@
+     </disk>
+     <disk type='file' device='disk'>
+       <source file='/tmp/logs.img'/>
++      <backingStore/>
+       <target dev='vdb' bus='virtio'/>
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+     </disk>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml
+index 91f573db7d..d37b950cbf 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml
+@@ -18,6 +18,7 @@
+       <source dev='/dev/HostVG/QEMUGuest1'>
+         <seclabel model='selinux' labelskip='yes'/>
+       </source>
++      <backingStore/>
+       <target dev='hda' bus='ide'/>
+       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+     </disk>
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-conf-Refactor-virCPUDefParseXML.patch b/SOURCES/libvirt-conf-Refactor-virCPUDefParseXML.patch
deleted file mode 100644
index eaa2ab7..0000000
--- a/SOURCES/libvirt-conf-Refactor-virCPUDefParseXML.patch
+++ /dev/null
@@ -1,413 +0,0 @@
-From 7bdac52dd6979f76f9a75a404a76e79f7da11a06 Mon Sep 17 00:00:00 2001
-Message-Id: <7bdac52dd6979f76f9a75a404a76e79f7da11a06@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 23 May 2017 09:29:36 +0200
-Subject: [PATCH] conf: Refactor virCPUDefParseXML
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 702013f3b3ad8bd28c326058e2dd9ea8afbd1e61)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/cpu_conf.c    | 109 +++++++++++++++++++++++++++----------------------
- src/conf/cpu_conf.h    |   9 ++--
- src/conf/domain_conf.c |  12 +-----
- src/cpu/cpu.c          |   5 +--
- tests/cputest.c        |   5 +--
- 5 files changed, 72 insertions(+), 68 deletions(-)
-
-diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
-index ffb2e83d67..da40e9ba97 100644
---- a/src/conf/cpu_conf.c
-+++ b/src/conf/cpu_conf.c
-@@ -245,12 +245,25 @@ virCPUDefCopy(const virCPUDef *cpu)
- }
- 
- 
--virCPUDefPtr
--virCPUDefParseXML(xmlNodePtr node,
--                  xmlXPathContextPtr ctxt,
--                  virCPUType type)
-+/*
-+ * Parses CPU definition XML from a node pointed to by @xpath. If @xpath is
-+ * NULL, the current node of @ctxt is used (i.e., it is a shortcut to ".").
-+ *
-+ * Missing <cpu> element in the XML document is not considered an error unless
-+ * @xpath is NULL in which case the function expects it was provided with a
-+ * valid <cpu> element already. In other words, the function returns success
-+ * and sets @cpu to NULL if @xpath is not NULL and the node pointed to by
-+ * @xpath is not found.
-+ *
-+ * Returns 0 on success, -1 on error.
-+ */
-+int
-+virCPUDefParseXML(xmlXPathContextPtr ctxt,
-+                  const char *xpath,
-+                  virCPUType type,
-+                  virCPUDefPtr *cpu)
- {
--    virCPUDefPtr def;
-+    virCPUDefPtr def = NULL;
-     xmlNodePtr *nodes = NULL;
-     xmlNodePtr oldnode = ctxt->node;
-     int n;
-@@ -258,15 +271,23 @@ virCPUDefParseXML(xmlNodePtr node,
-     char *cpuMode;
-     char *fallback = NULL;
-     char *vendor_id = NULL;
-+    int ret = -1;
- 
--    if (!xmlStrEqual(node->name, BAD_CAST "cpu")) {
-+    *cpu = NULL;
-+
-+    if (xpath && !(ctxt->node = virXPathNode(xpath, ctxt))) {
-+        ret = 0;
-+        goto cleanup;
-+    }
-+
-+    if (!xmlStrEqual(ctxt->node->name, BAD_CAST "cpu")) {
-         virReportError(VIR_ERR_XML_ERROR, "%s",
-                        _("XML does not contain expected 'cpu' element"));
--        return NULL;
-+        goto cleanup;
-     }
- 
-     if (VIR_ALLOC(def) < 0)
--        return NULL;
-+        goto cleanup;
- 
-     if (type == VIR_CPU_TYPE_AUTO) {
-         if (virXPathBoolean("boolean(./arch)", ctxt)) {
-@@ -274,7 +295,7 @@ virCPUDefParseXML(xmlNodePtr node,
-                 virReportError(VIR_ERR_XML_ERROR, "%s",
-                                _("'arch' element cannot be used inside 'cpu'"
-                                  " element with 'match' attribute'"));
--                goto error;
-+                goto cleanup;
-             }
-             def->type = VIR_CPU_TYPE_HOST;
-         } else {
-@@ -284,12 +305,12 @@ virCPUDefParseXML(xmlNodePtr node,
-         def->type = type;
-     }
- 
--    if ((cpuMode = virXMLPropString(node, "mode"))) {
-+    if ((cpuMode = virXMLPropString(ctxt->node, "mode"))) {
-         if (def->type == VIR_CPU_TYPE_HOST) {
-             VIR_FREE(cpuMode);
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                            _("Attribute mode is only allowed for guest CPU"));
--            goto error;
-+            goto cleanup;
-         } else {
-             def->mode = virCPUModeTypeFromString(cpuMode);
- 
-@@ -298,7 +319,7 @@ virCPUDefParseXML(xmlNodePtr node,
-                                _("Invalid mode attribute '%s'"),
-                                cpuMode);
-                 VIR_FREE(cpuMode);
--                goto error;
-+                goto cleanup;
-             }
-             VIR_FREE(cpuMode);
-         }
-@@ -310,7 +331,7 @@ virCPUDefParseXML(xmlNodePtr node,
-     }
- 
-     if (def->type == VIR_CPU_TYPE_GUEST) {
--        char *match = virXMLPropString(node, "match");
-+        char *match = virXMLPropString(ctxt->node, "match");
-         char *check;
- 
-         if (!match) {
-@@ -326,11 +347,11 @@ virCPUDefParseXML(xmlNodePtr node,
-                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                                _("Invalid match attribute for CPU "
-                                  "specification"));
--                goto error;
-+                goto cleanup;
-             }
-         }
- 
--        if ((check = virXMLPropString(node, "check"))) {
-+        if ((check = virXMLPropString(ctxt->node, "check"))) {
-             int value = virCPUCheckTypeFromString(check);
-             VIR_FREE(check);
- 
-@@ -338,7 +359,7 @@ virCPUDefParseXML(xmlNodePtr node,
-                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                                _("Invalid check attribute for CPU "
-                                  "specification"));
--                goto error;
-+                goto cleanup;
-             }
-             def->check = value;
-         }
-@@ -349,13 +370,13 @@ virCPUDefParseXML(xmlNodePtr node,
-         if (!arch) {
-             virReportError(VIR_ERR_XML_ERROR, "%s",
-                            _("Missing CPU architecture"));
--            goto error;
-+            goto cleanup;
-         }
-         if ((def->arch = virArchFromString(arch)) == VIR_ARCH_NONE) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                            _("Unknown architecture %s"), arch);
-             VIR_FREE(arch);
--            goto error;
-+            goto cleanup;
-         }
-         VIR_FREE(arch);
-     }
-@@ -364,7 +385,7 @@ virCPUDefParseXML(xmlNodePtr node,
-         def->type == VIR_CPU_TYPE_HOST) {
-         virReportError(VIR_ERR_XML_ERROR, "%s",
-                         _("Missing CPU model name"));
--        goto error;
-+        goto cleanup;
-     }
- 
-     if (def->type == VIR_CPU_TYPE_GUEST &&
-@@ -374,7 +395,7 @@ virCPUDefParseXML(xmlNodePtr node,
-             if ((def->fallback = virCPUFallbackTypeFromString(fallback)) < 0) {
-                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                                _("Invalid fallback attribute"));
--                goto error;
-+                goto cleanup;
-             }
-         }
- 
-@@ -384,14 +405,14 @@ virCPUDefParseXML(xmlNodePtr node,
-                 virReportError(VIR_ERR_XML_ERROR,
-                                _("vendor_id must be exactly %d characters long"),
-                                VIR_CPU_VENDOR_ID_LENGTH);
--                goto error;
-+                goto cleanup;
-             }
- 
-             /* ensure that the string can be passed to qemu*/
-             if (strchr(vendor_id, ',')) {
-                     virReportError(VIR_ERR_XML_ERROR, "%s",
-                                    _("vendor id is invalid"));
--                    goto error;
-+                    goto cleanup;
-             }
- 
-             def->vendor_id = vendor_id;
-@@ -403,61 +424,54 @@ virCPUDefParseXML(xmlNodePtr node,
-     if (def->vendor && !def->model) {
-         virReportError(VIR_ERR_XML_ERROR, "%s",
-                        _("CPU vendor specified without CPU model"));
--        goto error;
-+        goto cleanup;
-     }
- 
-     if (virXPathNode("./topology[1]", ctxt)) {
--        int ret;
-         unsigned long ul;
- 
--        ret = virXPathULong("string(./topology[1]/@sockets)",
--                            ctxt, &ul);
--        if (ret < 0) {
-+        if (virXPathULong("string(./topology[1]/@sockets)", ctxt, &ul) < 0) {
-             virReportError(VIR_ERR_XML_ERROR, "%s",
-                            _("Missing 'sockets' attribute in CPU topology"));
--            goto error;
-+            goto cleanup;
-         }
-         def->sockets = (unsigned int) ul;
- 
--        ret = virXPathULong("string(./topology[1]/@cores)",
--                            ctxt, &ul);
--        if (ret < 0) {
-+        if (virXPathULong("string(./topology[1]/@cores)", ctxt, &ul) < 0) {
-             virReportError(VIR_ERR_XML_ERROR, "%s",
-                            _("Missing 'cores' attribute in CPU topology"));
--            goto error;
-+            goto cleanup;
-         }
-         def->cores = (unsigned int) ul;
- 
--        ret = virXPathULong("string(./topology[1]/@threads)",
--                            ctxt, &ul);
--        if (ret < 0) {
-+        if (virXPathULong("string(./topology[1]/@threads)", ctxt, &ul) < 0) {
-             virReportError(VIR_ERR_XML_ERROR, "%s",
-                            _("Missing 'threads' attribute in CPU topology"));
--            goto error;
-+            goto cleanup;
-         }
-         def->threads = (unsigned int) ul;
- 
-         if (!def->sockets || !def->cores || !def->threads) {
-             virReportError(VIR_ERR_XML_ERROR, "%s",
-                            _("Invalid CPU topology"));
--            goto error;
-+            goto cleanup;
-         }
-     }
- 
-     if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) < 0)
--        goto error;
-+        goto cleanup;
- 
-     if (n > 0) {
-         if (!def->model && def->mode == VIR_CPU_MODE_CUSTOM) {
-             virReportError(VIR_ERR_XML_ERROR, "%s",
-                            _("Non-empty feature list specified without "
-                              "CPU model"));
--            goto error;
-+            goto cleanup;
-         }
- 
-         if (VIR_RESIZE_N(def->features, def->nfeatures_max,
-                          def->nfeatures, n) < 0)
--            goto error;
-+            goto cleanup;
- 
-         def->nfeatures = n;
-     }
-@@ -480,7 +494,7 @@ virCPUDefParseXML(xmlNodePtr node,
-             if (policy < 0) {
-                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                                _("Invalid CPU feature policy"));
--                goto error;
-+                goto cleanup;
-             }
-         } else {
-             policy = -1;
-@@ -490,7 +504,7 @@ virCPUDefParseXML(xmlNodePtr node,
-             VIR_FREE(name);
-             virReportError(VIR_ERR_XML_ERROR, "%s",
-                            _("Invalid CPU feature name"));
--            goto error;
-+            goto cleanup;
-         }
- 
-         for (j = 0; j < i; j++) {
-@@ -499,7 +513,7 @@ virCPUDefParseXML(xmlNodePtr node,
-                                _("CPU feature '%s' specified more than once"),
-                                name);
-                 VIR_FREE(name);
--                goto error;
-+                goto cleanup;
-             }
-         }
- 
-@@ -542,17 +556,16 @@ virCPUDefParseXML(xmlNodePtr node,
-         def->cache->mode = mode;
-     }
- 
-+    VIR_STEAL_PTR(*cpu, def);
-+    ret = 0;
-+
-  cleanup:
-     ctxt->node = oldnode;
-     VIR_FREE(fallback);
-     VIR_FREE(vendor_id);
-     VIR_FREE(nodes);
--    return def;
--
-- error:
-     virCPUDefFree(def);
--    def = NULL;
--    goto cleanup;
-+    return ret;
- }
- 
- 
-diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
-index b0d891552a..b44974f47e 100644
---- a/src/conf/cpu_conf.h
-+++ b/src/conf/cpu_conf.h
-@@ -182,10 +182,11 @@ virCPUDefCopy(const virCPUDef *cpu);
- virCPUDefPtr
- virCPUDefCopyWithoutModel(const virCPUDef *cpu);
- 
--virCPUDefPtr
--virCPUDefParseXML(xmlNodePtr node,
--                  xmlXPathContextPtr ctxt,
--                  virCPUType mode);
-+int
-+virCPUDefParseXML(xmlXPathContextPtr ctxt,
-+                  const char *xpath,
-+                  virCPUType mode,
-+                  virCPUDefPtr *cpu);
- 
- bool
- virCPUDefIsEqual(virCPUDefPtr src,
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 2197330a22..395dcc0531 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -17418,16 +17418,8 @@ virDomainDefParseXML(xmlDocPtr xml,
-     }
-     VIR_FREE(nodes);
- 
--    /* analysis of cpu handling */
--    if ((node = virXPathNode("./cpu[1]", ctxt)) != NULL) {
--        xmlNodePtr oldnode = ctxt->node;
--        ctxt->node = node;
--        def->cpu = virCPUDefParseXML(node, ctxt, VIR_CPU_TYPE_GUEST);
--        ctxt->node = oldnode;
--
--        if (def->cpu == NULL)
--            goto error;
--    }
-+    if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &def->cpu) < 0)
-+        goto error;
- 
-     if (virDomainNumaDefCPUParseXML(def->numa, ctxt) < 0)
-         goto error;
-diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
-index 702b14dbb7..96160901e1 100644
---- a/src/cpu/cpu.c
-+++ b/src/cpu/cpu.c
-@@ -130,7 +130,7 @@ virCPUCompareXML(virArch arch,
-     if (!(doc = virXMLParseStringCtxt(xml, _("(CPU_definition)"), &ctxt)))
-         goto cleanup;
- 
--    if (!(cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO)))
-+    if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu) < 0)
-         goto cleanup;
- 
-     ret = virCPUCompare(arch, host, cpu, failIncompatible);
-@@ -562,8 +562,7 @@ cpuBaselineXML(const char **xmlCPUs,
-         if (!(doc = virXMLParseStringCtxt(xmlCPUs[i], _("(CPU_definition)"), &ctxt)))
-             goto error;
- 
--        cpus[i] = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_HOST);
--        if (cpus[i] == NULL)
-+        if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i]) < 0)
-             goto error;
- 
-         xmlXPathFreeContext(ctxt);
-diff --git a/tests/cputest.c b/tests/cputest.c
-index efa891dc18..97b34de9ed 100644
---- a/tests/cputest.c
-+++ b/tests/cputest.c
-@@ -88,7 +88,7 @@ cpuTestLoadXML(virArch arch, const char *name)
-     if (!(doc = virXMLParseFileCtxt(xml, &ctxt)))
-         goto cleanup;
- 
--    cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO);
-+    virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu);
- 
-  cleanup:
-     xmlXPathFreeContext(ctxt);
-@@ -126,8 +126,7 @@ cpuTestLoadMultiXML(virArch arch,
- 
-     for (i = 0; i < n; i++) {
-         ctxt->node = nodes[i];
--        cpus[i] = virCPUDefParseXML(nodes[i], ctxt, VIR_CPU_TYPE_HOST);
--        if (!cpus[i])
-+        if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i]) < 0)
-             goto cleanup_cpus;
-     }
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-conf-Remove-ATTRIBUTE_FALLTHROUGH-from-virDomainChrTargetDefFormat.patch b/SOURCES/libvirt-conf-Remove-ATTRIBUTE_FALLTHROUGH-from-virDomainChrTargetDefFormat.patch
new file mode 100644
index 0000000..c95b076
--- /dev/null
+++ b/SOURCES/libvirt-conf-Remove-ATTRIBUTE_FALLTHROUGH-from-virDomainChrTargetDefFormat.patch
@@ -0,0 +1,55 @@
+From d91de09fa0a626e200ac0db133a6af69a0706105 Mon Sep 17 00:00:00 2001
+Message-Id: <d91de09fa0a626e200ac0db133a6af69a0706105@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:04 +0100
+Subject: [PATCH] conf: Remove ATTRIBUTE_FALLTHROUGH from
+ virDomainChrTargetDefFormat()
+
+Formatting the <target/> element for serial devices will become a
+bit more complicated later on, and leaving the fallthrough behavior
+there would do nothing but complicate it further.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 7983068fa50ea5222e62b24ea912a529994276f0)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c | 14 +++++++++-----
+ 1 file changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 2489705d6b..44d9bbe01d 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -24010,14 +24010,18 @@ virDomainChrTargetDefFormat(virBufferPtr buf,
+             return -1;
+         }
+ 
++        virBufferAddLit(buf, "<target ");
++
+         if (def->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) {
+             virBufferAsprintf(buf,
+-                              "<target type='%s' port='%d'/>\n",
+-                              targetType,
+-                              def->target.port);
+-            break;
++                              "type='%s' ",
++                              targetType);
+         }
+-        ATTRIBUTE_FALLTHROUGH;
++
++        virBufferAsprintf(buf,
++                          "port='%d'/>\n",
++                          def->target.port);
++        break;
+ 
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
+         virBufferAsprintf(buf, "<target port='%d'/>\n",
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Rename-mode-parameter-in-virCPUDefParseXML.patch b/SOURCES/libvirt-conf-Rename-mode-parameter-in-virCPUDefParseXML.patch
deleted file mode 100644
index 1c46aaf..0000000
--- a/SOURCES/libvirt-conf-Rename-mode-parameter-in-virCPUDefParseXML.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-From 46761b7fdb0707036482c98eb3a80279753df484 Mon Sep 17 00:00:00 2001
-Message-Id: <46761b7fdb0707036482c98eb3a80279753df484@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Mon, 24 Apr 2017 15:38:41 +0200
-Subject: [PATCH] conf: Rename mode parameter in virCPUDefParseXML
-
-The type of this parameter is virCPUType so calling it 'mode' is pretty
-strange, 'type' is a much better name.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit e841a41169dd726af13f29cb57fbafe658b7011a)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1428952
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/cpu_conf.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
-index b78531e60..623b1699f 100644
---- a/src/conf/cpu_conf.c
-+++ b/src/conf/cpu_conf.c
-@@ -230,7 +230,7 @@ virCPUDefCopy(const virCPUDef *cpu)
- virCPUDefPtr
- virCPUDefParseXML(xmlNodePtr node,
-                   xmlXPathContextPtr ctxt,
--                  virCPUType mode)
-+                  virCPUType type)
- {
-     virCPUDefPtr def;
-     xmlNodePtr *nodes = NULL;
-@@ -250,7 +250,7 @@ virCPUDefParseXML(xmlNodePtr node,
-     if (VIR_ALLOC(def) < 0)
-         return NULL;
- 
--    if (mode == VIR_CPU_TYPE_AUTO) {
-+    if (type == VIR_CPU_TYPE_AUTO) {
-         if (virXPathBoolean("boolean(./arch)", ctxt)) {
-             if (virXPathBoolean("boolean(./@match)", ctxt)) {
-                 virReportError(VIR_ERR_XML_ERROR, "%s",
-@@ -263,7 +263,7 @@ virCPUDefParseXML(xmlNodePtr node,
-             def->type = VIR_CPU_TYPE_GUEST;
-         }
-     } else {
--        def->type = mode;
-+        def->type = type;
-     }
- 
-     if ((cpuMode = virXMLPropString(node, "mode"))) {
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-conf-Resolve-corner-case-on-fc_host-deletion.patch b/SOURCES/libvirt-conf-Resolve-corner-case-on-fc_host-deletion.patch
deleted file mode 100644
index b5bfc3e..0000000
--- a/SOURCES/libvirt-conf-Resolve-corner-case-on-fc_host-deletion.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From 70c60798f09324a9e4d91f787cad493a1ceca5d9 Mon Sep 17 00:00:00 2001
-Message-Id: <70c60798f09324a9e4d91f787cad493a1ceca5d9@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Wed, 24 May 2017 10:27:57 -0400
-Subject: [PATCH] conf: Resolve corner case on fc_host deletion
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1420740
-
-Testing found an inventive way to cause an error at shutdown by providing the
-parent name for the fc host creation using the "same name" as the HBA. Since
-the code thus assumed the parent host name provided was the parent HBA and
-just extracted out the host number and sent that along to the vport_destroy
-this avoided checks made for equality.
-
-So just add the equality check to that path to resolve.
-
-(cherry picked from commit 2c8e30ee7e287d6490f643ccd2d7653a834e75e5)
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/node_device_conf.c | 14 +++++++++++---
- 1 file changed, 11 insertions(+), 3 deletions(-)
-
-diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
-index ac61db34c..2d0b14850 100644
---- a/src/conf/node_device_conf.c
-+++ b/src/conf/node_device_conf.c
-@@ -2300,17 +2300,25 @@ virNodeDeviceDeleteVport(virConnectPtr conn,
-         goto cleanup;
-     }
- 
-+    if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
-+        goto cleanup;
-+
-     /* If at startup time we provided a parent, then use that to
-      * get the parent_host value; otherwise, we have to determine
-      * the parent scsi_host which we did not save at startup time
-      */
-     if (fchost->parent) {
-+        /* Someone provided a parent string at startup time that
-+         * was the same as the scsi_host - meaning we have a pool
-+         * backed to an HBA, so there won't be a vHBA to delete */
-+        if (STREQ(scsi_host_name, fchost->parent)) {
-+            ret = 0;
-+            goto cleanup;
-+        }
-+
-         if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0)
-             goto cleanup;
-     } else {
--        if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
--            goto cleanup;
--
-         if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name)))
-             goto cleanup;
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-conf-Run-devicePostParse-again-for-the-first-serial-device.patch b/SOURCES/libvirt-conf-Run-devicePostParse-again-for-the-first-serial-device.patch
new file mode 100644
index 0000000..baa288e
--- /dev/null
+++ b/SOURCES/libvirt-conf-Run-devicePostParse-again-for-the-first-serial-device.patch
@@ -0,0 +1,60 @@
+From 0c9561ff6de749954395f562cbb8e3d12954566c Mon Sep 17 00:00:00 2001
+Message-Id: <0c9561ff6de749954395f562cbb8e3d12954566c@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:22:57 +0100
+Subject: [PATCH] conf: Run devicePostParse() again for the first serial device
+
+The devicePostParse() callback is invoked for all devices so that
+drivers have a chance to set their own specific values; however,
+virDomainDefAddImplicitDevices() runs *after* the devicePostParse()
+callbacks have been invoked and can add new devices, in which case
+the driver wouldn't have a chance to customize them.
+
+Work around the issue by invoking the devicePostParse() callback
+after virDomainDefAddImplicitDevices(), only for the first serial
+devices, which might have been added by it. The same was already
+happening for the first video device for the very same reason.
+
+This will become important later on, when we will change
+virDomainDefAddConsoleCompat() not to set a targetType for
+automatically added serial devices.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 2628afc143224d38e6ef8c06a8fbec1d0f69fb86)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 4b5e7c214f..41674a85af 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -4948,6 +4948,18 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
+             return -1;
+     }
+ 
++    if (def->nserials != 0) {
++        virDomainDeviceDef device = {
++            .type = VIR_DOMAIN_DEVICE_CHR,
++            .data.chr = def->serials[0],
++        };
++
++        /* serials[0] might have been added in AddImplicitDevices, after we've
++         * done the per-device post-parse */
++        if (virDomainDefPostParseDeviceIterator(def, &device, NULL, data) < 0)
++            return -1;
++    }
++
+     /* clean up possibly duplicated metadata entries */
+     virXMLNodeSanitizeNamespaces(def->metadata);
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Sort-cache-banks-in-capabilities-XML.patch b/SOURCES/libvirt-conf-Sort-cache-banks-in-capabilities-XML.patch
new file mode 100644
index 0000000..571ab1d
--- /dev/null
+++ b/SOURCES/libvirt-conf-Sort-cache-banks-in-capabilities-XML.patch
@@ -0,0 +1,67 @@
+From 6532e10f6ddec18ab70f58dc660062d369b82304 Mon Sep 17 00:00:00 2001
+Message-Id: <6532e10f6ddec18ab70f58dc660062d369b82304@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:17 +0100
+Subject: [PATCH] conf: Sort cache banks in capabilities XML
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Because the cache banks are initialized based on the order in which their
+respective directories exist on the filesystem, they can appear in different
+order.  This is here mainly for tests because the cache directory might have
+different order of children nodes and tests would fail otherwise.  It should not
+be the case with sysfs, but one can never be sure.  And this does not take
+almost any extra time, mainly because it gets initialized once per driver.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit b4698edcb0a459332b24410f59698005af37eecb)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/conf/capabilities.c | 23 +++++++++++++++++++++++
+ 1 file changed, 23 insertions(+)
+
+diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
+index 9920a675ac..1f7d8cdb31 100644
+--- a/src/conf/capabilities.c
++++ b/src/conf/capabilities.c
+@@ -1561,6 +1561,23 @@ virCapsHostCacheBankFree(virCapsHostCacheBankPtr ptr)
+     VIR_FREE(ptr);
+ }
+ 
++
++static int
++virCapsHostCacheBankSorter(const void *a,
++                           const void *b)
++{
++    virCapsHostCacheBankPtr ca = *(virCapsHostCacheBankPtr *)a;
++    virCapsHostCacheBankPtr cb = *(virCapsHostCacheBankPtr *)b;
++
++    if (ca->level < cb->level)
++        return -1;
++    if (ca->level > cb->level)
++        return 1;
++
++    return ca->id - cb->id;
++}
++
++
+ int
+ virCapabilitiesInitCaches(virCapsPtr caps)
+ {
+@@ -1700,6 +1717,12 @@ virCapabilitiesInitCaches(virCapsPtr caps)
+             goto cleanup;
+     }
+ 
++    /* Sort the array in order for the tests to be predictable.  This way we can
++     * still traverse the directory instead of guessing names (in case there is
++     * 'index1' and 'index3' but no 'index2'). */
++    qsort(caps->host.caches, caps->host.ncaches,
++          sizeof(*caps->host.caches), virCapsHostCacheBankSorter);
++
+     ret = 0;
+  cleanup:
+     VIR_FREE(type);
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-conf-Use-virResctrlInfo-in-capabilities.patch b/SOURCES/libvirt-conf-Use-virResctrlInfo-in-capabilities.patch
new file mode 100644
index 0000000..3121e3d
--- /dev/null
+++ b/SOURCES/libvirt-conf-Use-virResctrlInfo-in-capabilities.patch
@@ -0,0 +1,131 @@
+From af86f99a7745f9d54c3f4e42f58130478e6aa9f5 Mon Sep 17 00:00:00 2001
+Message-Id: <af86f99a7745f9d54c3f4e42f58130478e6aa9f5@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:26 +0100
+Subject: [PATCH] conf: Use virResctrlInfo in capabilities
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 3bbae43d8cc79ef1cd0b9a4ea2440203a0edc959)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/conf/capabilities.c | 53 ++++++++++++++++++++++++-------------------------
+ src/conf/capabilities.h |  2 ++
+ 2 files changed, 28 insertions(+), 27 deletions(-)
+
+diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
+index e93eaed2f0..edf9f54f77 100644
+--- a/src/conf/capabilities.c
++++ b/src/conf/capabilities.c
+@@ -245,6 +245,7 @@ virCapabilitiesDispose(void *object)
+     VIR_FREE(caps->host.netprefix);
+     VIR_FREE(caps->host.pagesSize);
+     virCPUDefFree(caps->host.cpu);
++    virObjectUnref(caps->host.resctrl);
+ }
+ 
+ /**
+@@ -1592,6 +1593,20 @@ virCapsHostCacheBankSorter(const void *a,
+ }
+ 
+ 
++static int
++virCapabilitiesInitResctrl(virCapsPtr caps)
++{
++    if (caps->host.resctrl)
++        return 0;
++
++    caps->host.resctrl = virResctrlInfoNew();
++    if (!caps->host.resctrl)
++        return -1;
++
++    return virResctrlGetInfo(caps->host.resctrl);
++}
++
++
+ int
+ virCapabilitiesInitCaches(virCapsPtr caps)
+ {
+@@ -1600,7 +1615,6 @@ virCapabilitiesInitCaches(virCapsPtr caps)
+     ssize_t pos = -1;
+     DIR *dirp = NULL;
+     int ret = -1;
+-    int typeret;
+     char *path = NULL;
+     char *type = NULL;
+     struct dirent *ent = NULL;
+@@ -1611,6 +1625,9 @@ virCapabilitiesInitCaches(virCapsPtr caps)
+      * lose information. */
+     const int cache_min_level = 3;
+ 
++    if (virCapabilitiesInitResctrl(caps) < 0)
++        return -1;
++
+     /* offline CPUs don't provide cache info */
+     if (virFileReadValueBitmap(&cpus, "%s/cpu/online", SYSFS_SYSTEM_PATH) < 0)
+         return -1;
+@@ -1676,32 +1693,6 @@ virCapabilitiesInitCaches(virCapsPtr caps)
+                                        SYSFS_SYSTEM_PATH, pos, ent->d_name) < 0)
+                 goto cleanup;
+ 
+-            typeret = virResctrlGetCacheControlType(bank->level);
+-            if (typeret < 0)
+-                goto cleanup;
+-
+-            if (typeret == 1) {
+-                if (virResctrlGetCacheInfo(bank->level,
+-                                           bank->size,
+-                                           VIR_CACHE_TYPE_BOTH,
+-                                           &bank->controls,
+-                                           &bank->ncontrols) < 0)
+-                    goto cleanup;
+-            } else if (typeret == 2) {
+-                if (virResctrlGetCacheInfo(bank->level,
+-                                           bank->size,
+-                                           VIR_CACHE_TYPE_CODE,
+-                                           &bank->controls,
+-                                           &bank->ncontrols) < 0)
+-                    goto cleanup;
+-                if (virResctrlGetCacheInfo(bank->level,
+-                                           bank->size,
+-                                           VIR_CACHE_TYPE_DATA,
+-                                           &bank->controls,
+-                                           &bank->ncontrols) < 0)
+-                    goto cleanup;
+-            }
+-
+             kernel_type = virCacheKernelTypeFromString(type);
+             if (kernel_type < 0) {
+                 virReportError(VIR_ERR_INTERNAL_ERROR,
+@@ -1717,6 +1708,14 @@ virCapabilitiesInitCaches(virCapsPtr caps)
+                     break;
+             }
+             if (i == caps->host.ncaches) {
++                /* If it is a new cache, then update its resctrl information. */
++                if (virResctrlInfoGetCache(caps->host.resctrl,
++                                           bank->level,
++                                           bank->size,
++                                           &bank->ncontrols,
++                                           &bank->controls) < 0)
++                    goto cleanup;
++
+                 if (VIR_APPEND_ELEMENT(caps->host.caches,
+                                        caps->host.ncaches,
+                                        bank) < 0) {
+diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
+index 27b88cb5ed..694a3590bf 100644
+--- a/src/conf/capabilities.h
++++ b/src/conf/capabilities.h
+@@ -170,6 +170,8 @@ struct _virCapsHost {
+     size_t nnumaCell_max;
+     virCapsHostNUMACellPtr *numaCell;
+ 
++    virResctrlInfoPtr resctrl;
++
+     size_t ncaches;
+     virCapsHostCacheBankPtr *caches;
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-conf-add-ABI-stability-checks-for-IOMMU-options.patch b/SOURCES/libvirt-conf-add-ABI-stability-checks-for-IOMMU-options.patch
deleted file mode 100644
index c3c59ef..0000000
--- a/SOURCES/libvirt-conf-add-ABI-stability-checks-for-IOMMU-options.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From 4383e358e2d8a85bd46936c997071c3b776fffd0 Mon Sep 17 00:00:00 2001
-Message-Id: <4383e358e2d8a85bd46936c997071c3b776fffd0@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:59 +0200
-Subject: [PATCH] conf: add ABI stability checks for IOMMU options
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-(cherry picked from commit 935d927aa881753fff30f6236eedcf9680bca638)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 26 ++++++++++++++++++++++++++
- 1 file changed, 26 insertions(+)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 7bf480f2a..370916396 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -19682,6 +19682,16 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
-         }
-     }
- 
-+    /* ioapic */
-+    if (src->ioapic != dst->ioapic) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("State of ioapic differs: "
-+                         "source: '%s', destination: '%s'"),
-+                       virDomainIOAPICTypeToString(src->ioapic),
-+                       virDomainIOAPICTypeToString(dst->ioapic));
-+        return false;
-+    }
-+
-     return true;
- }
- 
-@@ -19821,6 +19831,22 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src,
-                        virDomainIOMMUModelTypeToString(src->model));
-         return false;
-     }
-+    if (src->intremap != dst->intremap) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("Target domain IOMMU device intremap value '%s' "
-+                         "does not match source '%s'"),
-+                       virTristateSwitchTypeToString(dst->intremap),
-+                       virTristateSwitchTypeToString(src->intremap));
-+        return false;
-+    }
-+    if (src->caching_mode != dst->caching_mode) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("Target domain IOMMU device caching mode '%s' "
-+                         "does not match source '%s'"),
-+                       virTristateSwitchTypeToString(dst->caching_mode),
-+                       virTristateSwitchTypeToString(src->caching_mode));
-+        return false;
-+    }
-     return true;
- }
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-conf-add-VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP.patch b/SOURCES/libvirt-conf-add-VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP.patch
new file mode 100644
index 0000000..a1b7f82
--- /dev/null
+++ b/SOURCES/libvirt-conf-add-VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP.patch
@@ -0,0 +1,605 @@
+From f93cc7753900a7ff80a32dae2fd3337939909b86 Mon Sep 17 00:00:00 2001
+Message-Id: <f93cc7753900a7ff80a32dae2fd3337939909b86@dist-git>
+From: Pino Toscano <ptoscano@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:15 +0100
+Subject: [PATCH] conf: add VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP
+
+Introduce specific a target types with two models for the console
+devices (sclp and sclplm) used in s390 and s390x guests, so isa-serial
+is no more used for them.
+
+This makes <serial> usable on s390 and s390x guests, with at most only
+a single sclpconsole and one sclplmconsole devices usable in a single
+guest (due to limitations in QEMU, which will enforce already at
+runtime).
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+
+Signed-off-by: Pino Toscano <ptoscano@redhat.com>
+Reviewed-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 21332bf6587c23409fecb06ab81dbc14dd52c10b)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/formatdomain.html.in                          | 19 ++++++++----
+ docs/schemas/domaincommon.rng                      |  3 ++
+ src/conf/domain_conf.c                             |  4 +++
+ src/conf/domain_conf.h                             |  3 ++
+ src/qemu/qemu_command.c                            |  6 ++++
+ src/qemu/qemu_domain.c                             | 20 +++++++++++++
+ src/qemu/qemu_domain_address.c                     |  1 +
+ .../qemuxml2argv-s390-serial-2.args                | 24 +++++++++++++++
+ .../qemuxml2argv-s390-serial-2.xml                 | 19 ++++++++++++
+ .../qemuxml2argv-s390-serial-console.args          | 25 ++++++++++++++++
+ .../qemuxml2argv-s390-serial-console.xml           | 15 ++++++++++
+ .../qemuxml2argvdata/qemuxml2argv-s390-serial.args | 22 ++++++++++++++
+ .../qemuxml2argvdata/qemuxml2argv-s390-serial.xml  | 14 +++++++++
+ tests/qemuxml2argvtest.c                           | 16 ++++++++++
+ .../qemuxml2xmlout-s390-serial-2.xml               | 33 +++++++++++++++++++++
+ .../qemuxml2xmlout-s390-serial-console.xml         | 34 ++++++++++++++++++++++
+ .../qemuxml2xmlout-s390-serial.xml                 | 28 ++++++++++++++++++
+ tests/qemuxml2xmltest.c                            |  6 ++++
+ 18 files changed, 286 insertions(+), 6 deletions(-)
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-2.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial.xml
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index 87389f4e73..62dd6e1ec4 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -6463,8 +6463,9 @@ qemu-kvm -net nic,model=? /dev/null
+       with x86 guests), <code>usb-serial</code> (usable whenever USB support
+       is available) and <code>pci-serial</code> (usable whenever PCI support
+       is available); <span class="since">since 3.10.0</span>,
+-      <code>spapr-vio-serial</code> (usable with ppc64/pseries guests) and
+-      <code>system-serial</code> (usable with aarch64/virt guests) are
++      <code>spapr-vio-serial</code> (usable with ppc64/pseries guests),
++      <code>system-serial</code> (usable with aarch64/virt guests) and
++      <code>sclp-serial</code> (usable with s390 and s390x guests) are
+       available as well.
+     </p>
+ 
+@@ -6478,7 +6479,9 @@ qemu-kvm -net nic,model=? /dev/null
+       (usable with the <code>pci-serial</code> target type);
+       <code>spapr-vty</code> (usable with the <code>spapr-vio-serial</code>
+       target type); <code>pl011</code> (usable with the
+-      <code>system-serial</code> target type).
++      <code>system-serial</code> target type); <code>sclpconsole</code> and
++      <code>sclplmconsole</code> (usable with the <code>sclp-serial</code>
++      target type).
+     </p>
+ 
+     <p>
+@@ -6493,7 +6496,8 @@ qemu-kvm -net nic,model=? /dev/null
+       <code>isa-serial</code>), <code>usb</code> (for <code>usb-serial</code>),
+       <code>pci</code> (for <code>pci-serial</code>) and <code>spapr-vio</code>
+       (for <code>spapr-vio-serial</code>). The <code>system-serial</code>
+-      target type doesn't support specifying an address.
++      and <code>sclp-serial</code> target types don't support specifying an
++      address.
+     </p>
+ 
+     <p>
+@@ -6541,8 +6545,11 @@ qemu-kvm -net nic,model=? /dev/null
+       <code>virtio</code> (usable whenever VirtIO support is available);
+       <code>xen</code>, <code>lxc</code>, <code>uml</code> and
+       <code>openvz</code> (available when the corresponding hypervisor is in
+-      use); <code>sclp</code> and <code>sclplm</code> (usable for s390 and
+-      s390x QEMU guests).
++      use). <code>sclp</code> and <code>sclplm</code> (usable for s390 and
++      s390x QEMU guests) are supported for compatibility reasons but should
++      not be used for new guests: use the <code>sclpconsole</code> and
++      <code>sclplmconsole</code> target models, respectively, with the
++      <code>serial</code> element instead.
+     </p>
+ 
+     <p>
+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
+index 957eae2832..5576128db5 100644
+--- a/docs/schemas/domaincommon.rng
++++ b/docs/schemas/domaincommon.rng
+@@ -3573,6 +3573,7 @@
+         <value>pci-serial</value>
+         <value>spapr-vio-serial</value>
+         <value>system-serial</value>
++        <value>sclp-serial</value>
+       </choice>
+     </attribute>
+   </define>
+@@ -3586,6 +3587,8 @@
+           <value>pci-serial</value>
+           <value>spapr-vty</value>
+           <value>pl011</value>
++          <value>sclpconsole</value>
++          <value>sclplmconsole</value>
+         </choice>
+       </attribute>
+     </element>
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 32089df3c2..c58dae197c 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -447,6 +447,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget,
+               "pci-serial",
+               "spapr-vio-serial",
+               "system-serial",
++              "sclp-serial",
+ );
+ 
+ VIR_ENUM_IMPL(virDomainChrChannelTarget,
+@@ -476,6 +477,8 @@ VIR_ENUM_IMPL(virDomainChrSerialTargetModel,
+               "pci-serial",
+               "spapr-vty",
+               "pl011",
++              "sclpconsole",
++              "sclplmconsole",
+ );
+ 
+ VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST,
+@@ -4066,6 +4069,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def)
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: {
+ 
+             /* Create a stub console to match the serial port.
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index d6febf3059..0e97f0437e 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -1079,6 +1079,7 @@ typedef enum {
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP,
+ 
+     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
+ } virDomainChrSerialTargetType;
+@@ -1113,6 +1114,8 @@ typedef enum {
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY,
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE,
++    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE,
+ 
+     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
+ } virDomainChrSerialTargetModel;
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 483eee6056..a2cfb3d4a3 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9229,6 +9229,10 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel)
+         return QEMU_CAPS_DEVICE_PCI_SERIAL;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
+         return QEMU_CAPS_DEVICE_SPAPR_VTY;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE:
++        return QEMU_CAPS_DEVICE_SCLPCONSOLE;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
++        return QEMU_CAPS_DEVICE_SCLPLMCONSOLE;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+@@ -10355,6 +10359,8 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
+ 
+         caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
+ 
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 2fc173fa45..91c0e163e1 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3469,6 +3469,7 @@ qemuDomainChrSerialTargetTypeToAddressType(int targetType)
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
+         return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         break;
+@@ -3492,6 +3493,9 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel)
+         return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
+         return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
++        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+         break;
+@@ -3529,6 +3533,7 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr)
+             break;
+ 
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
+             if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                _("Target type '%s' cannot have an "
+@@ -3550,6 +3555,8 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr)
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
+ 
+             expected = qemuDomainChrSerialTargetModelToTargetType(chr->targetModel);
+ 
+@@ -3612,6 +3619,13 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev,
+             isCompatible = false;
+         }
+ 
++        if (!ARCH_IS_S390(def->os.arch) &&
++            (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP ||
++             dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE ||
++             dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE)) {
++            isCompatible = false;
++        }
++
+         if (!isCompatible) {
+             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                            _("Serial device with target type '%s' and "
+@@ -4265,6 +4279,8 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
+             chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO;
+         } else if (qemuDomainIsVirt(def)) {
+             chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM;
++        } else if (ARCH_IS_S390(def->os.arch)) {
++            chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP;
+         }
+     }
+ 
+@@ -4287,6 +4303,9 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
+             chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011;
+             break;
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
++            chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE;
++            break;
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+             /* Nothing to do */
+@@ -5210,6 +5229,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
+                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
+                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
+                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
++                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
+                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+                     /* Nothing to do */
+diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
+index db9656a3a5..a40cdb3993 100644
+--- a/src/qemu/qemu_domain_address.c
++++ b/src/qemu/qemu_domain_address.c
+@@ -785,6 +785,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+             return 0;
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.args
+new file mode 100644
+index 0000000000..346dcd16bb
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.args
+@@ -0,0 +1,24 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-s390x \
++-name QEMUGuest1 \
++-S \
++-M s390-ccw-virtio \
++-m 214 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-boot c \
++-chardev pty,id=charserial0 \
++-device sclpconsole,chardev=charserial0,id=serial0 \
++-chardev pty,id=charserial1 \
++-device sclplmconsole,chardev=charserial1,id=serial1
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.xml b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.xml
+new file mode 100644
+index 0000000000..b6eb377c98
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.xml
+@@ -0,0 +1,19 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219100</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch="s390x" machine="s390-ccw-virtio">hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-s390x</emulator>
++    <serial type='pty'/>
++    <serial type='pty'>
++      <target type='sclp-serial'>
++        <model name='sclplmconsole'/>
++      </target>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args
+new file mode 100644
+index 0000000000..c405fb59ee
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args
+@@ -0,0 +1,25 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-s390x \
++-name QEMUGuest1 \
++-S \
++-M s390-ccw-virtio \
++-m 214 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-boot c \
++-device virtio-serial-ccw,id=virtio-serial0,devno=fe.0.0000 \
++-chardev pty,id=charserial0 \
++-device sclpconsole,chardev=charserial0,id=serial0 \
++-chardev pty,id=charconsole1 \
++-device virtconsole,chardev=charconsole1,id=console1
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.xml b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.xml
+new file mode 100644
+index 0000000000..c841f1f245
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.xml
+@@ -0,0 +1,15 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219100</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch="s390x" machine="s390-ccw-virtio">hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-s390x</emulator>
++    <serial type='pty'/>
++    <console type='pty'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.args
+new file mode 100644
+index 0000000000..20968f7945
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.args
+@@ -0,0 +1,22 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-s390x \
++-name QEMUGuest1 \
++-S \
++-M s390-ccw-virtio \
++-m 214 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-boot c \
++-chardev pty,id=charserial0 \
++-device sclpconsole,chardev=charserial0,id=serial0
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.xml b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.xml
+new file mode 100644
+index 0000000000..55b45bac00
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.xml
+@@ -0,0 +1,14 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219100</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch="s390x" machine="s390-ccw-virtio">hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-s390x</emulator>
++    <serial type='pty'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 656b8c0995..852525e7b4 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -2049,6 +2049,22 @@ mymain(void)
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_VIRTIO_CCW,
+             QEMU_CAPS_VIRTIO_S390);
++    DO_TEST("s390-serial",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_VIRTIO_CCW,
++            QEMU_CAPS_VIRTIO_S390,
++            QEMU_CAPS_DEVICE_SCLPCONSOLE);
++    DO_TEST("s390-serial-2",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_VIRTIO_CCW,
++            QEMU_CAPS_VIRTIO_S390,
++            QEMU_CAPS_DEVICE_SCLPCONSOLE,
++            QEMU_CAPS_DEVICE_SCLPLMCONSOLE);
++    DO_TEST("s390-serial-console",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_VIRTIO_CCW,
++            QEMU_CAPS_VIRTIO_S390,
++            QEMU_CAPS_DEVICE_SCLPCONSOLE);
+ 
+     DO_TEST("ppc-dtb",
+             QEMU_CAPS_KVM,
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-2.xml
+new file mode 100644
+index 0000000000..bb9ca30f1d
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-2.xml
+@@ -0,0 +1,33 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219100</memory>
++  <currentMemory unit='KiB'>219100</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-s390x</emulator>
++    <serial type='pty'>
++      <target type='sclp-serial' port='0'>
++        <model name='sclpconsole'/>
++      </target>
++    </serial>
++    <serial type='pty'>
++      <target type='sclp-serial' port='1'>
++        <model name='sclplmconsole'/>
++      </target>
++    </serial>
++    <console type='pty'>
++      <target type='serial' port='0'/>
++    </console>
++    <memballoon model='none'/>
++    <panic model='s390'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml
+new file mode 100644
+index 0000000000..db3023b7a6
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml
+@@ -0,0 +1,34 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219100</memory>
++  <currentMemory unit='KiB'>219100</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-s390x</emulator>
++    <controller type='virtio-serial' index='0'>
++      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
++    </controller>
++    <serial type='pty'>
++      <target type='sclp-serial' port='0'>
++        <model name='sclpconsole'/>
++      </target>
++    </serial>
++    <console type='pty'>
++      <target type='serial' port='0'/>
++    </console>
++    <console type='pty'>
++      <target type='virtio' port='0'/>
++    </console>
++    <memballoon model='none'/>
++    <panic model='s390'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial.xml
+new file mode 100644
+index 0000000000..9c9b4dd27a
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial.xml
+@@ -0,0 +1,28 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219100</memory>
++  <currentMemory unit='KiB'>219100</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-s390x</emulator>
++    <serial type='pty'>
++      <target type='sclp-serial' port='0'>
++        <model name='sclpconsole'/>
++      </target>
++    </serial>
++    <console type='pty'>
++      <target type='serial' port='0'/>
++    </console>
++    <memballoon model='none'/>
++    <panic model='s390'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
+index bd18507bb6..8766646738 100644
+--- a/tests/qemuxml2xmltest.c
++++ b/tests/qemuxml2xmltest.c
+@@ -1155,6 +1155,12 @@ mymain(void)
+             QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
+     DO_TEST("s390-panic-no-address",
+             QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
++    DO_TEST("s390-serial",
++            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
++    DO_TEST("s390-serial-2",
++            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
++    DO_TEST("s390-serial-console",
++            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
+ 
+     DO_TEST("pcihole64", NONE);
+     DO_TEST("pcihole64-gib", NONE);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-add-a-new-parse-flag-VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION.patch b/SOURCES/libvirt-conf-add-a-new-parse-flag-VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION.patch
deleted file mode 100644
index 6ce10e4..0000000
--- a/SOURCES/libvirt-conf-add-a-new-parse-flag-VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From b24b004e1196889201142d1fc7d51e2fafdbe328 Mon Sep 17 00:00:00 2001
-Message-Id: <b24b004e1196889201142d1fc7d51e2fafdbe328@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Thu, 20 Apr 2017 09:16:20 +0200
-Subject: [PATCH] conf: add a new parse flag
- VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION
-
-So far there is probably no change that is allowed to be done
-by the VIR_DOMAIN_DEF_PARSE_ABI_UPDATE flag that would break
-guest ABI but this may change in the future.
-
-This introduces new VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION
-which should be used only for ABI updates that are "safe" for
-persistent migration.
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 5c7d88085a762cf4ecc9416a3b7581fa45738c2a)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1373184
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/conf/domain_conf.c           | 3 ++-
- src/conf/domain_conf.h           | 4 ++++
- src/qemu/qemu_migration_cookie.c | 2 +-
- 3 files changed, 7 insertions(+), 2 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 1b0a55b27..71f0c95c3 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -3805,7 +3805,8 @@ virDomainDefPostParseMemory(virDomainDefPtr def,
-     /* Attempt to infer the initial memory size from the sum NUMA memory sizes
-      * in case ABI updates are allowed or the <memory> element wasn't specified */
-     if (def->mem.total_memory == 0 ||
--        parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE)
-+        parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE ||
-+        parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION)
-         numaMemory = virDomainNumaGetMemorySize(def->numa);
- 
-     /* calculate the sizes of hotplug memory */
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 47eaacef3..71e651975 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -2725,6 +2725,10 @@ typedef enum {
-     VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE = 1 << 10,
-     /* skip parsing of security labels */
-     VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL        = 1 << 11,
-+    /* Allows updates in post parse callback for incoming persistent migration
-+     * that would break ABI otherwise.  This should be used only if it's safe
-+     * to do such change. */
-+    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION = 1 << 12,
- } virDomainDefParseFlags;
- 
- typedef enum {
-diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
-index bd12f1124..12887892d 100644
---- a/src/qemu/qemu_migration_cookie.c
-+++ b/src/qemu/qemu_migration_cookie.c
-@@ -1173,7 +1173,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
-         mig->persistent = virDomainDefParseNode(doc, nodes[0],
-                                                 caps, driver->xmlopt, NULL,
-                                                 VIR_DOMAIN_DEF_PARSE_INACTIVE |
--                                                VIR_DOMAIN_DEF_PARSE_ABI_UPDATE |
-+                                                VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION |
-                                                 VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
-         if (!mig->persistent) {
-             /* virDomainDefParseNode already reported
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-conf-add-caching_mode-attribute-to-iommu-device.patch b/SOURCES/libvirt-conf-add-caching_mode-attribute-to-iommu-device.patch
deleted file mode 100644
index 5e209b4..0000000
--- a/SOURCES/libvirt-conf-add-caching_mode-attribute-to-iommu-device.patch
+++ /dev/null
@@ -1,196 +0,0 @@
-From 3b7b827deb9eb7f43f548aabd27c300ae24c7db3 Mon Sep 17 00:00:00 2001
-Message-Id: <3b7b827deb9eb7f43f548aabd27c300ae24c7db3@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:56 +0200
-Subject: [PATCH] conf: add caching_mode attribute to iommu device
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Add a new attribute to control the caching mode.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-(cherry picked from commit d12781b47eb0c9f3a498d88b632c327aa08aaf8a)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                          |  9 ++++
- docs/schemas/domaincommon.rng                      |  5 +++
- src/conf/domain_conf.c                             | 24 +++++++++--
- src/conf/domain_conf.h                             |  1 +
- .../qemuxml2argv-intel-iommu-caching-mode.xml      | 50 ++++++++++++++++++++++
- .../qemuxml2xmlout-intel-iommu-caching-mode.xml    |  1 +
- tests/qemuxml2xmltest.c                            |  1 +
- 7 files changed, 88 insertions(+), 3 deletions(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml
- create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 41b8bfb50..43a75c1ee 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -7424,6 +7424,15 @@ qemu-kvm -net nic,model=? /dev/null
-               <span class="since">Since 3.4.0</span> (QEMU/KVM only)
-             </p>
-           </dd>
-+          <dt><code>caching_mode</code></dt>
-+          <dd>
-+            <p>
-+              The <code>caching_mode</code> attribute with possible values
-+              <code>on</code> and <code>off</code> can be used to
-+              turn on the VT-d caching mode (useful for assigned devices).
-+              <span class="since">Since 3.4.0</span> (QEMU/KVM only)
-+            </p>
-+          </dd>
-         </dl>
-       </dd>
-     </dl>
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index a400d961b..12ccbd4e2 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -3900,6 +3900,11 @@
-               <ref name="virOnOff"/>
-             </attribute>
-           </optional>
-+          <optional>
-+            <attribute name="caching_mode">
-+              <ref name="virOnOff"/>
-+            </attribute>
-+          </optional>
-         </element>
-       </optional>
-     </element>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 45473f65b..e77b542f3 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -14167,6 +14167,15 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
-         iommu->intremap = val;
-     }
- 
-+    VIR_FREE(tmp);
-+    if ((tmp = virXPathString("string(./driver/@caching_mode)", ctxt))) {
-+        if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
-+            virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode value: %s"), tmp);
-+            goto cleanup;
-+        }
-+        iommu->caching_mode = val;
-+    }
-+
-     ret = iommu;
-     iommu = NULL;
- 
-@@ -24114,9 +24123,18 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
- 
-     virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2);
- 
--    if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
--        virBufferAsprintf(&childBuf, "<driver intremap='%s'/>\n",
--                          virTristateSwitchTypeToString(iommu->intremap));
-+    if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT ||
-+        iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) {
-+        virBufferAddLit(&childBuf, "<driver");
-+        if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
-+            virBufferAsprintf(&childBuf, " intremap='%s'",
-+                              virTristateSwitchTypeToString(iommu->intremap));
-+        }
-+        if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) {
-+            virBufferAsprintf(&childBuf, " caching_mode='%s'",
-+                              virTristateSwitchTypeToString(iommu->caching_mode));
-+        }
-+        virBufferAddLit(&childBuf, "/>\n");
-     }
- 
-     virBufferAsprintf(buf, "<iommu model='%s'",
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 8eb422a57..825158a7d 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -2210,6 +2210,7 @@ typedef enum {
- struct _virDomainIOMMUDef {
-     virDomainIOMMUModel model;
-     virTristateSwitch intremap;
-+    virTristateSwitch caching_mode;
- };
- /*
-  * Guest VM main configuration
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml
-new file mode 100644
-index 000000000..5f3384da7
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml
-@@ -0,0 +1,50 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219100</memory>
-+  <currentMemory unit='KiB'>219100</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='q35'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <controller type='pci' index='0' model='pcie-root'/>
-+    <controller type='pci' index='1' model='dmi-to-pci-bridge'>
-+      <model name='i82801b11-bridge'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
-+    </controller>
-+    <controller type='pci' index='2' model='pci-bridge'>
-+      <model name='pci-bridge'/>
-+      <target chassisNr='2'/>
-+      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
-+    </controller>
-+    <controller type='pci' index='3' model='pcie-root-port'>
-+      <model name='ioh3420'/>
-+      <target chassis='3' port='0x10'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
-+    </controller>
-+    <controller type='sata' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
-+    </controller>
-+    <controller type='usb' index='0' model='ich9-ehci1'>
-+      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x7'/>
-+    </controller>
-+    <interface type='user'>
-+      <mac address='52:54:00:ab:0c:5c'/>
-+      <model type='rtl8139'/>
-+      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
-+    </interface>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <memballoon model='none'/>
-+    <iommu model='intel'>
-+      <driver intremap='on' caching_mode='on'/>
-+    </iommu>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml
-new file mode 120000
-index 000000000..d971a35dc
---- /dev/null
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml
-@@ -0,0 +1 @@
-+../qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml
-\ No newline at end of file
-diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
-index 0482ad9cb..e1938421a 100644
---- a/tests/qemuxml2xmltest.c
-+++ b/tests/qemuxml2xmltest.c
-@@ -1129,6 +1129,7 @@ mymain(void)
-             QEMU_CAPS_MACHINE_OPT,
-             QEMU_CAPS_MACHINE_IOMMU);
-     DO_TEST("intel-iommu-ioapic", NONE);
-+    DO_TEST("intel-iommu-caching-mode", NONE);
- 
-     DO_TEST("cpu-check-none", NONE);
-     DO_TEST("cpu-check-partial", NONE);
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-conf-add-driver-intremap-to-iommu.patch b/SOURCES/libvirt-conf-add-driver-intremap-to-iommu.patch
deleted file mode 100644
index 8bd9e7f..0000000
--- a/SOURCES/libvirt-conf-add-driver-intremap-to-iommu.patch
+++ /dev/null
@@ -1,201 +0,0 @@
-From 2bb15d3f041ec2506012aa701547334af429b915 Mon Sep 17 00:00:00 2001
-Message-Id: <2bb15d3f041ec2506012aa701547334af429b915@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:54 +0200
-Subject: [PATCH] conf: add <driver intremap> to <iommu>
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Add a new attribute to control interrupt remapping.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-(cherry picked from commit 2020e2c6f2656ca1aa9032859ccde76185c37c39)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                          | 24 +++++++++++++-
- docs/schemas/domaincommon.rng                      |  9 +++++
- src/conf/domain_conf.c                             | 38 +++++++++++++++++++---
- src/conf/domain_conf.h                             |  1 +
- .../qemuxml2argv-intel-iommu-ioapic.xml            |  4 ++-
- 5 files changed, 70 insertions(+), 6 deletions(-)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 869c1f73e..41b8bfb50 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -7393,7 +7393,9 @@ qemu-kvm -net nic,model=? /dev/null
- <pre>
- ...
- &lt;devices&gt;
--  &lt;iommu model='intel'/&gt;
-+  &lt;iommu model='intel'&gt;
-+    &lt;driver intremap='on'/&gt;
-+  &lt;/iommu&gt;
- &lt;/devices&gt;
- ...
- </pre>
-@@ -7404,6 +7406,26 @@ qemu-kvm -net nic,model=? /dev/null
-           Currently only the <code>intel</code> model is supported.
-         </p>
-       </dd>
-+      <dt><code>driver</code></dt>
-+      <dd>
-+        <p>
-+          The <code>driver</code> subelement can be used to configure
-+          additional options:
-+        </p>
-+        <dl>
-+          <dt><code>intremap</code></dt>
-+          <dd>
-+            <p>
-+              The <code>intremap</code> attribute with possible values
-+              <code>on</code> and <code>off</code> can be used to
-+              turn on interrupt remapping, a part of the VT-d functionality.
-+              Currently this requires split I/O APIC
-+              (<code>&lt;ioapic driver='qemu'/&gt;</code>).
-+              <span class="since">Since 3.4.0</span> (QEMU/KVM only)
-+            </p>
-+          </dd>
-+        </dl>
-+      </dd>
-     </dl>
- 
-     <h3><a name="seclabel">Security label</a></h3>
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index c72ba7e97..a400d961b 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -3893,6 +3893,15 @@
-       <attribute name="model">
-         <value>intel</value>
-       </attribute>
-+      <optional>
-+        <element name="driver">
-+          <optional>
-+            <attribute name="intremap">
-+              <ref name="virOnOff"/>
-+            </attribute>
-+          </optional>
-+        </element>
-+      </optional>
-     </element>
-   </define>
- 
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index d5c4f6ddd..45473f65b 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -14132,12 +14132,16 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
- 
- 
- static virDomainIOMMUDefPtr
--virDomainIOMMUDefParseXML(xmlNodePtr node)
-+virDomainIOMMUDefParseXML(xmlNodePtr node,
-+                          xmlXPathContextPtr ctxt)
- {
-     virDomainIOMMUDefPtr iommu = NULL, ret = NULL;
-+    xmlNodePtr save = ctxt->node;
-     char *tmp = NULL;
-     int val;
- 
-+    ctxt->node = node;
-+
-     if (VIR_ALLOC(iommu) < 0)
-         goto cleanup;
- 
-@@ -14154,10 +14158,20 @@ virDomainIOMMUDefParseXML(xmlNodePtr node)
- 
-     iommu->model = val;
- 
-+    VIR_FREE(tmp);
-+    if ((tmp = virXPathString("string(./driver/@intremap)", ctxt))) {
-+        if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
-+            virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %s"), tmp);
-+            goto cleanup;
-+        }
-+        iommu->intremap = val;
-+    }
-+
-     ret = iommu;
-     iommu = NULL;
- 
-  cleanup:
-+    ctxt->node = save;
-     VIR_FREE(iommu);
-     VIR_FREE(tmp);
-     return ret;
-@@ -14310,7 +14324,7 @@ virDomainDeviceDefParse(const char *xmlStr,
-             goto error;
-         break;
-     case VIR_DOMAIN_DEVICE_IOMMU:
--        if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node)))
-+        if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node, ctxt)))
-             goto error;
-         break;
-     case VIR_DOMAIN_DEVICE_NONE:
-@@ -18440,7 +18454,7 @@ virDomainDefParseXML(xmlDocPtr xml,
-     }
- 
-     if (n > 0) {
--        if (!(def->iommu = virDomainIOMMUDefParseXML(nodes[0])))
-+        if (!(def->iommu = virDomainIOMMUDefParseXML(nodes[0], ctxt)))
-             goto error;
-     }
-     VIR_FREE(nodes);
-@@ -24096,8 +24110,24 @@ static void
- virDomainIOMMUDefFormat(virBufferPtr buf,
-                         const virDomainIOMMUDef *iommu)
- {
--    virBufferAsprintf(buf, "<iommu model='%s'/>\n",
-+    virBuffer childBuf = VIR_BUFFER_INITIALIZER;
-+
-+    virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2);
-+
-+    if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
-+        virBufferAsprintf(&childBuf, "<driver intremap='%s'/>\n",
-+                          virTristateSwitchTypeToString(iommu->intremap));
-+    }
-+
-+    virBufferAsprintf(buf, "<iommu model='%s'",
-                       virDomainIOMMUModelTypeToString(iommu->model));
-+    if (virBufferUse(&childBuf)) {
-+        virBufferAddLit(buf, ">\n");
-+        virBufferAddBuffer(buf, &childBuf);
-+        virBufferAddLit(buf, "</iommu>\n");
-+    } else {
-+        virBufferAddLit(buf, "/>\n");
-+    }
- }
- 
- 
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 4cb37b1fc..8eb422a57 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -2209,6 +2209,7 @@ typedef enum {
- 
- struct _virDomainIOMMUDef {
-     virDomainIOMMUModel model;
-+    virTristateSwitch intremap;
- };
- /*
-  * Guest VM main configuration
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
-index 284d63a30..bfe714ad8 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
-@@ -24,6 +24,8 @@
-     <input type='mouse' bus='ps2'/>
-     <input type='keyboard' bus='ps2'/>
-     <memballoon model='none'/>
--    <iommu model='intel'/>
-+    <iommu model='intel'>
-+      <driver intremap='on'/>
-+    </iommu>
-   </devices>
- </domain>
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-conf-add-eim-attribute-to-iommu-driver.patch b/SOURCES/libvirt-conf-add-eim-attribute-to-iommu-driver.patch
deleted file mode 100644
index 8297928..0000000
--- a/SOURCES/libvirt-conf-add-eim-attribute-to-iommu-driver.patch
+++ /dev/null
@@ -1,191 +0,0 @@
-From d7a019948e1c1f0400ee174ef60bf0cb32d181f9 Mon Sep 17 00:00:00 2001
-Message-Id: <d7a019948e1c1f0400ee174ef60bf0cb32d181f9@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 26 May 2017 08:52:56 +0200
-Subject: [PATCH] conf: add eim attribute to <iommu><driver>
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Add an attribute to control extended interrupt mode.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1451282
-
-Reviewed-by: Andrea Bolognani <abologna@redhat.com>
-(cherry picked from commit dc61d927589b2b122868e6abea86b73caa682226)
-
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-Also:
-https://bugzilla.redhat.com/show_bug.cgi?id=1289153
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                          | 13 +++++++++
- docs/schemas/domaincommon.rng                      |  5 ++++
- src/conf/domain_conf.c                             | 21 +++++++++++++++
- src/conf/domain_conf.h                             |  1 +
- .../qemuxml2argv-intel-iommu-eim.xml               | 31 ++++++++++++++++++++++
- .../qemuxml2xmlout-intel-iommu-eim.xml             |  1 +
- tests/qemuxml2xmltest.c                            |  1 +
- 7 files changed, 73 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml
- create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-eim.xml
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 43a75c1ee..e886e4e17 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -7433,6 +7433,19 @@ qemu-kvm -net nic,model=? /dev/null
-               <span class="since">Since 3.4.0</span> (QEMU/KVM only)
-             </p>
-           </dd>
-+          <dt><code>eim</code></dt>
-+          <dd>
-+            <p>
-+              The <code>eim</code> attribute (with possible values
-+              <code>on</code> and <code>off</code>) can be used to
-+              configure Extended Interrupt Mode. A q35 domain with
-+              split I/O APIC (as described in
-+              <a href="#elementsFeatures">hypervisor features</a>),
-+              and both interrupt remapping and EIM turned on for
-+              the IOMMU, will be able to use more than 255 vCPUs.
-+              <span class="since">Since 3.4.0</span> (QEMU/KVM only)
-+            </p>
-+          </dd>
-         </dl>
-       </dd>
-     </dl>
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index 12ccbd4e2..af7824aa0 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -3905,6 +3905,11 @@
-               <ref name="virOnOff"/>
-             </attribute>
-           </optional>
-+          <optional>
-+            <attribute name="eim">
-+              <ref name="virOnOff"/>
-+            </attribute>
-+          </optional>
-         </element>
-       </optional>
-     </element>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 370916396..4404b8f73 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -14176,6 +14176,15 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
-         iommu->caching_mode = val;
-     }
- 
-+    VIR_FREE(tmp);
-+    if ((tmp = virXPathString("string(./driver/@eim)", ctxt))) {
-+        if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
-+            virReportError(VIR_ERR_XML_ERROR, _("unknown eim value: %s"), tmp);
-+            goto cleanup;
-+        }
-+        iommu->eim = val;
-+    }
-+
-     ret = iommu;
-     iommu = NULL;
- 
-@@ -19847,6 +19856,14 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src,
-                        virTristateSwitchTypeToString(src->caching_mode));
-         return false;
-     }
-+    if (src->eim != dst->eim) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("Target domain IOMMU device eim value '%s' "
-+                         "does not match source '%s'"),
-+                       virTristateSwitchTypeToString(dst->eim),
-+                       virTristateSwitchTypeToString(src->eim));
-+        return false;
-+    }
-     return true;
- }
- 
-@@ -24170,6 +24187,10 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
-             virBufferAsprintf(&childBuf, " caching_mode='%s'",
-                               virTristateSwitchTypeToString(iommu->caching_mode));
-         }
-+        if (iommu->eim != VIR_TRISTATE_SWITCH_ABSENT) {
-+            virBufferAsprintf(&childBuf, " eim='%s'",
-+                              virTristateSwitchTypeToString(iommu->eim));
-+        }
-         virBufferAddLit(&childBuf, "/>\n");
-     }
- 
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 825158a7d..980aafa66 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -2211,6 +2211,7 @@ struct _virDomainIOMMUDef {
-     virDomainIOMMUModel model;
-     virTristateSwitch intremap;
-     virTristateSwitch caching_mode;
-+    virTristateSwitch eim;
- };
- /*
-  * Guest VM main configuration
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml
-new file mode 100644
-index 000000000..8642ed349
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml
-@@ -0,0 +1,31 @@
-+<domain type='kvm'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219100</memory>
-+  <currentMemory unit='KiB'>219100</currentMemory>
-+  <vcpu placement='static'>288</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='q35'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <features>
-+    <ioapic driver='qemu'/>
-+  </features>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <controller type='pci' index='0' model='pcie-root'/>
-+    <controller type='sata' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
-+    </controller>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <memballoon model='none'/>
-+    <iommu model='intel'>
-+      <driver intremap='on' eim='on'/>
-+    </iommu>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-eim.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-eim.xml
-new file mode 120000
-index 000000000..9fbec36dc
---- /dev/null
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-eim.xml
-@@ -0,0 +1 @@
-+../qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml
-\ No newline at end of file
-diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
-index e1938421a..6283da409 100644
---- a/tests/qemuxml2xmltest.c
-+++ b/tests/qemuxml2xmltest.c
-@@ -1130,6 +1130,7 @@ mymain(void)
-             QEMU_CAPS_MACHINE_IOMMU);
-     DO_TEST("intel-iommu-ioapic", NONE);
-     DO_TEST("intel-iommu-caching-mode", NONE);
-+    DO_TEST("intel-iommu-eim", NONE);
- 
-     DO_TEST("cpu-check-none", NONE);
-     DO_TEST("cpu-check-partial", NONE);
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-conf-add-ioapic-driver-to-features.patch b/SOURCES/libvirt-conf-add-ioapic-driver-to-features.patch
deleted file mode 100644
index c7b34fa..0000000
--- a/SOURCES/libvirt-conf-add-ioapic-driver-to-features.patch
+++ /dev/null
@@ -1,249 +0,0 @@
-From abbea18f4b3747d738d05f36884dda3202128b65 Mon Sep 17 00:00:00 2001
-Message-Id: <abbea18f4b3747d738d05f36884dda3202128b65@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:52 +0200
-Subject: [PATCH] conf: add <ioapic driver> to <features>
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Add a new <ioapic> element with a driver attribute.
-
-Possible values are qemu and kvm. With 'qemu', the I/O
-APIC can be put in the userspace even for KVM domains.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-(cherry picked from commit 8023b21a95f271e51810de7f1362e609eaadc1e4)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                          |  9 ++++++
- docs/schemas/domaincommon.rng                      | 15 ++++++++++
- src/conf/domain_conf.c                             | 33 +++++++++++++++++++++-
- src/conf/domain_conf.h                             | 11 ++++++++
- .../qemuxml2argv-intel-iommu-ioapic.xml            | 29 +++++++++++++++++++
- .../qemuxml2xmlout-intel-iommu-ioapic.xml          |  1 +
- tests/qemuxml2xmltest.c                            |  1 +
- 7 files changed, 98 insertions(+), 1 deletion(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
- create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 7e55b0327..869c1f73e 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -1675,6 +1675,7 @@
-   &lt;/kvm&gt;
-   &lt;pvspinlock state='on'/&gt;
-   &lt;gic version='2'/&gt;
-+  &lt;ioapic driver='qemu'/&gt;
- 
- &lt;/features&gt;
- ...</pre>
-@@ -1836,6 +1837,14 @@
-           for hypervisor to decide.
-           <span class="since">Since 2.1.0</span>
-       </dd>
-+      <dt><code>ioapic</code></dt>
-+      <dd>Tune the I/O APIC. Possible values for the
-+          <code>driver</code> attribute are:
-+          <code>kvm</code> (default for KVM domains)
-+          and <code>qemu</code> which puts I/O APIC in userspace
-+          which is also known as a split I/O APIC mode.
-+          <span class="since">Since 3.4.0</span> (QEMU/KVM only)
-+      </dd>
-     </dl>
- 
-     <h3><a name="elementsTime">Time keeping</a></h3>
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index 7271f0113..c72ba7e97 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -4515,6 +4515,9 @@
-               </optional>
-             </element>
-           </optional>
-+          <optional>
-+            <ref name="ioapic"/>
-+          </optional>
-         </interleave>
-       </element>
-     </optional>
-@@ -4693,6 +4696,18 @@
-     </element>
-   </define>
- 
-+  <define name="ioapic">
-+    <element name="ioapic">
-+      <attribute name="driver">
-+        <choice>
-+          <value>qemu</value>
-+          <value>kvm</value>
-+        </choice>
-+      </attribute>
-+      <empty/>
-+    </element>
-+  </define>
-+
-   <define name="address">
-     <element name="address">
-       <choice>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 4096b9caf..d5c4f6ddd 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -141,7 +141,8 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
-               "pmu",
-               "vmport",
-               "gic",
--              "smm")
-+              "smm",
-+              "ioapic")
- 
- VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
-               "default",
-@@ -859,6 +860,11 @@ VIR_ENUM_IMPL(virDomainLoader,
-               "rom",
-               "pflash")
- 
-+VIR_ENUM_IMPL(virDomainIOAPIC,
-+              VIR_DOMAIN_IOAPIC_LAST,
-+              "qemu",
-+              "kvm")
-+
- /* Internal mapping: subset of block job types that can be present in
-  * <mirror> XML (remaining types are not two-phase). */
- VIR_ENUM_DECL(virDomainBlockJob)
-@@ -17518,6 +17524,24 @@ virDomainDefParseXML(xmlDocPtr xml,
-             ctxt->node = node;
-             break;
- 
-+        case VIR_DOMAIN_FEATURE_IOAPIC:
-+            node = ctxt->node;
-+            ctxt->node = nodes[i];
-+            tmp = virXPathString("string(./@driver)", ctxt);
-+            if (tmp) {
-+                int value = virDomainIOAPICTypeFromString(tmp);
-+                if (value < 0) {
-+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                                   _("Unknown driver mode: %s"),
-+                                   tmp);
-+                    goto error;
-+                }
-+                def->ioapic = value;
-+                def->features[val] = VIR_TRISTATE_SWITCH_ON;
-+            }
-+            ctxt->node = node;
-+            break;
-+
-         /* coverity[dead_error_begin] */
-         case VIR_DOMAIN_FEATURE_LAST:
-             break;
-@@ -24598,6 +24622,13 @@ virDomainDefFormatInternal(virDomainDefPtr def,
-                 }
-                 break;
- 
-+            case VIR_DOMAIN_FEATURE_IOAPIC:
-+                if (def->features[i] == VIR_TRISTATE_SWITCH_ON) {
-+                    virBufferAsprintf(buf, "<ioapic driver='%s'/>\n",
-+                                      virDomainIOAPICTypeToString(def->ioapic));
-+                }
-+                break;
-+
-             /* coverity[dead_error_begin] */
-             case VIR_DOMAIN_FEATURE_LAST:
-                 break;
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index f1e9fc2ba..4cb37b1fc 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -1670,6 +1670,7 @@ typedef enum {
-     VIR_DOMAIN_FEATURE_VMPORT,
-     VIR_DOMAIN_FEATURE_GIC,
-     VIR_DOMAIN_FEATURE_SMM,
-+    VIR_DOMAIN_FEATURE_IOAPIC,
- 
-     VIR_DOMAIN_FEATURE_LAST
- } virDomainFeature;
-@@ -1809,6 +1810,15 @@ struct _virDomainLoaderDef {
- 
- void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);
- 
-+typedef enum {
-+    VIR_DOMAIN_IOAPIC_QEMU = 0,
-+    VIR_DOMAIN_IOAPIC_KVM,
-+
-+    VIR_DOMAIN_IOAPIC_LAST
-+} virDomainIOAPIC;
-+
-+VIR_ENUM_DECL(virDomainIOAPIC);
-+
- /* Operating system configuration data & machine / arch */
- typedef struct _virDomainOSDef virDomainOSDef;
- typedef virDomainOSDef *virDomainOSDefPtr;
-@@ -2258,6 +2268,7 @@ struct _virDomainDef {
-     unsigned int hyperv_spinlocks;
-     virGICVersion gic_version;
-     char *hyperv_vendor_id;
-+    virDomainIOAPIC ioapic;
- 
-     /* These options are of type virTristateSwitch: ON = keep, OFF = drop */
-     int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
-new file mode 100644
-index 000000000..284d63a30
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
-@@ -0,0 +1,29 @@
-+<domain type='kvm'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219100</memory>
-+  <currentMemory unit='KiB'>219100</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='q35'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <features>
-+    <ioapic driver='qemu'/>
-+  </features>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <controller type='pci' index='0' model='pcie-root'/>
-+    <controller type='sata' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
-+    </controller>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <memballoon model='none'/>
-+    <iommu model='intel'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml
-new file mode 120000
-index 000000000..42d17b2c0
---- /dev/null
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml
-@@ -0,0 +1 @@
-+../qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
-\ No newline at end of file
-diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
-index ff533ab19..0482ad9cb 100644
---- a/tests/qemuxml2xmltest.c
-+++ b/tests/qemuxml2xmltest.c
-@@ -1128,6 +1128,7 @@ mymain(void)
-     DO_TEST("intel-iommu-machine",
-             QEMU_CAPS_MACHINE_OPT,
-             QEMU_CAPS_MACHINE_IOMMU);
-+    DO_TEST("intel-iommu-ioapic", NONE);
- 
-     DO_TEST("cpu-check-none", NONE);
-     DO_TEST("cpu-check-partial", NONE);
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-conf-add-iotlb-attribute-to-iommu.patch b/SOURCES/libvirt-conf-add-iotlb-attribute-to-iommu.patch
deleted file mode 100644
index d8b4894..0000000
--- a/SOURCES/libvirt-conf-add-iotlb-attribute-to-iommu.patch
+++ /dev/null
@@ -1,194 +0,0 @@
-From 1e915e38d422df8b3cb4e049e932a5e6900735bc Mon Sep 17 00:00:00 2001
-Message-Id: <1e915e38d422df8b3cb4e049e932a5e6900735bc@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:48:56 +0200
-Subject: [PATCH] conf: add iotlb attribute to iommu
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Add a new iotlb attribute to the iommu device
-to control the device IOTLB support for intel-iommu.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 27b187be3988c60cd26e08ab4bcab66bed5a3646)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                          | 10 +++++++
- docs/schemas/domaincommon.rng                      |  5 ++++
- src/conf/domain_conf.c                             | 23 +++++++++++++++-
- src/conf/domain_conf.h                             |  1 +
- .../qemuxml2argv-intel-iommu-device-iotlb.xml      | 31 ++++++++++++++++++++++
- .../qemuxml2xmlout-intel-iommu-device-iotlb.xml    |  1 +
- tests/qemuxml2xmltest.c                            |  1 +
- 7 files changed, 71 insertions(+), 1 deletion(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml
- create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index e886e4e17e..e8a3367bac 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -7446,6 +7446,16 @@ qemu-kvm -net nic,model=? /dev/null
-               <span class="since">Since 3.4.0</span> (QEMU/KVM only)
-             </p>
-           </dd>
-+          <dt><code>iotlb</code></dt>
-+          <dd>
-+            <p>
-+              The <code>iotlb</code> attribute with possible values
-+              <code>on</code> and <code>off</code> can be used to
-+              turn on the IOTLB used to cache address translation
-+              requests from devices.
-+              <span class="since">Since 3.5.0</span> (QEMU/KVM only)
-+            </p>
-+          </dd>
-         </dl>
-       </dd>
-     </dl>
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index af7824aa02..1b66362f17 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -3910,6 +3910,11 @@
-               <ref name="virOnOff"/>
-             </attribute>
-           </optional>
-+          <optional>
-+            <attribute name="iotlb">
-+              <ref name="virOnOff"/>
-+            </attribute>
-+          </optional>
-         </element>
-       </optional>
-     </element>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 275145b1ec..701a6d2136 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -14196,6 +14196,14 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
-         }
-         iommu->caching_mode = val;
-     }
-+    VIR_FREE(tmp);
-+    if ((tmp = virXPathString("string(./driver/@iotlb)", ctxt))) {
-+        if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
-+            virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: %s"), tmp);
-+            goto cleanup;
-+        }
-+        iommu->iotlb = val;
-+    }
- 
-     VIR_FREE(tmp);
-     if ((tmp = virXPathString("string(./driver/@eim)", ctxt))) {
-@@ -19877,6 +19885,14 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src,
-                        virTristateSwitchTypeToString(src->eim));
-         return false;
-     }
-+    if (src->iotlb != dst->iotlb) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("Target domain IOMMU device iotlb value '%s' "
-+                         "does not match source '%s'"),
-+                       virTristateSwitchTypeToString(dst->iotlb),
-+                       virTristateSwitchTypeToString(src->iotlb));
-+        return false;
-+    }
-     return true;
- }
- 
-@@ -24212,7 +24228,8 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
-     virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2);
- 
-     if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT ||
--        iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) {
-+        iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT ||
-+        iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT) {
-         virBufferAddLit(&childBuf, "<driver");
-         if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
-             virBufferAsprintf(&childBuf, " intremap='%s'",
-@@ -24226,6 +24243,10 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
-             virBufferAsprintf(&childBuf, " eim='%s'",
-                               virTristateSwitchTypeToString(iommu->eim));
-         }
-+        if (iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT) {
-+            virBufferAsprintf(&childBuf, " iotlb='%s'",
-+                              virTristateSwitchTypeToString(iommu->iotlb));
-+        }
-         virBufferAddLit(&childBuf, "/>\n");
-     }
- 
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 706d106ad9..e6c20a9e1e 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -2213,6 +2213,7 @@ struct _virDomainIOMMUDef {
-     virTristateSwitch intremap;
-     virTristateSwitch caching_mode;
-     virTristateSwitch eim;
-+    virTristateSwitch iotlb;
- };
- /*
-  * Guest VM main configuration
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml
-new file mode 100644
-index 0000000000..3eb08ab9af
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml
-@@ -0,0 +1,31 @@
-+<domain type='kvm'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219100</memory>
-+  <currentMemory unit='KiB'>219100</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='q35'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <features>
-+    <ioapic driver='qemu'/>
-+  </features>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <controller type='pci' index='0' model='pcie-root'/>
-+    <controller type='sata' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
-+    </controller>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <memballoon model='none'/>
-+    <iommu model='intel'>
-+      <driver intremap='on' iotlb='on'/>
-+    </iommu>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml
-new file mode 120000
-index 0000000000..3120d9f677
---- /dev/null
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml
-@@ -0,0 +1 @@
-+../qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml
-\ No newline at end of file
-diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
-index 6283da4096..3f7c268e43 100644
---- a/tests/qemuxml2xmltest.c
-+++ b/tests/qemuxml2xmltest.c
-@@ -1131,6 +1131,7 @@ mymain(void)
-     DO_TEST("intel-iommu-ioapic", NONE);
-     DO_TEST("intel-iommu-caching-mode", NONE);
-     DO_TEST("intel-iommu-eim", NONE);
-+    DO_TEST("intel-iommu-device-iotlb", NONE);
- 
-     DO_TEST("cpu-check-none", NONE);
-     DO_TEST("cpu-check-partial", NONE);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-conf-docs-Add-support-for-coalesce-setting-s.patch b/SOURCES/libvirt-conf-docs-Add-support-for-coalesce-setting-s.patch
deleted file mode 100644
index f7166fc..0000000
--- a/SOURCES/libvirt-conf-docs-Add-support-for-coalesce-setting-s.patch
+++ /dev/null
@@ -1,557 +0,0 @@
-From 705cbf8998e405b98f2d536f6d92c524755fe219 Mon Sep 17 00:00:00 2001
-Message-Id: <705cbf8998e405b98f2d536f6d92c524755fe219@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Tue, 25 Apr 2017 13:41:16 +0200
-Subject: [PATCH] conf, docs: Add support for coalesce setting(s)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1414627
-
-We are currently parsing only rx/frames/max because that's the only
-value that makes sense for us.  The tun device just added support for
-this one and the others are only supported by hardware devices which
-we don't need to worry about as the only way we'd pass those to the
-domain is using <hostdev/> or <interface type='hostdev'/>.  And in
-those cases the guest can modify the settings itself.
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-(cherry picked from commit 523c9960621eaf307ae8d4ae2735fb66f89d5634)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                          |  27 +++++
- docs/schemas/domaincommon.rng                      | 131 +++++++++++++++++++++
- src/conf/domain_conf.c                             |  80 +++++++++++++
- src/conf/domain_conf.h                             |   2 +
- src/qemu/qemu_domain.c                             |  31 +++++
- .../qemuxml2argvdata/qemuxml2argv-net-coalesce.xml |  68 +++++++++++
- .../qemuxml2xmlout-net-coalesce.xml                |  71 +++++++++++
- tests/qemuxml2xmltest.c                            |   1 +
- 8 files changed, 411 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml
- create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index aee1e1442..7374cb243 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -5437,6 +5437,33 @@ qemu-kvm -net nic,model=? /dev/null
-       <span class="since">Since 3.1.0</span>
-     </p>
- 
-+    <h5><a name="coalesce">Coalesce settings</a></h5>
-+<pre>
-+...
-+&lt;devices&gt;
-+  &lt;interface type='network'&gt;
-+    &lt;source network='default'/&gt;
-+    &lt;target dev='vnet0'/&gt;
-+    <b>&lt;coalesce&gt;
-+      &lt;rx&gt;
-+        &lt;frames max='7'/&gt;
-+      &lt;/rx&gt;
-+    &lt;/coalesce&gt;</b>
-+  &lt;/interface&gt;
-+&lt;/devices&gt;
-+...</pre>
-+
-+    <p>
-+      This element provides means of setting coalesce settings for
-+      some interface devices (currently only type <code>network</code>
-+      and <code>bridge</code>.  Currently there is just one attribute,
-+      <code>max</code>, to tweak, in element <code>frames<code> for
-+      the <code>rx</code> group, which accepts a non-negative integer
-+      that specifies the maximum number of packets that will be
-+      received before an interrupt.
-+      <span class="since">Since 3.3.0</span>
-+    </p>
-+
-     <h5><a name="ipconfig">IP configuration</a></h5>
- <pre>
- ...
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index d5c28ee3c..7a9b4b702 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -2509,6 +2509,9 @@
-         <ref name="mtu"/>
-       </optional>
-       <optional>
-+        <ref name="coalesce"/>
-+      </optional>
-+      <optional>
-         <element name="target">
-           <attribute name="dev">
-             <ref name="deviceName"/>
-@@ -5746,4 +5749,132 @@
-       </choice>
-     </attribute>
-   </define>
-+
-+  <define name="coalesce">
-+    <element name="coalesce">
-+      <interleave>
-+        <optional>
-+          <element name="rx">
-+            <optional>
-+              <element name="frames">
-+                <optional>
-+                  <attribute name="max">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <!--
-+                    This is how we'd add more Rx-related settings for
-+                    frames, like irq, high, and low
-+
-+                <optional>
-+                  <attribute name="irq">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="high">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="low">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+
-+              -->
-+              </element>
-+            </optional>
-+            <!--
-+                This is how we'd add more Rx-related settings, like
-+                usecs
-+
-+            <optional>
-+              <element name="usecs">
-+                <optional>
-+                  <attribute name="max">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="irq">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="high">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="low">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+              </element>
-+            </optional>
-+              -->
-+          </element>
-+        </optional>
-+        <!--
-+            This is how you would add more coalesce settings, like
-+            Tx-related ones
-+
-+        <optional>
-+          <element name="tx">
-+            <optional>
-+              <element name="frames">
-+                <optional>
-+                  <attribute name="max">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="irq">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="high">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="low">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+              </element>
-+            </optional>
-+            <optional>
-+              <element name="usecs">
-+                <optional>
-+                  <attribute name="max">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="irq">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="high">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+                <optional>
-+                  <attribute name="low">
-+                    <ref name="unsignedInt"/>
-+                  </attribute>
-+                </optional>
-+              </element>
-+            </optional>
-+          </element>
-+        </optional>
-+        -->
-+      </interleave>
-+    </element>
-+  </define>
-+
- </grammar>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 71f0c95c3..f2801ec84 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -6759,6 +6759,77 @@ virDomainNetIPInfoParseXML(const char *source,
-     return ret;
- }
- 
-+
-+static virNetDevCoalescePtr
-+virDomainNetDefCoalesceParseXML(xmlNodePtr node,
-+                                xmlXPathContextPtr ctxt)
-+{
-+    virNetDevCoalescePtr ret = NULL;
-+    xmlNodePtr save = NULL;
-+    char *str = NULL;
-+    unsigned long long tmp = 0;
-+
-+    save = ctxt->node;
-+    ctxt->node = node;
-+
-+    str = virXPathString("string(./rx/frames/@max)", ctxt);
-+    if (!str)
-+        goto cleanup;
-+
-+    if (!ret && VIR_ALLOC(ret) < 0)
-+        goto cleanup;
-+
-+    if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) {
-+        virReportError(VIR_ERR_XML_DETAIL,
-+                       _("cannot parse value '%s' for coalesce parameter"),
-+                       str);
-+        VIR_FREE(str);
-+        goto error;
-+    }
-+    VIR_FREE(str);
-+
-+    if (tmp > UINT32_MAX) {
-+        virReportError(VIR_ERR_OVERFLOW,
-+                       _("value '%llu' is too big for coalesce "
-+                         "parameter, maximum is '%lu'"),
-+                       tmp, (unsigned long) UINT32_MAX);
-+        goto error;
-+    }
-+    ret->rx_max_coalesced_frames = tmp;
-+
-+ cleanup:
-+    ctxt->node = save;
-+    return ret;
-+
-+ error:
-+    VIR_FREE(ret);
-+    goto cleanup;
-+}
-+
-+static void
-+virDomainNetDefCoalesceFormatXML(virBufferPtr buf,
-+                                 virNetDevCoalescePtr coalesce)
-+{
-+    if (!coalesce || !coalesce->rx_max_coalesced_frames)
-+        return;
-+
-+    virBufferAddLit(buf, "<coalesce>\n");
-+    virBufferAdjustIndent(buf, 2);
-+
-+    virBufferAddLit(buf, "<rx>\n");
-+    virBufferAdjustIndent(buf, 2);
-+
-+    virBufferAsprintf(buf, "<frames max='%u'/>\n",
-+                      coalesce->rx_max_coalesced_frames);
-+
-+    virBufferAdjustIndent(buf, -2);
-+    virBufferAddLit(buf, "</rx>\n");
-+
-+    virBufferAdjustIndent(buf, -2);
-+    virBufferAddLit(buf, "</coalesce>\n");
-+}
-+
-+
- static int
- virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
-                                 xmlXPathContextPtr ctxt,
-@@ -10242,6 +10313,13 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
-         goto error;
-     }
- 
-+    node = virXPathNode("./coalesce", ctxt);
-+    if (node) {
-+        def->coalesce = virDomainNetDefCoalesceParseXML(node, ctxt);
-+        if (!def->coalesce)
-+            goto error;
-+    }
-+
-  cleanup:
-     ctxt->node = oldnode;
-     VIR_FREE(macaddr);
-@@ -22135,6 +22213,8 @@ virDomainNetDefFormat(virBufferPtr buf,
-     if (def->mtu)
-         virBufferAsprintf(buf, "<mtu size='%u'/>\n", def->mtu);
- 
-+    virDomainNetDefCoalesceFormatXML(buf, def->coalesce);
-+
-     if (virDomainDeviceInfoFormat(buf, &def->info,
-                                   flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT
-                                   | VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) < 0)
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 71e651975..1dbbcdc51 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -41,6 +41,7 @@
- # include "numa_conf.h"
- # include "virnetdevmacvlan.h"
- # include "virsysinfo.h"
-+# include "virnetdev.h"
- # include "virnetdevip.h"
- # include "virnetdevvportprofile.h"
- # include "virnetdevbandwidth.h"
-@@ -1036,6 +1037,7 @@ struct _virDomainNetDef {
-     int trustGuestRxFilters; /* enum virTristateBool */
-     int linkstate;
-     unsigned int mtu;
-+    virNetDevCoalescePtr coalesce;
- };
- 
- /* Used for prefix of ifname of any network name generated dynamically
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index d31645fd1..53586878b 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -3012,6 +3012,30 @@ qemuDomainDefValidate(const virDomainDef *def,
- }
- 
- 
-+static bool
-+qemuDomainNetSupportsCoalesce(virDomainNetType type)
-+{
-+    switch (type) {
-+    case VIR_DOMAIN_NET_TYPE_NETWORK:
-+    case VIR_DOMAIN_NET_TYPE_BRIDGE:
-+        return true;
-+    case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
-+    case VIR_DOMAIN_NET_TYPE_ETHERNET:
-+    case VIR_DOMAIN_NET_TYPE_DIRECT:
-+    case VIR_DOMAIN_NET_TYPE_HOSTDEV:
-+    case VIR_DOMAIN_NET_TYPE_USER:
-+    case VIR_DOMAIN_NET_TYPE_SERVER:
-+    case VIR_DOMAIN_NET_TYPE_CLIENT:
-+    case VIR_DOMAIN_NET_TYPE_MCAST:
-+    case VIR_DOMAIN_NET_TYPE_INTERNAL:
-+    case VIR_DOMAIN_NET_TYPE_UDP:
-+    case VIR_DOMAIN_NET_TYPE_LAST:
-+        break;
-+    }
-+    return false;
-+}
-+
-+
- static int
- qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
-                             const virDomainDef *def ATTRIBUTE_UNUSED,
-@@ -3046,6 +3070,13 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
-                            virDomainNetTypeToString(net->type));
-             goto cleanup;
-         }
-+
-+        if (net->coalesce && !qemuDomainNetSupportsCoalesce(net->type)) {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                           _("coalesce settings on interface type %s are not supported"),
-+                           virDomainNetTypeToString(net->type));
-+            goto cleanup;
-+        }
-     }
- 
-     ret = 0;
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml
-new file mode 100644
-index 000000000..b51032442
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml
-@@ -0,0 +1,68 @@
-+<domain type='qemu'>
-+  <name>test</name>
-+  <uuid>15d091de-0181-456b-9554-e4382dc1f1ab</uuid>
-+  <memory unit='KiB'>1048576</memory>
-+  <currentMemory unit='KiB'>1048576</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc-0.13'>hvm</type>
-+    <boot dev='cdrom'/>
-+    <boot dev='hd'/>
-+    <bootmenu enable='yes'/>
-+  </os>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>restart</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <disk type='file' device='disk'>
-+      <driver name='qemu' type='qcow2' event_idx='on'/>
-+      <source file='/var/lib/libvirt/images/f14.img'/>
-+      <target dev='vda' bus='virtio'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
-+    </disk>
-+    <disk type='file' device='cdrom'>
-+      <driver name='qemu' type='raw'/>
-+      <source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/>
-+      <target dev='hdc' bus='ide'/>
-+      <readonly/>
-+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
-+    </disk>
-+    <controller type='usb' index='0'/>
-+    <controller type='virtio-serial' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
-+    </controller>
-+    <controller type='ide' index='0'/>
-+    <controller type='pci' index='0' model='pci-root'/>
-+    <interface type='network'>
-+      <source network='default'/>
-+      <mac address='52:54:00:e5:48:58'/>
-+      <model type='virtio'/>
-+      <coalesce>
-+        <rx>
-+          <frames max='7'/>
-+        </rx>
-+      </coalesce>
-+    </interface>
-+    <interface type='network'>
-+      <source network='default'/>
-+      <mac address='52:54:00:e5:48:59'/>
-+      <model type='virtio'/>
-+      <coalesce>
-+        <rx>
-+          <frames max='0'/>
-+        </rx>
-+      </coalesce>
-+    </interface>
-+    <serial type='pty'>
-+      <target port='0'/>
-+    </serial>
-+    <console type='pty'>
-+      <target type='serial' port='0'/>
-+    </console>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <memballoon model='virtio'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml
-new file mode 100644
-index 000000000..fd5fdbece
---- /dev/null
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml
-@@ -0,0 +1,71 @@
-+<domain type='qemu'>
-+  <name>test</name>
-+  <uuid>15d091de-0181-456b-9554-e4382dc1f1ab</uuid>
-+  <memory unit='KiB'>1048576</memory>
-+  <currentMemory unit='KiB'>1048576</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc-0.13'>hvm</type>
-+    <boot dev='cdrom'/>
-+    <boot dev='hd'/>
-+    <bootmenu enable='yes'/>
-+  </os>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>restart</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <disk type='file' device='disk'>
-+      <driver name='qemu' type='qcow2' event_idx='on'/>
-+      <source file='/var/lib/libvirt/images/f14.img'/>
-+      <target dev='vda' bus='virtio'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
-+    </disk>
-+    <disk type='file' device='cdrom'>
-+      <driver name='qemu' type='raw'/>
-+      <source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/>
-+      <target dev='hdc' bus='ide'/>
-+      <readonly/>
-+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
-+    </disk>
-+    <controller type='usb' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
-+    </controller>
-+    <controller type='virtio-serial' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
-+    </controller>
-+    <controller type='ide' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
-+    </controller>
-+    <controller type='pci' index='0' model='pci-root'/>
-+    <interface type='network'>
-+      <mac address='52:54:00:e5:48:58'/>
-+      <source network='default'/>
-+      <model type='virtio'/>
-+      <coalesce>
-+        <rx>
-+          <frames max='7'/>
-+        </rx>
-+      </coalesce>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
-+    </interface>
-+    <interface type='network'>
-+      <mac address='52:54:00:e5:48:59'/>
-+      <source network='default'/>
-+      <model type='virtio'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
-+    </interface>
-+    <serial type='pty'>
-+      <target port='0'/>
-+    </serial>
-+    <console type='pty'>
-+      <target type='serial' port='0'/>
-+    </console>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <memballoon model='virtio'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
-+    </memballoon>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
-index eae999dd6..26a2259fd 100644
---- a/tests/qemuxml2xmltest.c
-+++ b/tests/qemuxml2xmltest.c
-@@ -532,6 +532,7 @@ mymain(void)
-     DO_TEST("net-bandwidth", NONE);
-     DO_TEST("net-bandwidth2", NONE);
-     DO_TEST("net-mtu", NONE);
-+    DO_TEST("net-coalesce", NONE);
- 
-     DO_TEST("serial-vc", NONE);
-     DO_TEST("serial-pty", NONE);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-conf-don-t-ignore-target-dev-blah-for-macvtap-interfaces.patch b/SOURCES/libvirt-conf-don-t-ignore-target-dev-blah-for-macvtap-interfaces.patch
deleted file mode 100644
index 4b716d6..0000000
--- a/SOURCES/libvirt-conf-don-t-ignore-target-dev-blah-for-macvtap-interfaces.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From c2e748f3d928f8030e5c12b474c427086c962ad4 Mon Sep 17 00:00:00 2001
-Message-Id: <c2e748f3d928f8030e5c12b474c427086c962ad4@dist-git>
-From: Laine Stump <laine@laine.org>
-Date: Tue, 2 May 2017 12:33:11 -0400
-Subject: [PATCH] conf: don't ignore <target dev='blah'/> for macvtap
- interfaces
-
-The parser had been clearing out *all* suggested device names for
-type='direct' (aka macvtap) interfaces. All of the code implementing
-macvtap allows for a user-specified device name, so we should allow
-it. In the case that an interface name starts with "macvtap" or
-"macvlan" though, we do still clear it out, just as we do with "vnet"
-(which is the prefix used for automatically generated tap device
-names), since those are the prefixes for the names we autogenerate for
-macvtap and macvlan devices.
-
-Resolves: https://bugzilla.redhat.com/1335798
-(cherry picked from commit 9cb891141c4a5a96243c61518c4e0dbcf6a86c24)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in | 6 +++---
- src/conf/domain_conf.c    | 7 ++++++-
- 2 files changed, 9 insertions(+), 4 deletions(-)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 2dc5e751a..7e55b0327 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -5207,9 +5207,9 @@ qemu-kvm -net nic,model=? /dev/null
-       If no target is specified, certain hypervisors will
-       automatically generate a name for the created tun device. This
-       name can be manually specified, however the name <i>should not
--      start with either 'vnet' or 'vif'</i>, which are prefixes
--      reserved by libvirt and certain hypervisors. Manually specified
--      targets using these prefixes may be ignored.
-+      start with either 'vnet', 'vif', 'macvtap', or 'macvlan'</i>,
-+      which are prefixes reserved by libvirt and certain hypervisors.
-+      Manually specified targets using these prefixes may be ignored.
-     </p>
- 
-     <p>
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 7ab5e5051..84a8a94e5 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -55,6 +55,7 @@
- #include "virtpm.h"
- #include "virstring.h"
- #include "virnetdev.h"
-+#include "virnetdevmacvlan.h"
- #include "virhostdev.h"
- #include "virmdev.h"
- 
-@@ -10016,8 +10017,12 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
-         def->data.direct.linkdev = dev;
-         dev = NULL;
- 
--        if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
-+        if (ifname &&
-+            flags & VIR_DOMAIN_DEF_PARSE_INACTIVE &&
-+            (STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX) ||
-+             STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX))) {
-             VIR_FREE(ifname);
-+        }
- 
-         break;
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-conf-fix-migratable-XML-for-graphics-if-socket-is-generated-based-on-config.patch b/SOURCES/libvirt-conf-fix-migratable-XML-for-graphics-if-socket-is-generated-based-on-config.patch
new file mode 100644
index 0000000..10cf184
--- /dev/null
+++ b/SOURCES/libvirt-conf-fix-migratable-XML-for-graphics-if-socket-is-generated-based-on-config.patch
@@ -0,0 +1,57 @@
+From a1c433306e79ec6b5c0ca4b3e3243875ccabdeb2 Mon Sep 17 00:00:00 2001
+Message-Id: <a1c433306e79ec6b5c0ca4b3e3243875ccabdeb2@dist-git>
+From: Pavel Hrdina <phrdina@redhat.com>
+Date: Thu, 30 Nov 2017 17:56:41 +0100
+Subject: [PATCH] conf: fix migratable XML for graphics if socket is generated
+ based on config
+
+The graphics code is complex and there are a lot of exceptions and
+backward compatible combinations.  One of them is the possibility
+to configure "spice_auto_unix_socket" in qemu.conf which will convert
+all spice graphics with listen type "address" without any address
+specified to listen type "socket" when the guest is started.
+
+We don't format this generated socket into migratable XML to make
+migration work with older libvirt.  However, spice has another
+exception that if autoport='no' and there is no port configured
+it is converted to listen type "none".  Because of this we need
+to format autoport='yes' to make sure that the listen type will
+be the same as the offline XML.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511407
+
+Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
+Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit cb06ea57ad80a964028f22fb49d6ab96648ae741)
+Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index c58dae197c..ec138ea861 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -25150,6 +25150,18 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
+             break;
+ 
+         case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
++            /* If socket is auto-generated based on config option we don't
++             * add any listen element into migratable XML because the original
++             * listen type is "address".
++             * We need to set autoport to make sure that libvirt on destination
++             * will parse it as listen type "address", without autoport it is
++             * parsed as listen type "none". */
++            if ((flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) &&
++                glisten->fromConfig) {
++                virBufferAddStr(buf, " autoport='yes'");
++            }
++            break;
++
+         case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
+             break;
+         }
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-honor-maxnames-in-nodeListDevices-API.patch b/SOURCES/libvirt-conf-honor-maxnames-in-nodeListDevices-API.patch
new file mode 100644
index 0000000..f7b19a7
--- /dev/null
+++ b/SOURCES/libvirt-conf-honor-maxnames-in-nodeListDevices-API.patch
@@ -0,0 +1,36 @@
+From a64f825a244c77556c0ed7c5f425ba70b28cca70 Mon Sep 17 00:00:00 2001
+Message-Id: <a64f825a244c77556c0ed7c5f425ba70b28cca70@dist-git>
+From: Pavel Hrdina <phrdina@redhat.com>
+Date: Tue, 2 Jan 2018 12:39:13 +0100
+Subject: [PATCH] conf: honor maxnames in nodeListDevices API
+
+Introduced by commit <4ae9dbea99c>.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1528572
+
+Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit bbf6573e94528ac8a8867855e6671b48e13f1cd1)
+Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
+Reviewed-by: Erik Skultety <eskultet@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/virnodedeviceobj.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
+index 872ec1fd4b..c4e3a40d3a 100644
+--- a/src/conf/virnodedeviceobj.c
++++ b/src/conf/virnodedeviceobj.c
+@@ -798,6 +798,9 @@ virNodeDeviceObjListGetNamesCallback(void *payload,
+     if (data->error)
+         return 0;
+ 
++    if (data->nnames >= data->maxnames)
++        return 0;
++
+     virObjectLock(obj);
+     def = obj->def;
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-include-x86-microcode-version-in-virsh-capabiltiies.patch b/SOURCES/libvirt-conf-include-x86-microcode-version-in-virsh-capabiltiies.patch
index 7c45cd5..edf12a0 100644
--- a/SOURCES/libvirt-conf-include-x86-microcode-version-in-virsh-capabiltiies.patch
+++ b/SOURCES/libvirt-conf-include-x86-microcode-version-in-virsh-capabiltiies.patch
@@ -1,5 +1,5 @@
-From a2fe4ef20df702070ffec676172c19e6c89b8312 Mon Sep 17 00:00:00 2001
-Message-Id: <a2fe4ef20df702070ffec676172c19e6c89b8312@dist-git>
+From 4f1684dd855d48517e04507edadba2fd454e4ada Mon Sep 17 00:00:00 2001
+Message-Id: <4f1684dd855d48517e04507edadba2fd454e4ada@dist-git>
 From: Paolo Bonzini <pbonzini@redhat.com>
 Date: Tue, 12 Dec 2017 16:23:40 +0100
 Subject: [PATCH] conf: include x86 microcode version in virsh capabiltiies
@@ -16,60 +16,17 @@ CVE-2017-5715
 
 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-
-Conflicts:
-	src/cpu/cpu_x86.c
-            - context; x86DecodeCPUData has more parameters in 7.4
 ---
- src/conf/capabilities.c  | 12 ++++++++++++
- src/conf/capabilities.h  |  2 ++
- src/conf/cpu_conf.c      | 14 ++++++++++++++
- src/conf/cpu_conf.h      |  1 +
- src/cpu/cpu_x86.c        |  9 +++++++++
- src/libvirt_private.syms |  1 +
- 6 files changed, 39 insertions(+)
+ src/conf/cpu_conf.c | 14 ++++++++++++++
+ src/conf/cpu_conf.h |  1 +
+ src/cpu/cpu_x86.c   |  9 +++++++++
+ 3 files changed, 24 insertions(+)
 
-diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
-index 08907aced1..fad6cc1c07 100644
---- a/src/conf/capabilities.c
-+++ b/src/conf/capabilities.c
-@@ -355,6 +355,18 @@ virCapabilitiesAddHostNUMACell(virCapsPtr caps,
- }
- 
- 
-+/**
-+ * virCapabilitiesGetMicrocodeVersion:
-+ * @caps: capabilities to access
-+ *
-+ * Get host CPU microcode version, or 0 if unavailable
-+ */
-+unsigned int
-+virCapabilitiesGetMicrocodeVersion(virCapsPtr caps)
-+{
-+    return caps->host.cpu ? caps->host.cpu->microcodeVersion : 0;
-+}
-+
- /**
-  * virCapabilitiesSetHostCPU:
-  * @caps: capabilities to extend
-diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
-index d10eef3afd..75e0748e9e 100644
---- a/src/conf/capabilities.h
-+++ b/src/conf/capabilities.h
-@@ -299,6 +299,8 @@ virBitmapPtr virCapabilitiesGetCpusForNodemask(virCapsPtr caps,
- 
- int virCapabilitiesGetNodeInfo(virNodeInfoPtr nodeinfo);
- 
-+unsigned int virCapabilitiesGetMicrocodeVersion(virCapsPtr caps);
-+
- int virCapabilitiesInitPages(virCapsPtr caps);
- 
- int virCapabilitiesInitNUMA(virCapsPtr caps);
 diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
-index e570dffcd2..239f671fa7 100644
+index 669935acf8..7e00299c66 100644
 --- a/src/conf/cpu_conf.c
 +++ b/src/conf/cpu_conf.c
-@@ -127,6 +127,7 @@ virCPUDefCopyModelFilter(virCPUDefPtr dst,
+@@ -130,6 +130,7 @@ virCPUDefCopyModelFilter(virCPUDefPtr dst,
          VIR_STRDUP(dst->vendor_id, src->vendor_id) < 0 ||
          VIR_ALLOC_N(dst->features, src->nfeatures) < 0)
          return -1;
@@ -77,7 +34,7 @@ index e570dffcd2..239f671fa7 100644
      dst->nfeatures_max = src->nfeatures;
      dst->nfeatures = 0;
  
-@@ -178,6 +179,7 @@ virCPUDefStealModel(virCPUDefPtr dst,
+@@ -181,6 +182,7 @@ virCPUDefStealModel(virCPUDefPtr dst,
  
      VIR_STEAL_PTR(dst->model, src->model);
      VIR_STEAL_PTR(dst->features, src->features);
@@ -85,7 +42,7 @@ index e570dffcd2..239f671fa7 100644
      dst->nfeatures_max = src->nfeatures_max;
      src->nfeatures_max = 0;
      dst->nfeatures = src->nfeatures;
-@@ -379,6 +381,14 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
+@@ -382,6 +384,14 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
              goto cleanup;
          }
          VIR_FREE(arch);
@@ -112,7 +69,7 @@ index e570dffcd2..239f671fa7 100644
          virBufferAddLit(buf, "<topology");
          virBufferAsprintf(buf, " sockets='%u'", def->sockets);
 diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
-index 1978814d36..1a13ae6e46 100644
+index d1983f5d4f..9f2e7ee264 100644
 --- a/src/conf/cpu_conf.h
 +++ b/src/conf/cpu_conf.h
 @@ -133,6 +133,7 @@ struct _virCPUDef {
@@ -124,7 +81,7 @@ index 1978814d36..1a13ae6e46 100644
      unsigned int cores;
      unsigned int threads;
 diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
-index 8af0a1a2b7..efef7f235d 100644
+index 693e571a3d..ad35532fc1 100644
 --- a/src/cpu/cpu_x86.c
 +++ b/src/cpu/cpu_x86.c
 @@ -33,6 +33,7 @@
@@ -144,7 +101,7 @@ index 8af0a1a2b7..efef7f235d 100644
  int virCPUx86DriverOnceInit(void);
  VIR_ONCE_GLOBAL_INIT(virCPUx86Driver);
  
-@@ -1391,6 +1394,8 @@ virCPUx86DriverOnceInit(void)
+@@ -1409,6 +1412,8 @@ virCPUx86DriverOnceInit(void)
      if (!(cpuMap = virCPUx86LoadMap()))
          return -1;
  
@@ -153,7 +110,7 @@ index 8af0a1a2b7..efef7f235d 100644
      return 0;
  }
  
-@@ -2408,6 +2413,9 @@ virCPUx86GetHost(virCPUDefPtr cpu,
+@@ -2424,6 +2429,9 @@ virCPUx86GetHost(virCPUDefPtr cpu,
      virCPUDataPtr cpuData = NULL;
      int ret = -1;
  
@@ -163,26 +120,14 @@ index 8af0a1a2b7..efef7f235d 100644
      if (!(cpuData = virCPUDataNew(archs[0])))
          goto cleanup;
  
-@@ -2416,6 +2424,7 @@ virCPUx86GetHost(virCPUDefPtr cpu,
+@@ -2432,6 +2440,7 @@ virCPUx86GetHost(virCPUDefPtr cpu,
          goto cleanup;
  
-     ret = x86DecodeCPUData(cpu, cpuData, models, nmodels, NULL);
+     ret = x86DecodeCPUData(cpu, cpuData, models);
 +    cpu->microcodeVersion = microcodeVersion;
  
   cleanup:
      virCPUx86DataFree(cpuData);
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index c50b6c2f77..c7834115fd 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -57,6 +57,7 @@ virCapabilitiesFreeGuest;
- virCapabilitiesFreeMachines;
- virCapabilitiesFreeNUMAInfo;
- virCapabilitiesGetCpusForNodemask;
-+virCapabilitiesGetMicrocodeVersion;
- virCapabilitiesGetNodeInfo;
- virCapabilitiesHostSecModelAddBaseLabel;
- virCapabilitiesInitNUMA;
 -- 
 2.15.1
 
diff --git a/SOURCES/libvirt-conf-introduce-virDomainControllerDriverFormat.patch b/SOURCES/libvirt-conf-introduce-virDomainControllerDriverFormat.patch
deleted file mode 100644
index 5f37f4f..0000000
--- a/SOURCES/libvirt-conf-introduce-virDomainControllerDriverFormat.patch
+++ /dev/null
@@ -1,104 +0,0 @@
-From 8874ecd393f7098376d9c46c34f43d47a697f932 Mon Sep 17 00:00:00 2001
-Message-Id: <8874ecd393f7098376d9c46c34f43d47a697f932@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:48:55 +0200
-Subject: [PATCH] conf: introduce virDomainControllerDriverFormat
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Split out formatting the <driver> subelement of <controller>
-to make adding new options easier.
-
-(cherry picked from commit fe262186dccfa5c5cbcfe5ab7eb95195cf3b10f5)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 55 +++++++++++++++++++++++++++++---------------------
- 1 file changed, 32 insertions(+), 23 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index e004559f9f..275145b1ec 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -21323,6 +21323,37 @@ virDomainDiskDefFormat(virBufferPtr buf,
- #undef FORMAT_IOTUNE
- 
- 
-+static void
-+virDomainControllerDriverFormat(virBufferPtr buf,
-+                                virDomainControllerDefPtr def)
-+{
-+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
-+
-+    if (def->queues)
-+        virBufferAsprintf(&driverBuf, " queues='%u'", def->queues);
-+
-+    if (def->cmd_per_lun)
-+        virBufferAsprintf(&driverBuf, " cmd_per_lun='%u'", def->cmd_per_lun);
-+
-+    if (def->max_sectors)
-+        virBufferAsprintf(&driverBuf, " max_sectors='%u'", def->max_sectors);
-+
-+    if (def->ioeventfd) {
-+        virBufferAsprintf(&driverBuf, " ioeventfd='%s'",
-+                          virTristateSwitchTypeToString(def->ioeventfd));
-+    }
-+
-+    if (def->iothread)
-+        virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
-+
-+    if (virBufferUse(&driverBuf)) {
-+        virBufferAddLit(buf, "<driver");
-+        virBufferAddBuffer(buf, &driverBuf);
-+        virBufferAddLit(buf, "/>\n");
-+    }
-+}
-+
-+
- static int
- virDomainControllerDefFormat(virBufferPtr buf,
-                              virDomainControllerDefPtr def,
-@@ -21332,7 +21363,6 @@ virDomainControllerDefFormat(virBufferPtr buf,
-     const char *model = NULL;
-     const char *modelName = NULL;
-     bool pcihole64 = false, pciModel = false, pciTarget = false;
--    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
- 
-     if (!type) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-@@ -21437,28 +21467,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
-             }
-         }
- 
--        if (def->queues)
--            virBufferAsprintf(&driverBuf, " queues='%u'", def->queues);
--
--        if (def->cmd_per_lun)
--            virBufferAsprintf(&driverBuf, " cmd_per_lun='%u'", def->cmd_per_lun);
--
--        if (def->max_sectors)
--            virBufferAsprintf(&driverBuf, " max_sectors='%u'", def->max_sectors);
--
--        if (def->ioeventfd) {
--            virBufferAsprintf(&driverBuf, " ioeventfd='%s'",
--                              virTristateSwitchTypeToString(def->ioeventfd));
--        }
--
--        if (def->iothread)
--            virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
--
--        if (virBufferUse(&driverBuf)) {
--            virBufferAddLit(buf, "<driver");
--            virBufferAddBuffer(buf, &driverBuf);
--            virBufferAddLit(buf, "/>\n");
--        }
-+        virDomainControllerDriverFormat(buf, def);
- 
-         if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
-             virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-conf-move-generated-member-from-virMacAddr-to-virDomainNetDef.patch b/SOURCES/libvirt-conf-move-generated-member-from-virMacAddr-to-virDomainNetDef.patch
new file mode 100644
index 0000000..32863e9
--- /dev/null
+++ b/SOURCES/libvirt-conf-move-generated-member-from-virMacAddr-to-virDomainNetDef.patch
@@ -0,0 +1,162 @@
+From 5b225fe7ac882c8696b9759251c519c785f5407c Mon Sep 17 00:00:00 2001
+Message-Id: <5b225fe7ac882c8696b9759251c519c785f5407c@dist-git>
+From: Laine Stump <laine@laine.org>
+Date: Tue, 6 Mar 2018 16:19:31 -0500
+Subject: [PATCH] conf: move 'generated' member from virMacAddr to
+ virDomainNetDef
+
+Commit 7e62c4cd26d (first appearing in libvirt-3.9.0 as a resolution
+to rhbz #1343919) added a "generated" attribute to virMacAddr that was
+set whenever a mac address was auto-generated by libvirt. This
+knowledge was used in a single place - when trying to match a NetDef
+from the Domain to Delete with user-provided XML. Since the XML parser
+always auto-generates a MAC address for NetDefs when none is provided,
+it was previously impossible to make a search where the MAC address
+isn't significant, but the addition of the "generated" attribute made
+it possible for the search function to ignore auto-generated MACs.
+
+This implementation had a problem though - it was adding a field to a
+"low level" struct - virMacAddr - which is used in other places with
+the assumption that it contains exactly a 6 byte MAC address and
+nothing else. In particular, virNWFilterSnoopEthHdr uses virMacAddr as
+part of the definition of an ethernet packet header, whose layout must
+of course match an actual ethernet packet. Adding the extra bools into
+virNWFilterSnoopEthHdr caused the nwfilter driver's "IP discovery via
+DHCP packet snooping" functionality to mysteriously stop working.
+
+In order to fix that behavior, and prevent potential future similar
+odd behavior, this patch moves the "generated" member out of
+virMacAddr (so that it is again really is just a MAC address) into
+virDomainNetDef, and sets it only when virDomainNetGenerateMAC() is
+called from virDomainNetDefParseXML() (which is the only time we care
+about it).
+
+Resolves: https://bugzilla.redhat.com/1529338
+
+(It should also be applied to any maintenance branch that applies
+commit 7e62c4cd26 and friends to resolve
+https://bugzilla.redhat.com/1343919)
+
+Signed-off-by: Laine Stump <laine@laine.org>
+(cherry picked from commit e62cb4a9b78c7f4499a206635fb4f06e6ac627e5)
+---
+ src/conf/domain_conf.c    | 3 ++-
+ src/conf/domain_conf.h    | 1 +
+ src/util/virmacaddr.c     | 5 -----
+ src/util/virmacaddr.h     | 9 +++++++--
+ tests/bhyveargv2xmlmock.c | 1 -
+ 5 files changed, 10 insertions(+), 9 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 0af3dd5ab6..1a3db4a7be 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -10989,6 +10989,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
+         }
+     } else {
+         virDomainNetGenerateMAC(xmlopt, &def->mac);
++        def->mac_generated = true;
+     }
+ 
+     if (devaddr) {
+@@ -16205,7 +16206,7 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net)
+     size_t i;
+     int matchidx = -1;
+     char mac[VIR_MAC_STRING_BUFLEN];
+-    bool MACAddrSpecified = !net->mac.generated;
++    bool MACAddrSpecified = !net->mac_generated;
+     bool PCIAddrSpecified = virDomainDeviceAddressIsValid(&net->info,
+                                                           VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI);
+ 
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index ed7b587bed..3817887322 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -962,6 +962,7 @@ struct _virDomainActualNetDef {
+ struct _virDomainNetDef {
+     virDomainNetType type;
+     virMacAddr mac;
++    bool mac_generated; /* true if mac was *just now* auto-generated by libvirt */
+     char *model;
+     union {
+         struct {
+diff --git a/src/util/virmacaddr.c b/src/util/virmacaddr.c
+index 409fdc34d5..7afe032b9c 100644
+--- a/src/util/virmacaddr.c
++++ b/src/util/virmacaddr.c
+@@ -107,7 +107,6 @@ void
+ virMacAddrSet(virMacAddrPtr dst, const virMacAddr *src)
+ {
+     memcpy(dst, src, sizeof(*src));
+-    dst->generated = false;
+ }
+ 
+ /**
+@@ -121,7 +120,6 @@ void
+ virMacAddrSetRaw(virMacAddrPtr dst, const unsigned char src[VIR_MAC_BUFLEN])
+ {
+     memcpy(dst->addr, src, VIR_MAC_BUFLEN);
+-    dst->generated = false;
+ }
+ 
+ /**
+@@ -151,7 +149,6 @@ virMacAddrParse(const char* str, virMacAddrPtr addr)
+ {
+     size_t i;
+ 
+-    addr->generated = false;
+     errno = 0;
+     for (i = 0; i < VIR_MAC_BUFLEN; i++) {
+         char *end_ptr;
+@@ -220,7 +217,6 @@ virMacAddrParseHex(const char *str, virMacAddrPtr addr)
+         str[VIR_MAC_HEXLEN])
+         return -1;
+ 
+-    addr->generated = false;
+     for (i = 0; i < VIR_MAC_BUFLEN; i++)
+         addr->addr[i] = (virHexToBin(str[2 * i]) << 4 |
+                          virHexToBin(str[2 * i + 1]));
+@@ -236,7 +232,6 @@ void virMacAddrGenerate(const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN],
+     addr->addr[3] = virRandomBits(8);
+     addr->addr[4] = virRandomBits(8);
+     addr->addr[5] = virRandomBits(8);
+-    addr->generated = true;
+ }
+ 
+ /* The low order bit of the first byte is the "multicast" bit. */
+diff --git a/src/util/virmacaddr.h b/src/util/virmacaddr.h
+index ef4285d639..d0dd4a45c6 100644
+--- a/src/util/virmacaddr.h
++++ b/src/util/virmacaddr.h
+@@ -36,9 +36,14 @@ typedef virMacAddr *virMacAddrPtr;
+ 
+ struct _virMacAddr {
+     unsigned char addr[VIR_MAC_BUFLEN];
+-    bool generated; /* True if MAC address was autogenerated,
+-                       false otherwise. */
+ };
++/* This struct is used as a part of a larger struct that is
++ * overlaid on an ethernet packet captured with libpcap, so it
++ * must not have any extra members added - it must remain exactly
++ * 6 bytes in length.
++ */
++verify(sizeof(struct _virMacAddr) == 6);
++
+ 
+ int virMacAddrCompare(const char *mac1, const char *mac2);
+ int virMacAddrCmp(const virMacAddr *mac1, const virMacAddr *mac2);
+diff --git a/tests/bhyveargv2xmlmock.c b/tests/bhyveargv2xmlmock.c
+index dd25f4e13a..1f08bebb7b 100644
+--- a/tests/bhyveargv2xmlmock.c
++++ b/tests/bhyveargv2xmlmock.c
+@@ -16,7 +16,6 @@ virMacAddrGenerate(const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN],
+     addr->addr[3] = 0;
+     addr->addr[4] = 0;
+     addr->addr[5] = 0;
+-    addr->generated = true;
+ }
+ 
+ int
+-- 
+2.16.2
+
diff --git a/SOURCES/libvirt-conf-nodedev-Split-virNodeDeviceDefFormat-into-more-functions.patch b/SOURCES/libvirt-conf-nodedev-Split-virNodeDeviceDefFormat-into-more-functions.patch
deleted file mode 100644
index 7cd3720..0000000
--- a/SOURCES/libvirt-conf-nodedev-Split-virNodeDeviceDefFormat-into-more-functions.patch
+++ /dev/null
@@ -1,644 +0,0 @@
-From f636c368f181c9f18ee135e8902490faf30186f9 Mon Sep 17 00:00:00 2001
-Message-Id: <f636c368f181c9f18ee135e8902490faf30186f9@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 18 May 2017 14:02:48 +0200
-Subject: [PATCH] conf: nodedev: Split virNodeDeviceDefFormat into more
- functions
-
-Make the code look cleaner by moving the capability specific bits into
-separate functions.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1452072
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit bfaaaf108da087c38cc0f2890ed96730a3734ba8)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/node_device_conf.c | 578 ++++++++++++++++++++++++--------------------
- 1 file changed, 322 insertions(+), 256 deletions(-)
-
-diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
-index cc3fad8b9..02215f32d 100644
---- a/src/conf/node_device_conf.c
-+++ b/src/conf/node_device_conf.c
-@@ -155,6 +155,320 @@ virPCIEDeviceInfoFormat(virBufferPtr buf,
- }
- 
- 
-+static void
-+virNodeDeviceCapSystemDefFormat(virBufferPtr buf,
-+                                const virNodeDevCapData *data)
-+{
-+    char uuidstr[VIR_UUID_STRING_BUFLEN];
-+
-+    if (data->system.product_name)
-+        virBufferEscapeString(buf, "<product>%s</product>\n",
-+                              data->system.product_name);
-+    virBufferAddLit(buf, "<hardware>\n");
-+    virBufferAdjustIndent(buf, 2);
-+    if (data->system.hardware.vendor_name)
-+        virBufferEscapeString(buf, "<vendor>%s</vendor>\n",
-+                              data->system.hardware.vendor_name);
-+    if (data->system.hardware.version)
-+        virBufferEscapeString(buf, "<version>%s</version>\n",
-+                              data->system.hardware.version);
-+    if (data->system.hardware.serial)
-+        virBufferEscapeString(buf, "<serial>%s</serial>\n",
-+                              data->system.hardware.serial);
-+    virUUIDFormat(data->system.hardware.uuid, uuidstr);
-+    virBufferAsprintf(buf, "<uuid>%s</uuid>\n", uuidstr);
-+    virBufferAdjustIndent(buf, -2);
-+    virBufferAddLit(buf, "</hardware>\n");
-+
-+    virBufferAddLit(buf, "<firmware>\n");
-+    virBufferAdjustIndent(buf, 2);
-+    if (data->system.firmware.vendor_name)
-+        virBufferEscapeString(buf, "<vendor>%s</vendor>\n",
-+                              data->system.firmware.vendor_name);
-+    if (data->system.firmware.version)
-+        virBufferEscapeString(buf, "<version>%s</version>\n",
-+                              data->system.firmware.version);
-+    if (data->system.firmware.release_date)
-+        virBufferEscapeString(buf, "<release_date>%s</release_date>\n",
-+                              data->system.firmware.release_date);
-+    virBufferAdjustIndent(buf, -2);
-+    virBufferAddLit(buf, "</firmware>\n");
-+}
-+
-+
-+static void
-+virNodeDeviceCapPCIDefFormat(virBufferPtr buf,
-+                             const virNodeDevCapData *data)
-+{
-+    size_t i;
-+
-+    virBufferAsprintf(buf, "<domain>%d</domain>\n",
-+                      data->pci_dev.domain);
-+    virBufferAsprintf(buf, "<bus>%d</bus>\n", data->pci_dev.bus);
-+    virBufferAsprintf(buf, "<slot>%d</slot>\n",
-+                      data->pci_dev.slot);
-+    virBufferAsprintf(buf, "<function>%d</function>\n",
-+                      data->pci_dev.function);
-+    virBufferAsprintf(buf, "<product id='0x%04x'",
-+                      data->pci_dev.product);
-+    if (data->pci_dev.product_name)
-+        virBufferEscapeString(buf, ">%s</product>\n",
-+                              data->pci_dev.product_name);
-+    else
-+        virBufferAddLit(buf, " />\n");
-+    virBufferAsprintf(buf, "<vendor id='0x%04x'",
-+                      data->pci_dev.vendor);
-+    if (data->pci_dev.vendor_name)
-+        virBufferEscapeString(buf, ">%s</vendor>\n",
-+                              data->pci_dev.vendor_name);
-+    else
-+        virBufferAddLit(buf, " />\n");
-+    if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION) {
-+        virBufferAddLit(buf, "<capability type='phys_function'>\n");
-+        virBufferAdjustIndent(buf, 2);
-+        virBufferAsprintf(buf,
-+                          "<address domain='0x%.4x' bus='0x%.2x' "
-+                          "slot='0x%.2x' function='0x%.1x'/>\n",
-+                          data->pci_dev.physical_function->domain,
-+                          data->pci_dev.physical_function->bus,
-+                          data->pci_dev.physical_function->slot,
-+                          data->pci_dev.physical_function->function);
-+        virBufferAdjustIndent(buf, -2);
-+        virBufferAddLit(buf, "</capability>\n");
-+    }
-+    if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION) {
-+        virBufferAddLit(buf, "<capability type='virt_functions'");
-+        if (data->pci_dev.max_virtual_functions)
-+            virBufferAsprintf(buf, " maxCount='%u'",
-+                              data->pci_dev.max_virtual_functions);
-+        if (data->pci_dev.num_virtual_functions == 0) {
-+            virBufferAddLit(buf, "/>\n");
-+        } else {
-+            virBufferAddLit(buf, ">\n");
-+            virBufferAdjustIndent(buf, 2);
-+            for (i = 0; i < data->pci_dev.num_virtual_functions; i++) {
-+                virBufferAsprintf(buf,
-+                                  "<address domain='0x%.4x' bus='0x%.2x' "
-+                                  "slot='0x%.2x' function='0x%.1x'/>\n",
-+                                  data->pci_dev.virtual_functions[i]->domain,
-+                                  data->pci_dev.virtual_functions[i]->bus,
-+                                  data->pci_dev.virtual_functions[i]->slot,
-+                                  data->pci_dev.virtual_functions[i]->function);
-+            }
-+            virBufferAdjustIndent(buf, -2);
-+            virBufferAddLit(buf, "</capability>\n");
-+        }
-+    }
-+    if (data->pci_dev.hdrType) {
-+        virBufferAsprintf(buf, "<capability type='%s'/>\n",
-+                          virPCIHeaderTypeToString(data->pci_dev.hdrType));
-+    }
-+    if (data->pci_dev.nIommuGroupDevices) {
-+        virBufferAsprintf(buf, "<iommuGroup number='%d'>\n",
-+                          data->pci_dev.iommuGroupNumber);
-+        virBufferAdjustIndent(buf, 2);
-+        for (i = 0; i < data->pci_dev.nIommuGroupDevices; i++) {
-+            virBufferAsprintf(buf,
-+                              "<address domain='0x%.4x' bus='0x%.2x' "
-+                              "slot='0x%.2x' function='0x%.1x'/>\n",
-+                              data->pci_dev.iommuGroupDevices[i]->domain,
-+                              data->pci_dev.iommuGroupDevices[i]->bus,
-+                              data->pci_dev.iommuGroupDevices[i]->slot,
-+                              data->pci_dev.iommuGroupDevices[i]->function);
-+        }
-+        virBufferAdjustIndent(buf, -2);
-+        virBufferAddLit(buf, "</iommuGroup>\n");
-+    }
-+    if (data->pci_dev.numa_node >= 0)
-+        virBufferAsprintf(buf, "<numa node='%d'/>\n",
-+                          data->pci_dev.numa_node);
-+
-+    if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCIE)
-+        virPCIEDeviceInfoFormat(buf, data->pci_dev.pci_express);
-+}
-+
-+
-+static void
-+virNodeDeviceCapUSBDevDefFormat(virBufferPtr buf,
-+                                const virNodeDevCapData *data)
-+{
-+    virBufferAsprintf(buf, "<bus>%d</bus>\n", data->usb_dev.bus);
-+    virBufferAsprintf(buf, "<device>%d</device>\n",
-+                      data->usb_dev.device);
-+    virBufferAsprintf(buf, "<product id='0x%04x'",
-+                      data->usb_dev.product);
-+    if (data->usb_dev.product_name)
-+        virBufferEscapeString(buf, ">%s</product>\n",
-+                              data->usb_dev.product_name);
-+    else
-+        virBufferAddLit(buf, " />\n");
-+    virBufferAsprintf(buf, "<vendor id='0x%04x'",
-+                      data->usb_dev.vendor);
-+    if (data->usb_dev.vendor_name)
-+        virBufferEscapeString(buf, ">%s</vendor>\n",
-+                              data->usb_dev.vendor_name);
-+    else
-+        virBufferAddLit(buf, " />\n");
-+}
-+
-+
-+static void
-+virNodeDeviceCapUSBInterfaceDefFormat(virBufferPtr buf,
-+                                      const virNodeDevCapData *data)
-+{
-+    virBufferAsprintf(buf, "<number>%d</number>\n",
-+                      data->usb_if.number);
-+    virBufferAsprintf(buf, "<class>%d</class>\n",
-+                      data->usb_if._class);
-+    virBufferAsprintf(buf, "<subclass>%d</subclass>\n",
-+                      data->usb_if.subclass);
-+    virBufferAsprintf(buf, "<protocol>%d</protocol>\n",
-+                      data->usb_if.protocol);
-+    if (data->usb_if.description)
-+        virBufferEscapeString(buf,
-+                              "<description>%s</description>\n",
-+                              data->usb_if.description);
-+}
-+
-+
-+static void
-+virNodeDeviceCapNetDefFormat(virBufferPtr buf,
-+                             const virNodeDevCapData *data)
-+{
-+    size_t i;
-+
-+    virBufferEscapeString(buf, "<interface>%s</interface>\n",
-+                          data->net.ifname);
-+    if (data->net.address)
-+        virBufferEscapeString(buf, "<address>%s</address>\n",
-+                              data->net.address);
-+    virInterfaceLinkFormat(buf, &data->net.lnk);
-+    if (data->net.features) {
-+        for (i = 0; i < VIR_NET_DEV_FEAT_LAST; i++) {
-+            if (virBitmapIsBitSet(data->net.features, i)) {
-+                virBufferAsprintf(buf, "<feature name='%s'/>\n",
-+                                  virNetDevFeatureTypeToString(i));
-+            }
-+        }
-+    }
-+    if (data->net.subtype != VIR_NODE_DEV_CAP_NET_LAST) {
-+        const char *subtyp =
-+            virNodeDevNetCapTypeToString(data->net.subtype);
-+        virBufferEscapeString(buf, "<capability type='%s'/>\n",
-+                              subtyp);
-+    }
-+}
-+
-+
-+static void
-+virNodeDeviceCapSCSIHostDefFormat(virBufferPtr buf,
-+                                  const virNodeDevCapData *data)
-+{
-+    virBufferAsprintf(buf, "<host>%d</host>\n",
-+                      data->scsi_host.host);
-+    if (data->scsi_host.unique_id != -1)
-+        virBufferAsprintf(buf, "<unique_id>%d</unique_id>\n",
-+                          data->scsi_host.unique_id);
-+    if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
-+        virBufferAddLit(buf, "<capability type='fc_host'>\n");
-+        virBufferAdjustIndent(buf, 2);
-+        virBufferEscapeString(buf, "<wwnn>%s</wwnn>\n",
-+                              data->scsi_host.wwnn);
-+        virBufferEscapeString(buf, "<wwpn>%s</wwpn>\n",
-+                              data->scsi_host.wwpn);
-+        virBufferEscapeString(buf, "<fabric_wwn>%s</fabric_wwn>\n",
-+                              data->scsi_host.fabric_wwn);
-+        virBufferAdjustIndent(buf, -2);
-+        virBufferAddLit(buf, "</capability>\n");
-+    }
-+    if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) {
-+        virBufferAddLit(buf, "<capability type='vport_ops'>\n");
-+        virBufferAdjustIndent(buf, 2);
-+        virBufferAsprintf(buf, "<max_vports>%d</max_vports>\n",
-+                          data->scsi_host.max_vports);
-+        virBufferAsprintf(buf, "<vports>%d</vports>\n",
-+                          data->scsi_host.vports);
-+        virBufferAdjustIndent(buf, -2);
-+        virBufferAddLit(buf, "</capability>\n");
-+    }
-+}
-+
-+
-+static void
-+virNodeDeviceCapSCSIDefFormat(virBufferPtr buf,
-+                              const virNodeDevCapData *data)
-+{
-+    virBufferAsprintf(buf, "<host>%d</host>\n", data->scsi.host);
-+    virBufferAsprintf(buf, "<bus>%d</bus>\n", data->scsi.bus);
-+    virBufferAsprintf(buf, "<target>%d</target>\n",
-+                      data->scsi.target);
-+    virBufferAsprintf(buf, "<lun>%d</lun>\n", data->scsi.lun);
-+    if (data->scsi.type)
-+        virBufferEscapeString(buf, "<type>%s</type>\n",
-+                              data->scsi.type);
-+}
-+
-+
-+static void
-+virNodeDeviceCapStorageDefFormat(virBufferPtr buf,
-+                                 const virNodeDevCapData *data)
-+{
-+    virBufferEscapeString(buf, "<block>%s</block>\n",
-+                          data->storage.block);
-+    if (data->storage.bus)
-+        virBufferEscapeString(buf, "<bus>%s</bus>\n",
-+                              data->storage.bus);
-+    if (data->storage.drive_type)
-+        virBufferEscapeString(buf, "<drive_type>%s</drive_type>\n",
-+                              data->storage.drive_type);
-+    if (data->storage.model)
-+        virBufferEscapeString(buf, "<model>%s</model>\n",
-+                              data->storage.model);
-+    if (data->storage.vendor)
-+        virBufferEscapeString(buf, "<vendor>%s</vendor>\n",
-+                              data->storage.vendor);
-+    if (data->storage.serial)
-+        virBufferEscapeString(buf, "<serial>%s</serial>\n",
-+                              data->storage.serial);
-+    if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) {
-+        int avl = data->storage.flags &
-+            VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE;
-+        virBufferAddLit(buf, "<capability type='removable'>\n");
-+        virBufferAdjustIndent(buf, 2);
-+        virBufferAsprintf(buf, "<media_available>%d"
-+                          "</media_available>\n", avl ? 1 : 0);
-+        virBufferAsprintf(buf, "<media_size>%llu</media_size>\n",
-+                          data->storage.removable_media_size);
-+        if (data->storage.media_label)
-+            virBufferEscapeString(buf,
-+                                  "<media_label>%s</media_label>\n",
-+                                  data->storage.media_label);
-+        if (data->storage.logical_block_size > 0)
-+            virBufferAsprintf(buf, "<logical_block_size>%llu"
-+                              "</logical_block_size>\n",
-+                              data->storage.logical_block_size);
-+        if (data->storage.num_blocks > 0)
-+            virBufferAsprintf(buf,
-+                              "<num_blocks>%llu</num_blocks>\n",
-+                              data->storage.num_blocks);
-+        virBufferAdjustIndent(buf, -2);
-+        virBufferAddLit(buf, "</capability>\n");
-+    } else {
-+        virBufferAsprintf(buf, "<size>%llu</size>\n",
-+                          data->storage.size);
-+        if (data->storage.logical_block_size > 0)
-+            virBufferAsprintf(buf, "<logical_block_size>%llu"
-+                              "</logical_block_size>\n",
-+                              data->storage.logical_block_size);
-+        if (data->storage.num_blocks > 0)
-+            virBufferAsprintf(buf, "<num_blocks>%llu</num_blocks>\n",
-+                              data->storage.num_blocks);
-+    }
-+    if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE)
-+        virBufferAddLit(buf, "<capability type='hotpluggable'/>\n");
-+}
-+
-+
- char *
- virNodeDeviceDefFormat(const virNodeDeviceDef *def)
- {
-@@ -185,7 +499,6 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
-     }
- 
-     for (caps = def->caps; caps; caps = caps->next) {
--        char uuidstr[VIR_UUID_STRING_BUFLEN];
-         virNodeDevCapDataPtr data = &caps->data;
- 
-         virBufferAsprintf(&buf, "<capability type='%s'>\n",
-@@ -193,279 +506,32 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
-         virBufferAdjustIndent(&buf, 2);
-         switch (caps->data.type) {
-         case VIR_NODE_DEV_CAP_SYSTEM:
--            if (data->system.product_name)
--                virBufferEscapeString(&buf, "<product>%s</product>\n",
--                                      data->system.product_name);
--            virBufferAddLit(&buf, "<hardware>\n");
--            virBufferAdjustIndent(&buf, 2);
--            if (data->system.hardware.vendor_name)
--                virBufferEscapeString(&buf, "<vendor>%s</vendor>\n",
--                                      data->system.hardware.vendor_name);
--            if (data->system.hardware.version)
--                virBufferEscapeString(&buf, "<version>%s</version>\n",
--                                      data->system.hardware.version);
--            if (data->system.hardware.serial)
--                virBufferEscapeString(&buf, "<serial>%s</serial>\n",
--                                      data->system.hardware.serial);
--            virUUIDFormat(data->system.hardware.uuid, uuidstr);
--            virBufferAsprintf(&buf, "<uuid>%s</uuid>\n", uuidstr);
--            virBufferAdjustIndent(&buf, -2);
--            virBufferAddLit(&buf, "</hardware>\n");
--
--            virBufferAddLit(&buf, "<firmware>\n");
--            virBufferAdjustIndent(&buf, 2);
--            if (data->system.firmware.vendor_name)
--                virBufferEscapeString(&buf, "<vendor>%s</vendor>\n",
--                                      data->system.firmware.vendor_name);
--            if (data->system.firmware.version)
--                virBufferEscapeString(&buf, "<version>%s</version>\n",
--                                      data->system.firmware.version);
--            if (data->system.firmware.release_date)
--                virBufferEscapeString(&buf, "<release_date>%s</release_date>\n",
--                                      data->system.firmware.release_date);
--            virBufferAdjustIndent(&buf, -2);
--            virBufferAddLit(&buf, "</firmware>\n");
-+            virNodeDeviceCapSystemDefFormat(&buf, data);
-             break;
-         case VIR_NODE_DEV_CAP_PCI_DEV:
--            virBufferAsprintf(&buf, "<domain>%d</domain>\n",
--                              data->pci_dev.domain);
--            virBufferAsprintf(&buf, "<bus>%d</bus>\n", data->pci_dev.bus);
--            virBufferAsprintf(&buf, "<slot>%d</slot>\n",
--                              data->pci_dev.slot);
--            virBufferAsprintf(&buf, "<function>%d</function>\n",
--                              data->pci_dev.function);
--            virBufferAsprintf(&buf, "<product id='0x%04x'",
--                                  data->pci_dev.product);
--            if (data->pci_dev.product_name)
--                virBufferEscapeString(&buf, ">%s</product>\n",
--                                      data->pci_dev.product_name);
--            else
--                virBufferAddLit(&buf, " />\n");
--            virBufferAsprintf(&buf, "<vendor id='0x%04x'",
--                                  data->pci_dev.vendor);
--            if (data->pci_dev.vendor_name)
--                virBufferEscapeString(&buf, ">%s</vendor>\n",
--                                      data->pci_dev.vendor_name);
--            else
--                virBufferAddLit(&buf, " />\n");
--            if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION) {
--                virBufferAddLit(&buf, "<capability type='phys_function'>\n");
--                virBufferAdjustIndent(&buf, 2);
--                virBufferAsprintf(&buf,
--                                  "<address domain='0x%.4x' bus='0x%.2x' "
--                                  "slot='0x%.2x' function='0x%.1x'/>\n",
--                                  data->pci_dev.physical_function->domain,
--                                  data->pci_dev.physical_function->bus,
--                                  data->pci_dev.physical_function->slot,
--                                  data->pci_dev.physical_function->function);
--                virBufferAdjustIndent(&buf, -2);
--                virBufferAddLit(&buf, "</capability>\n");
--            }
--            if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION) {
--                virBufferAddLit(&buf, "<capability type='virt_functions'");
--                if (data->pci_dev.max_virtual_functions)
--                    virBufferAsprintf(&buf, " maxCount='%u'",
--                                      data->pci_dev.max_virtual_functions);
--                if (data->pci_dev.num_virtual_functions == 0) {
--                    virBufferAddLit(&buf, "/>\n");
--                } else {
--                    virBufferAddLit(&buf, ">\n");
--                    virBufferAdjustIndent(&buf, 2);
--                    for (i = 0; i < data->pci_dev.num_virtual_functions; i++) {
--                        virBufferAsprintf(&buf,
--                                          "<address domain='0x%.4x' bus='0x%.2x' "
--                                          "slot='0x%.2x' function='0x%.1x'/>\n",
--                                          data->pci_dev.virtual_functions[i]->domain,
--                                          data->pci_dev.virtual_functions[i]->bus,
--                                          data->pci_dev.virtual_functions[i]->slot,
--                                          data->pci_dev.virtual_functions[i]->function);
--                    }
--                    virBufferAdjustIndent(&buf, -2);
--                    virBufferAddLit(&buf, "</capability>\n");
--                }
--            }
--            if (data->pci_dev.hdrType) {
--                virBufferAsprintf(&buf, "<capability type='%s'/>\n",
--                                  virPCIHeaderTypeToString(data->pci_dev.hdrType));
--            }
--            if (data->pci_dev.nIommuGroupDevices) {
--                virBufferAsprintf(&buf, "<iommuGroup number='%d'>\n",
--                                  data->pci_dev.iommuGroupNumber);
--                virBufferAdjustIndent(&buf, 2);
--                for (i = 0; i < data->pci_dev.nIommuGroupDevices; i++) {
--                    virBufferAsprintf(&buf,
--                                      "<address domain='0x%.4x' bus='0x%.2x' "
--                                      "slot='0x%.2x' function='0x%.1x'/>\n",
--                                      data->pci_dev.iommuGroupDevices[i]->domain,
--                                      data->pci_dev.iommuGroupDevices[i]->bus,
--                                      data->pci_dev.iommuGroupDevices[i]->slot,
--                                      data->pci_dev.iommuGroupDevices[i]->function);
--                }
--                virBufferAdjustIndent(&buf, -2);
--                virBufferAddLit(&buf, "</iommuGroup>\n");
--            }
--            if (data->pci_dev.numa_node >= 0)
--                virBufferAsprintf(&buf, "<numa node='%d'/>\n",
--                                  data->pci_dev.numa_node);
--
--            if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCIE)
--                virPCIEDeviceInfoFormat(&buf, data->pci_dev.pci_express);
-+            virNodeDeviceCapPCIDefFormat(&buf, data);
-             break;
-         case VIR_NODE_DEV_CAP_USB_DEV:
--            virBufferAsprintf(&buf, "<bus>%d</bus>\n", data->usb_dev.bus);
--            virBufferAsprintf(&buf, "<device>%d</device>\n",
--                              data->usb_dev.device);
--            virBufferAsprintf(&buf, "<product id='0x%04x'",
--                                  data->usb_dev.product);
--            if (data->usb_dev.product_name)
--                virBufferEscapeString(&buf, ">%s</product>\n",
--                                      data->usb_dev.product_name);
--            else
--                virBufferAddLit(&buf, " />\n");
--            virBufferAsprintf(&buf, "<vendor id='0x%04x'",
--                                  data->usb_dev.vendor);
--            if (data->usb_dev.vendor_name)
--                virBufferEscapeString(&buf, ">%s</vendor>\n",
--                                      data->usb_dev.vendor_name);
--            else
--                virBufferAddLit(&buf, " />\n");
-+            virNodeDeviceCapUSBDevDefFormat(&buf, data);
-             break;
-         case VIR_NODE_DEV_CAP_USB_INTERFACE:
--            virBufferAsprintf(&buf, "<number>%d</number>\n",
--                              data->usb_if.number);
--            virBufferAsprintf(&buf, "<class>%d</class>\n",
--                              data->usb_if._class);
--            virBufferAsprintf(&buf, "<subclass>%d</subclass>\n",
--                              data->usb_if.subclass);
--            virBufferAsprintf(&buf, "<protocol>%d</protocol>\n",
--                              data->usb_if.protocol);
--            if (data->usb_if.description)
--                virBufferEscapeString(&buf,
--                                  "<description>%s</description>\n",
--                                  data->usb_if.description);
-+            virNodeDeviceCapUSBInterfaceDefFormat(&buf, data);
-             break;
-         case VIR_NODE_DEV_CAP_NET:
--            virBufferEscapeString(&buf, "<interface>%s</interface>\n",
--                              data->net.ifname);
--            if (data->net.address)
--                virBufferEscapeString(&buf, "<address>%s</address>\n",
--                                  data->net.address);
--            virInterfaceLinkFormat(&buf, &data->net.lnk);
--            if (data->net.features) {
--                for (i = 0; i < VIR_NET_DEV_FEAT_LAST; i++) {
--                    if (virBitmapIsBitSet(data->net.features, i)) {
--                        virBufferAsprintf(&buf, "<feature name='%s'/>\n",
--                                          virNetDevFeatureTypeToString(i));
--                    }
--                }
--            }
--            if (data->net.subtype != VIR_NODE_DEV_CAP_NET_LAST) {
--                const char *subtyp =
--                    virNodeDevNetCapTypeToString(data->net.subtype);
--                virBufferEscapeString(&buf, "<capability type='%s'/>\n",
--                                      subtyp);
--            }
-+            virNodeDeviceCapNetDefFormat(&buf, data);
-             break;
-         case VIR_NODE_DEV_CAP_SCSI_HOST:
--            virBufferAsprintf(&buf, "<host>%d</host>\n",
--                              data->scsi_host.host);
--            if (data->scsi_host.unique_id != -1)
--                virBufferAsprintf(&buf, "<unique_id>%d</unique_id>\n",
--                                  data->scsi_host.unique_id);
--            if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
--                virBufferAddLit(&buf, "<capability type='fc_host'>\n");
--                virBufferAdjustIndent(&buf, 2);
--                virBufferEscapeString(&buf, "<wwnn>%s</wwnn>\n",
--                                      data->scsi_host.wwnn);
--                virBufferEscapeString(&buf, "<wwpn>%s</wwpn>\n",
--                                      data->scsi_host.wwpn);
--                virBufferEscapeString(&buf, "<fabric_wwn>%s</fabric_wwn>\n",
--                                      data->scsi_host.fabric_wwn);
--                virBufferAdjustIndent(&buf, -2);
--                virBufferAddLit(&buf, "</capability>\n");
--            }
--            if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) {
--                virBufferAddLit(&buf, "<capability type='vport_ops'>\n");
--                virBufferAdjustIndent(&buf, 2);
--                virBufferAsprintf(&buf, "<max_vports>%d</max_vports>\n",
--                                  data->scsi_host.max_vports);
--                virBufferAsprintf(&buf, "<vports>%d</vports>\n",
--                                  data->scsi_host.vports);
--                virBufferAdjustIndent(&buf, -2);
--                virBufferAddLit(&buf, "</capability>\n");
--            }
--
-+            virNodeDeviceCapSCSIHostDefFormat(&buf, data);
-             break;
--
-         case VIR_NODE_DEV_CAP_SCSI_TARGET:
-             virBufferEscapeString(&buf, "<target>%s</target>\n",
-                                   data->scsi_target.name);
-             break;
--
-         case VIR_NODE_DEV_CAP_SCSI:
--            virBufferAsprintf(&buf, "<host>%d</host>\n", data->scsi.host);
--            virBufferAsprintf(&buf, "<bus>%d</bus>\n", data->scsi.bus);
--            virBufferAsprintf(&buf, "<target>%d</target>\n",
--                              data->scsi.target);
--            virBufferAsprintf(&buf, "<lun>%d</lun>\n", data->scsi.lun);
--            if (data->scsi.type)
--                virBufferEscapeString(&buf, "<type>%s</type>\n",
--                                      data->scsi.type);
-+            virNodeDeviceCapSCSIDefFormat(&buf, data);
-             break;
-         case VIR_NODE_DEV_CAP_STORAGE:
--            virBufferEscapeString(&buf, "<block>%s</block>\n",
--                                  data->storage.block);
--            if (data->storage.bus)
--                virBufferEscapeString(&buf, "<bus>%s</bus>\n",
--                                      data->storage.bus);
--            if (data->storage.drive_type)
--                virBufferEscapeString(&buf, "<drive_type>%s</drive_type>\n",
--                                      data->storage.drive_type);
--            if (data->storage.model)
--                virBufferEscapeString(&buf, "<model>%s</model>\n",
--                                      data->storage.model);
--            if (data->storage.vendor)
--                virBufferEscapeString(&buf, "<vendor>%s</vendor>\n",
--                                      data->storage.vendor);
--            if (data->storage.serial)
--                virBufferEscapeString(&buf, "<serial>%s</serial>\n",
--                                      data->storage.serial);
--            if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) {
--                int avl = data->storage.flags &
--                    VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE;
--                virBufferAddLit(&buf, "<capability type='removable'>\n");
--                virBufferAdjustIndent(&buf, 2);
--                virBufferAsprintf(&buf, "<media_available>%d"
--                                  "</media_available>\n", avl ? 1 : 0);
--                virBufferAsprintf(&buf, "<media_size>%llu</media_size>\n",
--                                  data->storage.removable_media_size);
--                if (data->storage.media_label)
--                    virBufferEscapeString(&buf,
--                                          "<media_label>%s</media_label>\n",
--                                          data->storage.media_label);
--                if (data->storage.logical_block_size > 0)
--                    virBufferAsprintf(&buf, "<logical_block_size>%llu"
--                                      "</logical_block_size>\n",
--                                      data->storage.logical_block_size);
--                if (data->storage.num_blocks > 0)
--                    virBufferAsprintf(&buf,
--                                      "<num_blocks>%llu</num_blocks>\n",
--                                      data->storage.num_blocks);
--                virBufferAdjustIndent(&buf, -2);
--                virBufferAddLit(&buf, "</capability>\n");
--            } else {
--                virBufferAsprintf(&buf, "<size>%llu</size>\n",
--                                  data->storage.size);
--                if (data->storage.logical_block_size > 0)
--                    virBufferAsprintf(&buf, "<logical_block_size>%llu"
--                                      "</logical_block_size>\n",
--                                      data->storage.logical_block_size);
--                if (data->storage.num_blocks > 0)
--                    virBufferAsprintf(&buf, "<num_blocks>%llu</num_blocks>\n",
--                                      data->storage.num_blocks);
--            }
--            if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE)
--                virBufferAddLit(&buf, "<capability type='hotpluggable'/>\n");
-+            virNodeDeviceCapStorageDefFormat(&buf, data);
-             break;
-         case VIR_NODE_DEV_CAP_SCSI_GENERIC:
-             virBufferEscapeString(&buf, "<char>%s</char>\n",
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-conf-qemu-Use-type-aware-switches-where-possible.patch b/SOURCES/libvirt-conf-qemu-Use-type-aware-switches-where-possible.patch
new file mode 100644
index 0000000..0af72f8
--- /dev/null
+++ b/SOURCES/libvirt-conf-qemu-Use-type-aware-switches-where-possible.patch
@@ -0,0 +1,115 @@
+From 08c0c0562f8444859cc110e4fc2199d2c4254a53 Mon Sep 17 00:00:00 2001
+Message-Id: <08c0c0562f8444859cc110e4fc2199d2c4254a53@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:22:54 +0100
+Subject: [PATCH] conf, qemu: Use type-aware switches where possible
+
+The compiler can warn us if we add a value to the
+virDomainChrSerialTargetType enumeration but forget to handle
+it properly in the code. Let's take advantage of that.
+
+This commit is best viewed with 'git diff -w'.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 18dfc0014501c3811ee32669ea96583131dca9b3)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c  | 47 ++++++++++++++++++++++++++++++-----------------
+ src/qemu/qemu_command.c |  7 ++++++-
+ 2 files changed, 36 insertions(+), 18 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 530fae9d9d..4b5e7c214f 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -4046,26 +4046,39 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def)
+             def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+         }
+     } else if (def->os.type == VIR_DOMAIN_OSTYPE_HVM && def->nserials > 0 &&
+-               def->serials[0]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+-               def->serials[0]->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA) {
+-        /* Create a stub console to match the serial port.
+-         * console[0] either does not exist
+-         *                or has a different type than SERIAL or NONE.
+-         */
+-        virDomainChrDefPtr chr;
+-        if (!(chr = virDomainChrDefNew(NULL)))
+-            return -1;
++               def->serials[0]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
+ 
+-        if (VIR_INSERT_ELEMENT(def->consoles,
+-                               0,
+-                               def->nconsoles,
+-                               chr) < 0) {
+-            virDomainChrDefFree(chr);
+-            return -1;
++        switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) {
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: {
++
++            /* Create a stub console to match the serial port.
++             * console[0] either does not exist
++             *                or has a different type than SERIAL or NONE.
++             */
++            virDomainChrDefPtr chr;
++            if (!(chr = virDomainChrDefNew(NULL)))
++                return -1;
++
++            if (VIR_INSERT_ELEMENT(def->consoles,
++                                   0,
++                                   def->nconsoles,
++                                   chr) < 0) {
++                virDomainChrDefFree(chr);
++                return -1;
++            }
++
++            def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
++            def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
++
++            break;
+         }
+ 
+-        def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+-        def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
++            /* Nothing to do */
++            break;
++        }
+     }
+ 
+     return 0;
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 19a819a3aa..3d970ed9d1 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -10338,7 +10338,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+                               serial->info.alias);
+         }
+     } else {
+-        switch (serial->targetType) {
++        switch ((virDomainChrSerialTargetType) serial->targetType) {
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
+             if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_SERIAL)) {
+                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+@@ -10377,6 +10377,11 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+                 goto error;
+             }
+             break;
++
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
++            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                           _("Invalid target type for serial device"));
++            goto error;
+         }
+ 
+         virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s",
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-s-virDomainObjGetShortName-virDomainDefGetShortName.patch b/SOURCES/libvirt-conf-s-virDomainObjGetShortName-virDomainDefGetShortName.patch
new file mode 100644
index 0000000..7e74c84
--- /dev/null
+++ b/SOURCES/libvirt-conf-s-virDomainObjGetShortName-virDomainDefGetShortName.patch
@@ -0,0 +1,130 @@
+From db9daffe41e8804f9db0fb70678be99e02efc168 Mon Sep 17 00:00:00 2001
+Message-Id: <db9daffe41e8804f9db0fb70678be99e02efc168@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Thu, 9 Nov 2017 16:06:42 +0100
+Subject: [PATCH] conf: s/virDomainObjGetShortName/virDomainDefGetShortName/
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1461214
+
+This function works over domain definition and not domain object.
+Its name is thus misleading.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit fe70fd0c106e7fbe4f7272e5c041324ea3633ce4)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c   | 4 ++--
+ src/conf/domain_conf.h   | 2 +-
+ src/libvirt_private.syms | 2 +-
+ src/qemu/qemu_conf.c     | 2 +-
+ src/qemu/qemu_domain.c   | 4 ++--
+ src/qemu/qemu_driver.c   | 2 +-
+ 6 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 394afb0d80..27cfecffda 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -27871,14 +27871,14 @@ virDomainDefHasMemballoon(const virDomainDef *def)
+ #define VIR_DOMAIN_SHORT_NAME_MAX 20
+ 
+ /**
+- * virDomainObjGetShortName:
++ * virDomainDefGetShortName:
+  * @vm: Machine for which to get a name
+  * @unique: Make sure the name is unique (use id as well)
+  *
+  * Shorten domain name to avoid possible path length limitations.
+  */
+ char *
+-virDomainObjGetShortName(const virDomainDef *def)
++virDomainDefGetShortName(const virDomainDef *def)
+ {
+     wchar_t wshortname[VIR_DOMAIN_SHORT_NAME_MAX + 1] = {0};
+     size_t len = 0;
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 171f340785..388fa92dda 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -3366,7 +3366,7 @@ int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
+ 
+ bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);
+ 
+-char *virDomainObjGetShortName(const virDomainDef *def) ATTRIBUTE_NONNULL(1);
++char *virDomainDefGetShortName(const virDomainDef *def) ATTRIBUTE_NONNULL(1);
+ 
+ int
+ virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 811d9053e6..6653f95722 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -262,6 +262,7 @@ virDomainDefGetMemoryInitial;
+ virDomainDefGetMemoryTotal;
+ virDomainDefGetOnlineVcpumap;
+ virDomainDefGetSecurityLabelDef;
++virDomainDefGetShortName;
+ virDomainDefGetVcpu;
+ virDomainDefGetVcpuPinInfoHelper;
+ virDomainDefGetVcpus;
+@@ -458,7 +459,6 @@ virDomainObjGetMetadata;
+ virDomainObjGetOneDef;
+ virDomainObjGetOneDefState;
+ virDomainObjGetPersistentDef;
+-virDomainObjGetShortName;
+ virDomainObjGetState;
+ virDomainObjNew;
+ virDomainObjParseNode;
+diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
+index 4e5b33b788..66f9761eea 100644
+--- a/src/qemu/qemu_conf.c
++++ b/src/qemu/qemu_conf.c
+@@ -1676,7 +1676,7 @@ qemuGetDomainHugepagePath(const virDomainDef *def,
+                           virHugeTLBFSPtr hugepage)
+ {
+     char *base = qemuGetBaseHugepagePath(hugepage);
+-    char *domPath = virDomainObjGetShortName(def);
++    char *domPath = virDomainDefGetShortName(def);
+     char *ret = NULL;
+ 
+     if (base && domPath)
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 81bfef946e..27117d83ef 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -1706,7 +1706,7 @@ qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
+ {
+     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+     qemuDomainObjPrivatePtr priv = vm->privateData;
+-    char *domname = virDomainObjGetShortName(vm->def);
++    char *domname = virDomainDefGetShortName(vm->def);
+     int ret = -1;
+ 
+     if (!domname)
+@@ -8207,7 +8207,7 @@ qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg,
+     char *path = NULL;
+     char *tmp;
+     const char *suffix = mountpoint + strlen(DEVPREFIX);
+-    char *domname = virDomainObjGetShortName(vm->def);
++    char *domname = virDomainDefGetShortName(vm->def);
+     size_t off;
+ 
+     if (!domname)
+diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
+index 82c60e6ef1..5617c78997 100644
+--- a/src/qemu/qemu_driver.c
++++ b/src/qemu/qemu_driver.c
+@@ -4088,7 +4088,7 @@ getAutoDumpPath(virQEMUDriverPtr driver,
+                 virDomainObjPtr vm)
+ {
+     char *dumpfile = NULL;
+-    char *domname = virDomainObjGetShortName(vm->def);
++    char *domname = virDomainDefGetShortName(vm->def);
+     char timestr[100];
+     struct tm time_info;
+     time_t curtime = time(NULL);
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-conf-split-out-virDomainIOMMUDefCheckABIStability.patch b/SOURCES/libvirt-conf-split-out-virDomainIOMMUDefCheckABIStability.patch
deleted file mode 100644
index 9d33757..0000000
--- a/SOURCES/libvirt-conf-split-out-virDomainIOMMUDefCheckABIStability.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From 244b42c385fc611380bfb2532905a63ce4380254 Mon Sep 17 00:00:00 2001
-Message-Id: <244b42c385fc611380bfb2532905a63ce4380254@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:58 +0200
-Subject: [PATCH] conf: split out virDomainIOMMUDefCheckABIStability
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-(cherry picked from commit 3a276c6524026b661ed7bee4539fc5387b963611)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 24 +++++++++++++++++-------
- 1 file changed, 17 insertions(+), 7 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index e77b542f3..7bf480f2a 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -19810,6 +19810,22 @@ virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src,
- 
- 
- static bool
-+virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src,
-+                                   virDomainIOMMUDefPtr dst)
-+{
-+    if (src->model != dst->model) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("Target domain IOMMU device model '%s' "
-+                         "does not match source '%s'"),
-+                       virDomainIOMMUModelTypeToString(dst->model),
-+                       virDomainIOMMUModelTypeToString(src->model));
-+        return false;
-+    }
-+    return true;
-+}
-+
-+
-+static bool
- virDomainDefVcpuCheckAbiStability(virDomainDefPtr src,
-                                   virDomainDefPtr dst)
- {
-@@ -20275,14 +20291,8 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
-     }
- 
-     if (src->iommu &&
--        src->iommu->model != dst->iommu->model) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("Target domain IOMMU device model '%s' "
--                         "does not match source '%s'"),
--                       virDomainIOMMUModelTypeToString(dst->iommu->model),
--                       virDomainIOMMUModelTypeToString(src->iommu->model));
-+        !virDomainIOMMUDefCheckABIStability(src->iommu, dst->iommu))
-         goto error;
--    }
- 
-     /* Coverity is not very happy with this - all dead_error_condition */
- #if !STATIC_ANALYSIS
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-conf-use-a-leading-space-in-virDomainVirtioNetDriverFormat.patch b/SOURCES/libvirt-conf-use-a-leading-space-in-virDomainVirtioNetDriverFormat.patch
deleted file mode 100644
index fe28da8..0000000
--- a/SOURCES/libvirt-conf-use-a-leading-space-in-virDomainVirtioNetDriverFormat.patch
+++ /dev/null
@@ -1,77 +0,0 @@
-From 5238dd8211d06fc8c7003bb608e41bb2a4653dec Mon Sep 17 00:00:00 2001
-Message-Id: <5238dd8211d06fc8c7003bb608e41bb2a4653dec@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:48:59 +0200
-Subject: [PATCH] conf: use a leading space in virDomainVirtioNetDriverFormat
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Instead of formatting a space after every option.
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit d1feb4773d41b928dc1079dfc19d17b5a0e5957b)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/domain_conf.c | 18 ++++++++----------
- 1 file changed, 8 insertions(+), 10 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 701a6d2136..4652e1c72b 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -22053,29 +22053,27 @@ virDomainVirtioNetDriverFormat(char **outstr,
- {
-     virBuffer buf = VIR_BUFFER_INITIALIZER;
-     if (def->driver.virtio.name) {
--        virBufferAsprintf(&buf, "name='%s' ",
-+        virBufferAsprintf(&buf, " name='%s'",
-                           virDomainNetBackendTypeToString(def->driver.virtio.name));
-     }
-     if (def->driver.virtio.txmode) {
--        virBufferAsprintf(&buf, "txmode='%s' ",
-+        virBufferAsprintf(&buf, " txmode='%s'",
-                           virDomainNetVirtioTxModeTypeToString(def->driver.virtio.txmode));
-     }
-     if (def->driver.virtio.ioeventfd) {
--        virBufferAsprintf(&buf, "ioeventfd='%s' ",
-+        virBufferAsprintf(&buf, " ioeventfd='%s'",
-                           virTristateSwitchTypeToString(def->driver.virtio.ioeventfd));
-     }
-     if (def->driver.virtio.event_idx) {
--        virBufferAsprintf(&buf, "event_idx='%s' ",
-+        virBufferAsprintf(&buf, " event_idx='%s'",
-                           virTristateSwitchTypeToString(def->driver.virtio.event_idx));
-     }
-     if (def->driver.virtio.queues)
--        virBufferAsprintf(&buf, "queues='%u' ", def->driver.virtio.queues);
-+        virBufferAsprintf(&buf, " queues='%u'", def->driver.virtio.queues);
-     if (def->driver.virtio.rx_queue_size)
--        virBufferAsprintf(&buf, "rx_queue_size='%u' ",
-+        virBufferAsprintf(&buf, " rx_queue_size='%u'",
-                           def->driver.virtio.rx_queue_size);
- 
--    virBufferTrim(&buf, " ", -1);
--
-     if (virBufferCheckError(&buf) < 0)
-         return -1;
- 
-@@ -22323,10 +22321,10 @@ virDomainNetDefFormat(virBufferPtr buf,
- 
-             if (!gueststr && !hoststr) {
-                 if (str)
--                    virBufferAsprintf(buf, "<driver %s/>\n", str);
-+                    virBufferAsprintf(buf, "<driver%s/>\n", str);
-             } else {
-                 if (str)
--                    virBufferAsprintf(buf, "<driver %s>\n", str);
-+                    virBufferAsprintf(buf, "<driver%s>\n", str);
-                 else
-                     virBufferAddLit(buf, "<driver>\n");
-                 virBufferAdjustIndent(buf, 2);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-cpu-Drop-feature-filtering-from-virCPUUpdate.patch b/SOURCES/libvirt-cpu-Drop-feature-filtering-from-virCPUUpdate.patch
deleted file mode 100644
index 239d248..0000000
--- a/SOURCES/libvirt-cpu-Drop-feature-filtering-from-virCPUUpdate.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From 2642333131bda397dc4b00fd945efdd34e2aa314 Mon Sep 17 00:00:00 2001
-Message-Id: <2642333131bda397dc4b00fd945efdd34e2aa314@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 29 Mar 2017 15:00:21 +0200
-Subject: [PATCH] cpu: Drop feature filtering from virCPUUpdate
-
-Because of the changes done in the previous commit, @host is already a
-migratable CPU and there's no need to do any additional filtering.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 232d87c7dd081d126a079fb45178e0be096cc680)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/cpu/cpu_x86.c | 9 +++------
- 1 file changed, 3 insertions(+), 6 deletions(-)
-
-diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
-index a771b251e..53359ff9b 100644
---- a/src/cpu/cpu_x86.c
-+++ b/src/cpu/cpu_x86.c
-@@ -2549,8 +2549,7 @@ x86Baseline(virCPUDefPtr *cpus,
- 
- static int
- x86UpdateHostModel(virCPUDefPtr guest,
--                   const virCPUDef *host,
--                   virCPUx86MapPtr map)
-+                   const virCPUDef *host)
- {
-     virCPUDefPtr updated = NULL;
-     size_t i;
-@@ -2559,11 +2558,9 @@ x86UpdateHostModel(virCPUDefPtr guest,
-     if (!(updated = virCPUDefCopyWithoutModel(host)))
-         goto cleanup;
- 
--    /* Remove non-migratable features by default */
-     updated->type = VIR_CPU_TYPE_GUEST;
-     updated->mode = VIR_CPU_MODE_CUSTOM;
--    if (virCPUDefCopyModelFilter(updated, host, true,
--                                 x86FeatureIsMigratable, map) < 0)
-+    if (virCPUDefCopyModel(updated, host, true) < 0)
-         goto cleanup;
- 
-     if (guest->vendor_id) {
-@@ -2627,7 +2624,7 @@ virCPUx86Update(virCPUDefPtr guest,
- 
-     if (guest->mode == VIR_CPU_MODE_HOST_MODEL ||
-         guest->match == VIR_CPU_MATCH_MINIMUM)
--        ret = x86UpdateHostModel(guest, host, map);
-+        ret = x86UpdateHostModel(guest, host);
-     else
-         ret = 0;
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-cpu-Introduce-virCPUCopyMigratable.patch b/SOURCES/libvirt-cpu-Introduce-virCPUCopyMigratable.patch
deleted file mode 100644
index 382224f..0000000
--- a/SOURCES/libvirt-cpu-Introduce-virCPUCopyMigratable.patch
+++ /dev/null
@@ -1,154 +0,0 @@
-From 57b2e02a1c4cf52f3ea1ec3af469dd4e44402595 Mon Sep 17 00:00:00 2001
-Message-Id: <57b2e02a1c4cf52f3ea1ec3af469dd4e44402595@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 29 Mar 2017 14:45:44 +0200
-Subject: [PATCH] cpu: Introduce virCPUCopyMigratable
-
-This new internal API makes a copy of virCPUDef while removing all
-features which would block migration. It uses cpu_map.xml as a database
-of such features, which should only be used as a fallback when we cannot
-get the data from a hypervisor. The main goal of this API is to decouple
-this filtering from virCPUUpdate so that the hypervisor driver can
-filter the features according to the hypervisor.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 05e91c79f19e0be96526098d58a3498dac3f8529)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/cpu/cpu.c            | 31 +++++++++++++++++++++++++++++++
- src/cpu/cpu.h            |  8 ++++++++
- src/cpu/cpu_x86.c        | 25 +++++++++++++++++++++++++
- src/libvirt_private.syms |  1 +
- 4 files changed, 65 insertions(+)
-
-diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
-index 93647a2ed..8a407ac18 100644
---- a/src/cpu/cpu.c
-+++ b/src/cpu/cpu.c
-@@ -1130,3 +1130,34 @@ virCPUExpandFeatures(virArch arch,
-     VIR_DEBUG("nfeatures=%zu", cpu->nfeatures);
-     return 0;
- }
-+
-+
-+/**
-+ * virCPUCopyMigratable:
-+ *
-+ * @arch: CPU architecture
-+ * @cpu: CPU definition to be copied
-+ *
-+ * Makes a copy of @cpu with all features which would block migration removed.
-+ * If this doesn't make sense for a given architecture, the function returns a
-+ * plain copy of @cpu (i.e., a copy with no features removed).
-+ *
-+ * Returns the copy of the CPU or NULL on error.
-+ */
-+virCPUDefPtr
-+virCPUCopyMigratable(virArch arch,
-+                     virCPUDefPtr cpu)
-+{
-+    struct cpuArchDriver *driver;
-+
-+    VIR_DEBUG("arch=%s, cpu=%p, model=%s",
-+              virArchToString(arch), cpu, NULLSTR(cpu->model));
-+
-+    if (!(driver = cpuGetSubDriver(arch)))
-+        return NULL;
-+
-+    if (driver->copyMigratable)
-+        return driver->copyMigratable(cpu);
-+    else
-+        return virCPUDefCopy(cpu);
-+}
-diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
-index 8c238ad55..352445c40 100644
---- a/src/cpu/cpu.h
-+++ b/src/cpu/cpu.h
-@@ -118,6 +118,9 @@ typedef int
- typedef int
- (*virCPUArchExpandFeatures)(virCPUDefPtr cpu);
- 
-+typedef virCPUDefPtr
-+(*virCPUArchCopyMigratable)(virCPUDefPtr cpu);
-+
- struct cpuArchDriver {
-     const char *name;
-     const virArch *arch;
-@@ -138,6 +141,7 @@ struct cpuArchDriver {
-     virCPUArchTranslate translate;
-     virCPUArchConvertLegacy convertLegacy;
-     virCPUArchExpandFeatures expandFeatures;
-+    virCPUArchCopyMigratable copyMigratable;
- };
- 
- 
-@@ -254,6 +258,10 @@ int
- virCPUExpandFeatures(virArch arch,
-                      virCPUDefPtr cpu);
- 
-+virCPUDefPtr
-+virCPUCopyMigratable(virArch arch,
-+                     virCPUDefPtr cpu);
-+
- /* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and
-  * have no real-life usage
-  */
-diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
-index 48648a7f4..a771b251e 100644
---- a/src/cpu/cpu_x86.c
-+++ b/src/cpu/cpu_x86.c
-@@ -2903,6 +2903,30 @@ virCPUx86ExpandFeatures(virCPUDefPtr cpu)
- }
- 
- 
-+static virCPUDefPtr
-+virCPUx86CopyMigratable(virCPUDefPtr cpu)
-+{
-+    virCPUDefPtr copy;
-+    virCPUx86MapPtr map;
-+
-+    if (!(map = virCPUx86GetMap()))
-+        return NULL;
-+
-+    if (!(copy = virCPUDefCopyWithoutModel(cpu)))
-+        return NULL;
-+
-+    if (virCPUDefCopyModelFilter(copy, cpu, false,
-+                                 x86FeatureIsMigratable, map) < 0)
-+        goto error;
-+
-+    return copy;
-+
-+ error:
-+    virCPUDefFree(copy);
-+    return NULL;
-+}
-+
-+
- int
- virCPUx86DataAddCPUID(virCPUDataPtr cpuData,
-                       const virCPUx86CPUID *cpuid)
-@@ -2978,4 +3002,5 @@ struct cpuArchDriver cpuDriverX86 = {
-     .getModels  = virCPUx86GetModels,
-     .translate  = virCPUx86Translate,
-     .expandFeatures = virCPUx86ExpandFeatures,
-+    .copyMigratable = virCPUx86CopyMigratable,
- };
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 9a334311d..cc78c5975 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -1018,6 +1018,7 @@ virCPUCheckFeature;
- virCPUCompare;
- virCPUCompareXML;
- virCPUConvertLegacy;
-+virCPUCopyMigratable;
- virCPUDataCheckFeature;
- virCPUDataFormat;
- virCPUDataFree;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-cpu-Introduce-virCPUGetHostIsSupported.patch b/SOURCES/libvirt-cpu-Introduce-virCPUGetHostIsSupported.patch
deleted file mode 100644
index 87757a9..0000000
--- a/SOURCES/libvirt-cpu-Introduce-virCPUGetHostIsSupported.patch
+++ /dev/null
@@ -1,83 +0,0 @@
-From 401cbf50f18234b0631b4b0e01b9e403137fee95 Mon Sep 17 00:00:00 2001
-Message-Id: <401cbf50f18234b0631b4b0e01b9e403137fee95@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 11 Apr 2017 20:45:07 +0200
-Subject: [PATCH] cpu: Introduce virCPUGetHostIsSupported
-
-Sometimes we want to call virCPUGetHost only when it is implemented for
-a given architecture to avoid logging expected and possibly misleading
-errors. The new virCPUGetHostIsSupported API may be used to guard such
-calls to virCPUGetHost.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit bf1a881715c905c67f7d38dcd5bd6c2afbff1f9b)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/cpu/cpu.c            | 20 ++++++++++++++++++++
- src/cpu/cpu.h            |  3 +++
- src/libvirt_private.syms |  1 +
- 3 files changed, 24 insertions(+)
-
-diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
-index 8a407ac18..702b14dbb 100644
---- a/src/cpu/cpu.c
-+++ b/src/cpu/cpu.c
-@@ -358,6 +358,26 @@ virCPUDataFree(virCPUDataPtr data)
- 
- 
- /**
-+ * virCPUGetHostIsSupported:
-+ *
-+ * @arch: CPU architecture
-+ *
-+ * Check whether virCPUGetHost is supported for @arch.
-+ *
-+ * Returns true if virCPUGetHost is supported, false otherwise.
-+ */
-+bool
-+virCPUGetHostIsSupported(virArch arch)
-+{
-+    struct cpuArchDriver *driver;
-+
-+    VIR_DEBUG("arch=%s", virArchToString(arch));
-+
-+    return (driver = cpuGetSubDriver(arch)) && driver->getHost;
-+}
-+
-+
-+/**
-  * virCPUGetHost:
-  *
-  * @arch: CPU architecture
-diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
-index 352445c40..c6ca111e9 100644
---- a/src/cpu/cpu.h
-+++ b/src/cpu/cpu.h
-@@ -183,6 +183,9 @@ virCPUDataNew(virArch arch);
- void
- virCPUDataFree(virCPUDataPtr data);
- 
-+bool
-+virCPUGetHostIsSupported(virArch arch);
-+
- virCPUDefPtr
- virCPUGetHost(virArch arch,
-               virCPUType type,
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index cc78c5975..d802e7598 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -1026,6 +1026,7 @@ virCPUDataNew;
- virCPUDataParse;
- virCPUExpandFeatures;
- virCPUGetHost;
-+virCPUGetHostIsSupported;
- virCPUGetModels;
- virCPUProbeHost;
- virCPUTranslate;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-cpu-add-CPU-features-and-model-for-indirect-branch-prediction-protection.patch b/SOURCES/libvirt-cpu-add-CPU-features-and-model-for-indirect-branch-prediction-protection.patch
index d264d5d..a915513 100644
--- a/SOURCES/libvirt-cpu-add-CPU-features-and-model-for-indirect-branch-prediction-protection.patch
+++ b/SOURCES/libvirt-cpu-add-CPU-features-and-model-for-indirect-branch-prediction-protection.patch
@@ -1,5 +1,5 @@
-From b3505e6f099cf4af35e254e077bb61cf62f035ed Mon Sep 17 00:00:00 2001
-Message-Id: <b3505e6f099cf4af35e254e077bb61cf62f035ed@dist-git>
+From 9df09ec5e1afef8659271c6cc4a5b741d5d06815 Mon Sep 17 00:00:00 2001
+Message-Id: <9df09ec5e1afef8659271c6cc4a5b741d5d06815@dist-git>
 From: Paolo Bonzini <pbonzini@redhat.com>
 Date: Tue, 12 Dec 2017 16:23:42 +0100
 Subject: [PATCH] cpu: add CPU features and model for indirect branch
@@ -9,21 +9,17 @@ CVE-2017-5715
 
 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-
-Conflicts:
-	src/cpu/cpu_map.xml
-            - no Skylake-Server and EPYC CPU models
 ---
- src/cpu/cpu_map.xml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 50 insertions(+)
+ src/cpu/cpu_map.xml | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 58 insertions(+)
 
 diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
-index 29b5b596f4..7fbba9f0d8 100644
+index 96f4ce60dd..a7888ec134 100644
 --- a/src/cpu/cpu_map.xml
 +++ b/src/cpu/cpu_map.xml
-@@ -283,6 +283,15 @@
+@@ -292,6 +292,15 @@
      <feature name='avx512-4fmaps'>
-       <cpuid eax_in='0x07' edx='0x00000008'/>
+       <cpuid eax_in='0x07' ecx_in='0x00' edx='0x00000008'/>
      </feature>
 +    <feature name='spec-ctrl'>
 +      <cpuid eax_in='0x07' ecx_in='0x00' edx='0x04000000'/>
@@ -37,7 +33,7 @@ index 29b5b596f4..7fbba9f0d8 100644
  
      <!-- Processor Extended State Enumeration sub leaf 1 -->
      <feature name='xsaveopt'>
-@@ -411,6 +420,11 @@
+@@ -420,6 +429,11 @@
        <cpuid eax_in='0x80000007' edx='0x00000100'/>
      </feature>
  
@@ -49,7 +45,7 @@ index 29b5b596f4..7fbba9f0d8 100644
      <!-- models -->
      <model name='486'>
        <feature name='fpu'/>
-@@ -857,6 +871,10 @@
+@@ -866,6 +880,10 @@
        <feature name='syscall'/>
        <feature name='tsc'/>
      </model>
@@ -60,7 +56,7 @@ index 29b5b596f4..7fbba9f0d8 100644
  
      <model name='Westmere'>
        <signature family='6' model='44'/>
-@@ -894,6 +912,10 @@
+@@ -903,6 +921,10 @@
        <feature name='syscall'/>
        <feature name='tsc'/>
      </model>
@@ -71,7 +67,7 @@ index 29b5b596f4..7fbba9f0d8 100644
  
      <model name='SandyBridge'>
        <signature family='6' model='42'/>
-@@ -937,6 +959,10 @@
+@@ -946,6 +968,10 @@
        <feature name='x2apic'/>
        <feature name='xsave'/>
      </model>
@@ -82,7 +78,7 @@ index 29b5b596f4..7fbba9f0d8 100644
  
      <model name='IvyBridge'>
        <signature family='6' model='58'/>
-@@ -986,6 +1012,10 @@
+@@ -995,6 +1021,10 @@
        <feature name='x2apic'/>
        <feature name='xsave'/>
      </model>
@@ -93,7 +89,7 @@ index 29b5b596f4..7fbba9f0d8 100644
  
      <model name='Haswell-noTSX'>
        <signature family='6' model='60'/>
-@@ -1039,6 +1069,10 @@
+@@ -1048,6 +1078,10 @@
        <feature name='x2apic'/>
        <feature name='xsave'/>
      </model>
@@ -104,7 +100,7 @@ index 29b5b596f4..7fbba9f0d8 100644
  
      <model name='Haswell'>
        <signature family='6' model='60'/>
-@@ -1094,6 +1128,10 @@
+@@ -1103,6 +1137,10 @@
        <feature name='x2apic'/>
        <feature name='xsave'/>
      </model>
@@ -115,7 +111,7 @@ index 29b5b596f4..7fbba9f0d8 100644
  
      <model name='Broadwell-noTSX'>
        <signature family='6' model='61'/>
-@@ -1151,6 +1189,10 @@
+@@ -1160,6 +1198,10 @@
        <feature name='x2apic'/>
        <feature name='xsave'/>
      </model>
@@ -126,7 +122,7 @@ index 29b5b596f4..7fbba9f0d8 100644
  
      <model name='Broadwell'>
        <signature family='6' model='61'/>
-@@ -1210,6 +1252,10 @@
+@@ -1219,6 +1261,10 @@
        <feature name='x2apic'/>
        <feature name='xsave'/>
      </model>
@@ -137,7 +133,7 @@ index 29b5b596f4..7fbba9f0d8 100644
  
      <model name='Skylake-Client'>
        <signature family='6' model='94'/>
-@@ -1278,6 +1324,10 @@
+@@ -1287,6 +1333,10 @@
        <feature name='xsavec'/>
        <feature name='xsaveopt'/>
      </model>
@@ -146,8 +142,30 @@ index 29b5b596f4..7fbba9f0d8 100644
 +      <feature name='spec-ctrl'/>
 +    </model>
  
+     <model name='Skylake-Server'>
+       <signature family='6' model='85'/>
+@@ -1362,6 +1412,10 @@
+       <feature name='xsavec'/>
+       <feature name='xsaveopt'/>
+     </model>
++    <model name='Skylake-Server-IBRS'>
++      <model name='Skylake-Server'/>
++      <feature name='spec-ctrl'/>
++    </model>
+ 
      <!-- AMD CPUs -->
      <model name='athlon'>
+@@ -1700,6 +1754,10 @@
+       <feature name='xsavec'/>
+       <feature name='xsaveopt'/>
+     </model>
++    <model name='EPYC-IBRS'>
++      <model name='EPYC'/>
++      <feature name='ibpb'/>
++    </model>
+   </arch>
+ 
+   <arch name='ppc64'>
 -- 
 2.15.1
 
diff --git a/SOURCES/libvirt-cpu_x86-Copy-CPU-signature-from-ancestor.patch b/SOURCES/libvirt-cpu_x86-Copy-CPU-signature-from-ancestor.patch
index 77bda28..b81e716 100644
--- a/SOURCES/libvirt-cpu_x86-Copy-CPU-signature-from-ancestor.patch
+++ b/SOURCES/libvirt-cpu_x86-Copy-CPU-signature-from-ancestor.patch
@@ -1,7 +1,7 @@
-From e8639315f3f6116b3f589657bad57a15f119ddbc Mon Sep 17 00:00:00 2001
-Message-Id: <e8639315f3f6116b3f589657bad57a15f119ddbc@dist-git>
+From 38b3d773dddd7f3cfe715b9cbabaa296c16c1290 Mon Sep 17 00:00:00 2001
+Message-Id: <38b3d773dddd7f3cfe715b9cbabaa296c16c1290@dist-git>
 From: Jiri Denemark <jdenemar@redhat.com>
-Date: Thu, 11 Jan 2018 14:33:07 +0100
+Date: Fri, 5 Jan 2018 17:43:03 +0100
 Subject: [PATCH] cpu_x86: Copy CPU signature from ancestor
 
 When specifying a new CPU model in cpu_map.xml as an extension to an
@@ -17,7 +17,7 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
 Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
 (cherry picked from commit b427cf4831d0ea7aac9dd1a3aa7682478356a483)
 
-https://bugzilla.redhat.com/show_bug.cgi?id=1533418
+https://bugzilla.redhat.com/show_bug.cgi?id=1533125
 
 The new -IBRS and -IBPB CPU models were defined via inheritance from
 their original models in RHEL. Thus when the host CPU matches the
@@ -31,10 +31,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  1 file changed, 1 insertion(+)
 
 diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
-index efef7f235d..41aaa61c35 100644
+index ad35532fc1..001109f701 100644
 --- a/src/cpu/cpu_x86.c
 +++ b/src/cpu/cpu_x86.c
-@@ -1209,6 +1209,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
+@@ -1227,6 +1227,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
          VIR_FREE(name);
  
          model->vendor = ancestor->vendor;
diff --git a/SOURCES/libvirt-cpu_x86-Properly-disable-unknown-CPU-features.patch b/SOURCES/libvirt-cpu_x86-Properly-disable-unknown-CPU-features.patch
deleted file mode 100644
index a54fa77..0000000
--- a/SOURCES/libvirt-cpu_x86-Properly-disable-unknown-CPU-features.patch
+++ /dev/null
@@ -1,453 +0,0 @@
-From 73e87a037ccd6d9fd02c3fd0a082f014412c7555 Mon Sep 17 00:00:00 2001
-Message-Id: <73e87a037ccd6d9fd02c3fd0a082f014412c7555@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Mon, 19 Jun 2017 13:18:52 +0200
-Subject: [PATCH] cpu_x86: Properly disable unknown CPU features
-
-CPU features unknown to a hypervisor will not be present in dataDisabled
-even though the features won't naturally be enabled because.
-Thus any features we asked for which are not in dataEnabled should be
-considered disabled.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 83e081b8ab32dd990b4e4ccc7bf8a1a416fc51c2)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1470582
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/cpu/cpu_x86.c                                  |   9 +-
- tests/cputest.c                                    |   1 +
- .../x86_64-cpuid-Core-i7-5600U-arat-disabled.xml   |   5 +
- .../x86_64-cpuid-Core-i7-5600U-arat-enabled.xml    |   8 +
- .../x86_64-cpuid-Core-i7-5600U-arat-guest.xml      |  29 +++
- .../x86_64-cpuid-Core-i7-5600U-arat-host.xml       |  30 +++
- .../x86_64-cpuid-Core-i7-5600U-arat-json.xml       |  14 ++
- .../x86_64-cpuid-Core-i7-5600U-arat.json           | 202 +++++++++++++++++++++
- .../x86_64-cpuid-Core-i7-5600U-arat.xml            |  41 +++++
- 9 files changed, 335 insertions(+), 4 deletions(-)
- create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-disabled.xml
- create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-enabled.xml
- create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-guest.xml
- create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-host.xml
- create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-json.xml
- create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.json
- create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.xml
-
-diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
-index 53359ff9b6..2864454211 100644
---- a/src/cpu/cpu_x86.c
-+++ b/src/cpu/cpu_x86.c
-@@ -2664,12 +2664,11 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
-         x86DataCopy(&disabled, &dataDisabled->data.x86) < 0)
-         goto cleanup;
- 
--    x86DataSubtract(&enabled, &model->data);
--
-     for (i = 0; i < map->nfeatures; i++) {
-         virCPUx86FeaturePtr feature = map->features[i];
- 
--        if (x86DataIsSubset(&enabled, &feature->data)) {
-+        if (x86DataIsSubset(&enabled, &feature->data) &&
-+            !x86DataIsSubset(&model->data, &feature->data)) {
-             VIR_DEBUG("Feature '%s' enabled by the hypervisor", feature->name);
-             if (cpu->check == VIR_CPU_CHECK_FULL)
-                 virBufferAsprintf(&bufAdded, "%s,", feature->name);
-@@ -2678,7 +2677,9 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
-                 goto cleanup;
-         }
- 
--        if (x86DataIsSubset(&disabled, &feature->data)) {
-+        if (x86DataIsSubset(&disabled, &feature->data) ||
-+            (x86DataIsSubset(&model->data, &feature->data) &&
-+             !x86DataIsSubset(&enabled, &feature->data))) {
-             VIR_DEBUG("Feature '%s' disabled by the hypervisor", feature->name);
-             if (cpu->check == VIR_CPU_CHECK_FULL)
-                 virBufferAsprintf(&bufRemoved, "%s,", feature->name);
-diff --git a/tests/cputest.c b/tests/cputest.c
-index 97b34de9ed..5190a83467 100644
---- a/tests/cputest.c
-+++ b/tests/cputest.c
-@@ -991,6 +991,7 @@ mymain(void)
-     DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-4600U", true);
-     DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-4510U", true);
-     DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-5600U", true);
-+    DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-5600U-arat", true);
-     DO_TEST_CPUID(VIR_ARCH_X86_64, "Core2-E6850", true);
-     DO_TEST_CPUID(VIR_ARCH_X86_64, "Core2-Q9500", false);
-     DO_TEST_CPUID(VIR_ARCH_X86_64, "FX-8150", false);
-diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-disabled.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-disabled.xml
-new file mode 100644
-index 0000000000..4a0477f788
---- /dev/null
-+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-disabled.xml
-@@ -0,0 +1,5 @@
-+<!-- Features disabled by QEMU -->
-+<cpudata arch='x86'>
-+  <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x0800c1dc' edx='0xb0600000'/>
-+  <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
-+</cpudata>
-diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-enabled.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-enabled.xml
-new file mode 100644
-index 0000000000..5cffacef59
---- /dev/null
-+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-enabled.xml
-@@ -0,0 +1,8 @@
-+<!-- Features enabled by QEMU -->
-+<cpudata arch='x86'>
-+  <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0xf7fa3223' edx='0x0f8bfbff'/>
-+  <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x001c0fbb' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x00000001' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x40000001' ecx_in='0x00' eax='0x010000fa' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
-+</cpudata>
-diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-guest.xml
-new file mode 100644
-index 0000000000..877895cf15
---- /dev/null
-+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-guest.xml
-@@ -0,0 +1,29 @@
-+<cpu mode='custom' match='exact'>
-+  <model fallback='forbid'>Broadwell</model>
-+  <vendor>Intel</vendor>
-+  <feature policy='require' name='vme'/>
-+  <feature policy='require' name='ds'/>
-+  <feature policy='require' name='acpi'/>
-+  <feature policy='require' name='ss'/>
-+  <feature policy='require' name='ht'/>
-+  <feature policy='require' name='tm'/>
-+  <feature policy='require' name='pbe'/>
-+  <feature policy='require' name='dtes64'/>
-+  <feature policy='require' name='monitor'/>
-+  <feature policy='require' name='ds_cpl'/>
-+  <feature policy='require' name='vmx'/>
-+  <feature policy='require' name='smx'/>
-+  <feature policy='require' name='est'/>
-+  <feature policy='require' name='tm2'/>
-+  <feature policy='require' name='xtpr'/>
-+  <feature policy='require' name='pdcm'/>
-+  <feature policy='require' name='osxsave'/>
-+  <feature policy='require' name='f16c'/>
-+  <feature policy='require' name='rdrand'/>
-+  <feature policy='require' name='arat'/>
-+  <feature policy='require' name='tsc_adjust'/>
-+  <feature policy='require' name='xsaveopt'/>
-+  <feature policy='require' name='pdpe1gb'/>
-+  <feature policy='require' name='abm'/>
-+  <feature policy='require' name='invtsc'/>
-+</cpu>
-diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-host.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-host.xml
-new file mode 100644
-index 0000000000..9b24941e0e
---- /dev/null
-+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-host.xml
-@@ -0,0 +1,30 @@
-+<cpu>
-+  <arch>x86_64</arch>
-+  <model>Broadwell</model>
-+  <vendor>Intel</vendor>
-+  <feature name='vme'/>
-+  <feature name='ds'/>
-+  <feature name='acpi'/>
-+  <feature name='ss'/>
-+  <feature name='ht'/>
-+  <feature name='tm'/>
-+  <feature name='pbe'/>
-+  <feature name='dtes64'/>
-+  <feature name='monitor'/>
-+  <feature name='ds_cpl'/>
-+  <feature name='vmx'/>
-+  <feature name='smx'/>
-+  <feature name='est'/>
-+  <feature name='tm2'/>
-+  <feature name='xtpr'/>
-+  <feature name='pdcm'/>
-+  <feature name='osxsave'/>
-+  <feature name='f16c'/>
-+  <feature name='rdrand'/>
-+  <feature name='arat'/>
-+  <feature name='tsc_adjust'/>
-+  <feature name='xsaveopt'/>
-+  <feature name='pdpe1gb'/>
-+  <feature name='abm'/>
-+  <feature name='invtsc'/>
-+</cpu>
-diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-json.xml
-new file mode 100644
-index 0000000000..4f253fc08a
---- /dev/null
-+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-json.xml
-@@ -0,0 +1,14 @@
-+<cpu mode='custom' match='exact'>
-+  <model fallback='forbid'>Broadwell</model>
-+  <vendor>Intel</vendor>
-+  <feature policy='require' name='vme'/>
-+  <feature policy='require' name='ss'/>
-+  <feature policy='require' name='vmx'/>
-+  <feature policy='require' name='f16c'/>
-+  <feature policy='require' name='rdrand'/>
-+  <feature policy='require' name='hypervisor'/>
-+  <feature policy='require' name='tsc_adjust'/>
-+  <feature policy='require' name='xsaveopt'/>
-+  <feature policy='require' name='pdpe1gb'/>
-+  <feature policy='require' name='abm'/>
-+</cpu>
-diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.json b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.json
-new file mode 100644
-index 0000000000..f2aa7f3185
---- /dev/null
-+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.json
-@@ -0,0 +1,202 @@
-+{
-+  "return": {
-+    "model": {
-+      "name": "base",
-+      "props": {
-+        "pfthreshold": false,
-+        "pku": false,
-+        "rtm": true,
-+        "tsc_adjust": true,
-+        "tsc-deadline": true,
-+        "xstore-en": false,
-+        "tsc-scale": false,
-+        "sse": true,
-+        "smap": true,
-+        "stepping": 4,
-+        "tce": false,
-+        "kvm_steal_time": true,
-+        "smep": true,
-+        "rdpid": false,
-+        "xcrypt": false,
-+        "sse4_2": true,
-+        "monitor": false,
-+        "sse4_1": true,
-+        "kvm-mmu": false,
-+        "flushbyasid": false,
-+        "kvm-steal-time": true,
-+        "lm": true,
-+        "tsc": true,
-+        "adx": true,
-+        "fxsr": true,
-+        "sha-ni": false,
-+        "tm": false,
-+        "pclmuldq": true,
-+        "xgetbv1": false,
-+        "xstore": false,
-+        "vmcb_clean": false,
-+        "vme": true,
-+        "vendor": "GenuineIntel",
-+        "ffxsr": false,
-+        "de": true,
-+        "avx512f": false,
-+        "pse": true,
-+        "ds-cpl": false,
-+        "tbm": false,
-+        "ia64": false,
-+        "phe-en": false,
-+        "f16c": true,
-+        "ds": false,
-+        "mpx": false,
-+        "tsc-adjust": true,
-+        "aes": true,
-+        "avx2": true,
-+        "pbe": false,
-+        "cx16": true,
-+        "ds_cpl": false,
-+        "movbe": true,
-+        "perfctr-nb": false,
-+        "nrip_save": false,
-+        "kvm_mmu": false,
-+        "ospke": false,
-+        "avx512ifma": false,
-+        "vmx": true,
-+        "sep": true,
-+        "xsaveopt": true,
-+        "sse4a": false,
-+        "avx512dq": false,
-+        "i64": true,
-+        "avx512-4vnniw": false,
-+        "xsave": true,
-+        "erms": true,
-+        "hle": true,
-+        "nodeid_msr": false,
-+        "est": false,
-+        "svm_lock": false,
-+        "xop": false,
-+        "model-id": "Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz",
-+        "abm": true,
-+        "avx512er": false,
-+        "sse4.1": true,
-+        "sse4.2": true,
-+        "pause-filter": false,
-+        "lahf-lm": true,
-+        "kvm-nopiodelay": true,
-+        "cmp_legacy": false,
-+        "acpi": false,
-+        "fma4": false,
-+        "popcnt": true,
-+        "mmx": true,
-+        "osxsave": false,
-+        "pcommit": false,
-+        "avx512pf": false,
-+        "clwb": false,
-+        "dca": false,
-+        "pdcm": false,
-+        "xcrypt-en": false,
-+        "3dnow": false,
-+        "invtsc": false,
-+        "tm2": false,
-+        "hypervisor": true,
-+        "kvmclock-stable-bit": true,
-+        "fxsr-opt": false,
-+        "pcid": true,
-+        "sse4-1": true,
-+        "sse4-2": true,
-+        "avx512-vpopcntdq": false,
-+        "avx512-4fmaps": false,
-+        "pause_filter": false,
-+        "svm-lock": false,
-+        "rdrand": true,
-+        "nrip-save": false,
-+        "avx512vl": false,
-+        "x2apic": true,
-+        "kvmclock": true,
-+        "pge": true,
-+        "family": 6,
-+        "dtes64": false,
-+        "xd": true,
-+        "kvm_pv_eoi": true,
-+        "ace2": false,
-+        "kvm_pv_unhalt": true,
-+        "xtpr": false,
-+        "perfctr_nb": false,
-+        "avx512bw": false,
-+        "nx": true,
-+        "lwp": false,
-+        "msr": true,
-+        "ace2-en": false,
-+        "decodeassists": false,
-+        "perfctr-core": false,
-+        "pn": false,
-+        "fma": true,
-+        "nodeid-msr": false,
-+        "kvm_asyncpf": true,
-+        "clflush": true,
-+        "cx8": true,
-+        "mce": true,
-+        "avx512cd": false,
-+        "cr8legacy": false,
-+        "mca": true,
-+        "pni": true,
-+        "rdseed": true,
-+        "apic": true,
-+        "fsgsbase": true,
-+        "cmp-legacy": false,
-+        "kvm-pv-unhalt": true,
-+        "rdtscp": true,
-+        "mmxext": false,
-+        "cid": false,
-+        "ssse3": true,
-+        "extapic": false,
-+        "pse36": true,
-+        "mtrr": true,
-+        "ibs": false,
-+        "la57": false,
-+        "avx": true,
-+        "syscall": true,
-+        "umip": false,
-+        "invpcid": true,
-+        "avx512vbmi": false,
-+        "kvm-asyncpf": true,
-+        "vmcb-clean": false,
-+        "pmm": false,
-+        "cmov": true,
-+        "perfctr_core": false,
-+        "misalignsse": false,
-+        "clflushopt": false,
-+        "pat": true,
-+        "lbrv": false,
-+        "3dnowprefetch": true,
-+        "fpu": true,
-+        "pae": true,
-+        "wdt": false,
-+        "tsc_scale": false,
-+        "skinit": false,
-+        "fxsr_opt": false,
-+        "kvm_nopiodelay": true,
-+        "pmm-en": false,
-+        "phe": false,
-+        "3dnowext": false,
-+        "osvw": false,
-+        "ht": false,
-+        "pdpe1gb": true,
-+        "kvm-pv-eoi": true,
-+        "npt": false,
-+        "xsavec": false,
-+        "lahf_lm": true,
-+        "pclmulqdq": true,
-+        "svm": false,
-+        "sse3": true,
-+        "sse2": true,
-+        "ss": true,
-+        "topoext": false,
-+        "smx": false,
-+        "bmi1": true,
-+        "bmi2": true,
-+        "xsaves": false,
-+        "model": 61
-+      }
-+    }
-+  },
-+  "id": "model-expansion"
-+}
-diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.xml
-new file mode 100644
-index 0000000000..ecb4a6e15c
---- /dev/null
-+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.xml
-@@ -0,0 +1,41 @@
-+<!-- Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz -->
-+<cpudata arch='x86'>
-+  <cpuid eax_in='0x00000000' ecx_in='0x00' eax='0x00000014' ebx='0x756e6547' ecx='0x6c65746e' edx='0x49656e69'/>
-+  <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x000306d4' ebx='0x00100800' ecx='0x7ffafbff' edx='0xbfebfbff'/>
-+  <cpuid eax_in='0x00000002' ecx_in='0x00' eax='0x76036301' ebx='0x00f0b5ff' ecx='0x00000000' edx='0x00c30000'/>
-+  <cpuid eax_in='0x00000003' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000004' ecx_in='0x00' eax='0x1c004121' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000004' ecx_in='0x01' eax='0x1c004122' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000004' ecx_in='0x02' eax='0x1c004143' ebx='0x01c0003f' ecx='0x000001ff' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000004' ecx_in='0x03' eax='0x1c03c163' ebx='0x03c0003f' ecx='0x00000fff' edx='0x00000006'/>
-+  <cpuid eax_in='0x00000005' ecx_in='0x00' eax='0x00000040' ebx='0x00000040' ecx='0x00000003' edx='0x11142120'/>
-+  <cpuid eax_in='0x00000006' ecx_in='0x00' eax='0x00000077' ebx='0x00000002' ecx='0x00000009' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x021c2fbb' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000008' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000009' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x0000000a' ecx_in='0x00' eax='0x07300403' ebx='0x00000000' ecx='0x00000000' edx='0x00000603'/>
-+  <cpuid eax_in='0x0000000b' ecx_in='0x00' eax='0x00000001' ebx='0x00000002' ecx='0x00000100' edx='0x00000000'/>
-+  <cpuid eax_in='0x0000000b' ecx_in='0x01' eax='0x00000004' ebx='0x00000004' ecx='0x00000201' edx='0x00000000'/>
-+  <cpuid eax_in='0x0000000c' ecx_in='0x00' eax='0x00000000' ebx='0x00000001' ecx='0x00000001' edx='0x00000000'/>
-+  <cpuid eax_in='0x0000000d' ecx_in='0x00' eax='0x00000007' ebx='0x00000340' ecx='0x00000340' edx='0x00000000'/>
-+  <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x00000001' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x0000000d' ecx_in='0x02' eax='0x00000100' ebx='0x00000240' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x0000000e' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x0000000f' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000010' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000011' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000012' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000013' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x00000014' ecx_in='0x00' eax='0x00000000' ebx='0x00000001' ecx='0x00000001' edx='0x00000000'/>
-+  <cpuid eax_in='0x80000000' ecx_in='0x00' eax='0x80000008' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000121' edx='0x2c100800'/>
-+  <cpuid eax_in='0x80000002' ecx_in='0x00' eax='0x65746e49' ebx='0x2952286c' ecx='0x726f4320' edx='0x4d542865'/>
-+  <cpuid eax_in='0x80000003' ecx_in='0x00' eax='0x37692029' ebx='0x3036352d' ecx='0x43205530' edx='0x40205550'/>
-+  <cpuid eax_in='0x80000004' ecx_in='0x00' eax='0x362e3220' ebx='0x7a484730' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x80000005' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x80000006' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x01006040' edx='0x00000000'/>
-+  <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
-+  <cpuid eax_in='0x80000008' ecx_in='0x00' eax='0x00003027' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
-+  <cpuid eax_in='0x80860000' ecx_in='0x00' eax='0x00000000' ebx='0x00000001' ecx='0x00000001' edx='0x00000000'/>
-+  <cpuid eax_in='0xc0000000' ecx_in='0x00' eax='0x00000000' ebx='0x00000001' ecx='0x00000001' edx='0x00000000'/>
-+</cpudata>
--- 
-2.13.2
-
diff --git a/SOURCES/libvirt-cpu_x86-Rename-virCPUx86MapInitialize.patch b/SOURCES/libvirt-cpu_x86-Rename-virCPUx86MapInitialize.patch
index 1808387..b757b16 100644
--- a/SOURCES/libvirt-cpu_x86-Rename-virCPUx86MapInitialize.patch
+++ b/SOURCES/libvirt-cpu_x86-Rename-virCPUx86MapInitialize.patch
@@ -1,5 +1,5 @@
-From 3a74e5ae1229d1be6792178e650174f4a740e869 Mon Sep 17 00:00:00 2001
-Message-Id: <3a74e5ae1229d1be6792178e650174f4a740e869@dist-git>
+From b200b9cbb5c6c7d3d3b1bb4f745a7371cc35a429 Mon Sep 17 00:00:00 2001
+Message-Id: <b200b9cbb5c6c7d3d3b1bb4f745a7371cc35a429@dist-git>
 From: Jiri Denemark <jdenemar@redhat.com>
 Date: Wed, 13 Dec 2017 22:30:31 +0100
 Subject: [PATCH] cpu_x86: Rename virCPUx86MapInitialize
@@ -15,7 +15,7 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  1 file changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
-index 2864454211..8af0a1a2b7 100644
+index a6cbd45766..693e571a3d 100644
 --- a/src/cpu/cpu_x86.c
 +++ b/src/cpu/cpu_x86.c
 @@ -153,8 +153,8 @@ struct _virCPUx86Map {
@@ -29,7 +29,7 @@ index 2864454211..8af0a1a2b7 100644
  
  
  typedef enum {
-@@ -1386,7 +1386,7 @@ virCPUx86LoadMap(void)
+@@ -1404,7 +1404,7 @@ virCPUx86LoadMap(void)
  
  
  int
@@ -38,7 +38,7 @@ index 2864454211..8af0a1a2b7 100644
  {
      if (!(cpuMap = virCPUx86LoadMap()))
          return -1;
-@@ -1398,7 +1398,7 @@ virCPUx86MapOnceInit(void)
+@@ -1416,7 +1416,7 @@ virCPUx86MapOnceInit(void)
  static virCPUx86MapPtr
  virCPUx86GetMap(void)
  {
diff --git a/SOURCES/libvirt-daemon-Don-t-initialize-SASL-context-if-not-necessary.patch b/SOURCES/libvirt-daemon-Don-t-initialize-SASL-context-if-not-necessary.patch
deleted file mode 100644
index 159fca0..0000000
--- a/SOURCES/libvirt-daemon-Don-t-initialize-SASL-context-if-not-necessary.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From 8c9296cbe21657aadbc4bff88eabd617168349f6 Mon Sep 17 00:00:00 2001
-Message-Id: <8c9296cbe21657aadbc4bff88eabd617168349f6@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Fri, 2 Jun 2017 15:07:59 +0200
-Subject: [PATCH] daemon: Don't initialize SASL context if not necessary
-
-SASL context would be initialized even if the corresponding TCP or TLS
-sockets are not enabled.
-
-fe772f24a68 attempted to fix the symptom by commenting out the settings,
-but that did not fix the root cause. 3c647ee4bbb later reverted those
-changes so that the more secure algorithm is used.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1450095
-(cherry picked from commit ed914284ba74afb7dd16dcb623073bb1a1d5cd21)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- daemon/libvirtd.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
-index 891238bcbe..bac4bc1b65 100644
---- a/daemon/libvirtd.c
-+++ b/daemon/libvirtd.c
-@@ -613,11 +613,11 @@ daemonSetupNetworking(virNetServerPtr srv,
- 
- #if WITH_SASL
-     if (config->auth_unix_rw == REMOTE_AUTH_SASL ||
--        config->auth_unix_ro == REMOTE_AUTH_SASL ||
-+        (sock_path_ro && config->auth_unix_ro == REMOTE_AUTH_SASL) ||
- # if WITH_GNUTLS
--        config->auth_tls == REMOTE_AUTH_SASL ||
-+        (ipsock && config->listen_tls && config->auth_tls == REMOTE_AUTH_SASL) ||
- # endif
--        config->auth_tcp == REMOTE_AUTH_SASL) {
-+        (ipsock && config->listen_tcp && config->auth_tcp == REMOTE_AUTH_SASL)) {
-         saslCtxt = virNetSASLContextNewServer(
-             (const char *const*)config->sasl_allowed_username_list);
-         if (!saslCtxt)
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-disk-Force-usage-of-parted-when-checking-disk-format-for-bsd.patch b/SOURCES/libvirt-disk-Force-usage-of-parted-when-checking-disk-format-for-bsd.patch
deleted file mode 100644
index e867cc5..0000000
--- a/SOURCES/libvirt-disk-Force-usage-of-parted-when-checking-disk-format-for-bsd.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From 911438df6c652e377f80712c67da90aed91444b7 Mon Sep 17 00:00:00 2001
-Message-Id: <911438df6c652e377f80712c67da90aed91444b7@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Wed, 26 Apr 2017 08:41:09 -0400
-Subject: [PATCH] disk: Force usage of parted when checking disk format for
- "bsd"
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439132
-
-Add "bsd" to the list of format types to not checked during blkid
-processing even though it supposedly knows the format - for some
-(now unknown) reason it's returning partition table not found. So
-let's just let PARTED handle "bsd" too.
-
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-(cherry picked from commit 98f424d5038b362d1b62549930d0b9253106bdca)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/storage/storage_util.c | 6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
-index 7a458b828..adec9ab6f 100644
---- a/src/storage/storage_util.c
-+++ b/src/storage/storage_util.c
-@@ -3002,10 +3002,12 @@ virStorageBackendBLKIDFindPart(blkid_probe probe,
- 
-     /* A blkid_known_pttype on "dvh" and "pc98" returns a failure;
-      * however, the blkid_do_probe for "dvh" returns "sgi" and
--     * for "pc98" it returns "dos". So since those will cause problems
-+     * for "pc98" it returns "dos". Although "bsd" is recognized,
-+     * it seems that the parted created partition table is not being
-+     * properly recogized. Since each of these will cause problems
-      * with startup comparison, let's just treat them as UNKNOWN causing
-      * the caller to fallback to using PARTED */
--    if (STREQ(format, "dvh") || STREQ(format, "pc98"))
-+    if (STREQ(format, "dvh") || STREQ(format, "pc98") || STREQ(format, "bsd"))
-         return VIR_STORAGE_BLKID_PROBE_UNKNOWN;
- 
-     /* Make sure we're doing a partitions probe from the start */
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-disk-Resolve-issues-with-disk-partition-build-start-checks.patch b/SOURCES/libvirt-disk-Resolve-issues-with-disk-partition-build-start-checks.patch
deleted file mode 100644
index 77b111d..0000000
--- a/SOURCES/libvirt-disk-Resolve-issues-with-disk-partition-build-start-checks.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 5c1a822cfa7993b1f55f90b75b66c86787a063d1 Mon Sep 17 00:00:00 2001
-Message-Id: <5c1a822cfa7993b1f55f90b75b66c86787a063d1@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Wed, 26 Apr 2017 08:41:08 -0400
-Subject: [PATCH] disk: Resolve issues with disk partition build/start checks
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439132
-
-Commit id 'a48c674fb' added a check for format types "dvh" and "pc98"
-to use the parted print processing instead of using blkid processing
-in order to validate the label on the disk was what is expected for
-disk pool startup. However, commit id 'a4cb4a74f' really messed things
-up by missing an else condition causing PARTEDFindLabel to always
-return DIFFERENT.
-
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-(cherry picked from commit f2a123203105b4fe010aea866e87f8bcf5f31193)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/storage/storage_util.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
-index 0ceaab6b9..7a458b828 100644
---- a/src/storage/storage_util.c
-+++ b/src/storage/storage_util.c
-@@ -3213,8 +3213,8 @@ virStorageBackendPARTEDFindLabel(const char *device,
-     /*  Does the on disk match what the pool desired? */
-     if (STREQ(start, format))
-         ret = VIR_STORAGE_PARTED_MATCH;
--
--    ret = VIR_STORAGE_PARTED_DIFFERENT;
-+    else
-+        ret = VIR_STORAGE_PARTED_DIFFERENT;
- 
-  cleanup:
-     virCommandFree(cmd);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-disk-Use-virStorageBackendZeroPartitionTable.patch b/SOURCES/libvirt-disk-Use-virStorageBackendZeroPartitionTable.patch
deleted file mode 100644
index 705de4d..0000000
--- a/SOURCES/libvirt-disk-Use-virStorageBackendZeroPartitionTable.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-From 9aeaadcf7d7f33cc5208bcbc788676f27691843a Mon Sep 17 00:00:00 2001
-Message-Id: <9aeaadcf7d7f33cc5208bcbc788676f27691843a@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Wed, 26 Apr 2017 08:41:14 -0400
-Subject: [PATCH] disk: Use virStorageBackendZeroPartitionTable
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439132
-
-During 'matrix' testing of all possible combinations I found that if
-device is formated with "gpt" first, then an attempt is made to format
-using "mac", a startup will fail.
-
-Deeper analysis by Peter Krempa indicates that the "mac" table fits
-into the first block on the disk. Since the GPT disklabel is stored
-at LBA address 1 it is not overwritten at all. Thus it's apparent that
-the (blkid) detection tool then prefers GPT over a older disklabel.
-
-The GPT disklabel has also a secondary copy at the last LBA of the disk.
-
-So, follow the same logic as the logical pool in clearing a 1MB swath
-at the beginning and end of the device to avoid potential issues with
-larger sector sizes for the device.
-
-Also fixed a minor formatting nit in virStorageBackendDeviceIsEmpty call.
-
-(cherry picked from commit 3c4f2e3fb725054921f855a229afc7daca7119ae)
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/storage/storage_backend_disk.c | 6 +++++-
- 1 file changed, 5 insertions(+), 1 deletion(-)
-
-diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
-index 39371f2d9..e8f67bb00 100644
---- a/src/storage/storage_backend_disk.c
-+++ b/src/storage/storage_backend_disk.c
-@@ -491,11 +491,15 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
-         ok_to_mklabel = true;
-     } else {
-         if (virStorageBackendDeviceIsEmpty(pool->def->source.devices[0].path,
--                                              fmt, true))
-+                                           fmt, true))
-             ok_to_mklabel = true;
-     }
- 
-     if (ok_to_mklabel) {
-+        if (virStorageBackendZeroPartitionTable(pool->def->source.devices[0].path,
-+                                                1024 * 1024) < 0)
-+            goto error;
-+
-         /* eg parted /dev/sda mklabel --script msdos */
-         if (format == VIR_STORAGE_POOL_DISK_UNKNOWN)
-             format = pool->def->source.format = VIR_STORAGE_POOL_DISK_DOS;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-docs-Document-the-mediated-devices-within-the-nodedev-driver.patch b/SOURCES/libvirt-docs-Document-the-mediated-devices-within-the-nodedev-driver.patch
deleted file mode 100644
index fa10ab2..0000000
--- a/SOURCES/libvirt-docs-Document-the-mediated-devices-within-the-nodedev-driver.patch
+++ /dev/null
@@ -1,231 +0,0 @@
-From 9a202d80f7b60fcf6caf059570bfd2d0b0cbe8a4 Mon Sep 17 00:00:00 2001
-Message-Id: <9a202d80f7b60fcf6caf059570bfd2d0b0cbe8a4@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 18 May 2017 14:02:55 +0200
-Subject: [PATCH] docs: Document the mediated devices within the nodedev driver
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1452072
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit a0a0b3cf71cbee1df40dd0fdebd7bb6a84682f09)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/drvnodedev.html.in | 168 +++++++++++++++++++++++++++++++++++++++++++++++-
- tools/virsh.pod         |   7 +-
- 2 files changed, 171 insertions(+), 4 deletions(-)
-
-diff --git a/docs/drvnodedev.html.in b/docs/drvnodedev.html.in
-index 0a3870343..26c52dd0d 100644
---- a/docs/drvnodedev.html.in
-+++ b/docs/drvnodedev.html.in
-@@ -9,7 +9,7 @@
-       (historically also referred to as node devices) like USB, PCI, SCSI, and
-       network devices. This also includes various virtualization capabilities
-       which the aforementioned devices provide for utilization, for example
--      SR-IOV, NPIV, DRM, etc.
-+      SR-IOV, NPIV, MDEV, DRM, etc.
-     </p>
- 
-     <p>
-@@ -75,6 +75,7 @@
-           <code>storage</code> (<span class="since">Since 1.0.4</span>),
-           <code>scsi_generic</code> (<span class="since">Since 1.0.7</span>),
-           <code>drm</code> (<span class="since">Since 3.1.0</span>), and
-+          <code>mdev</code> (<span class="since">Since 3.4.0</span>).
-           This element can be nested in which case it further specifies a
-           device's capability. Refer to specific device types to see more values
-           for the <code>type</code> attribute which are exclusive.
-@@ -185,5 +186,170 @@
- ...
- &lt;device&gt;</pre>
- 
-+    <h3><a name="MDEVCap">MDEV capability</a></h3>
-+    <p>
-+      A PCI device capable of creating mediated devices will include a nested
-+      capability <code>mdev_types</code> which enumerates all supported mdev
-+      types on the physical device, along with the type attributes available
-+      through sysfs:
-+    </p>
-+
-+    <dl>
-+      <dt><code>type</code></dt>
-+      <dd>
-+        This element describes a mediated device type which acts as an
-+        abstract template defining a resource allocation for instances of this
-+        device type. The element has one attribute <code>id</code> which holds
-+        an official vendor-supplied identifier for the type.
-+        <span class="since">Since 3.4.0</span>
-+      </dd>
-+
-+      <dt><code>name</code></dt>
-+      <dd>
-+        The <code>name</code> element holds a vendor-supplied code name for
-+        the given mediated device type. This is an optional element.
-+        <span class="since">Since 3.4.0</span>
-+      </dd>
-+
-+      <dt><code>deviceAPI</code></dt>
-+      <dd>
-+        The value of this element describes how an instance of the given type
-+        will be presented to the guest by the VFIO framework.
-+        <span class="since">Since 3.4.0</span>
-+      </dd>
-+
-+      <dt><code>availableInstances</code></dt>
-+      <dd>
-+        This element reports the current state of resource allocation. In other
-+        words, how many instances of the given type can still be successfully
-+        created on the physical device.
-+        <span class="since">Since 3.4.0</span>
-+      </dd>
-+    </dl>
-+
-+    <p>
-+      For a more info about mediated devices, refer to the
-+      <a href="#MDEV">paragraph below</a>.
-+    </p>
-+
-+<pre>
-+&lt;device&gt;
-+...
-+  &lt;driver&gt;
-+    &lt;name&gt;nvidia&lt;/name&gt;
-+  &lt;/driver&gt;
-+  &lt;capability type='pci'&gt;
-+...
-+    &lt;capability type='mdev_types'&gt;
-+      &lt;type id='nvidia-11'&gt;
-+        &lt;name&gt;GRID M60-0B&lt;/name&gt;
-+        &lt;deviceAPI&gt;vfio-pci&lt;/deviceAPI&gt;
-+        &lt;availableInstances&gt;16&lt;/availableInstances&gt;
-+      &lt;/type&gt;
-+      &lt;!-- Here would come the rest of the available mdev types --&gt;
-+    &lt;/capability&gt;
-+...
-+  &lt;/capability&gt;
-+&lt;/device&gt;</pre>
-+
-+    <h2><a name="MDEV">Mediated devices (MDEVs)</a></h2>
-+    <p>
-+      Mediated devices (<span class="since">Since 3.2.0</span>) are software
-+      devices defining resource allocation on the backing physical device which
-+      in turn allows the parent physical device's resources to be divided into
-+      several mediated devices, thus sharing the physical device's performance
-+      among multiple guests. Unlike SR-IOV however, where a PCIe device appears
-+      as multiple separate PCIe devices on the host's PCI bus, mediated devices
-+      only appear on the mdev virtual bus. Therefore, no detach/reattach
-+      procedure from/to the host driver procedure is involved even though
-+      mediated devices are used in a direct device assignment manner.
-+    </p>
-+
-+    <p>
-+      The following sub-elements and attributes are exposed within the
-+      <code>capability</code> element:
-+    </p>
-+
-+    <dl>
-+      <dt><code>type</code></dt>
-+      <dd>
-+        This element describes a mediated device type which acts as an
-+        abstract template defining a resource allocation for instances of this
-+        device type. The element has one attribute <code>id</code> which holds
-+        an official vendor-supplied identifier for the type.
-+        <span class="since">Since 3.4.0</span>
-+      </dd>
-+
-+      <dt><code>iommuGroup</code></dt>
-+      <dd>
-+        This element supports a single attribute <code>number</code> which holds
-+        the IOMMU group number the mediated device belongs to.
-+        <span class="since">Since 3.4.0</span>
-+      </dd>
-+    </dl>
-+
-+    <h3>Example of a mediated device</h3>
-+    <pre>
-+&lt;device&gt;
-+  &lt;name&gt;mdev_4b20d080_1b54_4048_85b3_a6a62d165c01&lt;/name&gt;
-+  &lt;path&gt;/sys/devices/pci0000:00/0000:00:02.0/4b20d080-1b54-4048-85b3-a6a62d165c01&lt;/path&gt;
-+  &lt;parent&gt;pci_0000_06_00_0&lt;/parent&gt;
-+  &lt;driver&gt;
-+    &lt;name&gt;vfio_mdev&lt;/name&gt;
-+  &lt;/driver&gt;
-+  &lt;capability type='mdev'&gt;
-+    &lt;type id='nvidia-11'/&gt;
-+    &lt;iommuGroup number='12'/&gt;
-+  &lt;capability/&gt;
-+&lt;device/&gt;</pre>
-+
-+    <p>
-+      The support of mediated device's framework in libvirt's node device driver
-+      covers the following features:
-+    </p>
-+
-+    <ul>
-+      <li>
-+        list available mediated devices on the host
-+        (<span class="since">Since 3.4.0</span>)
-+      </li>
-+      <li>
-+        display device details
-+        (<span class="since">Since 3.4.0</span>)
-+      </li>
-+    </ul>
-+
-+    <p>
-+      Because mediated devices are instantiated from vendor specific templates,
-+      simply called 'types', information describing these types is contained
-+      within the parent device's capabilities
-+      (see the example in <a href="#PCI">PCI host devices</a>).
-+    </p>
-+
-+    <p>
-+      To see the supported mediated device types on a specific physical device
-+      use the following:
-+    </p>
-+
-+    <pre>
-+$ ls /sys/class/mdev_bus/&lt;device&gt;/mdev_supported_types</pre>
-+
-+    <p>
-+      To manually instantiate a mediated device, use one of the following as a
-+      reference:
-+    </p>
-+
-+    <pre>
-+$ uuidgen &gt; /sys/class/mdev_bus/&lt;device&gt;/mdev_supported_types/&lt;type&gt;/create
-+...
-+$ echo &lt;UUID&gt; &gt; /sys/class/mdev_bus/&lt;device&gt;/mdev_supported_types/&lt;type&gt;/create</pre>
-+
-+    <p>
-+      Manual removal of a mediated device is then performed as follows:
-+    </p>
-+
-+    <pre>
-+$ echo 1 &gt; /sys/bus/mdev/devices/&lt;uuid&gt;/remove</pre>
-+
-   </body>
- </html>
-diff --git a/tools/virsh.pod b/tools/virsh.pod
-index 0dd1fc7b2..11bacefa9 100644
---- a/tools/virsh.pod
-+++ b/tools/virsh.pod
-@@ -3155,10 +3155,11 @@ for HBA).
- 
- List all of the devices available on the node that are known by libvirt.
- I<cap> is used to filter the list by capability types, the types must be
--separated by comma, e.g. --cap pci,scsi, valid capability types include
-+separated by comma, e.g. --cap pci,scsi. Valid capability types include
- 'system', 'pci', 'usb_device', 'usb', 'net', 'scsi_host', 'scsi_target',
--'scsi', 'storage', 'fc_host', 'vports', 'scsi_generic', 'drm'.If I<--tree>
--is used, the output is formatted in a tree representing parents of each
-+'scsi', 'storage', 'fc_host', 'vports', 'scsi_generic', 'drm', 'mdev',
-+'mdev_types'.
-+If I<--tree> is used, the output is formatted in a tree representing parents of each
- node.  I<cap> and I<--tree> are mutually exclusive.
- 
- =item B<nodedev-reattach> I<nodedev>
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-docs-Improve-documentation-for-serial-consoles.patch b/SOURCES/libvirt-docs-Improve-documentation-for-serial-consoles.patch
new file mode 100644
index 0000000..7467515
--- /dev/null
+++ b/SOURCES/libvirt-docs-Improve-documentation-for-serial-consoles.patch
@@ -0,0 +1,294 @@
+From 07ed5aa86d223b1e99ef716429be60c1823ce0f5 Mon Sep 17 00:00:00 2001
+Message-Id: <07ed5aa86d223b1e99ef716429be60c1823ce0f5@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:22:55 +0100
+Subject: [PATCH] docs: Improve documentation for serial consoles
+
+Our current documentation is missing some information and doesn't
+do a great job at explaining how the <serial> and <console> elements
+are connected. Let's try to fix that.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 4567cecb372c48095fce23ce3040d1c687cc3640)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/formatdomain.html.in | 224 +++++++++++++++++++++++++++++++++-------------
+ 1 file changed, 164 insertions(+), 60 deletions(-)
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index 4f28dce355..f57a124056 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -6434,77 +6434,68 @@ qemu-kvm -net nic,model=? /dev/null
+ <pre>
+ ...
+ &lt;devices&gt;
++  &lt;!-- Serial port --&gt;
+   &lt;serial type='pty'&gt;
+     &lt;source path='/dev/pts/3'/&gt;
+     &lt;target port='0'/&gt;
+   &lt;/serial&gt;
+ &lt;/devices&gt;
++...</pre>
++
++<pre>
++...
++&lt;devices&gt;
++  &lt;!-- USB serial port --&gt;
++  &lt;serial type='pty'&gt;
++    &lt;target type='usb-serial' port='0'/&gt;
++    &lt;address type='usb' bus='0' port='1'/&gt;
++  &lt;/serial&gt;
++&lt;/devices&gt;
+ ...</pre>
+ 
+     <p>
+-      <code>target</code> can have a <code>port</code> attribute, which
+-      specifies the port number. Ports are numbered starting from 0. There are
+-      usually 0, 1 or 2 serial ports. There is also an optional
+-      <code>type</code> attribute <span class="since">since 1.0.2</span>
+-      which has three choices for its value, one is <code>isa-serial</code>,
+-      then <code>usb-serial</code> and last one is <code>pci-serial</code>.
+-      If <code>type</code> is missing, <code>isa-serial</code> will be used by
+-      default. For <code>usb-serial</code> an optional sub-element
+-      <code>&lt;address/&gt;</code> with <code>type='usb'</code> can tie the
+-      device to a particular controller, <a href="#elementsAddress">documented above</a>.
+-      Similarly, <code>pci-serial</code> can be used to attach the device to
+-      the pci bus (<span class="since">since 1.2.16</span>). Again, it has
+-      optional sub-element <code>&lt;address/&gt;</code> with
+-      <code>type='pci'</code> to select desired location on the PCI bus.
++      The <code>target</code> element can have an optional <code>port</code>
++      attribute, which specifies the port number (starting from 0), and an
++      optional <code>type</code> attribute: valid values are,
++      <span class="since">since 1.0.2</span>, <code>isa-serial</code> (usable
++      with x86 guests), <code>usb-serial</code> (usable whenever USB support
++      is available) and <code>pci-serial</code> (usable whenever PCI support
++      is available).
++    </p>
++
++    <p>
++      If any of the attributes is not specified by the user, libvirt will
++      choose a value suitable for most users.
++    </p>
++
++    <p>
++      All of the target types support configuring the guest-visible device
++      address as <a href="#elementsAddress">documented above</a>; more
++      specifically, acceptable address types are <code>isa</code> (for
++      <code>isa-serial</code>), <code>usb</code> (for <code>usb-serial</code>)
++      and <code>pci</code> (for <code>pci-serial</code>).
++    </p>
++
++    <p>
++      For the relationship between serial ports and consoles,
++      <a href="#elementCharSerialAndConsole">see below</a>.
+     </p>
+ 
+     <h6><a id="elementCharConsole">Console</a></h6>
+ 
+-    <p>
+-      The console element is used to represent interactive consoles. Depending
+-      on the type of guest in use, the consoles might be paravirtualized devices,
+-      or they might be a clone of a serial device, according to the following
+-      rules:
+-    </p>
+-
+-    <ul>
+-      <li>If no <code>targetType</code> attribute is set, then the default
+-        device type is according to the hypervisor's rules. The default
+-        type will be added when re-querying the XML fed into libvirt.
+-        For fully virtualized guests, the default device type will usually
+-        be a serial port.</li>
+-      <li>If the <code>targetType</code> attribute is <code>serial</code>,
+-        then if no <code>&lt;serial&gt;</code> element exists, the console
+-        element will be copied to the serial element. If a <code>&lt;serial&gt;</code>
+-        element does already exist, the console element will be ignored.</li>
+-      <li>If the <code>targetType</code> attribute is not <code>serial</code>,
+-        it will be treated normally.</li>
+-      <li>Only the first <code>console</code> element may use a <code>targetType</code>
+-        of <code>serial</code>. Secondary consoles must all be paravirtualized.
+-      </li>
+-      <li>On S390, the <code>console</code> element may use a
+-        <code>targetType</code> of <code>sclp</code> or <code>sclplm</code>
+-        (line mode). SCLP is the native console type for S390. There's no
+-        controller associated to SCLP consoles.
+-        <span class="since">Since 1.0.2</span>
+-      </li>
+-    </ul>
+-
+-    <p>
+-      A virtio console device is exposed in the
+-      guest as /dev/hvc[0-7] (for more information, see
+-      <a href="http://fedoraproject.org/wiki/Features/VirtioSerial">http://fedoraproject.org/wiki/Features/VirtioSerial</a>)
+-      <span class="since">Since 0.8.3</span>
+-    </p>
+-
+ <pre>
+ ...
+ &lt;devices&gt;
++  &lt;!-- Serial console --&gt;
+   &lt;console type='pty'&gt;
+-    &lt;source path='/dev/pts/4'/&gt;
+-    &lt;target port='0'/&gt;
++    &lt;source path='/dev/pts/2'/&gt;
++    &lt;target type='serial' port='0'/&gt;
+   &lt;/console&gt;
++&lt;/devices&gt;
++...</pre>
+ 
++<pre>
++...
+   &lt;!-- KVM virtio console --&gt;
+   &lt;console type='pty'&gt;
+     &lt;source path='/dev/pts/5'/&gt;
+@@ -6513,21 +6504,134 @@ qemu-kvm -net nic,model=? /dev/null
+ &lt;/devices&gt;
+ ...</pre>
+ 
++    <p>
++      The <code>console</code> element is used to represent interactive
++      serial consoles. Depending on the type of guest in use and the specifics
++      of the configuration, the <code>console</code> element might represent
++      the same device as an existing <code>serial</code> element or a separate
++      device.
++    </p>
++
++    <p>
++      A <code>target</code> subelement is supported and works the same
++      way as with the <code>serial</code> element
++      (<a href="#elementCharSerial">see above</a> for details).
++      Valid values for the <code>type</code> attribute are:
++      <code>serial</code> (described below);
++      <code>virtio</code> (usable whenever VirtIO support is available);
++      <code>xen</code>, <code>lxc</code>, <code>uml</code> and
++      <code>openvz</code> (available when the corresponding hypervisor is in
++      use); <code>sclp</code> and <code>sclplm</code> (usable for s390 and
++      s390x QEMU guests).
++    </p>
++
++    <p>
++      Of the target types listed above, <code>serial</code> is special in
++      that it doesn't represents a separate device, but rather the same
++      device as the first <code>serial</code> element. Due to this, there can
++      only be a single <code>console</code> element with target type
++      <code>serial</code> per guest.
++    </p>
++
++    <p>
++      Virtio consoles are usually accessible as <code>/dev/hvc[0-7]</code>
++      from inside the guest; for more information, see
++      <a href="http://fedoraproject.org/wiki/Features/VirtioSerial">http://fedoraproject.org/wiki/Features/VirtioSerial</a>.
++      <span class="since">Since 0.8.3</span>
++    </p>
++
++    <p>
++      For the relationship between serial ports and consoles,
++      <a href="#elementCharSerialAndConsole">see below</a>.
++    </p>
++
++    <h6><a id="elementCharSerialAndConsole">Relationship between serial ports and consoles</a></h6>
++
++    <p>
++      Due to hystorical reasons, the <code>serial</code> and
++      <code>console</code> elements have partially overlapping scopes.
++    </p>
++
++    <p>
++      In general, both elements are used to configure one or more serial
++      consoles to be used for interacting with the guest. The main difference
++      between the two is that <code>serial</code> is used for emulated,
++      usually native, serial consoles, whereas <code>console</code> is used
++      for paravirtualized ones.
++    </p>
++
++    <p>
++      Both emulated and paravirtualized serial consoles have advantages and
++      disadvantages:
++    </p>
++
++    <ul>
++      <li>
++        emulated serial consoles are usually initialized much earlier than
++        paravirtualized ones, so they can be used to control the bootloader
++        and display both firmware and early boot messages;
++      </li>
++      <li>
++        on several platforms, there can only be a single emulated serial
++        console per guest but paravirtualized consoles don't suffer from the
++        same limitation.
++      </li>
++    </ul>
++
++    <p>
++      A configuration such as:
++    </p>
++
+ <pre>
+ ...
+-&lt;devices&gt;
+-  &lt;!-- KVM S390 sclp console --&gt;
++&lt;/devices&gt;
+   &lt;console type='pty'&gt;
+-    &lt;source path='/dev/pts/1'/&gt;
+-    &lt;target type='sclp' port='0'/&gt;
++    &lt;target type='serial'/&gt;
++  &lt;/console&gt;
++  &lt;console type='pty'&gt;
++    &lt;target type='virtio'/&gt;
+   &lt;/console&gt;
+ &lt;/devices&gt;
+ ...</pre>
+ 
+     <p>
+-      If the console is presented as a serial port, the <code>target</code>
+-      element has the same attributes as for a serial port. There is usually
+-      only 1 console.
++      will work on any platform and will result in one emulated serial console
++      for early boot logging / interactive / recovery use, and one
++      paravirtualized serial console to be used eg. as a side channel. Most
++      people will be fine with having just the first <code>console</code>
++      element in their configuration.
++    </p>
++
++    <p>
++      Note that, due to the compatibility concerns mentioned earlier, all the
++      following configurations:
++    </p>
++
++<pre>
++...
++&lt;/devices&gt;
++  &lt;serial type='pty'/&gt;
++&lt;/devices&gt;
++...</pre>
++
++<pre>
++...
++&lt;/devices&gt;
++  &lt;console type='pty'/&gt;
++&lt;/devices&gt;
++...</pre>
++
++<pre>
++...
++&lt;/devices&gt;
++  &lt;serial type='pty'/&gt;
++  &lt;console type='pty'/&gt;
++&lt;/devices&gt;
++...</pre>
++
++    <p>
++      will be treated the same and will result in a single emulated serial
++      console being available to the guest.
+     </p>
+ 
+     <h6><a id="elementCharChannel">Channel</a></h6>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-docs-Provide-a-nodedev-driver-stub-documentation.patch b/SOURCES/libvirt-docs-Provide-a-nodedev-driver-stub-documentation.patch
deleted file mode 100644
index f7047b8..0000000
--- a/SOURCES/libvirt-docs-Provide-a-nodedev-driver-stub-documentation.patch
+++ /dev/null
@@ -1,237 +0,0 @@
-From 8c30b1e683b37d67d7fe827f6ab63174c596494e Mon Sep 17 00:00:00 2001
-Message-Id: <8c30b1e683b37d67d7fe827f6ab63174c596494e@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 18 May 2017 14:02:49 +0200
-Subject: [PATCH] docs: Provide a nodedev driver stub documentation
-
-There's lot more to document about the nodedev driver, besides PCI and
-SR-IOV (even this might need to be extended), but let's start small-ish
-and at least have a page for it linked from the drivers.html.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1452072
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit a94d431dc46070034de7798f572dc1d257542a50)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/drivers.html.in    |   6 +-
- docs/drvnodedev.html.in | 189 ++++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 194 insertions(+), 1 deletion(-)
- create mode 100644 docs/drvnodedev.html.in
-
-diff --git a/docs/drivers.html.in b/docs/drivers.html.in
-index be7483b9b..61993861e 100644
---- a/docs/drivers.html.in
-+++ b/docs/drivers.html.in
-@@ -4,7 +4,11 @@
-   <body>
-     <h1>Internal drivers</h1>
- 
--    <ul id="toc"></ul>
-+    <ul>
-+      <li><a href="#hypervisor">Hypervisor drivers</a></li>
-+      <li><a href="#storage">Storage drivers</a></li>
-+      <li><a href="drvnodedev.html">Node device driver</a></li>
-+    </ul>
- 
-     <p>
-       The libvirt public API delegates its implementation to one or
-diff --git a/docs/drvnodedev.html.in b/docs/drvnodedev.html.in
-new file mode 100644
-index 000000000..0a3870343
---- /dev/null
-+++ b/docs/drvnodedev.html.in
-@@ -0,0 +1,189 @@
-+<?xml version="1.0" encoding="UTF-8"?>
-+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-+<html xmlns="http://www.w3.org/1999/xhtml">
-+  <body>
-+    <h1>Host device management</h1>
-+
-+    <p>
-+      Libvirt provides management of both physical and virtual host devices
-+      (historically also referred to as node devices) like USB, PCI, SCSI, and
-+      network devices. This also includes various virtualization capabilities
-+      which the aforementioned devices provide for utilization, for example
-+      SR-IOV, NPIV, DRM, etc.
-+    </p>
-+
-+    <p>
-+      The node device driver provides means to list and show details about host
-+      devices (<code>virsh nodedev-list</code>,
-+      <code>virsh nodedev-dumpxml</code>), which are generic and can be used
-+      with all devices. It also provides means to create and destroy devices
-+      (<code>virsh nodedev-create</code>, <code>virsh nodedev-destroy</code>)
-+      which are meant to be used to create virtual devices, currently only
-+      supported by NPIV
-+      (<a href="http://wiki.libvirt.org/page/NPIV_in_libvirt">more info about NPIV)</a>).
-+      Devices on the host system are arranged in a tree-like hierarchy, with
-+      the root node being called <code>computer</code>. The node device driver
-+      supports two backends to manage the devices, HAL and udev, with the former
-+      being deprecated in favour of the latter.
-+    </p>
-+
-+    <p>
-+      The generic format of a host device XML can be seen below.
-+      To identify a device both within the host and the device tree hierarchy,
-+      the following elements are used:
-+    </p>
-+      <dl>
-+        <dt><code>name</code></dt>
-+        <dd>
-+          The device's name will be generated by libvirt using the subsystem,
-+          like pci and the device's sysfs basename.
-+        </dd>
-+        <dt><code>path</code></dt>
-+        <dd>
-+          Fully qualified sysfs path to the device.
-+        </dd>
-+        <dt><code>parent</code></dt>
-+        <dd>
-+          This element identifies the parent node in the device hierarchy. The
-+          value of the element will correspond with the device parent's
-+          <code>name</code> element or <code>computer</code> if the device does
-+          not have any parent.
-+        </dd>
-+        <dt><code>driver</code></dt>
-+        <dd>
-+          This elements reports the driver in use for this device. The presence
-+          of this element in the output XML depends on whether the underlying
-+          device manager (most likely udev) exposes information about the
-+          driver.
-+        </dd>
-+        <dt><code>capability</code></dt>
-+        <dd>
-+          Describes the device in terms of feature support. The element has one
-+          mandatory attribute <code>type</code> the value of which determines
-+          the type of the device. Currently recognized values for the attribute
-+          are:
-+          <code>system</code>,
-+          <code>pci</code>,
-+          <code>usb</code>,
-+          <code>usb_device</code>,
-+          <code>net</code>,
-+          <code>scsi</code>,
-+          <code>scsi_host</code> (<span class="since">Since 0.4.7</span>),
-+          <code>fc_host</code>,
-+          <code>vports</code>,
-+          <code>scsi_target</code> (<span class="since">Since 0.7.3</span>),
-+          <code>storage</code> (<span class="since">Since 1.0.4</span>),
-+          <code>scsi_generic</code> (<span class="since">Since 1.0.7</span>),
-+          <code>drm</code> (<span class="since">Since 3.1.0</span>), and
-+          This element can be nested in which case it further specifies a
-+          device's capability. Refer to specific device types to see more values
-+          for the <code>type</code> attribute which are exclusive.
-+        </dd>
-+      </dl>
-+
-+    <h2>Basic structure of a node device</h2>
-+    <pre>
-+&lt;device&gt;
-+  &lt;name&gt;pci_0000_00_17_0&lt;/name&gt;
-+  &lt;path&gt;/sys/devices/pci0000:00/0000:00:17.0&lt;/path&gt;
-+  &lt;parent&gt;computer&lt;/parent&gt;
-+  &lt;driver&gt;
-+    &lt;name&gt;ahci&lt;/name&gt;
-+  &lt;/driver&gt;
-+  &lt;capability type='pci'&gt;
-+...
-+  &lt;/capability&gt;
-+&lt;/device&gt;</pre>
-+
-+    <ul id="toc"/>
-+
-+    <h2><a name="PCI">PCI host devices</a></h2>
-+    <dl>
-+      <dt><code>capability</code></dt>
-+      <dd>
-+        When used as top level element, the supported values for the
-+        <code>type</code> attribute are <code>pci</code> and
-+        <code>phys_function</code> (see <a href="#SRIOVCap">SR-IOV below</a>).
-+      </dd>
-+    </dl>
-+    <pre>
-+&lt;device&gt;
-+  &lt;name&gt;pci_0000_04_00_1&lt;/name&gt;
-+  &lt;path&gt;/sys/devices/pci0000:00/0000:00:06.0/0000:04:00.1&lt;/path&gt;
-+  &lt;parent&gt;pci_0000_00_06_0&lt;/parent&gt;
-+  &lt;driver&gt;
-+    &lt;name&gt;igb&lt;/name&gt;
-+  &lt;/driver&gt;
-+  &lt;capability type='pci'&gt;
-+    &lt;domain&gt;0&lt;/domain&gt;
-+    &lt;bus&gt;4&lt;/bus&gt;
-+    &lt;slot&gt;0&lt;/slot&gt;
-+    &lt;function&gt;1&lt;/function&gt;
-+    &lt;product id='0x10c9'&gt;82576 Gigabit Network Connection&lt;/product&gt;
-+    &lt;vendor id='0x8086'&gt;Intel Corporation&lt;/vendor&gt;
-+    &lt;iommuGroup number='15'&gt;
-+      &lt;address domain='0x0000' bus='0x04' slot='0x00' function='0x1'/&gt;
-+    &lt;/iommuGroup&gt;
-+    &lt;numa node='0'/&gt;
-+    &lt;pci-express&gt;
-+      &lt;link validity='cap' port='1' speed='2.5' width='2'/&gt;
-+      &lt;link validity='sta' speed='2.5' width='2'/&gt;
-+    &lt;/pci-express&gt;
-+  &lt;/capability&gt;
-+&lt;/device&gt;</pre>
-+
-+    <p>
-+      The XML format for a PCI device stays the same for any further
-+      capabilities it supports, a single nested <code>&lt;capability&gt;</code>
-+      element will be included for each capability the device supports.
-+    </p>
-+
-+    <h3><a name="SRIOVCap">SR-IOV capability</a></h3>
-+    <p>
-+      Single root input/output virtualization (SR-IOV) allows sharing of the
-+      PCIe resources by multiple virtual environments. That is achieved by
-+      slicing up a single full-featured physical resource called physical
-+      function (PF) into multiple devices called virtual functions (VFs) sharing
-+      their configuration with the underlying PF. Despite the SR-IOV
-+      specification, the amount of VFs that can be created on a PF varies among
-+      manufacturers.
-+    </p>
-+
-+    <p>
-+      Suppose the NIC <a href="#PCI">above</a> was also SR-IOV capable, it would
-+      also include a nested
-+      <code>&lt;capability&gt;</code> element enumerating all virtual
-+      functions available on the physical device (physical port) like in the
-+      example below.
-+    </p>
-+
-+    <pre>
-+&lt;capability type='pci'&gt;
-+...
-+  &lt;capability type='virt_functions' maxCount='7'&gt;
-+    &lt;address domain='0x0000' bus='0x04' slot='0x10' function='0x1'/&gt;
-+    &lt;address domain='0x0000' bus='0x04' slot='0x10' function='0x3'/&gt;
-+    &lt;address domain='0x0000' bus='0x04' slot='0x10' function='0x5'/&gt;
-+    &lt;address domain='0x0000' bus='0x04' slot='0x10' function='0x7'/&gt;
-+    &lt;address domain='0x0000' bus='0x04' slot='0x11' function='0x1'/&gt;
-+    &lt;address domain='0x0000' bus='0x04' slot='0x11' function='0x3'/&gt;
-+    &lt;address domain='0x0000' bus='0x04' slot='0x11' function='0x5'/&gt;
-+  &lt;/capability&gt;
-+...
-+&lt;/capability&gt;</pre>
-+    <p>
-+      A SR-IOV child device on the other hand, would then report its top level
-+      capability type as a <code>phys_function</code> instead:
-+    </p>
-+
-+    <pre>
-+&lt;device&gt;
-+...
-+  &lt;capability type='phys_function'&gt;
-+    &lt;address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/&gt;
-+  &lt;/capability&gt;
-+...
-+&lt;device&gt;</pre>
-+
-+  </body>
-+</html>
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-docs-correct-improper-information-about-domain-states-in-virsh-manpage.patch b/SOURCES/libvirt-docs-correct-improper-information-about-domain-states-in-virsh-manpage.patch
deleted file mode 100644
index 866c030..0000000
--- a/SOURCES/libvirt-docs-correct-improper-information-about-domain-states-in-virsh-manpage.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From 7a40c13d93a300f6f2c493c864da7342f34e9a6c Mon Sep 17 00:00:00 2001
-Message-Id: <7a40c13d93a300f6f2c493c864da7342f34e9a6c@dist-git>
-From: Laine Stump <laine@laine.org>
-Date: Tue, 6 Jun 2017 12:07:49 -0400
-Subject: [PATCH] docs: correct improper information about domain states in
- virsh manpage
-
-Commit 24d4a0a1f removed the non-existent "dying" state from the list
-of possible domain states given in the virsh manpage, but didn't
-correct the count of states from 8 down to 7. This patch fixes that
-mismatch by completely removing any reference to the exact number of
-states (thus preventing a potential future mismatch), while wording
-the sentence in a more readable/truthful manner.
-
-(cherry picked from commit c44482eb4fb703391f2ee00c23b2187e0415e799)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1408778
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- tools/virsh.pod | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/tools/virsh.pod b/tools/virsh.pod
-index 0315f1f265..6386c39fbc 100644
---- a/tools/virsh.pod
-+++ b/tools/virsh.pod
-@@ -418,8 +418,9 @@ State is the run state (see below).
- 
- B<STATES>
- 
--The State field lists 8 states for a domain, and which ones the
--current domain is in.
-+The State field lists what state each domain is currently in. A domain
-+can be in one of the following possible states:
-+
- 
- =over 4
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-docs-domain-Fix-documentation-of-the-snapshot-attribute-for-disk.patch b/SOURCES/libvirt-docs-domain-Fix-documentation-of-the-snapshot-attribute-for-disk.patch
new file mode 100644
index 0000000..b6944df
--- /dev/null
+++ b/SOURCES/libvirt-docs-domain-Fix-documentation-of-the-snapshot-attribute-for-disk.patch
@@ -0,0 +1,51 @@
+From 60643d072a849ffbb01e8313124154f7aecc02ad Mon Sep 17 00:00:00 2001
+Message-Id: <60643d072a849ffbb01e8313124154f7aecc02ad@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 7 Dec 2017 14:36:06 +0100
+Subject: [PATCH] docs: domain: Fix documentation of the 'snapshot' attribute
+ for <disk>
+
+Emphasise the valid values by wrapping them in <code> and reword the
+last sentence so that the invalid value example can be dropped.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1523070
+(cherry picked from commit 1e98d450f27ae0131ac2ac8aa1c1d7a254d22dd1)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/formatdomain.html.in | 19 +++++++++----------
+ 1 file changed, 9 insertions(+), 10 deletions(-)
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index 6807da5c6f..0cfbf051b7 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -2573,17 +2573,16 @@
+           <dt><code>snapshot</code></dt>
+             <dd>
+             Indicates the default behavior of the disk during disk snapshots:
+-            "internal" requires a file format such as qcow2 that can store
+-            both the snapshot and the data changes since the snapshot;
+-            "external" will separate the snapshot from the live data; and
+-            "no" means the disk will not participate in snapshots. Read-only
+-            disks default to "no", while the default for other disks depends
+-            on the hypervisor's capabilities.  Some hypervisors allow a
+-            per-snapshot choice as well, during
++            "<code>internal</code>" requires a file format such as qcow2 that
++            can store both the snapshot and the data changes since the snapshot;
++            "<code>external</code>" will separate the snapshot from the live
++            data; and "<code>no</code>" means the disk will not participate in
++            snapshots. Read-only disks default to "<code>no</code>", while the
++            default for other disks depends on the hypervisor's capabilities.
++            Some hypervisors allow a per-snapshot choice as well, during
+             <a href="formatsnapshot.html">domain snapshot creation</a>.
+-            Not all snapshot modes are supported; for example,
+-            <code>snapshot='yes'</code> with a transient disk generally
+-            does not make sense.
++            Not all snapshot modes are supported; for example, enabling
++            snapshots with a transient disk generally does not make sense.
+             <span class="since">Since 0.9.5</span>
+             </dd>
+         </dl>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-docs-fix-typo-in-closing-HTML-element.patch b/SOURCES/libvirt-docs-fix-typo-in-closing-HTML-element.patch
deleted file mode 100644
index 0469959..0000000
--- a/SOURCES/libvirt-docs-fix-typo-in-closing-HTML-element.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From 3983bc29326d6f247d4dc3517ca42896042c02e0 Mon Sep 17 00:00:00 2001
-Message-Id: <3983bc29326d6f247d4dc3517ca42896042c02e0@dist-git>
-From: "Daniel P. Berrange" <berrange@redhat.com>
-Date: Tue, 25 Apr 2017 13:41:18 +0200
-Subject: [PATCH] docs: fix typo in closing HTML element
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1414627
-
-Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
-(cherry picked from commit dfda3a8ed988e6542294b85b78e816d593b22dc3)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index 7374cb243..c82cd69a2 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -5457,7 +5457,7 @@ qemu-kvm -net nic,model=? /dev/null
-       This element provides means of setting coalesce settings for
-       some interface devices (currently only type <code>network</code>
-       and <code>bridge</code>.  Currently there is just one attribute,
--      <code>max</code>, to tweak, in element <code>frames<code> for
-+      <code>max</code>, to tweak, in element <code>frames</code> for
-       the <code>rx</code> group, which accepts a non-negative integer
-       that specifies the maximum number of packets that will be
-       received before an interrupt.
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-fixup_resctrlinfo.patch b/SOURCES/libvirt-fixup_resctrlinfo.patch
new file mode 100644
index 0000000..1c0125e
--- /dev/null
+++ b/SOURCES/libvirt-fixup_resctrlinfo.patch
@@ -0,0 +1,76 @@
+From ff96b6f60e7062da45f24366db871c3ce675892e Mon Sep 17 00:00:00 2001
+Message-Id: <ff96b6f60e7062da45f24366db871c3ce675892e@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:28 +0100
+Subject: [PATCH] fixup_resctrlinfo
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 434848d7dca9d1a7838ab53bbfdcf580ef7f2cc2)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 29 +++++++++++++++++++----------
+ 1 file changed, 19 insertions(+), 10 deletions(-)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index f122af2050..d439e7792c 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -200,6 +200,8 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
+     }
+ 
+     while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0) {
++        VIR_DEBUG("Parsing info type '%s'", ent->d_name);
++
+         if (ent->d_type != DT_DIR)
+             continue;
+ 
+@@ -207,16 +209,14 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
+             continue;
+ 
+         if (virStrToLong_uip(ent->d_name + 1, &endptr, 10, &level) < 0) {
+-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+-                           _("Cannot parse resctrl cache info level"));
+-            goto cleanup;
++            VIR_DEBUG("Cannot parse resctrl cache info level '%s'", ent->d_name + 1);
++            continue;
+         }
+ 
+         type = virResctrlTypeFromString(endptr);
+         if (type < 0) {
+-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+-                           _("Cannot parse resctrl cache info type"));
+-            goto cleanup;
++            VIR_DEBUG("Cannot parse resctrl cache info type '%s'", endptr);
++            continue;
+         }
+ 
+         if (VIR_ALLOC(i_type) < 0)
+@@ -259,10 +259,19 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
+                          level - resctrl->nlevels + 1) < 0)
+             goto cleanup;
+ 
+-        if (!resctrl->levels[level] &&
+-            (VIR_ALLOC(resctrl->levels[level]) < 0 ||
+-             VIR_ALLOC_N(resctrl->levels[level]->types, VIR_CACHE_TYPE_LAST) < 0))
+-            goto cleanup;
++        if (!resctrl->levels[level]) {
++            virResctrlInfoPerTypePtr *types = NULL;
++
++            if (VIR_ALLOC_N(types, VIR_CACHE_TYPE_LAST) < 0)
++                goto cleanup;
++
++            if (VIR_ALLOC(resctrl->levels[level]) < 0) {
++                VIR_FREE(types);
++                goto cleanup;
++            }
++            resctrl->levels[level]->types = types;
++        }
++
+         i_level = resctrl->levels[level];
+ 
+         if (i_level->types[type]) {
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-locking-Add-support-for-sanlock_strerror.patch b/SOURCES/libvirt-locking-Add-support-for-sanlock_strerror.patch
deleted file mode 100644
index 1d51b32..0000000
--- a/SOURCES/libvirt-locking-Add-support-for-sanlock_strerror.patch
+++ /dev/null
@@ -1,339 +0,0 @@
-From 6744458379e73967a95507d3c0b91b52a62fc3ec Mon Sep 17 00:00:00 2001
-Message-Id: <6744458379e73967a95507d3c0b91b52a62fc3ec@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Thu, 27 Apr 2017 11:54:44 +0200
-Subject: [PATCH] locking: Add support for sanlock_strerror
-
-The recently added sanlock_strerror function can be used to translate
-sanlock's numeric errors into human readable strings.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1409511
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 23377c539b72a7fc4e2749a068711fe1f626998d)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- m4/virt-sanlock.m4                |   7 ++
- src/locking/lock_driver_sanlock.c | 154 ++++++++++++++++++++++++++------------
- 2 files changed, 115 insertions(+), 46 deletions(-)
-
-diff --git a/m4/virt-sanlock.m4 b/m4/virt-sanlock.m4
-index e4476cae4..00de7980e 100644
---- a/m4/virt-sanlock.m4
-+++ b/m4/virt-sanlock.m4
-@@ -61,6 +61,13 @@ AC_DEFUN([LIBVIRT_CHECK_SANLOCK],[
-         [whether sanlock supports sanlock_write_lockspace])
-     fi
- 
-+    AC_CHECK_LIB([sanlock_client], [sanlock_strerror],
-+                 [sanlock_strerror=yes], [sanlock_strerror=no])
-+    if test "x$sanlock_strerror" = "xyes" ; then
-+      AC_DEFINE_UNQUOTED([HAVE_SANLOCK_STRERROR], 1,
-+        [whether sanlock supports sanlock_strerror])
-+    fi
-+
-     CPPFLAGS="$old_cppflags"
-     LIBS="$old_libs"
-   fi
-diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
-index 280219f72..b5e69c472 100644
---- a/src/locking/lock_driver_sanlock.c
-+++ b/src/locking/lock_driver_sanlock.c
-@@ -97,6 +97,25 @@ struct _virLockManagerSanlockPrivate {
-     bool registered;
- };
- 
-+
-+static bool
-+ATTRIBUTE_NONNULL(2)
-+virLockManagerSanlockError(int err,
-+                           char **message)
-+{
-+    if (err <= -200) {
-+#if HAVE_SANLOCK_STRERROR
-+        ignore_value(VIR_STRDUP_QUIET(*message, sanlock_strerror(err)));
-+#else
-+        ignore_value(virAsprintfQuiet(message, _("sanlock error %d"), err));
-+#endif
-+        return true;
-+    } else {
-+        return false;
-+    }
-+}
-+
-+
- /*
-  * sanlock plugin for the libvirt virLockManager API
-  */
-@@ -263,14 +282,17 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver)
-             }
- 
-             if ((rv = sanlock_align(&ls.host_id_disk)) < 0) {
--                if (rv <= -200)
-+                char *err = NULL;
-+                if (virLockManagerSanlockError(rv, &err)) {
-                     virReportError(VIR_ERR_INTERNAL_ERROR,
--                                   _("Unable to query sector size %s: error %d"),
--                                   path, rv);
--                else
-+                                   _("Unable to query sector size %s: %s"),
-+                                   path, NULLSTR(err));
-+                    VIR_FREE(err);
-+                } else {
-                     virReportSystemError(-rv,
-                                          _("Unable to query sector size %s"),
-                                          path);
-+                }
-                 goto error_unlink;
-             }
- 
-@@ -292,14 +314,17 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver)
-             }
- 
-             if ((rv = virLockManagerSanlockInitLockspace(driver, &ls) < 0)) {
--                if (rv <= -200)
-+                char *err = NULL;
-+                if (virLockManagerSanlockError(rv, &err)) {
-                     virReportError(VIR_ERR_INTERNAL_ERROR,
--                                   _("Unable to initialize lockspace %s: error %d"),
--                                   path, rv);
--                else
-+                                   _("Unable to initialize lockspace %s: %s"),
-+                                   path, NULLSTR(err));
-+                    VIR_FREE(err);
-+                } else {
-                     virReportSystemError(-rv,
-                                          _("Unable to initialize lockspace %s"),
-                                          path);
-+                }
-                 goto error_unlink;
-             }
-             VIR_DEBUG("Lockspace %s has been initialized", path);
-@@ -362,14 +387,17 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver)
-             goto retry;
-         }
-         if (-rv != EEXIST) {
--            if (rv <= -200)
-+            char *err = NULL;
-+            if (virLockManagerSanlockError(rv, &err)) {
-                 virReportError(VIR_ERR_INTERNAL_ERROR,
--                               _("Unable to add lockspace %s: error %d"),
--                               path, rv);
--            else
-+                               _("Unable to add lockspace %s: %s"),
-+                               path, NULLSTR(err));
-+                VIR_FREE(err);
-+            } else {
-                 virReportSystemError(-rv,
-                                      _("Unable to add lockspace %s"),
-                                      path);
-+            }
-             goto error;
-         } else {
-             VIR_DEBUG("Lockspace %s is already registered", path);
-@@ -694,14 +722,17 @@ virLockManagerSanlockCreateLease(virLockManagerSanlockDriverPtr driver,
-             }
- 
-             if ((rv = sanlock_align(&res->disks[0])) < 0) {
--                if (rv <= -200)
-+                char *err = NULL;
-+                if (virLockManagerSanlockError(rv, &err)) {
-                     virReportError(VIR_ERR_INTERNAL_ERROR,
--                                   _("Unable to query sector size %s: error %d"),
--                                   res->disks[0].path, rv);
--                else
-+                                   _("Unable to query sector size %s: %s"),
-+                                   res->disks[0].path, NULLSTR(err));
-+                    VIR_FREE(err);
-+                } else {
-                     virReportSystemError(-rv,
-                                          _("Unable to query sector size %s"),
-                                          res->disks[0].path);
-+                }
-                 goto error_unlink;
-             }
- 
-@@ -723,14 +754,17 @@ virLockManagerSanlockCreateLease(virLockManagerSanlockDriverPtr driver,
-             }
- 
-             if ((rv = sanlock_init(NULL, res, 0, 0)) < 0) {
--                if (rv <= -200)
-+                char *err = NULL;
-+                if (virLockManagerSanlockError(rv, &err)) {
-                     virReportError(VIR_ERR_INTERNAL_ERROR,
--                                   _("Unable to initialize lease %s: error %d"),
--                                   res->disks[0].path, rv);
--                else
-+                                   _("Unable to initialize lease %s: %s"),
-+                                   res->disks[0].path, NULLSTR(err));
-+                    VIR_FREE(err);
-+                } else {
-                     virReportSystemError(-rv,
-                                          _("Unable to initialize lease %s"),
-                                          res->disks[0].path);
-+                }
-                 goto error_unlink;
-             }
-             VIR_DEBUG("Lease %s has been initialized", res->disks[0].path);
-@@ -867,10 +901,12 @@ virLockManagerSanlockRegisterKillscript(int sock,
-     }
- 
-     if ((rv = sanlock_killpath(sock, 0, path, args)) < 0) {
--        if (rv <= -200) {
-+        char *err = NULL;
-+        if (virLockManagerSanlockError(rv, &err)) {
-             virReportError(VIR_ERR_INTERNAL_ERROR,
--                           _("Failed to register lock failure action:"
--                             " error %d"), rv);
-+                           _("Failed to register lock failure action: %s"),
-+                           NULLSTR(err));
-+            VIR_FREE(err);
-         } else {
-             virReportSystemError(-rv, "%s",
-                                  _("Failed to register lock failure"
-@@ -934,13 +970,16 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
-     if (priv->vm_pid == getpid()) {
-         VIR_DEBUG("Register sanlock %d", flags);
-         if ((sock = sanlock_register()) < 0) {
--            if (sock <= -200)
-+            char *err = NULL;
-+            if (virLockManagerSanlockError(sock, &err)) {
-                 virReportError(VIR_ERR_INTERNAL_ERROR,
--                               _("Failed to open socket to sanlock daemon: error %d"),
--                               sock);
--            else
-+                               _("Failed to open socket to sanlock daemon: %s"),
-+                               NULLSTR(err));
-+                VIR_FREE(err);
-+            } else {
-                 virReportSystemError(-sock, "%s",
-                                      _("Failed to open socket to sanlock daemon"));
-+            }
-             goto error;
-         }
- 
-@@ -971,14 +1010,17 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
-         if ((rv = sanlock_state_to_args((char *)state,
-                                         &res_count,
-                                         &res_args)) < 0) {
--            if (rv <= -200)
-+            char *err = NULL;
-+            if (virLockManagerSanlockError(rv, &err)) {
-                 virReportError(VIR_ERR_INTERNAL_ERROR,
--                               _("Unable to parse lock state %s: error %d"),
--                               state, rv);
--            else
-+                               _("Unable to parse lock state %s: %s"),
-+                               state, NULLSTR(err));
-+                VIR_FREE(err);
-+            } else {
-                 virReportSystemError(-rv,
-                                      _("Unable to parse lock state %s"),
-                                      state);
-+            }
-             goto error;
-         }
-         res_free = true;
-@@ -992,12 +1034,16 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
-         if ((rv = sanlock_acquire(sock, priv->vm_pid, 0,
-                                   priv->res_count, priv->res_args,
-                                   opt)) < 0) {
--            if (rv <= -200)
-+            char *err = NULL;
-+            if (virLockManagerSanlockError(rv, &err)) {
-                 virReportError(VIR_ERR_RESOURCE_BUSY,
--                               _("Failed to acquire lock: error %d"), rv);
--            else
-+                               _("Failed to acquire lock: %s"),
-+                               NULLSTR(err));
-+                VIR_FREE(err);
-+            } else {
-                 virReportSystemError(-rv, "%s",
-                                      _("Failed to acquire lock"));
-+            }
-             goto error;
-         }
-     }
-@@ -1016,12 +1062,16 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
- 
-     if (flags & VIR_LOCK_MANAGER_ACQUIRE_RESTRICT) {
-         if ((rv = sanlock_restrict(sock, SANLK_RESTRICT_ALL)) < 0) {
--            if (rv <= -200)
-+            char *err = NULL;
-+            if (virLockManagerSanlockError(rv, &err)) {
-                 virReportError(VIR_ERR_INTERNAL_ERROR,
--                               _("Failed to restrict process: error %d"), rv);
--            else
-+                               _("Failed to restrict process: %s"),
-+                               NULLSTR(err));
-+                VIR_FREE(err);
-+            } else {
-                 virReportSystemError(-rv, "%s",
-                                      _("Failed to restrict process"));
-+            }
-             goto error;
-         }
-     }
-@@ -1068,12 +1118,16 @@ static int virLockManagerSanlockRelease(virLockManagerPtr lock,
- 
-     if (state) {
-         if ((rv = sanlock_inquire(-1, priv->vm_pid, 0, &res_count, state)) < 0) {
--            if (rv <= -200)
-+            char *err = NULL;
-+            if (virLockManagerSanlockError(rv, &err)) {
-                 virReportError(VIR_ERR_INTERNAL_ERROR,
--                               _("Failed to inquire lock: error %d"), rv);
--            else
-+                               _("Failed to inquire lock: %s"),
-+                               NULLSTR(err));
-+                VIR_FREE(err);
-+            } else {
-                 virReportSystemError(-rv, "%s",
-                                      _("Failed to inquire lock"));
-+            }
-             return -1;
-         }
- 
-@@ -1083,12 +1137,16 @@ static int virLockManagerSanlockRelease(virLockManagerPtr lock,
- 
-     if ((rv = sanlock_release(-1, priv->vm_pid, 0, res_count,
-                               priv->res_args)) < 0) {
--        if (rv <= -200)
-+        char *err = NULL;
-+        if (virLockManagerSanlockError(rv, &err)) {
-             virReportError(VIR_ERR_INTERNAL_ERROR,
--                           _("Failed to release lock: error %d"), rv);
--        else
-+                           _("Failed to release lock: %s"),
-+                           NULLSTR(err));
-+            VIR_FREE(err);
-+        } else {
-             virReportSystemError(-rv, "%s",
-                                  _("Failed to release lock"));
-+        }
-         return -1;
-     }
- 
-@@ -1118,12 +1176,16 @@ static int virLockManagerSanlockInquire(virLockManagerPtr lock,
-     }
- 
-     if ((rv = sanlock_inquire(-1, priv->vm_pid, 0, &res_count, state)) < 0) {
--        if (rv <= -200)
-+        char *err;
-+        if (virLockManagerSanlockError(rv, &err)) {
-             virReportError(VIR_ERR_INTERNAL_ERROR,
--                           _("Failed to inquire lock: error %d"), rv);
--        else
-+                           _("Failed to inquire lock: %s"),
-+                           NULLSTR(err));
-+            VIR_FREE(err);
-+        } else {
-             virReportSystemError(-rv, "%s",
-                                  _("Failed to inquire lock"));
-+        }
-         return -1;
-     }
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-logical-Increase-the-size-of-the-data-to-wipe.patch b/SOURCES/libvirt-logical-Increase-the-size-of-the-data-to-wipe.patch
deleted file mode 100644
index 87be249..0000000
--- a/SOURCES/libvirt-logical-Increase-the-size-of-the-data-to-wipe.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From f4b39613c3c345e33fa749911f34127cf91c07fc Mon Sep 17 00:00:00 2001
-Message-Id: <f4b39613c3c345e33fa749911f34127cf91c07fc@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Wed, 26 Apr 2017 08:41:13 -0400
-Subject: [PATCH] logical: Increase the size of the data to wipe
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439132
-https://bugzilla.redhat.com/show_bug.cgi?id=1373711
-
-Since a sector size may be larger than 512 bytes, let's just increase
-the size to wipe to 1MB rather than 2KB
-
-(cherry picked from commit d942bf6e9e8e3991808ca5185098257e84acab5d)
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/storage/storage_backend_logical.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
-index a8650368b..ed26c2450 100644
---- a/src/storage/storage_backend_logical.c
-+++ b/src/storage/storage_backend_logical.c
-@@ -100,7 +100,7 @@ virStorageBackendLogicalInitializeDevice(const char *path)
-      * a whole disk as a PV. So we just blank them out regardless
-      * rather than trying to figure out if we're a disk or partition
-      */
--    if (virStorageBackendZeroPartitionTable(path, 4 * PV_BLANK_SECTOR_SIZE) < 0)
-+    if (virStorageBackendZeroPartitionTable(path, 1024 * 1024) < 0)
-         return -1;
- 
-     /*
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-logical-Use-virStorageBackendZeroPartitionTable.patch b/SOURCES/libvirt-logical-Use-virStorageBackendZeroPartitionTable.patch
deleted file mode 100644
index 78c876e..0000000
--- a/SOURCES/libvirt-logical-Use-virStorageBackendZeroPartitionTable.patch
+++ /dev/null
@@ -1,92 +0,0 @@
-From 0ea93040c8172ff8848b6295e53b7bd26f66ef05 Mon Sep 17 00:00:00 2001
-Message-Id: <0ea93040c8172ff8848b6295e53b7bd26f66ef05@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Wed, 26 Apr 2017 08:41:12 -0400
-Subject: [PATCH] logical: Use virStorageBackendZeroPartitionTable
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439132
-https://bugzilla.redhat.com/show_bug.cgi?id=1373711
-
-Rather than open code it, use the new function which uses the wipe algorithm
-in order to zero the front and tail of the partition.
-
-(cherry picked from commit c6aa81c65abe3f327af870d5789a98a0c9b276d1)
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/storage/storage_backend_logical.c | 44 +----------------------------------
- 1 file changed, 1 insertion(+), 43 deletions(-)
-
-diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
-index d87aaf0b6..a8650368b 100644
---- a/src/storage/storage_backend_logical.c
-+++ b/src/storage/storage_backend_logical.c
-@@ -92,9 +92,6 @@ virStorageBackendLogicalRemoveDevice(const char *path)
- static int
- virStorageBackendLogicalInitializeDevice(const char *path)
- {
--    int fd = -1;
--    char zeros[4 * PV_BLANK_SECTOR_SIZE] = {0};
--    off_t size;
-     int ret = -1;
-     virCommandPtr pvcmd = NULL;
- 
-@@ -103,46 +100,8 @@ virStorageBackendLogicalInitializeDevice(const char *path)
-      * a whole disk as a PV. So we just blank them out regardless
-      * rather than trying to figure out if we're a disk or partition
-      */
--    if ((fd = open(path, O_WRONLY)) < 0) {
--        virReportSystemError(errno, _("cannot open device '%s'"), path);
-+    if (virStorageBackendZeroPartitionTable(path, 4 * PV_BLANK_SECTOR_SIZE) < 0)
-         return -1;
--    }
--
--    if ((size = lseek(fd, 0, SEEK_END)) == (off_t)-1) {
--        virReportSystemError(errno,
--                             _("failed to seek to end of %s"), path);
--        goto cleanup;
--    }
--
--    if (size < 4 * PV_BLANK_SECTOR_SIZE) {
--        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
--                       _("cannot initialize '%s' detected size='%zd' less "
--                         "than minimum required='%d"),
--                         path, (ssize_t) size, 4 * PV_BLANK_SECTOR_SIZE);
--        goto cleanup;
--    }
--    if ((size = lseek(fd, 0, SEEK_SET)) == (off_t)-1) {
--        virReportSystemError(errno,
--                             _("failed to seek to start of %s"), path);
--        goto cleanup;
--    }
--
--    if (safewrite(fd, zeros, sizeof(zeros)) < 0) {
--        virReportSystemError(errno, _("cannot clear device header of '%s'"),
--                             path);
--        goto cleanup;
--    }
--
--    if (fsync(fd) < 0) {
--        virReportSystemError(errno, _("cannot flush header of device'%s'"),
--                             path);
--        goto cleanup;
--    }
--
--    if (VIR_CLOSE(fd) < 0) {
--        virReportSystemError(errno, _("cannot close device '%s'"), path);
--        goto cleanup;
--    }
- 
-     /*
-      * Initialize the physical volume because vgcreate is not
-@@ -155,7 +114,6 @@ virStorageBackendLogicalInitializeDevice(const char *path)
-     ret = 0;
- 
-  cleanup:
--    VIR_FORCE_CLOSE(fd);
-     virCommandFree(pvcmd);
- 
-     return ret;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-mdev-Fix-daemon-crash-on-domain-shutdown-after-reconnect.patch b/SOURCES/libvirt-mdev-Fix-daemon-crash-on-domain-shutdown-after-reconnect.patch
deleted file mode 100644
index 3162d40..0000000
--- a/SOURCES/libvirt-mdev-Fix-daemon-crash-on-domain-shutdown-after-reconnect.patch
+++ /dev/null
@@ -1,117 +0,0 @@
-From 2122aadba5eb30ae466a3e825bbe9ed75b8d9735 Mon Sep 17 00:00:00 2001
-Message-Id: <2122aadba5eb30ae466a3e825bbe9ed75b8d9735@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 4 May 2017 13:50:00 +0200
-Subject: [PATCH] mdev: Fix daemon crash on domain shutdown after reconnect
-
-The problem resides in virHostdevUpdateActiveMediatedDevices which gets
-called during qemuProcessReconnect. The issue here is that
-virMediatedDeviceListAdd takes a pointer to the item to be added to the
-list to which VIR_APPEND_ELEMENT is used, which also clears the pointer.
-However, in this case only the local copy of the pointer got cleared,
-leaving the original pointing to valid memory. To sum it up, during
-cleanup phase, the original pointer is freed and the daemon crashes
-basically any time it would access it.
-
-Backtrace:
-0x00007ffff3ccdeba in __strcmp_sse2_unaligned
-0x00007ffff72a444a in virMediatedDeviceListFindIndex
-0x00007ffff7241446 in virHostdevReAttachMediatedDevices
-0x00007fffc60215d9 in qemuHostdevReAttachMediatedDevices
-0x00007fffc60216dc in qemuHostdevReAttachDomainDevices
-0x00007fffc6046e6f in qemuProcessStop
-0x00007fffc6091596 in processMonitorEOFEvent
-0x00007fffc6091793 in qemuProcessEventHandler
-0x00007ffff7294bf5 in virThreadPoolWorker
-0x00007ffff7294184 in virThreadHelper
-0x00007ffff3fdc3c4 in start_thread () from /lib64/libpthread.so.0
-0x00007ffff3d269cf in clone () from /lib64/libc.so.6
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1446455
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Reviewed-by: Laine Stump <laine@laine.org>
-(cherry picked from commit 92e30a4dace54d06433f763e1acba0a81bb5c82e)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/util/virhostdev.c |  4 ++--
- src/util/virmdev.c    | 13 ++++++++-----
- src/util/virmdev.h    |  2 +-
- 3 files changed, 11 insertions(+), 8 deletions(-)
-
-diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
-index 2c557f5bb..579563c3f 100644
---- a/src/util/virhostdev.c
-+++ b/src/util/virhostdev.c
-@@ -1294,7 +1294,7 @@ virHostdevUpdateActiveMediatedDevices(virHostdevManagerPtr mgr,
- 
-         virMediatedDeviceSetUsedBy(mdev, drv_name, dom_name);
- 
--        if (virMediatedDeviceListAdd(mgr->activeMediatedHostdevs, mdev) < 0)
-+        if (virMediatedDeviceListAdd(mgr->activeMediatedHostdevs, &mdev) < 0)
-             goto cleanup;
-     }
- 
-@@ -1790,7 +1790,7 @@ virHostdevPrepareMediatedDevices(virHostdevManagerPtr mgr,
-         if (!(mdev = virMediatedDeviceNew(src->uuidstr, src->model)))
-             goto cleanup;
- 
--        if (virMediatedDeviceListAdd(list, mdev) < 0) {
-+        if (virMediatedDeviceListAdd(list, &mdev) < 0) {
-             virMediatedDeviceFree(mdev);
-             goto cleanup;
-         }
-diff --git a/src/util/virmdev.c b/src/util/virmdev.c
-index c1499d238..c861d21c9 100644
---- a/src/util/virmdev.c
-+++ b/src/util/virmdev.c
-@@ -312,16 +312,19 @@ virMediatedDeviceListDispose(void *obj)
- }
- 
- 
-+/* The reason for @dev to be double pointer is that VIR_APPEND_ELEMENT clears
-+ * the pointer and we need to clear the original not a copy on the stack
-+ */
- int
- virMediatedDeviceListAdd(virMediatedDeviceListPtr list,
--                         virMediatedDevicePtr dev)
-+                         virMediatedDevicePtr *dev)
- {
--    if (virMediatedDeviceListFind(list, dev)) {
-+    if (virMediatedDeviceListFind(list, *dev)) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
--                       _("device %s is already in use"), dev->path);
-+                       _("device %s is already in use"), (*dev)->path);
-         return -1;
-     }
--    return VIR_APPEND_ELEMENT(list->devs, list->count, dev);
-+    return VIR_APPEND_ELEMENT(list->devs, list->count, *dev);
- }
- 
- 
-@@ -457,7 +460,7 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
-          * - caller is responsible for NOT freeing devices in @src on success
-          * - we're responsible for performing a rollback on failure
-          */
--        if (virMediatedDeviceListAdd(dst, mdev) < 0)
-+        if (virMediatedDeviceListAdd(dst, &mdev) < 0)
-             goto rollback;
- 
-         VIR_DEBUG("'%s' added to list of active mediated devices used by '%s'",
-diff --git a/src/util/virmdev.h b/src/util/virmdev.h
-index 2f3d6bb84..8bb46b9c5 100644
---- a/src/util/virmdev.h
-+++ b/src/util/virmdev.h
-@@ -86,7 +86,7 @@ virMediatedDeviceListNew(void);
- 
- int
- virMediatedDeviceListAdd(virMediatedDeviceListPtr list,
--                         virMediatedDevicePtr dev);
-+                         virMediatedDevicePtr *dev);
- 
- virMediatedDevicePtr
- virMediatedDeviceListGet(virMediatedDeviceListPtr list,
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-mdev-Pass-a-uuidstr-rather-than-an-mdev-object-to-some-util-functions.patch b/SOURCES/libvirt-mdev-Pass-a-uuidstr-rather-than-an-mdev-object-to-some-util-functions.patch
deleted file mode 100644
index 1f4d74a..0000000
--- a/SOURCES/libvirt-mdev-Pass-a-uuidstr-rather-than-an-mdev-object-to-some-util-functions.patch
+++ /dev/null
@@ -1,269 +0,0 @@
-From ebb336d5b22b9707b53bcc4fd2e24845666fdc4f Mon Sep 17 00:00:00 2001
-Message-Id: <ebb336d5b22b9707b53bcc4fd2e24845666fdc4f@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 18 May 2017 14:02:50 +0200
-Subject: [PATCH] mdev: Pass a uuidstr rather than an mdev object to some util
- functions
-
-Namely, this patch is about virMediatedDeviceGetIOMMUGroup{Dev,Num}
-functions. There's no compelling reason why these functions should take
-an object, on the contrary, having to create an object every time one
-needs to query the IOMMU group number, discarding the object afterwards,
-seems odd.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1452072
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit 3a2a2a7401d06a8f06fa75359190f59737c5dc5d)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c           |  8 +-------
- src/security/security_apparmor.c | 10 +---------
- src/security/security_dac.c      | 20 ++------------------
- src/security/security_selinux.c  | 20 ++------------------
- src/util/virmdev.c               | 21 +++++++++++++--------
- src/util/virmdev.h               |  4 ++--
- 6 files changed, 21 insertions(+), 62 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 117c6142b..04d1b39db 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -7216,7 +7216,6 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
-     virUSBDevicePtr usb = NULL;
-     virSCSIDevicePtr scsi = NULL;
-     virSCSIVHostDevicePtr host = NULL;
--    virMediatedDevicePtr mdev = NULL;
-     char *tmpPath = NULL;
-     bool freeTmpPath = false;
-     bool includeVFIO = false;
-@@ -7317,11 +7316,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
-         }
- 
-         case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
--            if (!(mdev = virMediatedDeviceNew(mdevsrc->uuidstr,
--                                              mdevsrc->model)))
--                goto cleanup;
--
--            if (!(tmpPath = virMediatedDeviceGetIOMMUGroupDev(mdev)))
-+            if (!(tmpPath = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr)))
-                 goto cleanup;
- 
-             freeTmpPath = true;
-@@ -7377,7 +7372,6 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
-     virUSBDeviceFree(usb);
-     virSCSIDeviceFree(scsi);
-     virSCSIVHostDeviceFree(host);
--    virMediatedDeviceFree(mdev);
-     if (freeTmpPath)
-         VIR_FREE(tmpPath);
-     return ret;
-diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
-index fc5581526..62672b0af 100644
---- a/src/security/security_apparmor.c
-+++ b/src/security/security_apparmor.c
-@@ -905,21 +905,13 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
- 
-     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: {
-         char *vfiodev = NULL;
--        virMediatedDevicePtr mdev = virMediatedDeviceNew(mdevsrc->uuidstr,
--                                                         mdevsrc->model);
- 
--        if (!mdev)
-+        if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr)))
-             goto done;
- 
--        if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdev))) {
--            virMediatedDeviceFree(mdev);
--            goto done;
--        }
--
-         ret = AppArmorSetSecurityHostdevLabelHelper(vfiodev, ptr);
- 
-         VIR_FREE(vfiodev);
--        virMediatedDeviceFree(mdev);
-         break;
-     }
- 
-diff --git a/src/security/security_dac.c b/src/security/security_dac.c
-index 922e48494..7dcf4c15f 100644
---- a/src/security/security_dac.c
-+++ b/src/security/security_dac.c
-@@ -968,21 +968,13 @@ virSecurityDACSetHostdevLabel(virSecurityManagerPtr mgr,
- 
-     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: {
-         char *vfiodev = NULL;
--        virMediatedDevicePtr mdev = virMediatedDeviceNew(mdevsrc->uuidstr,
--                                                         mdevsrc->model);
- 
--        if (!mdev)
-+        if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr)))
-             goto done;
- 
--        if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdev))) {
--            virMediatedDeviceFree(mdev);
--            goto done;
--        }
--
-         ret = virSecurityDACSetHostdevLabelHelper(vfiodev, &cbdata);
- 
-         VIR_FREE(vfiodev);
--        virMediatedDeviceFree(mdev);
-         break;
-     }
- 
-@@ -1144,21 +1136,13 @@ virSecurityDACRestoreHostdevLabel(virSecurityManagerPtr mgr,
- 
-     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: {
-         char *vfiodev = NULL;
--        virMediatedDevicePtr mdev = virMediatedDeviceNew(mdevsrc->uuidstr,
--                                                         mdevsrc->model);
- 
--        if (!mdev)
-+        if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr)))
-             goto done;
- 
--        if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdev))) {
--            virMediatedDeviceFree(mdev);
--            goto done;
--        }
--
-         ret = virSecurityDACRestoreFileLabel(virSecurityManagerGetPrivateData(mgr),
-                                              vfiodev);
-         VIR_FREE(vfiodev);
--        virMediatedDeviceFree(mdev);
-         break;
-     }
- 
-diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
-index df7c96833..c7a2dfe98 100644
---- a/src/security/security_selinux.c
-+++ b/src/security/security_selinux.c
-@@ -1843,21 +1843,13 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityManagerPtr mgr,
- 
-     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: {
-         char *vfiodev = NULL;
--        virMediatedDevicePtr mdev = virMediatedDeviceNew(mdevsrc->uuidstr,
--                                                         mdevsrc->model);
- 
--        if (!mdev)
-+        if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr)))
-             goto done;
- 
--        if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdev))) {
--            virMediatedDeviceFree(mdev);
--            goto done;
--        }
--
-         ret = virSecuritySELinuxSetHostdevLabelHelper(vfiodev, &data);
- 
-         VIR_FREE(vfiodev);
--        virMediatedDeviceFree(mdev);
-         break;
-     }
- 
-@@ -2092,21 +2084,13 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecurityManagerPtr mgr,
- 
-     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: {
-         char *vfiodev = NULL;
--        virMediatedDevicePtr mdev = virMediatedDeviceNew(mdevsrc->uuidstr,
--                                                         mdevsrc->model);
- 
--        if (!mdev)
-+        if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr)))
-             goto done;
- 
--        if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdev))) {
--            virMediatedDeviceFree(mdev);
--            goto done;
--        }
--
-         ret = virSecuritySELinuxRestoreFileLabel(mgr, vfiodev);
- 
-         VIR_FREE(vfiodev);
--        virMediatedDeviceFree(mdev);
-         break;
-     }
- 
-diff --git a/src/util/virmdev.c b/src/util/virmdev.c
-index c861d21c9..169deedfd 100644
---- a/src/util/virmdev.c
-+++ b/src/util/virmdev.c
-@@ -209,43 +209,48 @@ virMediatedDeviceGetPath(virMediatedDevicePtr dev)
-  * for freeing the result.
-  */
- char *
--virMediatedDeviceGetIOMMUGroupDev(virMediatedDevicePtr dev)
-+virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr)
- {
--    char *resultpath = NULL;
-+    char *result_path = NULL;
-     char *iommu_path = NULL;
-     char *vfio_path = NULL;
-+    char *dev_path = virMediatedDeviceGetSysfsPath(uuidstr);
- 
--    if (virAsprintf(&iommu_path, "%s/iommu_group", dev->path) < 0)
-+    if (!dev_path)
-         return NULL;
- 
-+    if (virAsprintf(&iommu_path, "%s/iommu_group", dev_path) < 0)
-+        goto cleanup;
-+
-     if (!virFileExists(iommu_path)) {
-         virReportSystemError(errno, _("failed to access '%s'"), iommu_path);
-         goto cleanup;
-     }
- 
--    if (virFileResolveLink(iommu_path, &resultpath) < 0) {
-+    if (virFileResolveLink(iommu_path, &result_path) < 0) {
-         virReportSystemError(errno, _("failed to resolve '%s'"), iommu_path);
-         goto cleanup;
-     }
- 
--    if (virAsprintf(&vfio_path, "/dev/vfio/%s", last_component(resultpath)) < 0)
-+    if (virAsprintf(&vfio_path, "/dev/vfio/%s", last_component(result_path)) < 0)
-         goto cleanup;
- 
-  cleanup:
--    VIR_FREE(resultpath);
-+    VIR_FREE(result_path);
-     VIR_FREE(iommu_path);
-+    VIR_FREE(dev_path);
-     return vfio_path;
- }
- 
- 
- int
--virMediatedDeviceGetIOMMUGroupNum(virMediatedDevicePtr dev)
-+virMediatedDeviceGetIOMMUGroupNum(const char *uuidstr)
- {
-     char *vfio_path = NULL;
-     char *group_num_str = NULL;
-     unsigned int group_num = -1;
- 
--    if (!(vfio_path = virMediatedDeviceGetIOMMUGroupDev(dev)))
-+    if (!(vfio_path = virMediatedDeviceGetIOMMUGroupDev(uuidstr)))
-         return -1;
- 
-     group_num_str = last_component(vfio_path);
-diff --git a/src/util/virmdev.h b/src/util/virmdev.h
-index 8bb46b9c5..0b8e830f4 100644
---- a/src/util/virmdev.h
-+++ b/src/util/virmdev.h
-@@ -65,10 +65,10 @@ virMediatedDeviceSetUsedBy(virMediatedDevicePtr dev,
-                            const char *domname);
- 
- char *
--virMediatedDeviceGetIOMMUGroupDev(virMediatedDevicePtr dev);
-+virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr);
- 
- int
--virMediatedDeviceGetIOMMUGroupNum(virMediatedDevicePtr dev);
-+virMediatedDeviceGetIOMMUGroupNum(const char *uuidstr);
- 
- char *
- virMediatedDeviceGetSysfsPath(const char *uuidstr);
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-migration.html-Clarify-configuration-file-handling-docs.patch b/SOURCES/libvirt-migration.html-Clarify-configuration-file-handling-docs.patch
new file mode 100644
index 0000000..bf807c0
--- /dev/null
+++ b/SOURCES/libvirt-migration.html-Clarify-configuration-file-handling-docs.patch
@@ -0,0 +1,162 @@
+From d52ae79470eb8725b63a6470e393149b48f508da Mon Sep 17 00:00:00 2001
+Message-Id: <d52ae79470eb8725b63a6470e393149b48f508da@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Fri, 8 Dec 2017 10:31:38 +0100
+Subject: [PATCH] migration.html: Clarify configuration file handling docs
+
+Migration never removes any configuration files on the destination host.
+Thus when the domain is already defined on the destination, it will stay
+persistent even after migration without --persist.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1514930
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+(cherry picked from commit 2c01e4febcd161226ce707892d8e53f4e66f708f)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/migration.html.in | 34 +++++++++++++++++-----------------
+ 1 file changed, 17 insertions(+), 17 deletions(-)
+
+diff --git a/docs/migration.html.in b/docs/migration.html.in
+index de7d4def75..7c345b65b7 100644
+--- a/docs/migration.html.in
++++ b/docs/migration.html.in
+@@ -206,14 +206,14 @@
+     <h2><a id="config">Configuration file handling</a></h2>
+ 
+     <p>
+-      There are two types of virtual machine known to libvirt. A <em>transient</em>
++      There are two types of virtual machines known to libvirt. A <em>transient</em>
+       guest only exists while it is running, and has no configuration file stored
+       on disk. A <em>persistent</em> guest maintains a configuration file on disk
+       even when it is not running.
+     </p>
+ 
+     <p>
+-      By default, a migration operation will not attempt to change any configuration
++      By default, a migration operation will not attempt to modify any configuration
+       files that may be stored on either the source or destination host. It is the
+       administrator, or management application's, responsibility to manage distribution
+       of configuration files (if desired). It is important to note that the <code>/etc/libvirt</code>
+@@ -230,14 +230,14 @@
+         host and removed on the original.
+       </li>
+       <li>Centralized configuration files outside libvirt, in a database. A data center
+-        management application may not storage configuration files at all. Instead it
++        management application may not store configuration files at all. Instead it
+         may generate libvirt XML on the fly when a guest is booted. It will typically
+         use transient guests, and thus not have to consider configuration files during
+         migration.
+       </li>
+       <li>Distributed configuration inside libvirt. The configuration file for each
+         guest is copied to every host where the guest is able to run. Upon migration
+-        the existing config merely needs to be updated with any changes
++        the existing config merely needs to be updated with any changes.
+       </li>
+       <li>Ad-hoc configuration management inside libvirt. Each guest is tied to a
+         specific host and rarely migrated. When migration is required, the config
+@@ -246,7 +246,7 @@
+     </ul>
+ 
+     <p>
+-      As mentioned above, libvirt will not touch configuration files during
++      As mentioned above, libvirt will not modify configuration files during
+       migration by default. The <code>virsh</code> command has two flags to
+       influence this behaviour. The  <code>--undefine-source</code> flag
+       will cause the configuration file to be removed on the source host
+@@ -265,12 +265,12 @@
+           <th colspan="3">After migration</th>
+         </tr>
+         <tr class="subhead">
+-          <th>Guest type</th>
++          <th>Source type</th>
+           <th>Source config</th>
+           <th>Dest config</th>
+           <th>--undefine-source</th>
+           <th>--persist</th>
+-          <th>Guest type</th>
++          <th>Dest type</th>
+           <th>Source config</th>
+           <th>Dest config</th>
+         </tr>
+@@ -325,9 +325,9 @@
+           <td class="y">Y</td>
+           <td class="n">N</td>
+           <td class="n">N</td>
+-          <td>Transient</td>
+-          <td class="n">N</td>
++          <td>Persistent</td>
+           <td class="n">N</td>
++          <td class="y">Y<br/>(unchanged dest config)</td>
+         </tr>
+         <tr>
+           <td>Transient</td>
+@@ -335,9 +335,9 @@
+           <td class="y">Y</td>
+           <td class="y">Y</td>
+           <td class="n">N</td>
+-          <td>Transient</td>
+-          <td class="n">N</td>
++          <td>Persistent</td>
+           <td class="n">N</td>
++          <td class="y">Y<br/>(unchanged dest config)</td>
+         </tr>
+         <tr>
+           <td>Transient</td>
+@@ -347,7 +347,7 @@
+           <td class="y">Y</td>
+           <td>Persistent</td>
+           <td class="n">N</td>
+-          <td class="y">Y</td>
++          <td class="y">Y<br/>(replaced with source)</td>
+         </tr>
+         <tr>
+           <td>Transient</td>
+@@ -357,7 +357,7 @@
+           <td class="y">Y</td>
+           <td>Persistent</td>
+           <td class="n">N</td>
+-          <td class="y">Y</td>
++          <td class="y">Y<br/>(replaced with source)</td>
+         </tr>
+ 
+         <!-- src:Y dst:N -->
+@@ -411,7 +411,7 @@
+           <td class="n">N</td>
+           <td>Persistent</td>
+           <td class="y">Y</td>
+-          <td class="y">Y</td>
++          <td class="y">Y<br/>(unchanged dest config)</td>
+         </tr>
+         <tr>
+           <td>Persistent</td>
+@@ -421,7 +421,7 @@
+           <td class="n">N</td>
+           <td>Persistent</td>
+           <td class="n">N</td>
+-          <td class="y">Y</td>
++          <td class="y">Y<br/>(unchanged dest config)</td>
+         </tr>
+         <tr>
+           <td>Persistent</td>
+@@ -431,7 +431,7 @@
+           <td class="y">Y</td>
+           <td>Persistent</td>
+           <td class="y">Y</td>
+-          <td class="y">Y</td>
++          <td class="y">Y<br/>(replaced with source)</td>
+         </tr>
+         <tr>
+           <td>Persistent</td>
+@@ -441,7 +441,7 @@
+           <td class="y">Y</td>
+           <td>Persistent</td>
+           <td class="n">N</td>
+-          <td class="y">Y</td>
++          <td class="y">Y<br/>(replaced with source)</td>
+         </tr>
+       </tbody>
+     </table>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-network-better-log-message-when-network-is-inactive-during-reconnect.patch b/SOURCES/libvirt-network-better-log-message-when-network-is-inactive-during-reconnect.patch
deleted file mode 100644
index 6689d63..0000000
--- a/SOURCES/libvirt-network-better-log-message-when-network-is-inactive-during-reconnect.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From c85276bfbfda6818ae1dddbe91d971cb26669044 Mon Sep 17 00:00:00 2001
-Message-Id: <c85276bfbfda6818ae1dddbe91d971cb26669044@dist-git>
-From: Laine Stump <laine@laine.org>
-Date: Tue, 2 May 2017 12:31:52 -0400
-Subject: [PATCH] network: better log message when network is inactive during
- reconnect
-
-If the network isn't active during networkNotifyActualDevice(), we
-would log an error message stating that the bridge device didn't
-exist. This patch adds a check to see if the network is active, making
-the logs more useful in the case that it isn't.
-
-Partially resolves: https://bugzilla.redhat.com/1442700
-
-(cherry picked from commit 7949de960eaba07661c1e0ab6e4aa945db8c1b25)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/network/bridge_driver.c | 7 +++++++
- 1 file changed, 7 insertions(+)
-
-diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
-index cb91a2c90..41bce794a 100644
---- a/src/network/bridge_driver.c
-+++ b/src/network/bridge_driver.c
-@@ -4682,6 +4682,13 @@ networkNotifyActualDevice(virDomainDefPtr dom,
-     }
-     netdef = network->def;
- 
-+    if (!virNetworkObjIsActive(network)) {
-+        virReportError(VIR_ERR_OPERATION_INVALID,
-+                       _("network '%s' is not active"),
-+                       netdef->name);
-+        goto error;
-+    }
-+
-     /* if we're restarting libvirtd after an upgrade from a version
-      * that didn't save bridge name in actualNetDef for
-      * actualType==network, we need to copy it in so that it will be
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-nodedev-Increase-the-netlink-socket-buffer-size-to-the-one-used-by-udev.patch b/SOURCES/libvirt-nodedev-Increase-the-netlink-socket-buffer-size-to-the-one-used-by-udev.patch
deleted file mode 100644
index 526a99f..0000000
--- a/SOURCES/libvirt-nodedev-Increase-the-netlink-socket-buffer-size-to-the-one-used-by-udev.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-From c0b489c317a0cd3b709008d742d6653634455ded Mon Sep 17 00:00:00 2001
-Message-Id: <c0b489c317a0cd3b709008d742d6653634455ded@dist-git>
-From: "ning.bo" <ning.bo9@zte.com.cn>
-Date: Mon, 29 May 2017 16:22:50 +0200
-Subject: [PATCH] nodedev: Increase the netlink socket buffer size to the one
- used by udev
-
-When a number of SRIOV VFs (up to 128 on Intel XL710) is created:
-for i in `seq 0 1`; do
-  echo 63 > /sys/class/net/<interface>/device/sriov_numvfs
-done
-
-libvirtd will then report "udev_monitor_receive_device returned NULL"
-error because the netlink socket buffer is not big enough (using GDB on
-libudev confirmed this with ENOBUFFS) and thus some udev events were
-dropped. This results in some devices being missing in the nodedev-list
-output. This patch overrides the system's rmem_max limit but for that,
-we need to make sure we've got root privileges.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1450960
-
-Signed-off-by: ning.bo <ning.bo9@zte.com.cn>
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit d1eea6c12aad5cb503562a52915138bf0d0a70a2)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1442307
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/node_device/node_device_udev.c | 7 +++++++
- 1 file changed, 7 insertions(+)
-
-diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
-index 37528ee48..20c0fc837 100644
---- a/src/node_device/node_device_udev.c
-+++ b/src/node_device/node_device_udev.c
-@@ -1732,6 +1732,13 @@ static int nodeStateInitialize(bool privileged,
- 
-     udev_monitor_enable_receiving(priv->udev_monitor);
- 
-+    /* mimic udevd's behaviour and override the systems rmem_max limit in case
-+     * there's a significant number of device 'add' events
-+     */
-+    if (geteuid() == 0)
-+        udev_monitor_set_receive_buffer_size(priv->udev_monitor,
-+                                             128 * 1024 * 1024);
-+
-     /* We register the monitor with the event callback so we are
-      * notified by udev of device changes before we enumerate existing
-      * devices because libvirt will simply recreate the device if we
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-nodedev-Introduce-mdev-capability-for-mediated-devices.patch b/SOURCES/libvirt-nodedev-Introduce-mdev-capability-for-mediated-devices.patch
deleted file mode 100644
index 9db594c..0000000
--- a/SOURCES/libvirt-nodedev-Introduce-mdev-capability-for-mediated-devices.patch
+++ /dev/null
@@ -1,282 +0,0 @@
-From 8e5ac9cdbe38dd3b3320b97385d8e2cf0e862ef7 Mon Sep 17 00:00:00 2001
-Message-Id: <8e5ac9cdbe38dd3b3320b97385d8e2cf0e862ef7@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 18 May 2017 14:02:54 +0200
-Subject: [PATCH] nodedev: Introduce mdev capability for mediated devices
-
-Start discovering the mediated devices on the host system and format the
-attributes for the mediated device into the XML. Compared to the parent
-device which reports generic information about the abstract mediated
-devices types, a child device only reports the type name it has been
-instantiated from and the IOMMU group number, since that's device
-specific compared to the rest of the info that can be gathered about
-mediated devices at the moment.
-This patch introduces both the formatting and parsing routines, updates
-nodedev.rng schema, adding a testcase as well.
-
-The resulting mdev child device XML:
-<device>
-  <name>mdev_4b20d080_1b54_4048_85b3_a6a62d165c01</name>
-  <path>/sys/devices/.../4b20d080-1b54-4048-85b3-a6a62d165c01</path>
-  <parent>pci_0000_06_00_0</parent>
-  <driver>
-    <name>vfio_mdev</name>
-  </driver>
-  <capability type='mdev'>
-    <type id='vendor_supplied_type_id'/>
-    <iommuGroup number='NUM'/>
-  <capability/>
-<device/>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1452072
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit 88ef73e13cddc8c0ff01dfe7a914342f8720c517)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/schemas/nodedev.rng                           | 17 +++++++++
- src/conf/node_device_conf.c                        | 41 +++++++++++++++++++++
- src/conf/node_device_conf.h                        |  8 ++++
- src/node_device/node_device_udev.c                 | 43 +++++++++++++++++++++-
- .../mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml  |  8 ++++
- tests/nodedevxml2xmltest.c                         |  1 +
- 6 files changed, 117 insertions(+), 1 deletion(-)
- create mode 100644 tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml
-
-diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
-index e0a2c5032..924f73861 100644
---- a/docs/schemas/nodedev.rng
-+++ b/docs/schemas/nodedev.rng
-@@ -83,6 +83,7 @@
-         <ref name="capscsi"/>
-         <ref name="capstorage"/>
-         <ref name="capdrm"/>
-+        <ref name="capmdev"/>
-       </choice>
-     </element>
-   </define>
-@@ -580,6 +581,22 @@
-     </element>
-   </define>
- 
-+  <define name='capmdev'>
-+    <attribute name='type'>
-+      <value>mdev</value>
-+    </attribute>
-+    <element name='type'>
-+      <attribute name='id'>
-+        <data type='string'/>
-+      </attribute>
-+    </element>
-+    <element name='iommuGroup'>
-+      <attribute name='number'>
-+        <ref name='unsignedInt'/>
-+      </attribute>
-+    </element>
-+  </define>
-+
-   <define name='address'>
-     <element name='address'>
-       <attribute name='domain'><ref name='hexuint'/></attribute>
-diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
-index de8ba8f9d..ac61db34c 100644
---- a/src/conf/node_device_conf.c
-+++ b/src/conf/node_device_conf.c
-@@ -577,6 +577,10 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
-             virBufferEscapeString(&buf, "<type>%s</type>\n", virNodeDevDRMTypeToString(data->drm.type));
-             break;
-         case VIR_NODE_DEV_CAP_MDEV:
-+            virBufferEscapeString(&buf, "<type id='%s'/>\n", data->mdev.type);
-+            virBufferAsprintf(&buf, "<iommuGroup number='%u'/>\n",
-+                              data->mdev.iommuGroupNumber);
-+            break;
-         case VIR_NODE_DEV_CAP_MDEV_TYPES:
-         case VIR_NODE_DEV_CAP_FC_HOST:
-         case VIR_NODE_DEV_CAP_VPORTS:
-@@ -1647,6 +1651,39 @@ virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt,
- }
- 
- 
-+static int
-+virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt,
-+                          virNodeDeviceDefPtr def,
-+                          xmlNodePtr node,
-+                          virNodeDevCapMdevPtr mdev)
-+{
-+    xmlNodePtr orignode;
-+    int ret = -1;
-+
-+    orignode = ctxt->node;
-+    ctxt->node = node;
-+
-+    if (!(mdev->type = virXPathString("string(./type[1]/@id)", ctxt))) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("missing type id attribute for '%s'"), def->name);
-+        goto out;
-+    }
-+
-+    if (virNodeDevCapsDefParseULong("number(./iommuGroup[1]/@number)", ctxt,
-+                                    &mdev->iommuGroupNumber, def,
-+                                    _("missing iommuGroup number attribute for "
-+                                      "'%s'"),
-+                                    _("invalid iommuGroup number attribute for "
-+                                      "'%s'")) < 0)
-+        goto out;
-+
-+    ret = 0;
-+ out:
-+    ctxt->node = orignode;
-+    return ret;
-+}
-+
-+
- static virNodeDevCapsDefPtr
- virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
-                           virNodeDeviceDefPtr def,
-@@ -1715,6 +1752,8 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
-         ret = virNodeDevCapDRMParseXML(ctxt, def, node, &caps->data.drm);
-         break;
-     case VIR_NODE_DEV_CAP_MDEV:
-+        ret = virNodeDevCapMdevParseXML(ctxt, def, node, &caps->data.mdev);
-+        break;
-     case VIR_NODE_DEV_CAP_MDEV_TYPES:
-     case VIR_NODE_DEV_CAP_FC_HOST:
-     case VIR_NODE_DEV_CAP_VPORTS:
-@@ -2037,6 +2076,8 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
-         VIR_FREE(data->sg.path);
-         break;
-     case VIR_NODE_DEV_CAP_MDEV:
-+        VIR_FREE(data->mdev.type);
-+        break;
-     case VIR_NODE_DEV_CAP_MDEV_TYPES:
-     case VIR_NODE_DEV_CAP_DRM:
-     case VIR_NODE_DEV_CAP_FC_HOST:
-diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
-index 18aaff8b5..5743f9d3e 100644
---- a/src/conf/node_device_conf.h
-+++ b/src/conf/node_device_conf.h
-@@ -143,6 +143,13 @@ struct _virNodeDevCapMdevType {
-     unsigned int available_instances;
- };
- 
-+typedef struct _virNodeDevCapMdev virNodeDevCapMdev;
-+typedef virNodeDevCapMdev *virNodeDevCapMdevPtr;
-+struct _virNodeDevCapMdev {
-+    char *type;
-+    unsigned int iommuGroupNumber;
-+};
-+
- typedef struct _virNodeDevCapPCIDev virNodeDevCapPCIDev;
- typedef virNodeDevCapPCIDev *virNodeDevCapPCIDevPtr;
- struct _virNodeDevCapPCIDev {
-@@ -276,6 +283,7 @@ struct _virNodeDevCapData {
-         virNodeDevCapStorage storage;
-         virNodeDevCapSCSIGeneric sg;
-         virNodeDevCapDRM drm;
-+        virNodeDevCapMdev mdev;
-     };
- };
- 
-diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
-index b89099c82..37528ee48 100644
---- a/src/node_device/node_device_udev.c
-+++ b/src/node_device/node_device_udev.c
-@@ -1073,6 +1073,42 @@ udevProcessSCSIGeneric(struct udev_device *dev,
- }
- 
- static int
-+udevProcessMediatedDevice(struct udev_device *dev,
-+                          virNodeDeviceDefPtr def)
-+{
-+    int ret = -1;
-+    const char *uuidstr = NULL;
-+    int iommugrp = -1;
-+    char *linkpath = NULL;
-+    char *realpath = NULL;
-+    virNodeDevCapMdevPtr data = &def->caps->data.mdev;
-+
-+    if (virAsprintf(&linkpath, "%s/mdev_type", udev_device_get_syspath(dev)) < 0)
-+        goto cleanup;
-+
-+    if (virFileResolveLink(linkpath, &realpath) < 0)
-+        goto cleanup;
-+
-+    if (VIR_STRDUP(data->type, last_component(realpath)) < 0)
-+        goto cleanup;
-+
-+    uuidstr = udev_device_get_sysname(dev);
-+    if ((iommugrp = virMediatedDeviceGetIOMMUGroupNum(uuidstr)) < 0)
-+        goto cleanup;
-+
-+    if (udevGenerateDeviceName(dev, def, NULL) != 0)
-+        goto cleanup;
-+
-+    data->iommuGroupNumber = iommugrp;
-+
-+    ret = 0;
-+ cleanup:
-+    VIR_FREE(linkpath);
-+    VIR_FREE(realpath);
-+    return ret;
-+}
-+
-+static int
- udevGetDeviceNodes(struct udev_device *device,
-                    virNodeDeviceDefPtr def)
- {
-@@ -1140,12 +1176,16 @@ udevGetDeviceType(struct udev_device *device,
-         if (udevHasDeviceProperty(device, "INTERFACE"))
-             *type = VIR_NODE_DEV_CAP_NET;
- 
--        /* SCSI generic device doesn't set DEVTYPE property */
-+        /* Neither SCSI generic devices nor mediated devices set DEVTYPE
-+         * property, therefore we need to rely on the SUBSYSTEM property */
-         if (udevGetStringProperty(device, "SUBSYSTEM", &subsystem) < 0)
-             return -1;
- 
-         if (STREQ_NULLABLE(subsystem, "scsi_generic"))
-             *type = VIR_NODE_DEV_CAP_SCSI_GENERIC;
-+        else if (STREQ_NULLABLE(subsystem, "mdev"))
-+            *type = VIR_NODE_DEV_CAP_MDEV;
-+
-         VIR_FREE(subsystem);
-     }
- 
-@@ -1185,6 +1225,7 @@ static int udevGetDeviceDetails(struct udev_device *device,
-     case VIR_NODE_DEV_CAP_DRM:
-         return udevProcessDRMDevice(device, def);
-     case VIR_NODE_DEV_CAP_MDEV:
-+        return udevProcessMediatedDevice(device, def);
-     case VIR_NODE_DEV_CAP_MDEV_TYPES:
-     case VIR_NODE_DEV_CAP_SYSTEM:
-     case VIR_NODE_DEV_CAP_FC_HOST:
-diff --git a/tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml b/tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml
-new file mode 100644
-index 000000000..470e5917e
---- /dev/null
-+++ b/tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml
-@@ -0,0 +1,8 @@
-+<device>
-+  <name>mdev_3627463d_b7f0_4fea_b468_f1da537d301b</name>
-+  <parent>computer</parent>
-+  <capability type='mdev'>
-+    <type id='mtty-1'/>
-+    <iommuGroup number='12'/>
-+  </capability>
-+</device>
-diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
-index eb5c50b86..26f0d25bc 100644
---- a/tests/nodedevxml2xmltest.c
-+++ b/tests/nodedevxml2xmltest.c
-@@ -102,6 +102,7 @@ mymain(void)
-     DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all_header_type");
-     DO_TEST("drm_renderD129");
-     DO_TEST("pci_0000_02_10_7_mdev_types");
-+    DO_TEST("mdev_3627463d_b7f0_4fea_b468_f1da537d301b");
- 
-     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
- }
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-nodedev-Introduce-new-mdev_types-and-mdev-nodedev-capabilities.patch b/SOURCES/libvirt-nodedev-Introduce-new-mdev_types-and-mdev-nodedev-capabilities.patch
deleted file mode 100644
index 11333ed..0000000
--- a/SOURCES/libvirt-nodedev-Introduce-new-mdev_types-and-mdev-nodedev-capabilities.patch
+++ /dev/null
@@ -1,193 +0,0 @@
-From 74e4d42a25e8e8823ce4e7c3544b8f1944cdb471 Mon Sep 17 00:00:00 2001
-Message-Id: <74e4d42a25e8e8823ce4e7c3544b8f1944cdb471@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 18 May 2017 14:02:52 +0200
-Subject: [PATCH] nodedev: Introduce new mdev_types and mdev nodedev
- capabilities
-
-The reason for introducing two capabilities, one for the device itself
-(cap 'mdev') and one for the parent device listing the available types
-('mdev_types'), is that we should be able to do
-'virsh nodedev-list --cap' not only for existing mdev devices but also
-for devices that support creation of mdev devices, since one day libvirt
-might be actually able to create the mdev devices in an automated way
-(just like we do for NPIV/vHBA).
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1452072
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit 4385df97fed24279fa8595a1a49c9f9b3eba5be1)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- include/libvirt/libvirt-nodedev.h    |  2 ++
- src/conf/node_device_conf.c          | 10 +++++++++-
- src/conf/node_device_conf.h          |  6 +++++-
- src/conf/virnodedeviceobj.c          |  4 +++-
- src/libvirt-nodedev.c                |  2 ++
- src/node_device/node_device_driver.c |  2 ++
- src/node_device/node_device_udev.c   |  3 +++
- tools/virsh-nodedev.c                |  6 ++++++
- 8 files changed, 32 insertions(+), 3 deletions(-)
-
-diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h
-index 85003903d..1e3043787 100644
---- a/include/libvirt/libvirt-nodedev.h
-+++ b/include/libvirt/libvirt-nodedev.h
-@@ -79,6 +79,8 @@ typedef enum {
-     VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS        = 1 << 10, /* Capable of vport */
-     VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC  = 1 << 11, /* Capable of scsi_generic */
-     VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM           = 1 << 12, /* DRM device */
-+    VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES    = 1 << 13, /* Capable of mediated devices */
-+    VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV          = 1 << 14, /* Mediated device */
- } virConnectListAllNodeDeviceFlags;
- 
- int                     virConnectListAllNodeDevices (virConnectPtr conn,
-diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
-index 56a26b578..90a087a37 100644
---- a/src/conf/node_device_conf.c
-+++ b/src/conf/node_device_conf.c
-@@ -60,7 +60,9 @@ VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST,
-               "fc_host",
-               "vports",
-               "scsi_generic",
--              "drm")
-+              "drm",
-+              "mdev_types",
-+              "mdev")
- 
- VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST,
-               "80203",
-@@ -540,6 +542,8 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
-         case VIR_NODE_DEV_CAP_DRM:
-             virBufferEscapeString(&buf, "<type>%s</type>\n", virNodeDevDRMTypeToString(data->drm.type));
-             break;
-+        case VIR_NODE_DEV_CAP_MDEV:
-+        case VIR_NODE_DEV_CAP_MDEV_TYPES:
-         case VIR_NODE_DEV_CAP_FC_HOST:
-         case VIR_NODE_DEV_CAP_VPORTS:
-         case VIR_NODE_DEV_CAP_LAST:
-@@ -1612,6 +1616,8 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
-     case VIR_NODE_DEV_CAP_DRM:
-         ret = virNodeDevCapDRMParseXML(ctxt, def, node, &caps->data.drm);
-         break;
-+    case VIR_NODE_DEV_CAP_MDEV:
-+    case VIR_NODE_DEV_CAP_MDEV_TYPES:
-     case VIR_NODE_DEV_CAP_FC_HOST:
-     case VIR_NODE_DEV_CAP_VPORTS:
-     case VIR_NODE_DEV_CAP_SCSI_GENERIC:
-@@ -1929,6 +1935,8 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
-     case VIR_NODE_DEV_CAP_SCSI_GENERIC:
-         VIR_FREE(data->sg.path);
-         break;
-+    case VIR_NODE_DEV_CAP_MDEV:
-+    case VIR_NODE_DEV_CAP_MDEV_TYPES:
-     case VIR_NODE_DEV_CAP_DRM:
-     case VIR_NODE_DEV_CAP_FC_HOST:
-     case VIR_NODE_DEV_CAP_VPORTS:
-diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
-index a5d5cdd2a..e168f2e27 100644
---- a/src/conf/node_device_conf.h
-+++ b/src/conf/node_device_conf.h
-@@ -64,6 +64,8 @@ typedef enum {
-     VIR_NODE_DEV_CAP_VPORTS,		/* HBA which is capable of vports */
-     VIR_NODE_DEV_CAP_SCSI_GENERIC,      /* SCSI generic device */
-     VIR_NODE_DEV_CAP_DRM,               /* DRM device */
-+    VIR_NODE_DEV_CAP_MDEV_TYPES,        /* Device capable of mediated devices */
-+    VIR_NODE_DEV_CAP_MDEV,              /* Mediated device */
- 
-     VIR_NODE_DEV_CAP_LAST
- } virNodeDevCapType;
-@@ -351,7 +353,9 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps);
-                  VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST       | \
-                  VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS        | \
-                  VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC  | \
--                 VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM)
-+                 VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM           | \
-+                 VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES    | \
-+                 VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV)
- 
- char *
- virNodeDeviceGetParentName(virConnectPtr conn,
-diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
-index 3fe3ae5fe..21d5d3f75 100644
---- a/src/conf/virnodedeviceobj.c
-+++ b/src/conf/virnodedeviceobj.c
-@@ -494,7 +494,9 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj,
-               MATCH(FC_HOST)       ||
-               MATCH(VPORTS)        ||
-               MATCH(SCSI_GENERIC)  ||
--              MATCH(DRM)))
-+              MATCH(DRM)           ||
-+              MATCH(MDEV_TYPES)    ||
-+              MATCH(MDEV)))
-             return false;
-     }
- 
-diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c
-index 83376b0d9..44e2b4efd 100644
---- a/src/libvirt-nodedev.c
-+++ b/src/libvirt-nodedev.c
-@@ -98,6 +98,8 @@ virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags)
-  *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS
-  *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC
-  *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM
-+ *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES
-+ *   VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV
-  *
-  * Returns the number of node devices found or -1 and sets @devices to NULL in
-  * case of error.  On success, the array stored into @devices is guaranteed to
-diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
-index 99f7bc547..082160d98 100644
---- a/src/node_device/node_device_driver.c
-+++ b/src/node_device/node_device_driver.c
-@@ -82,6 +82,8 @@ static int update_caps(virNodeDeviceObjPtr dev)
-         case VIR_NODE_DEV_CAP_FC_HOST:
-         case VIR_NODE_DEV_CAP_VPORTS:
-         case VIR_NODE_DEV_CAP_SCSI_GENERIC:
-+        case VIR_NODE_DEV_CAP_MDEV_TYPES:
-+        case VIR_NODE_DEV_CAP_MDEV:
-         case VIR_NODE_DEV_CAP_LAST:
-             break;
-         }
-diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
-index 591da8db2..d4489e2a5 100644
---- a/src/node_device/node_device_udev.c
-+++ b/src/node_device/node_device_udev.c
-@@ -43,6 +43,7 @@
- #include "virpci.h"
- #include "virstring.h"
- #include "virnetdev.h"
-+#include "virmdev.h"
- 
- #define VIR_FROM_THIS VIR_FROM_NODEDEV
- 
-@@ -1064,6 +1065,8 @@ static int udevGetDeviceDetails(struct udev_device *device,
-         return udevProcessSCSIGeneric(device, def);
-     case VIR_NODE_DEV_CAP_DRM:
-         return udevProcessDRMDevice(device, def);
-+    case VIR_NODE_DEV_CAP_MDEV:
-+    case VIR_NODE_DEV_CAP_MDEV_TYPES:
-     case VIR_NODE_DEV_CAP_SYSTEM:
-     case VIR_NODE_DEV_CAP_FC_HOST:
-     case VIR_NODE_DEV_CAP_VPORTS:
-diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
-index c69144021..ad96dda1f 100644
---- a/tools/virsh-nodedev.c
-+++ b/tools/virsh-nodedev.c
-@@ -454,6 +454,12 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
-         case VIR_NODE_DEV_CAP_DRM:
-             flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM;
-             break;
-+        case VIR_NODE_DEV_CAP_MDEV_TYPES:
-+            flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES;
-+            break;
-+        case VIR_NODE_DEV_CAP_MDEV:
-+            flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV;
-+            break;
-         case VIR_NODE_DEV_CAP_LAST:
-             break;
-         }
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-nodedev-Introduce-the-mdev-capability-to-a-PCI-parent-device.patch b/SOURCES/libvirt-nodedev-Introduce-the-mdev-capability-to-a-PCI-parent-device.patch
deleted file mode 100644
index 32d38c3..0000000
--- a/SOURCES/libvirt-nodedev-Introduce-the-mdev-capability-to-a-PCI-parent-device.patch
+++ /dev/null
@@ -1,522 +0,0 @@
-From 909d3ff4c0e4ab7486c60dade9900462c896d3ba Mon Sep 17 00:00:00 2001
-Message-Id: <909d3ff4c0e4ab7486c60dade9900462c896d3ba@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 18 May 2017 14:02:53 +0200
-Subject: [PATCH] nodedev: Introduce the mdev capability to a PCI parent device
-
-The parent device needs to report the generic stuff about the supported
-mediated devices types, like device API, available instances, type name,
-etc. Therefore this patch introduces a new nested capability element of
-type 'mdev_types' with the resulting XML of the following format:
-
-<device>
-  ...
-  <capability type='pci'>
-    ...
-    <capability type='mdev_types'>
-      <type id='vendor_supplied_id'>
-        <name>optional_vendor_supplied_codename</name>
-        <deviceAPI>vfio-pci</deviceAPI>
-        <availableInstances>NUM</availableInstances>
-      </type>
-        ...
-      <type>
-        ...
-      </type>
-    </capability>
-  </capability>
-  ...
-</device>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1452072
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit 500cbc066a5362834462c4eefb260b7c96a8554f)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/schemas/nodedev.rng                           |  26 +++++
- src/conf/node_device_conf.c                        | 101 +++++++++++++++++
- src/conf/node_device_conf.h                        |  15 +++
- src/conf/virnodedeviceobj.c                        |  20 +++-
- src/libvirt_private.syms                           |   1 +
- src/node_device/node_device_udev.c                 | 119 +++++++++++++++++++++
- .../pci_0000_02_10_7_mdev_types.xml                |  32 ++++++
- tests/nodedevxml2xmltest.c                         |   1 +
- 8 files changed, 313 insertions(+), 2 deletions(-)
- create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml
-
-diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
-index 0f90a73c8..e0a2c5032 100644
---- a/docs/schemas/nodedev.rng
-+++ b/docs/schemas/nodedev.rng
-@@ -205,6 +205,32 @@
-     </optional>
- 
-     <optional>
-+      <element name='capability'>
-+        <attribute name='type'>
-+          <value>mdev_types</value>
-+        </attribute>
-+        <oneOrMore>
-+          <element name='type'>
-+            <attribute name='id'>
-+              <data type='string'/>
-+            </attribute>
-+            <optional>
-+              <element name='name'><text/></element>
-+            </optional>
-+            <element name='deviceAPI'>
-+              <choice>
-+                <value>vfio-pci</value>
-+              </choice>
-+            </element>
-+            <element name='availableInstances'>
-+              <ref name='unsignedInt'/>
-+            </element>
-+          </element>
-+        </oneOrMore>
-+      </element>
-+   </optional>
-+
-+    <optional>
-       <element name='iommuGroup'>
-         <attribute name='number'>
-           <ref name='unsignedInt'/>
-diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
-index 90a087a37..de8ba8f9d 100644
---- a/src/conf/node_device_conf.c
-+++ b/src/conf/node_device_conf.c
-@@ -89,6 +89,19 @@ virNodeDevCapsDefParseString(const char *xpath,
- 
- 
- void
-+virNodeDevCapMdevTypeFree(virNodeDevCapMdevTypePtr type)
-+{
-+    if (!type)
-+        return;
-+
-+    VIR_FREE(type->id);
-+    VIR_FREE(type->name);
-+    VIR_FREE(type->device_api);
-+    VIR_FREE(type);
-+}
-+
-+
-+void
- virNodeDeviceDefFree(virNodeDeviceDefPtr def)
- {
-     virNodeDevCapsDefPtr caps;
-@@ -265,6 +278,27 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf,
-         virBufferAsprintf(buf, "<capability type='%s'/>\n",
-                           virPCIHeaderTypeToString(data->pci_dev.hdrType));
-     }
-+    if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) {
-+        virBufferAddLit(buf, "<capability type='mdev_types'>\n");
-+        virBufferAdjustIndent(buf, 2);
-+        for (i = 0; i < data->pci_dev.nmdev_types; i++) {
-+            virNodeDevCapMdevTypePtr type = data->pci_dev.mdev_types[i];
-+            virBufferEscapeString(buf, "<type id='%s'>\n", type->id);
-+            virBufferAdjustIndent(buf, 2);
-+            if (type->name)
-+                virBufferEscapeString(buf, "<name>%s</name>\n",
-+                                      type->name);
-+            virBufferEscapeString(buf, "<deviceAPI>%s</deviceAPI>\n",
-+                                  type->device_api);
-+            virBufferAsprintf(buf,
-+                              "<availableInstances>%u</availableInstances>\n",
-+                              type->available_instances);
-+            virBufferAdjustIndent(buf, -2);
-+            virBufferAddLit(buf, "</type>\n");
-+        }
-+        virBufferAdjustIndent(buf, -2);
-+        virBufferAddLit(buf, "</capability>\n");
-+    }
-     if (data->pci_dev.nIommuGroupDevices) {
-         virBufferAsprintf(buf, "<iommuGroup number='%d'>\n",
-                           data->pci_dev.iommuGroupNumber);
-@@ -1365,6 +1399,67 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt,
- 
- 
- static int
-+virNodeDevPCICapMdevTypesParseXML(xmlXPathContextPtr ctxt,
-+                                  virNodeDevCapPCIDevPtr pci_dev)
-+{
-+    int ret = -1;
-+    xmlNodePtr orignode = NULL;
-+    xmlNodePtr *nodes = NULL;
-+    int nmdev_types = -1;
-+    virNodeDevCapMdevTypePtr type = NULL;
-+    size_t i;
-+
-+    if ((nmdev_types = virXPathNodeSet("./type", ctxt, &nodes)) < 0)
-+        goto cleanup;
-+
-+    orignode = ctxt->node;
-+    for (i = 0; i < nmdev_types; i++) {
-+        ctxt->node = nodes[i];
-+
-+        if (VIR_ALLOC(type) < 0)
-+            goto cleanup;
-+
-+        if (!(type->id = virXPathString("string(./@id[1])", ctxt))) {
-+            virReportError(VIR_ERR_XML_ERROR, "%s",
-+                           _("missing 'id' attribute for mediated device's "
-+                             "<type> element"));
-+            goto cleanup;
-+        }
-+
-+        if (!(type->device_api = virXPathString("string(./deviceAPI[1])", ctxt))) {
-+            virReportError(VIR_ERR_XML_ERROR,
-+                           _("missing device API for mediated device type '%s'"),
-+                           type->id);
-+            goto cleanup;
-+        }
-+
-+        if (virXPathUInt("number(./availableInstances)", ctxt,
-+                         &type->available_instances) < 0) {
-+            virReportError(VIR_ERR_XML_ERROR,
-+                           _("missing number of available instances for "
-+                             "mediated device type '%s'"),
-+                           type->id);
-+            goto cleanup;
-+        }
-+
-+        type->name = virXPathString("string(./name)", ctxt);
-+
-+        if (VIR_APPEND_ELEMENT(pci_dev->mdev_types,
-+                               pci_dev->nmdev_types, type) < 0)
-+            goto cleanup;
-+    }
-+
-+    pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_MDEV;
-+    ret = 0;
-+ cleanup:
-+    VIR_FREE(nodes);
-+    virNodeDevCapMdevTypeFree(type);
-+    ctxt->node = orignode;
-+    return ret;
-+}
-+
-+
-+static int
- virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt,
-                                 xmlNodePtr node,
-                                 virNodeDevCapPCIDevPtr pci_dev)
-@@ -1386,6 +1481,9 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt,
-     } else if (STREQ(type, "virt_functions") &&
-                virNodeDevPCICapSRIOVVirtualParseXML(ctxt, pci_dev) < 0) {
-         goto cleanup;
-+    } else if (STREQ(type, "mdev_types") &&
-+        virNodeDevPCICapMdevTypesParseXML(ctxt, pci_dev) < 0) {
-+        goto cleanup;
-     } else {
-         int hdrType = virPCIHeaderTypeFromString(type);
- 
-@@ -1898,6 +1996,9 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
-             VIR_FREE(data->pci_dev.iommuGroupDevices[i]);
-         VIR_FREE(data->pci_dev.iommuGroupDevices);
-         virPCIEDeviceInfoFree(data->pci_dev.pci_express);
-+        for (i = 0; i < data->pci_dev.nmdev_types; i++)
-+            virNodeDevCapMdevTypeFree(data->pci_dev.mdev_types[i]);
-+        VIR_FREE(data->pci_dev.mdev_types);
-         break;
-     case VIR_NODE_DEV_CAP_USB_DEV:
-         VIR_FREE(data->usb_dev.product_name);
-diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
-index e168f2e27..18aaff8b5 100644
---- a/src/conf/node_device_conf.h
-+++ b/src/conf/node_device_conf.h
-@@ -95,6 +95,7 @@ typedef enum {
-     VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION     = (1 << 0),
-     VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION      = (1 << 1),
-     VIR_NODE_DEV_CAP_FLAG_PCIE                      = (1 << 2),
-+    VIR_NODE_DEV_CAP_FLAG_PCI_MDEV                  = (1 << 3),
- } virNodeDevPCICapFlags;
- 
- typedef enum {
-@@ -133,6 +134,15 @@ struct _virNodeDevCapSystem {
-     virNodeDevCapSystemFirmware firmware;
- };
- 
-+typedef struct _virNodeDevCapMdevType virNodeDevCapMdevType;
-+typedef virNodeDevCapMdevType *virNodeDevCapMdevTypePtr;
-+struct _virNodeDevCapMdevType {
-+    char *id;
-+    char *name;
-+    char *device_api;
-+    unsigned int available_instances;
-+};
-+
- typedef struct _virNodeDevCapPCIDev virNodeDevCapPCIDev;
- typedef virNodeDevCapPCIDev *virNodeDevCapPCIDevPtr;
- struct _virNodeDevCapPCIDev {
-@@ -156,6 +166,8 @@ struct _virNodeDevCapPCIDev {
-     int numa_node;
-     virPCIEDeviceInfoPtr pci_express;
-     int hdrType; /* enum virPCIHeaderType or -1 */
-+    virNodeDevCapMdevTypePtr *mdev_types;
-+    size_t nmdev_types;
- };
- 
- typedef struct _virNodeDevCapUSBDev virNodeDevCapUSBDev;
-@@ -340,6 +352,9 @@ virNodeDeviceDefFree(virNodeDeviceDefPtr def);
- void
- virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps);
- 
-+void
-+virNodeDevCapMdevTypeFree(virNodeDevCapMdevTypePtr type);
-+
- # define VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP \
-                 (VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM        | \
-                  VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV       | \
-diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
-index 21d5d3f75..ac25fb598 100644
---- a/src/conf/virnodedeviceobj.c
-+++ b/src/conf/virnodedeviceobj.c
-@@ -42,11 +42,13 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *dev,
-         virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_FC_HOST);
-     const char *vports_cap =
-         virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_VPORTS);
-+    const char *mdev_types =
-+        virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_MDEV_TYPES);
- 
-     while (caps) {
--        if (STREQ(cap, virNodeDevCapTypeToString(caps->data.type)))
-+        if (STREQ(cap, virNodeDevCapTypeToString(caps->data.type))) {
-             return 1;
--        else if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST)
-+        } else if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) {
-             if ((STREQ(cap, fc_host_cap) &&
-                 (caps->data.scsi_host.flags &
-                  VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST)) ||
-@@ -54,6 +56,13 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *dev,
-                 (caps->data.scsi_host.flags &
-                  VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS)))
-                 return 1;
-+        } else if (caps->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
-+            if ((STREQ(cap, mdev_types)) &&
-+                (caps->data.pci_dev.flags &
-+                 VIR_NODE_DEV_CAP_FLAG_PCI_MDEV))
-+                return 1;
-+        }
-+
-         caps = caps->next;
-     }
-     return 0;
-@@ -468,6 +477,13 @@ virNodeDeviceCapMatch(virNodeDeviceObjPtr devobj,
-                  VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS))
-                 return true;
-         }
-+
-+        if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
-+            if (type == VIR_NODE_DEV_CAP_MDEV_TYPES &&
-+                (cap->data.pci_dev.flags &
-+                 VIR_NODE_DEV_CAP_FLAG_PCI_MDEV))
-+                return true;
-+        }
-     }
- 
-     return false;
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 7e1a06db3..343966cd0 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -692,6 +692,7 @@ virNetDevIPRouteParseXML;
- 
- 
- # conf/node_device_conf.h
-+virNodeDevCapMdevTypeFree;
- virNodeDevCapsDefFree;
- virNodeDevCapTypeFromString;
- virNodeDevCapTypeToString;
-diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
-index d4489e2a5..b89099c82 100644
---- a/src/node_device/node_device_udev.c
-+++ b/src/node_device/node_device_udev.c
-@@ -314,6 +314,119 @@ static int udevTranslatePCIIds(unsigned int vendor,
- }
- 
- 
-+static int
-+udevFillMdevType(struct udev_device *device,
-+                 const char *dir,
-+                 virNodeDevCapMdevTypePtr type)
-+{
-+    int ret = -1;
-+    char *attrpath = NULL;
-+
-+#define MDEV_GET_SYSFS_ATTR(attr_name, cb, ...)                             \
-+    do {                                                                    \
-+        if (virAsprintf(&attrpath, "%s/%s", dir, #attr_name) < 0)           \
-+            goto cleanup;                                                   \
-+                                                                            \
-+        if (cb(device, attrpath, __VA_ARGS__) < 0)                          \
-+            goto cleanup;                                                   \
-+                                                                            \
-+        VIR_FREE(attrpath);                                                 \
-+    } while (0)                                                             \
-+
-+    if (VIR_STRDUP(type->id, last_component(dir)) < 0)
-+        goto cleanup;
-+
-+    /* query udev for the attributes under subdirectories using the relative
-+     * path stored in @dir, i.e. 'mdev_supported_types/<type_id>'
-+     */
-+    MDEV_GET_SYSFS_ATTR(name, udevGetStringSysfsAttr, &type->name);
-+    MDEV_GET_SYSFS_ATTR(device_api, udevGetStringSysfsAttr, &type->device_api);
-+    MDEV_GET_SYSFS_ATTR(available_instances, udevGetUintSysfsAttr,
-+                        &type->available_instances, 10);
-+
-+#undef MDEV_GET_SYSFS_ATTR
-+
-+    ret = 0;
-+ cleanup:
-+    VIR_FREE(attrpath);
-+    return ret;
-+}
-+
-+
-+static int
-+udevPCIGetMdevTypesCap(struct udev_device *device,
-+                       virNodeDevCapPCIDevPtr pcidata)
-+{
-+    int ret = -1;
-+    int dirret = -1;
-+    DIR *dir = NULL;
-+    struct dirent *entry;
-+    char *path = NULL;
-+    char *tmppath = NULL;
-+    virNodeDevCapMdevTypePtr type = NULL;
-+    virNodeDevCapMdevTypePtr *types = NULL;
-+    size_t ntypes = 0;
-+    size_t i;
-+
-+    if (virAsprintf(&path, "%s/mdev_supported_types",
-+                    udev_device_get_syspath(device)) < 0)
-+        return -1;
-+
-+    if ((dirret = virDirOpenIfExists(&dir, path)) < 0)
-+        goto cleanup;
-+
-+    if (dirret == 0) {
-+        ret = 0;
-+        goto cleanup;
-+    }
-+
-+    if (VIR_ALLOC(types) < 0)
-+        goto cleanup;
-+
-+    /* UDEV doesn't report attributes under subdirectories by default but is
-+     * able to query them if the path to the attribute is relative to the
-+     * device's base path, e.g. /sys/devices/../0000:00:01.0/ is the device's
-+     * base path as udev reports it, but we're interested in attributes under
-+     * /sys/devices/../0000:00:01.0/mdev_supported_types/<type>/. So, we need to
-+     * scan the subdirectories ourselves.
-+     */
-+    while ((dirret = virDirRead(dir, &entry, path)) > 0) {
-+        if (VIR_ALLOC(type) < 0)
-+            goto cleanup;
-+
-+        /* construct the relative mdev type path bit for udev */
-+        if (virAsprintf(&tmppath, "mdev_supported_types/%s", entry->d_name) < 0)
-+            goto cleanup;
-+
-+        if (udevFillMdevType(device, tmppath, type) < 0)
-+            goto cleanup;
-+
-+        if (VIR_APPEND_ELEMENT(types, ntypes, type) < 0)
-+            goto cleanup;
-+
-+        VIR_FREE(tmppath);
-+    }
-+
-+    if (dirret < 0)
-+        goto cleanup;
-+
-+    VIR_STEAL_PTR(pcidata->mdev_types, types);
-+    pcidata->nmdev_types = ntypes;
-+    pcidata->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_MDEV;
-+    ntypes = 0;
-+    ret = 0;
-+ cleanup:
-+    virNodeDevCapMdevTypeFree(type);
-+    for (i = 0; i < ntypes; i++)
-+        virNodeDevCapMdevTypeFree(types[i]);
-+    VIR_FREE(types);
-+    VIR_FREE(path);
-+    VIR_FREE(tmppath);
-+    VIR_DIR_CLOSE(dir);
-+    return ret;
-+}
-+
-+
- static int udevProcessPCI(struct udev_device *device,
-                           virNodeDeviceDefPtr def)
- {
-@@ -404,6 +517,12 @@ static int udevProcessPCI(struct udev_device *device,
-         }
-     }
- 
-+    /* check whether the device is mediated devices framework capable, if so,
-+     * process it
-+     */
-+    if (udevPCIGetMdevTypesCap(device, pci_dev) < 0)
-+        goto cleanup;
-+
-     ret = 0;
- 
-  cleanup:
-diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml b/tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml
-new file mode 100644
-index 000000000..a2d57569a
---- /dev/null
-+++ b/tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml
-@@ -0,0 +1,32 @@
-+<device>
-+  <name>pci_0000_02_10_7</name>
-+  <parent>pci_0000_00_04_0</parent>
-+  <capability type='pci'>
-+    <domain>0</domain>
-+    <bus>2</bus>
-+    <slot>16</slot>
-+    <function>7</function>
-+    <product id='0x10ca'>82576 Virtual Function</product>
-+    <vendor id='0x8086'>Intel Corporation</vendor>
-+    <capability type='mdev_types'>
-+      <type id='foo1'>
-+        <name>bar1</name>
-+        <deviceAPI>vfio-pci</deviceAPI>
-+        <availableInstances>1</availableInstances>
-+      </type>
-+      <type id='foo2'>
-+        <name>bar2</name>
-+        <deviceAPI>vfio-pci</deviceAPI>
-+        <availableInstances>2</availableInstances>
-+      </type>
-+    </capability>
-+    <iommuGroup number='31'>
-+      <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/>
-+    </iommuGroup>
-+    <numa node='0'/>
-+    <pci-express>
-+      <link validity='cap' port='0' speed='2.5' width='4'/>
-+      <link validity='sta' width='0'/>
-+    </pci-express>
-+  </capability>
-+</device>
-diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
-index 5e1ae170c..eb5c50b86 100644
---- a/tests/nodedevxml2xmltest.c
-+++ b/tests/nodedevxml2xmltest.c
-@@ -101,6 +101,7 @@ mymain(void)
-     DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all");
-     DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all_header_type");
-     DO_TEST("drm_renderD129");
-+    DO_TEST("pci_0000_02_10_7_mdev_types");
- 
-     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
- }
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-nodedev-Make-use-of-the-compile-time-missing-enum-in-switch-error.patch b/SOURCES/libvirt-nodedev-Make-use-of-the-compile-time-missing-enum-in-switch-error.patch
deleted file mode 100644
index 36c618b..0000000
--- a/SOURCES/libvirt-nodedev-Make-use-of-the-compile-time-missing-enum-in-switch-error.patch
+++ /dev/null
@@ -1,97 +0,0 @@
-From 403371cc06cd9ac36bbe7e7a2e046de82c09e762 Mon Sep 17 00:00:00 2001
-Message-Id: <403371cc06cd9ac36bbe7e7a2e046de82c09e762@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 18 May 2017 14:02:47 +0200
-Subject: [PATCH] nodedev: Make use of the compile-time missing enum in switch
- error
-
-So udevGetDeviceDetails was one those functions using an enum in a
-switch, but since it had a 'default' case, compiler didn't warn about an
-unhandled enum. Moreover, the error about an unsupported device type
-reported in the default case is unnecessary, since by the time we get
-there, udevGetDeviceType (which was called before) already made sure
-that any unrecognized device types had been handled properly.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1452072
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit 364c912cf384d2fb7575ba2f71a041297210e0e2)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/node_device/node_device_udev.c | 45 +++++++++++++-------------------------
- 1 file changed, 15 insertions(+), 30 deletions(-)
-
-diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
-index bcae444d8..591da8db2 100644
---- a/src/node_device/node_device_udev.c
-+++ b/src/node_device/node_device_udev.c
-@@ -1043,50 +1043,35 @@ udevGetDeviceType(struct udev_device *device,
- static int udevGetDeviceDetails(struct udev_device *device,
-                                 virNodeDeviceDefPtr def)
- {
--    int ret = 0;
--
-     switch (def->caps->data.type) {
--    case VIR_NODE_DEV_CAP_SYSTEM:
--        /* There's no libudev equivalent of system, so ignore it. */
--        break;
-     case VIR_NODE_DEV_CAP_PCI_DEV:
--        ret = udevProcessPCI(device, def);
--        break;
-+        return udevProcessPCI(device, def);
-     case VIR_NODE_DEV_CAP_USB_DEV:
--        ret = udevProcessUSBDevice(device, def);
--        break;
-+        return udevProcessUSBDevice(device, def);
-     case VIR_NODE_DEV_CAP_USB_INTERFACE:
--        ret = udevProcessUSBInterface(device, def);
--        break;
-+        return udevProcessUSBInterface(device, def);
-     case VIR_NODE_DEV_CAP_NET:
--        ret = udevProcessNetworkInterface(device, def);
--        break;
-+        return udevProcessNetworkInterface(device, def);
-     case VIR_NODE_DEV_CAP_SCSI_HOST:
--        ret = udevProcessSCSIHost(device, def);
--        break;
-+        return udevProcessSCSIHost(device, def);
-     case VIR_NODE_DEV_CAP_SCSI_TARGET:
--        ret = udevProcessSCSITarget(device, def);
--        break;
-+        return udevProcessSCSITarget(device, def);
-     case VIR_NODE_DEV_CAP_SCSI:
--        ret = udevProcessSCSIDevice(device, def);
--        break;
-+        return udevProcessSCSIDevice(device, def);
-     case VIR_NODE_DEV_CAP_STORAGE:
--        ret = udevProcessStorage(device, def);
--        break;
-+        return udevProcessStorage(device, def);
-     case VIR_NODE_DEV_CAP_SCSI_GENERIC:
--        ret = udevProcessSCSIGeneric(device, def);
--        break;
-+        return udevProcessSCSIGeneric(device, def);
-     case VIR_NODE_DEV_CAP_DRM:
--        ret = udevProcessDRMDevice(device, def);
--        break;
--    default:
--        virReportError(VIR_ERR_INTERNAL_ERROR,
--                       _("Unknown device type %d"), def->caps->data.type);
--        ret = -1;
-+        return udevProcessDRMDevice(device, def);
-+    case VIR_NODE_DEV_CAP_SYSTEM:
-+    case VIR_NODE_DEV_CAP_FC_HOST:
-+    case VIR_NODE_DEV_CAP_VPORTS:
-+    case VIR_NODE_DEV_CAP_LAST:
-         break;
-     }
- 
--    return ret;
-+    return 0;
- }
- 
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-nodedev-Restore-setting-of-privileged.patch b/SOURCES/libvirt-nodedev-Restore-setting-of-privileged.patch
new file mode 100644
index 0000000..94e6ada
--- /dev/null
+++ b/SOURCES/libvirt-nodedev-Restore-setting-of-privileged.patch
@@ -0,0 +1,36 @@
+From be8c0df9c361446003821c35af1531187d0080b9 Mon Sep 17 00:00:00 2001
+Message-Id: <be8c0df9c361446003821c35af1531187d0080b9@dist-git>
+From: John Ferlan <jferlan@redhat.com>
+Date: Fri, 24 Nov 2017 12:13:52 -0500
+Subject: [PATCH] nodedev: Restore setting of privileged
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1517372
+
+Commit id '36555364' removed the setting of the driver->privileged,
+which the udevProcessPCI would need in order to read the PCI device
+configs.
+
+Signed-off-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 9bfcf3ccdd2a0bb599dff27f97d5c1524cba1b79)
+Reviewed-by: Erik Skultety <eskultet@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/node_device/node_device_udev.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
+index d48334b857..ed012200f5 100644
+--- a/src/node_device/node_device_udev.c
++++ b/src/node_device/node_device_udev.c
+@@ -1933,6 +1933,8 @@ nodeStateInitialize(bool privileged,
+         return -1;
+     }
+ 
++    driver->privileged = privileged;
++
+     if (!(driver->devs = virNodeDeviceObjListNew()) ||
+         !(priv = udevEventDataNew()))
+         goto cleanup;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-nodedev-conf-Split-PCI-sub-capability-parsing-to-separate-methods.patch b/SOURCES/libvirt-nodedev-conf-Split-PCI-sub-capability-parsing-to-separate-methods.patch
deleted file mode 100644
index 9a5e2d4..0000000
--- a/SOURCES/libvirt-nodedev-conf-Split-PCI-sub-capability-parsing-to-separate-methods.patch
+++ /dev/null
@@ -1,198 +0,0 @@
-From 309e27ed960e7ac34177aa1fcac34cc6faf149fb Mon Sep 17 00:00:00 2001
-Message-Id: <309e27ed960e7ac34177aa1fcac34cc6faf149fb@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 18 May 2017 14:02:51 +0200
-Subject: [PATCH] nodedev: conf: Split PCI sub-capability parsing to separate
- methods
-
-Since there's at least SRIOV and MDEV sub-capabilities to be parsed,
-let's make the code more readable by splitting it to several logical
-blocks.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1452072
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit a5c1f3b7e028193e8cb9f9a420ac2fdd5f4a66fe)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/conf/node_device_conf.c | 142 ++++++++++++++++++++++++++------------------
- 1 file changed, 83 insertions(+), 59 deletions(-)
-
-diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
-index 02215f32d..56a26b578 100644
---- a/src/conf/node_device_conf.c
-+++ b/src/conf/node_device_conf.c
-@@ -1286,76 +1286,102 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt,
- 
- 
- static int
-+virNodeDevPCICapSRIOVPhysicalParseXML(xmlXPathContextPtr ctxt,
-+                                      virNodeDevCapPCIDevPtr pci_dev)
-+{
-+    xmlNodePtr address = virXPathNode("./address[1]", ctxt);
-+
-+    if (VIR_ALLOC(pci_dev->physical_function) < 0)
-+        return -1;
-+
-+    if (!address) {
-+        virReportError(VIR_ERR_XML_ERROR, "%s",
-+                       _("Missing address in 'phys_function' capability"));
-+        return -1;
-+    }
-+
-+    if (virPCIDeviceAddressParseXML(address,
-+                                    pci_dev->physical_function) < 0)
-+        return -1;
-+
-+    pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
-+
-+    return 0;
-+}
-+
-+
-+static int
-+virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt,
-+                                     virNodeDevCapPCIDevPtr pci_dev)
-+{
-+    int ret = -1;
-+    xmlNodePtr *addresses = NULL;
-+    int naddresses = virXPathNodeSet("./address", ctxt, &addresses);
-+    char *maxFuncsStr = virXPathString("string(./@maxCount)", ctxt);
-+    size_t i;
-+
-+    if (naddresses < 0)
-+        goto cleanup;
-+
-+    if (maxFuncsStr &&
-+        virStrToLong_uip(maxFuncsStr, NULL, 10,
-+                         &pci_dev->max_virtual_functions) < 0) {
-+        virReportError(VIR_ERR_XML_ERROR, "%s",
-+                       _("Malformed 'maxCount' parameter"));
-+        goto cleanup;
-+    }
-+
-+    if (VIR_ALLOC_N(pci_dev->virtual_functions, naddresses) < 0)
-+        goto cleanup;
-+
-+    for (i = 0; i < naddresses; i++) {
-+        virPCIDeviceAddressPtr addr = NULL;
-+
-+        if (VIR_ALLOC(addr) < 0)
-+            goto cleanup;
-+
-+        if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) {
-+            VIR_FREE(addr);
-+            goto cleanup;
-+        }
-+
-+        if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions,
-+                               pci_dev->num_virtual_functions,
-+                               addr) < 0)
-+            goto cleanup;
-+    }
-+
-+    pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
-+    ret = 0;
-+ cleanup:
-+    VIR_FREE(addresses);
-+    VIR_FREE(maxFuncsStr);
-+    return ret;
-+}
-+
-+
-+static int
- virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt,
-                                 xmlNodePtr node,
-                                 virNodeDevCapPCIDevPtr pci_dev)
- {
--    char *maxFuncsStr = virXMLPropString(node, "maxCount");
-     char *type = virXMLPropString(node, "type");
--    xmlNodePtr *addresses = NULL;
-     xmlNodePtr orignode = ctxt->node;
-     int ret = -1;
--    size_t i = 0;
- 
-     ctxt->node = node;
- 
-     if (!type) {
-         virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing capability type"));
--        goto out;
-+        goto cleanup;
-     }
- 
--    if (STREQ(type, "phys_function")) {
--        xmlNodePtr address = virXPathNode("./address[1]", ctxt);
--
--        if (VIR_ALLOC(pci_dev->physical_function) < 0)
--            goto out;
--
--        if (!address) {
--            virReportError(VIR_ERR_XML_ERROR, "%s",
--                           _("Missing address in 'phys_function' capability"));
--            goto out;
--        }
--
--        if (virPCIDeviceAddressParseXML(address,
--                                        pci_dev->physical_function) < 0)
--            goto out;
--
--        pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
--    } else if (STREQ(type, "virt_functions")) {
--        int naddresses;
--
--        if ((naddresses = virXPathNodeSet("./address", ctxt, &addresses)) < 0)
--            goto out;
--
--        if (maxFuncsStr &&
--            virStrToLong_uip(maxFuncsStr, NULL, 10,
--                             &pci_dev->max_virtual_functions) < 0) {
--            virReportError(VIR_ERR_XML_ERROR, "%s",
--                           _("Malformed 'maxCount' parameter"));
--            goto out;
--        }
--
--        if (VIR_ALLOC_N(pci_dev->virtual_functions, naddresses) < 0)
--            goto out;
--
--        for (i = 0; i < naddresses; i++) {
--            virPCIDeviceAddressPtr addr = NULL;
--
--            if (VIR_ALLOC(addr) < 0)
--                goto out;
--
--            if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) {
--                VIR_FREE(addr);
--                goto out;
--            }
--
--            if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions,
--                                   pci_dev->num_virtual_functions,
--                                   addr) < 0)
--                goto out;
--        }
--
--        pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
-+    if (STREQ(type, "phys_function") &&
-+        virNodeDevPCICapSRIOVPhysicalParseXML(ctxt, pci_dev) < 0) {
-+        goto cleanup;
-+    } else if (STREQ(type, "virt_functions") &&
-+               virNodeDevPCICapSRIOVVirtualParseXML(ctxt, pci_dev) < 0) {
-+        goto cleanup;
-     } else {
-         int hdrType = virPCIHeaderTypeFromString(type);
- 
-@@ -1364,9 +1390,7 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt,
-     }
- 
-     ret = 0;
-- out:
--    VIR_FREE(addresses);
--    VIR_FREE(maxFuncsStr);
-+ cleanup:
-     VIR_FREE(type);
-     ctxt->node = orignode;
-     return ret;
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-numa-Introduce-virDomainNumaNodeDistanceIsUsingDefaults.patch b/SOURCES/libvirt-numa-Introduce-virDomainNumaNodeDistanceIsUsingDefaults.patch
new file mode 100644
index 0000000..ee21082
--- /dev/null
+++ b/SOURCES/libvirt-numa-Introduce-virDomainNumaNodeDistanceIsUsingDefaults.patch
@@ -0,0 +1,84 @@
+From 8af3d229190faed68beda2a1493badc1eb78e108 Mon Sep 17 00:00:00 2001
+Message-Id: <8af3d229190faed68beda2a1493badc1eb78e108@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Mon, 4 Dec 2017 13:38:50 +0100
+Subject: [PATCH] numa: Introduce virDomainNumaNodeDistanceIsUsingDefaults
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1454889
+
+The function returns true/false depending on distance
+configuration being present in the domain XML.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit ab9baab7290a4a009e4e8ddfb63a2ddd19bb8091)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/numa_conf.c     | 21 +++++++++++++++++++++
+ src/conf/numa_conf.h     |  4 ++++
+ src/libvirt_private.syms |  1 +
+ 3 files changed, 26 insertions(+)
+
+diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
+index c2f0d1ca8c..8fc3b0a196 100644
+--- a/src/conf/numa_conf.c
++++ b/src/conf/numa_conf.c
+@@ -1137,6 +1137,27 @@ virDomainNumaSetNodeCount(virDomainNumaPtr numa, size_t nmem_nodes)
+     return numa->nmem_nodes;
+ }
+ 
++
++bool
++virDomainNumaNodeDistanceIsUsingDefaults(virDomainNumaPtr numa,
++                                         size_t node,
++                                         size_t sibling)
++{
++    if (node >= numa->nmem_nodes ||
++        sibling >= numa->nmem_nodes)
++        return false;
++
++    if (!numa->mem_nodes[node].distances)
++        return true;
++
++    if (numa->mem_nodes[node].distances[sibling].value == LOCAL_DISTANCE ||
++        numa->mem_nodes[node].distances[sibling].value == REMOTE_DISTANCE)
++        return true;
++
++    return false;
++}
++
++
+ size_t
+ virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
+                              size_t node,
+diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h
+index 4655de3aa7..7947fdb219 100644
+--- a/src/conf/numa_conf.h
++++ b/src/conf/numa_conf.h
+@@ -87,6 +87,10 @@ int virDomainNumatuneMaybeGetNodeset(virDomainNumaPtr numatune,
+ 
+ size_t virDomainNumaGetNodeCount(virDomainNumaPtr numa);
+ 
++bool virDomainNumaNodeDistanceIsUsingDefaults(virDomainNumaPtr numa,
++                                              size_t node,
++                                              size_t sibling)
++    ATTRIBUTE_NONNULL(1);
+ size_t virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
+                                     size_t node,
+                                     size_t sibling)
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 19543e06ae..0449b0185f 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -727,6 +727,7 @@ virDomainNumaGetNodeDistance;
+ virDomainNumaGetNodeMemoryAccessMode;
+ virDomainNumaGetNodeMemorySize;
+ virDomainNumaNew;
++virDomainNumaNodeDistanceIsUsingDefaults;
+ virDomainNumaSetNodeCount;
+ virDomainNumaSetNodeCpumask;
+ virDomainNumaSetNodeDistance;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-numa-describe-siblings-distances-within-cells.patch b/SOURCES/libvirt-numa-describe-siblings-distances-within-cells.patch
new file mode 100644
index 0000000..5439b5d
--- /dev/null
+++ b/SOURCES/libvirt-numa-describe-siblings-distances-within-cells.patch
@@ -0,0 +1,461 @@
+From 2ff472bc2ac9d01181c1dbd522153934de79907f Mon Sep 17 00:00:00 2001
+Message-Id: <2ff472bc2ac9d01181c1dbd522153934de79907f@dist-git>
+From: Wim ten Have <wim.ten.have@oracle.com>
+Date: Mon, 4 Dec 2017 13:38:47 +0100
+Subject: [PATCH] numa: describe siblings distances within cells
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1454889
+
+Add support for describing NUMA distances in a domain's <numa> <cell>
+XML description.
+
+Below is an example of a 4 node setup:
+
+  <cpu>
+    <numa>
+      <cell id='0' cpus='0-3' memory='2097152' unit='KiB'>
+        <distances>
+          <sibling id='0' value='10'/>
+          <sibling id='1' value='21'/>
+          <sibling id='2' value='31'/>
+          <sibling id='3' value='21'/>
+        </distances>
+      </cell>
+      <cell id='1' cpus='4-7' memory='2097152' unit='KiB'>
+        <distances>
+          <sibling id='0' value='21'/>
+          <sibling id='1' value='10'/>
+          <sibling id='2' value='21'/>
+          <sibling id='3' value='31'/>
+        </distances>
+      </cell>
+      <cell id='2' cpus='8-11' memory='2097152' unit='KiB'>
+        <distances>
+          <sibling id='0' value='31'/>
+          <sibling id='1' value='21'/>
+          <sibling id='2' value='10'/>
+          <sibling id='3' value='21'/>
+        </distances>
+      <cell id='3' cpus='12-15' memory='2097152' unit='KiB'>
+        <distances>
+          <sibling id='0' value='21'/>
+          <sibling id='1' value='31'/>
+          <sibling id='2' value='21'/>
+          <sibling id='3' value='10'/>
+        </distances>
+      </cell>
+    </numa>
+  </cpu>
+
+A <cell> defines a NUMA node. <distances> describes the NUMA distance
+from the <cell> to the other NUMA nodes (the <sibling>s).  For example,
+in above XML description, the distance between NUMA node0 <cell id='0'
+...> and NUMA node2 <sibling id='2' ...> is 31.
+
+Valid distance values are '10 <= value <= 255'.  A distance value of 10
+represents the distance to the node itself.  A distance value of 20
+represents the default value for remote nodes but other values are
+possible depending on the physical topology of the system.
+
+When distances are not fully described, any missing sibling distance
+values will default to 10 for local nodes and 20 for remote nodes.
+
+If distance is given for A -> B, then we default B -> A to the same
+value instead of 20.
+
+Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
+Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
+Signed-off-by: Jim Fehlig <jfehlig@suse.com>
+(cherry picked from commit 74119a03f184b79dcad28aa1e6f4ede6dc444998)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/formatdomain.html.in   |  64 ++++++++++++++-
+ docs/schemas/basictypes.rng |   7 ++
+ docs/schemas/cputypes.rng   |  18 +++++
+ src/conf/numa_conf.c        | 191 +++++++++++++++++++++++++++++++++++++++++++-
+ 4 files changed, 276 insertions(+), 4 deletions(-)
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index 62dd6e1ec4..a5adf5d9aa 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -1529,7 +1529,69 @@
+     </p>
+ 
+     <p>
+-      This guest NUMA specification is currently available only for QEMU/KVM.
++      This guest NUMA specification is currently available only for
++      QEMU/KVM and Xen.
++    </p>
++
++    <p>
++      A NUMA hardware architecture supports the notion of distances
++      between NUMA cells. <span class="since">Since 3.10.0</span> it
++      is possible to define the distance between NUMA cells using the
++      <code>distances</code> element within a NUMA <code>cell</code>
++      description. The <code>sibling</code> sub-element is used to
++      specify the distance value between sibling NUMA cells. For more
++      details, see the chapter explaining the system's SLIT (System
++      Locality Information Table) within the ACPI (Advanced
++      Configuration and Power Interface) specification.
++    </p>
++
++<pre>
++...
++&lt;cpu&gt;
++  ...
++  &lt;numa&gt;
++    &lt;cell id='0' cpus='0,4-7' memory='512000' unit='KiB'&gt;
++      &lt;distances&gt;
++        &lt;sibling id='0' value='10'/&gt;
++        &lt;sibling id='1' value='21'/&gt;
++        &lt;sibling id='2' value='31'/&gt;
++        &lt;sibling id='3' value='41'/&gt;
++      &lt;/distances&gt;
++    &lt;/cell&gt;
++    &lt;cell id='1' cpus='1,8-10,12-15' memory='512000' unit='KiB' memAccess='shared'&gt;
++      &lt;distances&gt;
++        &lt;sibling id='0' value='21'/&gt;
++        &lt;sibling id='1' value='10'/&gt;
++        &lt;sibling id='2' value='21'/&gt;
++        &lt;sibling id='3' value='31'/&gt;
++      &lt;/distances&gt;
++    &lt;/cell&gt;
++    &lt;cell id='2' cpus='2,11' memory='512000' unit='KiB' memAccess='shared'&gt;
++      &lt;distances&gt;
++        &lt;sibling id='0' value='31'/&gt;
++        &lt;sibling id='1' value='21'/&gt;
++        &lt;sibling id='2' value='10'/&gt;
++        &lt;sibling id='3' value='21'/&gt;
++      &lt;/distances&gt;
++    &lt;/cell&gt;
++    &lt;cell id='3' cpus='3' memory='512000' unit='KiB'&gt;
++      &lt;distances&gt;
++        &lt;sibling id='0' value='41'/&gt;
++        &lt;sibling id='1' value='31'/&gt;
++        &lt;sibling id='2' value='21'/&gt;
++        &lt;sibling id='3' value='10'/&gt;
++      &lt;/distances&gt;
++    &lt;/cell&gt;
++  &lt;/numa&gt;
++  ...
++&lt;/cpu&gt;
++...</pre>
++
++    <p>
++      Describing distances between NUMA cells is currently only supported
++      by Xen. If no <code>distances</code> are given to describe
++      the SLIT data between different cells, it will default to a scheme
++      using 10 for local and 20 for remote distances.
+     </p>
+ 
+     <h3><a id="elementsEvents">Events configuration</a></h3>
+diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
+index 1ea667cdf6..1a18cd31b1 100644
+--- a/docs/schemas/basictypes.rng
++++ b/docs/schemas/basictypes.rng
+@@ -77,6 +77,13 @@
+     </choice>
+   </define>
+ 
++  <define name="numaDistanceValue">
++    <data type="unsignedInt">
++      <param name="minInclusive">10</param>
++      <param name="maxInclusive">255</param>
++    </data>
++  </define>
++
+   <define name="pciaddress">
+     <optional>
+       <attribute name="domain">
+diff --git a/docs/schemas/cputypes.rng b/docs/schemas/cputypes.rng
+index 3eef16abce..c45b6dfb28 100644
+--- a/docs/schemas/cputypes.rng
++++ b/docs/schemas/cputypes.rng
+@@ -129,6 +129,24 @@
+           </choice>
+         </attribute>
+       </optional>
++      <optional>
++        <element name="distances">
++          <oneOrMore>
++            <ref name="numaDistance"/>
++          </oneOrMore>
++        </element>
++      </optional>
++    </element>
++  </define>
++
++  <define name="numaDistance">
++    <element name="sibling">
++      <attribute name="id">
++        <ref name="unsignedInt"/>
++      </attribute>
++      <attribute name="value">
++        <ref name="numaDistanceValue"/>
++      </attribute>
+     </element>
+   </define>
+ 
+diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
+index b71dc012c5..5fbcc72041 100644
+--- a/src/conf/numa_conf.c
++++ b/src/conf/numa_conf.c
+@@ -29,6 +29,15 @@
+ #include "virnuma.h"
+ #include "virstring.h"
+ 
++/*
++ * Distance definitions defined Conform ACPI 2.0 SLIT.
++ * See include/linux/topology.h
++ */
++#define LOCAL_DISTANCE          10
++#define REMOTE_DISTANCE         20
++/* SLIT entry value is a one-byte unsigned integer. */
++#define UNREACHABLE            255
++
+ #define VIR_FROM_THIS VIR_FROM_DOMAIN
+ 
+ VIR_ENUM_IMPL(virDomainNumatuneMemMode,
+@@ -48,6 +57,8 @@ VIR_ENUM_IMPL(virDomainMemoryAccess, VIR_DOMAIN_MEMORY_ACCESS_LAST,
+               "shared",
+               "private")
+ 
++typedef struct _virDomainNumaDistance virDomainNumaDistance;
++typedef virDomainNumaDistance *virDomainNumaDistancePtr;
+ 
+ typedef struct _virDomainNumaNode virDomainNumaNode;
+ typedef virDomainNumaNode *virDomainNumaNodePtr;
+@@ -66,6 +77,12 @@ struct _virDomainNuma {
+         virBitmapPtr nodeset;   /* host memory nodes where this guest node resides */
+         virDomainNumatuneMemMode mode;  /* memory mode selection */
+         virDomainMemoryAccess memAccess; /* shared memory access configuration */
++
++        struct _virDomainNumaDistance {
++            unsigned int value; /* locality value for node i->j or j->i */
++            unsigned int cellid;
++        } *distances;           /* remote node distances */
++        size_t ndistances;
+     } *mem_nodes;           /* guest node configuration */
+     size_t nmem_nodes;
+ 
+@@ -686,6 +703,144 @@ virDomainNumatuneNodesetIsAvailable(virDomainNumaPtr numatune,
+ }
+ 
+ 
++static int
++virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr def,
++                                     xmlXPathContextPtr ctxt,
++                                     unsigned int cur_cell)
++{
++    int ret = -1;
++    int sibling;
++    char *tmp = NULL;
++    xmlNodePtr *nodes = NULL;
++    size_t i, ndistances = def->nmem_nodes;
++
++    if (!ndistances)
++        return 0;
++
++    /* check if NUMA distances definition is present */
++    if (!virXPathNode("./distances[1]", ctxt))
++        return 0;
++
++    if ((sibling = virXPathNodeSet("./distances[1]/sibling", ctxt, &nodes)) <= 0) {
++        virReportError(VIR_ERR_XML_ERROR, "%s",
++                       _("NUMA distances defined without siblings"));
++        goto cleanup;
++    }
++
++    for (i = 0; i < sibling; i++) {
++        virDomainNumaDistancePtr ldist, rdist;
++        unsigned int sibling_id, sibling_value;
++
++        /* siblings are in order of parsing or explicitly numbered */
++        if (!(tmp = virXMLPropString(nodes[i], "id"))) {
++            virReportError(VIR_ERR_XML_ERROR,
++                           _("Missing 'id' attribute in NUMA "
++                             "distances under 'cell id %d'"),
++                           cur_cell);
++            goto cleanup;
++        }
++
++        /* The "id" needs to be applicable */
++        if (virStrToLong_uip(tmp, NULL, 10, &sibling_id) < 0) {
++            virReportError(VIR_ERR_XML_ERROR,
++                           _("Invalid 'id' attribute in NUMA "
++                             "distances for sibling: '%s'"),
++                           tmp);
++            goto cleanup;
++        }
++        VIR_FREE(tmp);
++
++        /* The "id" needs to be within numa/cell range */
++        if (sibling_id >= ndistances) {
++            virReportError(VIR_ERR_XML_ERROR,
++                           _("'sibling_id %d' does not refer to a "
++                             "valid cell within NUMA 'cell id %d'"),
++                           sibling_id, cur_cell);
++            goto cleanup;
++        }
++
++        /* We need a locality value. Check and correct
++         * distance to local and distance to remote node.
++         */
++        if (!(tmp = virXMLPropString(nodes[i], "value"))) {
++            virReportError(VIR_ERR_XML_ERROR,
++                           _("Missing 'value' attribute in NUMA distances "
++                             "under 'cell id %d' for 'sibling id %d'"),
++                           cur_cell, sibling_id);
++            goto cleanup;
++        }
++
++        /* The "value" needs to be applicable */
++        if (virStrToLong_uip(tmp, NULL, 10, &sibling_value) < 0) {
++            virReportError(VIR_ERR_XML_ERROR,
++                           _("'value %s' is invalid for "
++                             "'sibling id %d' under NUMA 'cell id %d'"),
++                           tmp, sibling_id, cur_cell);
++            goto cleanup;
++        }
++        VIR_FREE(tmp);
++
++        /* Assure LOCAL_DISTANCE <= "value" <= UNREACHABLE
++         * and correct LOCAL_DISTANCE setting if such applies.
++         */
++        if ((sibling_value < LOCAL_DISTANCE ||
++             sibling_value > UNREACHABLE) ||
++            (sibling_id == cur_cell &&
++             sibling_value != LOCAL_DISTANCE) ||
++            (sibling_id != cur_cell &&
++             sibling_value == LOCAL_DISTANCE)) {
++            virReportError(VIR_ERR_XML_ERROR,
++                           _("'value %d' is invalid for "
++                             "'sibling id %d' under NUMA 'cell id %d'"),
++                           sibling_value, sibling_id, cur_cell);
++            goto cleanup;
++        }
++
++        /* Apply the local / remote distance */
++        ldist = def->mem_nodes[cur_cell].distances;
++        if (!ldist) {
++            if (VIR_ALLOC_N(ldist, ndistances) < 0)
++                goto cleanup;
++
++            ldist[cur_cell].value = LOCAL_DISTANCE;
++            ldist[cur_cell].cellid = cur_cell;
++            def->mem_nodes[cur_cell].ndistances = ndistances;
++        }
++
++        ldist[sibling_id].cellid = sibling_id;
++        ldist[sibling_id].value = sibling_value;
++        def->mem_nodes[cur_cell].distances = ldist;
++
++        /* Apply symmetry if none given */
++        rdist = def->mem_nodes[sibling_id].distances;
++        if (!rdist) {
++            if (VIR_ALLOC_N(rdist, ndistances) < 0)
++                goto cleanup;
++
++            rdist[sibling_id].value = LOCAL_DISTANCE;
++            rdist[sibling_id].cellid = sibling_id;
++            def->mem_nodes[sibling_id].ndistances = ndistances;
++        }
++
++        rdist[cur_cell].cellid = cur_cell;
++        if (!rdist[cur_cell].value)
++            rdist[cur_cell].value = sibling_value;
++        def->mem_nodes[sibling_id].distances = rdist;
++    }
++
++    ret = 0;
++
++ cleanup:
++    if (ret) {
++        for (i = 0; i < ndistances; i++)
++            VIR_FREE(def->mem_nodes[i].distances);
++    }
++    VIR_FREE(nodes);
++    VIR_FREE(tmp);
++
++    return ret;
++}
++
+ int
+ virDomainNumaDefCPUParseXML(virDomainNumaPtr def,
+                             xmlXPathContextPtr ctxt)
+@@ -694,7 +849,7 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def,
+     xmlNodePtr oldNode = ctxt->node;
+     char *tmp = NULL;
+     int n;
+-    size_t i;
++    size_t i, j;
+     int ret = -1;
+ 
+     /* check if NUMA definition is present */
+@@ -712,7 +867,6 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def,
+     def->nmem_nodes = n;
+ 
+     for (i = 0; i < n; i++) {
+-        size_t j;
+         int rc;
+         unsigned int cur_cell = i;
+ 
+@@ -788,6 +942,10 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def,
+             def->mem_nodes[cur_cell].memAccess = rc;
+             VIR_FREE(tmp);
+         }
++
++        /* Parse NUMA distances info */
++        if (virDomainNumaDefNodeDistanceParseXML(def, ctxt, cur_cell) < 0)
++                goto cleanup;
+     }
+ 
+     ret = 0;
+@@ -815,6 +973,8 @@ virDomainNumaDefCPUFormatXML(virBufferPtr buf,
+     virBufferAddLit(buf, "<numa>\n");
+     virBufferAdjustIndent(buf, 2);
+     for (i = 0; i < ncells; i++) {
++        int ndistances;
++
+         memAccess = virDomainNumaGetNodeMemoryAccessMode(def, i);
+ 
+         if (!(cpustr = virBitmapFormat(virDomainNumaGetNodeCpumask(def, i))))
+@@ -829,7 +989,32 @@ virDomainNumaDefCPUFormatXML(virBufferPtr buf,
+         if (memAccess)
+             virBufferAsprintf(buf, " memAccess='%s'",
+                               virDomainMemoryAccessTypeToString(memAccess));
+-        virBufferAddLit(buf, "/>\n");
++
++        ndistances = def->mem_nodes[i].ndistances;
++        if (!ndistances) {
++            virBufferAddLit(buf, "/>\n");
++        } else {
++            size_t j;
++            virDomainNumaDistancePtr distances = def->mem_nodes[i].distances;
++
++            virBufferAddLit(buf, ">\n");
++            virBufferAdjustIndent(buf, 2);
++            virBufferAddLit(buf, "<distances>\n");
++            virBufferAdjustIndent(buf, 2);
++            for (j = 0; j < ndistances; j++) {
++                if (distances[j].value) {
++                    virBufferAddLit(buf, "<sibling");
++                    virBufferAsprintf(buf, " id='%d'", distances[j].cellid);
++                    virBufferAsprintf(buf, " value='%d'", distances[j].value);
++                    virBufferAddLit(buf, "/>\n");
++                }
++            }
++            virBufferAdjustIndent(buf, -2);
++            virBufferAddLit(buf, "</distances>\n");
++            virBufferAdjustIndent(buf, -2);
++            virBufferAddLit(buf, "</cell>\n");
++        }
++
+         VIR_FREE(cpustr);
+     }
+     virBufferAdjustIndent(buf, -2);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-nwfilter-don-t-crash-listing-filters-in-unprivileged-daemon.patch b/SOURCES/libvirt-nwfilter-don-t-crash-listing-filters-in-unprivileged-daemon.patch
new file mode 100644
index 0000000..a41ed00
--- /dev/null
+++ b/SOURCES/libvirt-nwfilter-don-t-crash-listing-filters-in-unprivileged-daemon.patch
@@ -0,0 +1,75 @@
+From 5bb56c9849bdef1f7108895a20a9f348107dbfb2 Mon Sep 17 00:00:00 2001
+Message-Id: <5bb56c9849bdef1f7108895a20a9f348107dbfb2@dist-git>
+From: "Daniel P. Berrange" <berrange@redhat.com>
+Date: Wed, 6 Dec 2017 12:11:17 -0500
+Subject: [PATCH] nwfilter: don't crash listing filters in unprivileged daemon
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1522879
+
+The unprivileged libvirtd does not support nwfilter config, by leaves the
+driver active. It is supposed to result in all APIs being an effective
+no-op, but several APIs rely on driver->nwfilters being non-NULL, or they
+will reference a NULL pointer. Rather than adding checks for NULL in many
+places, just make sure  driver->nwfilters is always initialized.
+
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
+(cherry picked from commit 7993554f70fd8d512dfde484490bcd1601b60b33)
+Signed-off-by: John Ferlan <jferlan@redhat.com>
+Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/nwfilter/nwfilter_driver.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
+index 2f9a51c405..885dbcc282 100644
+--- a/src/nwfilter/nwfilter_driver.c
++++ b/src/nwfilter/nwfilter_driver.c
+@@ -189,6 +189,8 @@ nwfilterStateInitialize(bool privileged,
+     /* remember that we are going to use firewalld */
+     driver->watchingFirewallD = (sysbus != NULL);
+     driver->privileged = privileged;
++    if (!(driver->nwfilters = virNWFilterObjListNew()))
++        goto error;
+ 
+     if (!privileged)
+         return 0;
+@@ -244,9 +246,6 @@ nwfilterStateInitialize(bool privileged,
+         goto error;
+     }
+ 
+-    if (!(driver->nwfilters = virNWFilterObjListNew()))
+-        goto error;
+-
+     if (virNWFilterObjListLoadAllConfigs(driver->nwfilters, driver->configDir) < 0)
+         goto error;
+ 
+@@ -271,6 +270,7 @@ nwfilterStateInitialize(bool privileged,
+     virNWFilterIPAddrMapShutdown();
+ 
+  err_free_driverstate:
++    virNWFilterObjListFree(driver->nwfilters);
+     VIR_FREE(driver);
+ 
+     return -1;
+@@ -349,13 +349,13 @@ nwfilterStateCleanup(void)
+ 
+         nwfilterDriverRemoveDBusMatches();
+ 
+-        /* free inactive nwfilters */
+-        virNWFilterObjListFree(driver->nwfilters);
+-
+         VIR_FREE(driver->configDir);
+         nwfilterDriverUnlock();
+     }
+ 
++    /* free inactive nwfilters */
++    virNWFilterObjListFree(driver->nwfilters);
++
+     virMutexDestroy(&driver->lock);
+     VIR_FREE(driver);
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-pci-fix-link-maximum-speed-detection.patch b/SOURCES/libvirt-pci-fix-link-maximum-speed-detection.patch
deleted file mode 100644
index 928b70b..0000000
--- a/SOURCES/libvirt-pci-fix-link-maximum-speed-detection.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From e971b5b913bc215ffb82419ae3db24a17ea094e8 Mon Sep 17 00:00:00 2001
-Message-Id: <e971b5b913bc215ffb82419ae3db24a17ea094e8@dist-git>
-From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
- <marmarek@invisiblethingslab.com>
-Date: Wed, 24 May 2017 12:56:09 -0400
-Subject: [PATCH] pci: fix link maximum speed detection
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Commit 8e09663 "pci: recognize/report GEN4 (PCIe 4.0) card 16GT/s Link
-speed" introduced another speed into enum, but mistakenly also altered
-field width, so one bit of link width was included there.
-
-Resolves: https://bugzilla.redhat.com/1455017
-
-Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
-(cherry picked from commit 1128769f9ee50bb250333a5a5d276afbe74711ea)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/util/virpci.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/util/virpci.c b/src/util/virpci.c
-index c89b94b5f..a2db65d7d 100644
---- a/src/util/virpci.c
-+++ b/src/util/virpci.c
-@@ -147,7 +147,7 @@ struct _virPCIDeviceList {
- #define PCI_EXP_DEVCAP          0x4     /* Device capabilities */
- #define PCI_EXP_DEVCAP_FLR     (1<<28)  /* Function Level Reset */
- #define PCI_EXP_LNKCAP          0xc     /* Link Capabilities */
--#define PCI_EXP_LNKCAP_SPEED    0x0001f /* Maximum Link Speed */
-+#define PCI_EXP_LNKCAP_SPEED    0x0000f /* Maximum Link Speed */
- #define PCI_EXP_LNKCAP_WIDTH    0x003f0 /* Maximum Link Width */
- #define PCI_EXP_LNKSTA          0x12    /* Link Status */
- #define PCI_EXP_LNKSTA_SPEED    0x000f  /* Negotiated Link Speed */
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-pci-recognize-report-GEN4-PCIe-4.0-card-16GT-s-Link-speed.patch b/SOURCES/libvirt-pci-recognize-report-GEN4-PCIe-4.0-card-16GT-s-Link-speed.patch
deleted file mode 100644
index 843d60c..0000000
--- a/SOURCES/libvirt-pci-recognize-report-GEN4-PCIe-4.0-card-16GT-s-Link-speed.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From 7cdf18b541dfdbbbe4ed1e35179dd41c0d473648 Mon Sep 17 00:00:00 2001
-Message-Id: <7cdf18b541dfdbbbe4ed1e35179dd41c0d473648@dist-git>
-From: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
-Date: Mon, 17 Apr 2017 17:16:44 -0400
-Subject: [PATCH] pci: recognize/report GEN4 (PCIe 4.0) card 16GT/s Link speed
-
-Without this added enum value, nodedev-dumpxml of a GEN4 (PCIe 4.0)
-card will fail (due to the unrecognized link speed), and since
-nodedev-detach and nodedev-reattach internally do a dumpxml+parse,
-they will also fail. With this patch, all those operations succeed.
-
-Resolves: https://bugzilla.redhat.com/1442831
-
-Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
-(cherry picked from commit 8e09663f7ff70b10a560746f17897d2c67c8460d)
----
- src/util/virpci.c | 4 ++--
- src/util/virpci.h | 1 +
- 2 files changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/src/util/virpci.c b/src/util/virpci.c
-index 65c108f2e..c89b94b5f 100644
---- a/src/util/virpci.c
-+++ b/src/util/virpci.c
-@@ -53,7 +53,7 @@ VIR_LOG_INIT("util.pci");
- #define PCI_ADDR_LEN 13 /* "XXXX:XX:XX.X" */
- 
- VIR_ENUM_IMPL(virPCIELinkSpeed, VIR_PCIE_LINK_SPEED_LAST,
--              "", "2.5", "5", "8")
-+              "", "2.5", "5", "8", "16")
- 
- VIR_ENUM_IMPL(virPCIStubDriver, VIR_PCI_STUB_DRIVER_LAST,
-               "none",
-@@ -147,7 +147,7 @@ struct _virPCIDeviceList {
- #define PCI_EXP_DEVCAP          0x4     /* Device capabilities */
- #define PCI_EXP_DEVCAP_FLR     (1<<28)  /* Function Level Reset */
- #define PCI_EXP_LNKCAP          0xc     /* Link Capabilities */
--#define PCI_EXP_LNKCAP_SPEED    0x0000f /* Maximum Link Speed */
-+#define PCI_EXP_LNKCAP_SPEED    0x0001f /* Maximum Link Speed */
- #define PCI_EXP_LNKCAP_WIDTH    0x003f0 /* Maximum Link Width */
- #define PCI_EXP_LNKSTA          0x12    /* Link Status */
- #define PCI_EXP_LNKSTA_SPEED    0x000f  /* Negotiated Link Speed */
-diff --git a/src/util/virpci.h b/src/util/virpci.h
-index 8637c2c68..570684e75 100644
---- a/src/util/virpci.h
-+++ b/src/util/virpci.h
-@@ -58,6 +58,7 @@ typedef enum {
-     VIR_PCIE_LINK_SPEED_25,
-     VIR_PCIE_LINK_SPEED_5,
-     VIR_PCIE_LINK_SPEED_8,
-+    VIR_PCIE_LINK_SPEED_16,
-     VIR_PCIE_LINK_SPEED_LAST
- } virPCIELinkSpeed;
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Add-QEMU_CAPS_DEVICE_ISA_SERIAL.patch b/SOURCES/libvirt-qemu-Add-QEMU_CAPS_DEVICE_ISA_SERIAL.patch
new file mode 100644
index 0000000..30a9a3f
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Add-QEMU_CAPS_DEVICE_ISA_SERIAL.patch
@@ -0,0 +1,361 @@
+From 62fe4cb859c0e86460879bcf676f1107ccd93129 Mon Sep 17 00:00:00 2001
+Message-Id: <62fe4cb859c0e86460879bcf676f1107ccd93129@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:17 +0100
+Subject: [PATCH] qemu: Add QEMU_CAPS_DEVICE_ISA_SERIAL
+
+All serial devices shoule have an associated capability.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit b0f1c291a0d3cbf2881a308a39f3f390f1cabcf5)
+
+ Conflicts:
+	src/qemu/qemu_capabilities.c
+	src/qemu/qemu_capabilities.h
+	tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml
+	tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml
+	tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+	tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+	tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+	tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
+
+	Insert the new capability in the right place, both in the
+	declaration and in the caps.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c                            | 3 +++
+ src/qemu/qemu_capabilities.h                            | 2 ++
+ tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml       | 1 +
+ tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml | 1 +
+ tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml | 1 +
+ tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml         | 1 +
+ tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml        | 1 +
+ tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml         | 1 +
+ tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml        | 1 +
+ tests/qemuhelptest.c                                    | 5 +++++
+ 22 files changed, 29 insertions(+)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 322e0423d6..08c6653424 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -451,6 +451,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
+               "sclplmconsole",
+ 
+               "disk-share-rw",
++
++              "isa-serial",
+     );
+ 
+ 
+@@ -1681,6 +1683,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
+     { "spapr-pci-host-bridge", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE },
+     { "spapr-vty", QEMU_CAPS_DEVICE_SPAPR_VTY },
+     { "sclplmconsole", QEMU_CAPS_DEVICE_SCLPLMCONSOLE },
++    { "isa-serial", QEMU_CAPS_DEVICE_ISA_SERIAL },
+ };
+ 
+ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = {
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index c3a15948cf..f0bd88f897 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -438,6 +438,8 @@ typedef enum {
+ 
+     QEMU_CAPS_DISK_SHARE_RW, /* share-rw=on for concurrent disk access */
+ 
++    QEMU_CAPS_DEVICE_ISA_SERIAL, /* -device isa-serial */
++
+     QEMU_CAPS_LAST /* this must always be the last item */
+ } virQEMUCapsFlags;
+ 
+diff --git a/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml
+index 956284d5d3..d560811ab7 100644
+--- a/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml
+@@ -109,6 +109,7 @@
+   <flag name='device-tray-moved-event'/>
+   <flag name='display'/>
+   <flag name='query-cpu-definitions'/>
++  <flag name='isa-serial'/>
+   <version>1002002</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml
+index 99384ce5e6..576475f7fa 100644
+--- a/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml
+@@ -127,6 +127,7 @@
+   <flag name='nec-usb-xhci-ports'/>
+   <flag name='display'/>
+   <flag name='query-cpu-definitions'/>
++  <flag name='isa-serial'/>
+   <version>1003001</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml
+index aea043c57d..0c271d3e41 100644
+--- a/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml
+@@ -128,6 +128,7 @@
+   <flag name='nec-usb-xhci-ports'/>
+   <flag name='display'/>
+   <flag name='query-cpu-definitions'/>
++  <flag name='isa-serial'/>
+   <version>1004002</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
+index 6f860e4f25..5c667975bf 100644
+--- a/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
+@@ -140,6 +140,7 @@
+   <flag name='vhost-scsi'/>
+   <flag name='query-cpu-definitions'/>
+   <flag name='kernel-irqchip'/>
++  <flag name='isa-serial'/>
+   <version>1005003</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
+index e5dc8360de..8ae07a91db 100644
+--- a/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
+@@ -145,6 +145,7 @@
+   <flag name='vhost-scsi'/>
+   <flag name='query-cpu-definitions'/>
+   <flag name='kernel-irqchip'/>
++  <flag name='isa-serial'/>
+   <version>1006000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
+index 86d87eaf0c..34bd6be1cd 100644
+--- a/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
+@@ -147,6 +147,7 @@
+   <flag name='vhost-scsi'/>
+   <flag name='query-cpu-definitions'/>
+   <flag name='kernel-irqchip'/>
++  <flag name='isa-serial'/>
+   <version>1007000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
+index 2fa551b1a0..0d7c144ff7 100644
+--- a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
+@@ -163,6 +163,7 @@
+   <flag name='query-cpu-definitions'/>
+   <flag name='query-named-block-nodes'/>
+   <flag name='kernel-irqchip'/>
++  <flag name='isa-serial'/>
+   <version>2001001</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+index c95025b41f..23356f4092 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+@@ -180,6 +180,7 @@
+   <flag name='machine.pseries.resize-hpt'/>
+   <flag name='spapr-vty'/>
+   <flag name='disk-share-rw'/>
++  <flag name='isa-serial'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.10.0)</package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+index 33db3e6674..e04e530b95 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+@@ -225,6 +225,7 @@
+   <flag name='vxhs'/>
+   <flag name='virtio-blk.num-queues'/>
+   <flag name='disk-share-rw'/>
++  <flag name='isa-serial'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.10.0)</package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
+index f97e4cb813..5007523c1f 100644
+--- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
+@@ -188,6 +188,7 @@
+   <flag name='vnc-multi-servers'/>
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
++  <flag name='isa-serial'/>
+   <version>2004000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
+index 2ba40fc494..a9ad292d01 100644
+--- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
+@@ -194,6 +194,7 @@
+   <flag name='vnc-multi-servers'/>
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
++  <flag name='isa-serial'/>
+   <version>2005000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
+index 0b34fa30d4..e699bdbafd 100644
+--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
+@@ -172,6 +172,7 @@
+   <flag name='vnc-multi-servers'/>
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
++  <flag name='isa-serial'/>
+   <version>2006000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
+index d41d578c7e..f4c1de7e1d 100644
+--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
+@@ -172,6 +172,7 @@
+   <flag name='vnc-multi-servers'/>
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
++  <flag name='isa-serial'/>
+   <version>2006000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
+index 5ff8598fc8..27d99bd937 100644
+--- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
+@@ -168,6 +168,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='spapr-vty'/>
++  <flag name='isa-serial'/>
+   <version>2006000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
+index bdf006f6be..97621612ab 100644
+--- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
+@@ -204,6 +204,7 @@
+   <flag name='vnc-multi-servers'/>
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
++  <flag name='isa-serial'/>
+   <version>2006000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
+index 59adff6c97..e4ea9452c5 100644
+--- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
+@@ -208,6 +208,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='isa-serial'/>
+   <version>2007000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.7.0)</package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
+index 3165b2dee3..c6d3e21d5c 100644
+--- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
+@@ -210,6 +210,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='isa-serial'/>
+   <version>2008000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.8.0)</package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+index 3b70b1a407..f5cf0ba932 100644
+--- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+@@ -175,6 +175,7 @@
+   <flag name='virtio-blk.num-queues'/>
+   <flag name='spapr-vty'/>
+   <flag name='disk-share-rw'/>
++  <flag name='isa-serial'/>
+   <version>2009000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.9.0)</package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
+index 0ea9a2fce3..82cc4e79f4 100644
+--- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
+@@ -222,6 +222,7 @@
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='virtio-blk.num-queues'/>
+   <flag name='disk-share-rw'/>
++  <flag name='isa-serial'/>
+   <version>2009000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.9.0)</package>
+diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
+index 1a6e7092fd..0e05aa9d8a 100644
+--- a/tests/qemuhelptest.c
++++ b/tests/qemuhelptest.c
+@@ -174,6 +174,7 @@ mymain(void)
+             QEMU_CAPS_DEVICE_USB_KBD,
+             QEMU_CAPS_DEVICE_RTL8139,
+             QEMU_CAPS_DEVICE_E1000,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_DEVICE_VIRTIO_NET);
+     DO_TEST("qemu-kvm-0.12.3", 12003, 1, 0,
+             QEMU_CAPS_DRIVE_BOOT,
+@@ -210,6 +211,7 @@ mymain(void)
+             QEMU_CAPS_DEVICE_USB_KBD,
+             QEMU_CAPS_DEVICE_RTL8139,
+             QEMU_CAPS_DEVICE_E1000,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_DEVICE_VIRTIO_NET);
+     DO_TEST("qemu-kvm-0.13.0", 13000, 1, 0,
+             QEMU_CAPS_DRIVE_BOOT,
+@@ -258,6 +260,7 @@ mymain(void)
+             QEMU_CAPS_DEVICE_IVSHMEM,
+             QEMU_CAPS_DEVICE_RTL8139,
+             QEMU_CAPS_DEVICE_E1000,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_DEVICE_VIRTIO_NET);
+     DO_TEST("qemu-1.0", 1000000, 0, 0,
+             QEMU_CAPS_DRIVE_CACHE_UNSAFE,
+@@ -328,6 +331,7 @@ mymain(void)
+             QEMU_CAPS_DEVICE_RTL8139,
+             QEMU_CAPS_DEVICE_E1000,
+             QEMU_CAPS_DEVICE_VIRTIO_NET,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_DISPLAY);
+     DO_TEST("qemu-1.1.0", 1001000, 0, 0,
+             QEMU_CAPS_DRIVE_CACHE_UNSAFE,
+@@ -411,6 +415,7 @@ mymain(void)
+             QEMU_CAPS_DEVICE_RTL8139,
+             QEMU_CAPS_DEVICE_E1000,
+             QEMU_CAPS_DEVICE_VIRTIO_NET,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_DISPLAY);
+     DO_TEST_FULL("qemu-1.2.0", 1002000, 0, 0, VIR_ERR_CONFIG_UNSUPPORTED,
+             QEMU_CAPS_LAST);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Add-QEMU_CAPS_DEVICE_PL011.patch b/SOURCES/libvirt-qemu-Add-QEMU_CAPS_DEVICE_PL011.patch
new file mode 100644
index 0000000..df40ba1
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Add-QEMU_CAPS_DEVICE_PL011.patch
@@ -0,0 +1,90 @@
+From 5b5832decc253ce95535c9a6cf1eee6b5ed475fc Mon Sep 17 00:00:00 2001
+Message-Id: <5b5832decc253ce95535c9a6cf1eee6b5ed475fc@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:19 +0100
+Subject: [PATCH] qemu: Add QEMU_CAPS_DEVICE_PL011
+
+All serial devices shoule have an associated capability.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit a45ecb7bf6b43a863ef0980156e822d414975994)
+
+ Conflicts:
+	tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml
+	tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml
+
+	These caps do not exists in the current version.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c                            | 4 ++++
+ src/qemu/qemu_capabilities.h                            | 3 +++
+ tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml | 1 +
+ tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml | 1 +
+ 4 files changed, 9 insertions(+)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 08c6653424..ae5448eaaa 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -453,6 +453,9 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
+               "disk-share-rw",
+ 
+               "isa-serial",
++
++              /* 280 */
++              "pl011",
+     );
+ 
+ 
+@@ -1684,6 +1687,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
+     { "spapr-vty", QEMU_CAPS_DEVICE_SPAPR_VTY },
+     { "sclplmconsole", QEMU_CAPS_DEVICE_SCLPLMCONSOLE },
+     { "isa-serial", QEMU_CAPS_DEVICE_ISA_SERIAL },
++    { "pl011", QEMU_CAPS_DEVICE_PL011 },
+ };
+ 
+ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = {
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index f0bd88f897..c809f83404 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -440,6 +440,9 @@ typedef enum {
+ 
+     QEMU_CAPS_DEVICE_ISA_SERIAL, /* -device isa-serial */
+ 
++    /* 280 */
++    QEMU_CAPS_DEVICE_PL011, /* -device pl011 (not user-instantiable) */
++
+     QEMU_CAPS_LAST /* this must always be the last item */
+ } virQEMUCapsFlags;
+ 
+diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
+index e699bdbafd..d3e2e18faa 100644
+--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
+@@ -173,6 +173,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='isa-serial'/>
++  <flag name='pl011'/>
+   <version>2006000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
+index f4c1de7e1d..bc86d03537 100644
+--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
+@@ -173,6 +173,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='isa-serial'/>
++  <flag name='pl011'/>
+   <version>2006000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Add-QEMU_CAPS_DEVICE_SPAPR_VTY.patch b/SOURCES/libvirt-qemu-Add-QEMU_CAPS_DEVICE_SPAPR_VTY.patch
new file mode 100644
index 0000000..7599fd4
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Add-QEMU_CAPS_DEVICE_SPAPR_VTY.patch
@@ -0,0 +1,195 @@
+From a8befcda79640ae13c9787cb3be54ca2ee861077 Mon Sep 17 00:00:00 2001
+Message-Id: <a8befcda79640ae13c9787cb3be54ca2ee861077@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:22:51 +0100
+Subject: [PATCH] qemu: Add QEMU_CAPS_DEVICE_SPAPR_VTY
+
+Up until now we assumed the spapr-vty device would always be
+present, which is not very nice. Check for its availability before
+using it instead.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 87eabeb17d637b753dbb1e63e417e25bbd0f7d61)
+
+ Conflicts:
+	src/qemu/qemu_capabilities.c
+	src/qemu/qemu_capabilities.h
+	tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+	tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+
+	Insert the new capability in the right place, in both
+	declarations and caps.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c                     |  3 ++-
+ src/qemu/qemu_capabilities.h                     |  2 +-
+ src/qemu/qemu_command.c                          |  6 ++++++
+ tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml |  1 +
+ tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml  |  1 +
+ tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml  |  1 +
+ tests/qemuxml2argvtest.c                         | 12 ++++++++++++
+ 7 files changed, 24 insertions(+), 2 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 2f41e076cb..0defa9a3e4 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -445,7 +445,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
+               "virtio-blk.num-queues",
+               "machine.pseries.resize-hpt",
+ 
+-
++              "spapr-vty",
+ 
+               /* 275 */
+ 
+@@ -1679,6 +1679,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
+     { "pcie-root-port", QEMU_CAPS_DEVICE_PCIE_ROOT_PORT },
+     { "qemu-xhci", QEMU_CAPS_DEVICE_QEMU_XHCI },
+     { "spapr-pci-host-bridge", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE },
++    { "spapr-vty", QEMU_CAPS_DEVICE_SPAPR_VTY },
+ };
+ 
+ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = {
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index 60818daa1c..65b969a0ea 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -431,7 +431,7 @@ typedef enum {
+     QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES, /* virtio-blk-*.num-queues */
+     QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT, /* -machine pseries,resize-hpt */
+ 
+-
++    QEMU_CAPS_DEVICE_SPAPR_VTY, /* -device spapr-vty */
+ 
+     /* 275 */
+ 
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index fc7f54e81e..65b6a59d3f 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -10308,6 +10308,12 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+     if (qemuDomainIsPSeries(def)) {
+         if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+             serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) {
++            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_VTY)) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                               _("spapr-vty not supported in this QEMU binary"));
++                goto error;
++            }
++
+             virBufferAsprintf(&cmd, "spapr-vty,chardev=char%s",
+                               serial->info.alias);
+         }
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+index c01777a5a3..c95025b41f 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+@@ -178,6 +178,7 @@
+   <flag name='vxhs'/>
+   <flag name='virtio-blk.num-queues'/>
+   <flag name='machine.pseries.resize-hpt'/>
++  <flag name='spapr-vty'/>
+   <flag name='disk-share-rw'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
+diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
+index f1c9fc98a4..5ff8598fc8 100644
+--- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
+@@ -167,6 +167,7 @@
+   <flag name='vnc-multi-servers'/>
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
++  <flag name='spapr-vty'/>
+   <version>2006000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+index e912211f40..3b70b1a407 100644
+--- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+@@ -173,6 +173,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='spapr-vty'/>
+   <flag name='disk-share-rw'/>
+   <version>2009000</version>
+   <kvmVersion>0</kvmVersion>
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 4e981c9fab..70c72e4e64 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -1756,50 +1756,62 @@ mymain(void)
+     DO_TEST_PARSE_ERROR("seclabel-device-duplicates", NONE);
+ 
+     DO_TEST("pseries-basic",
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("pseries-vio",
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("pseries-usb-default",
+             QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_PIIX3_USB_UHCI,
+             QEMU_CAPS_PCI_OHCI,
+             QEMU_CAPS_PCI_MULTIFUNCTION);
+     DO_TEST("pseries-usb-multi",
+             QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_PIIX3_USB_UHCI,
+             QEMU_CAPS_PCI_OHCI,
+             QEMU_CAPS_PCI_MULTIFUNCTION);
+     DO_TEST("pseries-vio-user-assigned",
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST_PARSE_ERROR("pseries-vio-address-clash",
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("pseries-nvram", QEMU_CAPS_DEVICE_NVRAM);
+     DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
+             QEMU_CAPS_DEVICE_USB_KBD,
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("pseries-cpu-exact",
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST_PARSE_ERROR("pseries-no-parallel",
+             QEMU_CAPS_NODEFCONFIG);
+ 
+     qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64);
+     DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST_FAILURE("pseries-cpu-compat-power9", QEMU_CAPS_KVM);
+ 
+     qemuTestSetHostCPU(driver.caps, cpuPower9);
+     DO_TEST("pseries-cpu-compat-power9",
+             QEMU_CAPS_KVM,
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_NODEFCONFIG);
+     qemuTestSetHostCPU(driver.caps, NULL);
+ 
+     qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
+ 
+     DO_TEST("pseries-panic-missing",
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("pseries-panic-no-address",
++            QEMU_CAPS_DEVICE_SPAPR_VTY,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST_FAILURE("pseries-panic-address",
+                     QEMU_CAPS_NODEFCONFIG);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Add-device-id-for-mediated-devices-on-qemu-command-line.patch b/SOURCES/libvirt-qemu-Add-device-id-for-mediated-devices-on-qemu-command-line.patch
deleted file mode 100644
index 939482a..0000000
--- a/SOURCES/libvirt-qemu-Add-device-id-for-mediated-devices-on-qemu-command-line.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 23a4263e7611fa3f1e69f5bab7056a85e48d6b23 Mon Sep 17 00:00:00 2001
-Message-Id: <23a4263e7611fa3f1e69f5bab7056a85e48d6b23@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Tue, 4 Apr 2017 08:54:51 +0200
-Subject: [PATCH] qemu: Add device id for mediated devices on qemu command line
-
-Like all devices, add the 'id' option for mdevs as well. Patch also
-adjusts the test accordingly.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1438431
-
-(cherry picked from commit c3272e5e12e0bfd43b8101b73ae13d264c13337f)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
----
- src/qemu/qemu_command.c                                          | 3 ++-
- tests/qemuxml2argvdata/qemuxml2argv-hostdev-mdev-precreated.args | 2 +-
- 2 files changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 1a2984e56..59fedaaaf 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -5231,7 +5231,8 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
-     char *ret = NULL;
- 
-     virBufferAddLit(&buf, "vfio-pci");
--    virBufferAsprintf(&buf, ",sysfsdev=%s",
-+    virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s",
-+                      dev->info->alias,
-                       virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr));
- 
-     if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-mdev-precreated.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-mdev-precreated.args
-index fdefeb610..76e77707b 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-mdev-precreated.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-mdev-precreated.args
-@@ -20,6 +20,6 @@ QEMU_AUDIO_DRV=none \
- -usb \
- -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
- -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
---device vfio-pci,\
-+-device vfio-pci,id=hostdev0,\
- sysfsdev=/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc,bus=pci.0,\
- addr=0x3
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Add-migratable-parameter-to-virQEMUCapsInitCPUModel.patch b/SOURCES/libvirt-qemu-Add-migratable-parameter-to-virQEMUCapsInitCPUModel.patch
deleted file mode 100644
index 48e7c6e..0000000
--- a/SOURCES/libvirt-qemu-Add-migratable-parameter-to-virQEMUCapsInitCPUModel.patch
+++ /dev/null
@@ -1,148 +0,0 @@
-From 241d9b0d3945072ad74f9a0a5dcdb541cc2ad50b Mon Sep 17 00:00:00 2001
-Message-Id: <241d9b0d3945072ad74f9a0a5dcdb541cc2ad50b@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 29 Mar 2017 13:33:50 +0200
-Subject: [PATCH] qemu: Add migratable parameter to virQEMUCapsInitCPUModel
-
-The caller can ask for a migratable CPU model by passing true for the
-new parameter.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 00e0cbcb567a57c7b5a145d7fd3fb662779f6bec)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 36 +++++++++++++++++++++++++-----------
- src/qemu/qemu_capspriv.h     |  3 ++-
- tests/cputest.c              |  2 +-
- 3 files changed, 28 insertions(+), 13 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index b71de9633..eb6b674b4 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -3118,7 +3118,8 @@ virQEMUCapsCPUFilterFeatures(const char *name,
- static int
- virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
-                             qemuMonitorCPUModelInfoPtr modelInfo,
--                            virCPUDefPtr cpu)
-+                            virCPUDefPtr cpu,
-+                            bool migratable)
- {
-     size_t i;
- 
-@@ -3146,8 +3147,12 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
- 
-         if (VIR_STRDUP(feature->name, prop->name) < 0)
-             return -1;
--        feature->policy = prop->value.boolean ? VIR_CPU_FEATURE_REQUIRE
--                                              : VIR_CPU_FEATURE_DISABLE;
-+
-+        if (!prop->value.boolean ||
-+            (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
-+            feature->policy = VIR_CPU_FEATURE_DISABLE;
-+        else
-+            feature->policy = VIR_CPU_FEATURE_REQUIRE;
-         cpu->nfeatures++;
-     }
- 
-@@ -3164,7 +3169,8 @@ static int
- virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
-                            virDomainVirtType type,
-                            qemuMonitorCPUModelInfoPtr model,
--                           virCPUDefPtr cpu)
-+                           virCPUDefPtr cpu,
-+                           bool migratable)
- {
-     virCPUDataPtr data = NULL;
-     unsigned long long sigFamily = 0;
-@@ -3185,9 +3191,13 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
- 
-         switch (prop->type) {
-         case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
--            if (prop->value.boolean &&
--                virCPUx86DataAddFeature(data, prop->name) < 0)
-+            if (!prop->value.boolean ||
-+                (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
-+                continue;
-+
-+            if (virCPUx86DataAddFeature(data, prop->name) < 0)
-                 goto cleanup;
-+
-             break;
- 
-         case QEMU_MONITOR_CPU_PROPERTY_STRING:
-@@ -3226,13 +3236,14 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
- 
- /**
-  * Returns  0 when host CPU model provided by QEMU was filled in qemuCaps,
-- *          1 when the caller should fall back to using virCapsPtr->host.cpu,
-+ *          1 when the caller should fall back to other methods
-  *         -1 on error.
-  */
- int
- virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
-                         virDomainVirtType type,
--                        virCPUDefPtr cpu)
-+                        virCPUDefPtr cpu,
-+                        bool migratable)
- {
-     qemuMonitorCPUModelInfoPtr model;
-     int ret = 1;
-@@ -3242,10 +3253,13 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
-     else
-         model = qemuCaps->tcgCPUModelInfo;
- 
-+    if (migratable && model && !model->migratability)
-+        return 1;
-+
-     if (ARCH_IS_S390(qemuCaps->arch))
--        ret = virQEMUCapsInitCPUModelS390(qemuCaps, model, cpu);
-+        ret = virQEMUCapsInitCPUModelS390(qemuCaps, model, cpu, migratable);
-     else if (ARCH_IS_X86(qemuCaps->arch))
--        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, model, cpu);
-+        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, model, cpu, migratable);
- 
-     if (ret == 0)
-         cpu->fallback = VIR_CPU_FALLBACK_FORBID;
-@@ -3274,7 +3288,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-     cpu->match = VIR_CPU_MATCH_EXACT;
-     cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
- 
--    if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, cpu)) < 0) {
-+    if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) {
-         goto error;
-     } else if (rc == 1) {
-         VIR_DEBUG("No host CPU model info from QEMU; probing host CPU directly");
-diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
-index 61ccd4517..1baaaf334 100644
---- a/src/qemu/qemu_capspriv.h
-+++ b/src/qemu/qemu_capspriv.h
-@@ -81,7 +81,8 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
- int
- virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
-                         virDomainVirtType type,
--                        virCPUDefPtr cpu);
-+                        virCPUDefPtr cpu,
-+                        bool migratable);
- 
- void
- virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
-diff --git a/tests/cputest.c b/tests/cputest.c
-index 3d3e43f16..8c07cf4f6 100644
---- a/tests/cputest.c
-+++ b/tests/cputest.c
-@@ -709,7 +709,7 @@ cpuTestJSONCPUID(const void *arg)
-     cpu->match = VIR_CPU_MATCH_EXACT;
-     cpu->fallback = VIR_CPU_FALLBACK_FORBID;
- 
--    if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu) != 0)
-+    if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu, false) != 0)
-         goto cleanup;
- 
-     ret = cpuTestCompareXML(data->arch, cpu, result, false);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Add-qemuDomainCheckABIStability.patch b/SOURCES/libvirt-qemu-Add-qemuDomainCheckABIStability.patch
deleted file mode 100644
index 581dc7c..0000000
--- a/SOURCES/libvirt-qemu-Add-qemuDomainCheckABIStability.patch
+++ /dev/null
@@ -1,110 +0,0 @@
-From bf20b6cf07e5462c892b5e3c3d76a3c354606ea4 Mon Sep 17 00:00:00 2001
-Message-Id: <bf20b6cf07e5462c892b5e3c3d76a3c354606ea4@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 14 Jun 2017 13:43:37 +0200
-Subject: [PATCH] qemu: Add qemuDomainCheckABIStability
-
-When making ABI stability checks for an active domain, we need to make
-sure we use the same migratable definition which virDomainGetXMLDesc
-with the MIGRATABLE flag provides, otherwise the ABI check will fail.
-This is implemented in the new qemuDomainCheckABIStability which takes a
-domain object and generates the right migratable definition from it.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 063b2b8788db204d0ac2e1d367fd0c5eb9b81451)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1460952
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 41 ++++++++++++++++++++++++++++++++++++-----
- src/qemu/qemu_domain.h |  4 ++++
- 2 files changed, 40 insertions(+), 5 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index b3dc2bc3ac..1528c6a137 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -5909,6 +5909,10 @@ qemuDomainMigratableDefCheckABIStability(virQEMUDriverPtr driver,
- }
- 
- 
-+#define COPY_FLAGS (VIR_DOMAIN_XML_SECURE | \
-+                    VIR_DOMAIN_XML_UPDATE_CPU | \
-+                    VIR_DOMAIN_XML_MIGRATABLE)
-+
- bool
- qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
-                                virDomainDefPtr src,
-@@ -5916,13 +5920,10 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
- {
-     virDomainDefPtr migratableDefSrc = NULL;
-     virDomainDefPtr migratableDefDst = NULL;
--    const unsigned int flags = VIR_DOMAIN_XML_SECURE |
--                               VIR_DOMAIN_XML_UPDATE_CPU |
--                               VIR_DOMAIN_XML_MIGRATABLE;
-     bool ret = false;
- 
--    if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, flags)) ||
--        !(migratableDefDst = qemuDomainDefCopy(driver, dst, flags)))
-+    if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, COPY_FLAGS)) ||
-+        !(migratableDefDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS)))
-         goto cleanup;
- 
-     ret = qemuDomainMigratableDefCheckABIStability(driver,
-@@ -5935,6 +5936,36 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
-     return ret;
- }
- 
-+
-+bool
-+qemuDomainCheckABIStability(virQEMUDriverPtr driver,
-+                            virDomainObjPtr vm,
-+                            virDomainDefPtr dst)
-+{
-+    virDomainDefPtr migratableSrc = NULL;
-+    virDomainDefPtr migratableDst = NULL;
-+    char *xml = NULL;
-+    bool ret = false;
-+
-+    if (!(xml = qemuDomainFormatXML(driver, vm, COPY_FLAGS)) ||
-+        !(migratableSrc = qemuDomainDefFromXML(driver, xml)) ||
-+        !(migratableDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS)))
-+        goto cleanup;
-+
-+    ret = qemuDomainMigratableDefCheckABIStability(driver,
-+                                                   vm->def, migratableSrc,
-+                                                   dst, migratableDst);
-+
-+ cleanup:
-+    VIR_FREE(xml);
-+    virDomainDefFree(migratableSrc);
-+    virDomainDefFree(migratableDst);
-+    return ret;
-+}
-+
-+#undef COPY_FLAGS
-+
-+
- bool
- qemuDomainAgentAvailable(virDomainObjPtr vm,
-                          bool reportError)
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index d635d2995f..7ad34e563e 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -668,6 +668,10 @@ bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
-                                     virDomainDefPtr src,
-                                     virDomainDefPtr dst);
- 
-+bool qemuDomainCheckABIStability(virQEMUDriverPtr driver,
-+                                 virDomainObjPtr vm,
-+                                 virDomainDefPtr dst);
-+
- bool qemuDomainAgentAvailable(virDomainObjPtr vm,
-                               bool reportError);
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Add-qemuDomainMigratableDefCheckABIStability.patch b/SOURCES/libvirt-qemu-Add-qemuDomainMigratableDefCheckABIStability.patch
deleted file mode 100644
index 4bd3edf..0000000
--- a/SOURCES/libvirt-qemu-Add-qemuDomainMigratableDefCheckABIStability.patch
+++ /dev/null
@@ -1,82 +0,0 @@
-From 2e728d3be5792685c38adbd61e80318e51985897 Mon Sep 17 00:00:00 2001
-Message-Id: <2e728d3be5792685c38adbd61e80318e51985897@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 14 Jun 2017 13:43:12 +0200
-Subject: [PATCH] qemu: Add qemuDomainMigratableDefCheckABIStability
-
-This patch separates the actual ABI checks from getting migratable defs
-in qemuDomainDefCheckABIStability so that we can create another wrapper
-which will use different methods to get the migratable defs.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit a0912df3faac8b58725f45b8cf928990999585a3)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1460952
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 34 +++++++++++++++++++++++-----------
- 1 file changed, 23 insertions(+), 11 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index ce75105afa..b3dc2bc3ac 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -5889,6 +5889,26 @@ virDomainABIStability virQEMUDriverDomainABIStability = {
- };
- 
- 
-+static bool
-+qemuDomainMigratableDefCheckABIStability(virQEMUDriverPtr driver,
-+                                         virDomainDefPtr src,
-+                                         virDomainDefPtr migratableSrc,
-+                                         virDomainDefPtr dst,
-+                                         virDomainDefPtr migratableDst)
-+{
-+    if (!virDomainDefCheckABIStabilityFlags(migratableSrc,
-+                                            migratableDst,
-+                                            driver->xmlopt,
-+                                            VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE))
-+        return false;
-+
-+    /* Force update any skipped values from the volatile flag */
-+    dst->mem.cur_balloon = src->mem.cur_balloon;
-+
-+    return true;
-+}
-+
-+
- bool
- qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
-                                virDomainDefPtr src,
-@@ -5899,23 +5919,15 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
-     const unsigned int flags = VIR_DOMAIN_XML_SECURE |
-                                VIR_DOMAIN_XML_UPDATE_CPU |
-                                VIR_DOMAIN_XML_MIGRATABLE;
--    const unsigned int check_flags = VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE;
-     bool ret = false;
- 
-     if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, flags)) ||
-         !(migratableDefDst = qemuDomainDefCopy(driver, dst, flags)))
-         goto cleanup;
- 
--    if (!virDomainDefCheckABIStabilityFlags(migratableDefSrc,
--                                            migratableDefDst,
--                                            driver->xmlopt,
--                                            check_flags))
--        goto cleanup;
--
--    /* Force update any skipped values from the volatile flag */
--    dst->mem.cur_balloon = src->mem.cur_balloon;
--
--    ret = true;
-+    ret = qemuDomainMigratableDefCheckABIStability(driver,
-+                                                   src, migratableDefSrc,
-+                                                   dst, migratableDefDst);
- 
-  cleanup:
-     virDomainDefFree(migratableDefSrc);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Add-qemuProcessFetchGuestCPU.patch b/SOURCES/libvirt-qemu-Add-qemuProcessFetchGuestCPU.patch
deleted file mode 100644
index 3890b04..0000000
--- a/SOURCES/libvirt-qemu-Add-qemuProcessFetchGuestCPU.patch
+++ /dev/null
@@ -1,102 +0,0 @@
-From 57a9f46878f57d1602a030cfd8484c8566201c40 Mon Sep 17 00:00:00 2001
-Message-Id: <57a9f46878f57d1602a030cfd8484c8566201c40@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 11 Jul 2017 13:18:45 +0200
-Subject: [PATCH] qemu: Add qemuProcessFetchGuestCPU
-
-Separated from qemuProcessUpdateLiveGuestCPU. Its purpose is to fetch
-guest CPU data from a running QEMU process. The data can later be used
-to verify and update the active guest CPU definition.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 40d246a22b46f1691d09cbce5904c79d712d8c16)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1470582
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_process.c | 58 +++++++++++++++++++++++++++++++++++++------------
- 1 file changed, 44 insertions(+), 14 deletions(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 4d7c8d8e40..d3fa8ef41e 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3905,6 +3905,47 @@ qemuProcessVerifyCPUFeatures(virDomainDefPtr def,
- 
- 
- static int
-+qemuProcessFetchGuestCPU(virQEMUDriverPtr driver,
-+                         virDomainObjPtr vm,
-+                         qemuDomainAsyncJob asyncJob,
-+                         virCPUDataPtr *enabled,
-+                         virCPUDataPtr *disabled)
-+{
-+    qemuDomainObjPrivatePtr priv = vm->privateData;
-+    virCPUDataPtr dataEnabled = NULL;
-+    virCPUDataPtr dataDisabled = NULL;
-+    int rc;
-+
-+    *enabled = NULL;
-+    *disabled = NULL;
-+
-+    if (!ARCH_IS_X86(vm->def->os.arch))
-+        return 0;
-+
-+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
-+        goto error;
-+
-+    rc = qemuMonitorGetGuestCPU(priv->mon, vm->def->os.arch,
-+                                &dataEnabled, &dataDisabled);
-+
-+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
-+        goto error;
-+
-+    if (rc == -1)
-+        goto error;
-+
-+    *enabled = dataEnabled;
-+    *disabled = dataDisabled;
-+    return 0;
-+
-+ error:
-+    virCPUDataFree(dataEnabled);
-+    virCPUDataFree(dataDisabled);
-+    return -1;
-+}
-+
-+
-+static int
- qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-                               virDomainObjPtr vm,
-                               qemuDomainAsyncJob asyncJob)
-@@ -3917,21 +3958,10 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-     int ret = -1;
-     virCPUDefPtr orig = NULL;
- 
--    if (ARCH_IS_X86(def->os.arch)) {
--        if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
--            goto cleanup;
--
--        rc = qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu, &disabled);
--
--        if (qemuDomainObjExitMonitor(driver, vm) < 0)
--            goto cleanup;
--
--        if (rc < 0) {
--            if (rc == -2)
--                ret = 0;
--            goto cleanup;
--        }
-+    if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < 0)
-+        goto cleanup;
- 
-+    if (cpu) {
-         if (qemuProcessVerifyKVMFeatures(def, cpu) < 0 ||
-             qemuProcessVerifyHypervFeatures(def, cpu) < 0)
-             goto cleanup;
--- 
-2.13.2
-
diff --git a/SOURCES/libvirt-qemu-Add-qemuProcessUpdateLiveGuestCPU.patch b/SOURCES/libvirt-qemu-Add-qemuProcessUpdateLiveGuestCPU.patch
deleted file mode 100644
index 33bd482..0000000
--- a/SOURCES/libvirt-qemu-Add-qemuProcessUpdateLiveGuestCPU.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-From e5840b68e6376a514c6c5de1897ac87dc57e7a58 Mon Sep 17 00:00:00 2001
-Message-Id: <e5840b68e6376a514c6c5de1897ac87dc57e7a58@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 11 Jul 2017 13:51:17 +0200
-Subject: [PATCH] qemu: Add qemuProcessUpdateLiveGuestCPU
-
-Separated from qemuProcessUpdateAndVerifyCPU to handle updating of an
-active guest CPU definition according to live data from QEMU.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit eef9f83b691e0713e4fc480b497b85517aba6ca4)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1470582
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_process.c | 72 ++++++++++++++++++++++++++++++-------------------
- 1 file changed, 44 insertions(+), 28 deletions(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 1e7724e784..9df463094e 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3971,17 +3971,55 @@ qemuProcessVerifyCPU(virDomainObjPtr vm,
- 
- 
- static int
-+qemuProcessUpdateLiveGuestCPU(virDomainObjPtr vm,
-+                              virCPUDataPtr enabled,
-+                              virCPUDataPtr disabled)
-+{
-+    virDomainDefPtr def = vm->def;
-+    qemuDomainObjPrivatePtr priv = vm->privateData;
-+    virCPUDefPtr orig = NULL;
-+    int rc;
-+    int ret = -1;
-+
-+    if (!enabled)
-+        return 0;
-+
-+    if (!def->cpu ||
-+        (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
-+         !def->cpu->model))
-+        return 0;
-+
-+    if (!(orig = virCPUDefCopy(def->cpu)))
-+        goto cleanup;
-+
-+    if ((rc = virCPUUpdateLive(def->os.arch, def->cpu, enabled, disabled)) < 0) {
-+        goto cleanup;
-+    } else if (rc == 0) {
-+        /* Store the original CPU in priv if QEMU changed it and we didn't
-+         * get the original CPU via migration, restore, or snapshot revert.
-+         */
-+        if (!priv->origCPU && !virCPUDefIsEqual(def->cpu, orig, false))
-+            VIR_STEAL_PTR(priv->origCPU, orig);
-+
-+        def->cpu->check = VIR_CPU_CHECK_FULL;
-+    }
-+
-+    ret = 0;
-+
-+ cleanup:
-+    virCPUDefFree(orig);
-+    return ret;
-+}
-+
-+
-+static int
- qemuProcessUpdateAndVerifyCPU(virQEMUDriverPtr driver,
-                               virDomainObjPtr vm,
-                               qemuDomainAsyncJob asyncJob)
- {
--    virDomainDefPtr def = vm->def;
-     virCPUDataPtr cpu = NULL;
-     virCPUDataPtr disabled = NULL;
--    qemuDomainObjPrivatePtr priv = vm->privateData;
--    int rc;
-     int ret = -1;
--    virCPUDefPtr orig = NULL;
- 
-     if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < 0)
-         goto cleanup;
-@@ -3989,36 +4027,14 @@ qemuProcessUpdateAndVerifyCPU(virQEMUDriverPtr driver,
-     if (qemuProcessVerifyCPU(vm, cpu) < 0)
-         goto cleanup;
- 
--    if (cpu) {
--        if (!def->cpu ||
--            (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
--             !def->cpu->model)) {
--            ret = 0;
--            goto cleanup;
--        }
--
--        if (!(orig = virCPUDefCopy(def->cpu)))
--            goto cleanup;
--
--        if ((rc = virCPUUpdateLive(def->os.arch, def->cpu, cpu, disabled)) < 0) {
--            goto cleanup;
--        } else if (rc == 0) {
--            /* Store the original CPU in priv if QEMU changed it and we didn't
--             * get the original CPU via migration, restore, or snapshot revert.
--             */
--            if (!priv->origCPU && !virCPUDefIsEqual(def->cpu, orig, false))
--                VIR_STEAL_PTR(priv->origCPU, orig);
--
--            def->cpu->check = VIR_CPU_CHECK_FULL;
--        }
--    }
-+    if (qemuProcessUpdateLiveGuestCPU(vm, cpu, disabled) < 0)
-+        goto cleanup;
- 
-     ret = 0;
- 
-  cleanup:
-     virCPUDataFree(cpu);
-     virCPUDataFree(disabled);
--    virCPUDefFree(orig);
-     return ret;
- }
- 
--- 
-2.13.2
-
diff --git a/SOURCES/libvirt-qemu-Add-qemuProcessVerifyCPU.patch b/SOURCES/libvirt-qemu-Add-qemuProcessVerifyCPU.patch
deleted file mode 100644
index c557e14..0000000
--- a/SOURCES/libvirt-qemu-Add-qemuProcessVerifyCPU.patch
+++ /dev/null
@@ -1,85 +0,0 @@
-From 9d41cae9942d2909be00261b3ae2a2e1ec717808 Mon Sep 17 00:00:00 2001
-Message-Id: <9d41cae9942d2909be00261b3ae2a2e1ec717808@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 11 Jul 2017 13:26:12 +0200
-Subject: [PATCH] qemu: Add qemuProcessVerifyCPU
-
-Separated from qemuProcessUpdateLiveGuestCPU. The function makes sure
-a guest CPU provides all features required by a domain definition.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 5cac2fe108f957b2629a29bea1747fdb3c8d7aa3)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1470582
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_process.c | 35 ++++++++++++++++++++++++++++-------
- 1 file changed, 28 insertions(+), 7 deletions(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index d3fa8ef41e..3f7a9f4c02 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3946,6 +3946,31 @@ qemuProcessFetchGuestCPU(virQEMUDriverPtr driver,
- 
- 
- static int
-+qemuProcessVerifyCPU(virDomainObjPtr vm,
-+                     virCPUDataPtr cpu)
-+{
-+    virDomainDefPtr def = vm->def;
-+
-+    if (!cpu)
-+        return 0;
-+
-+    if (qemuProcessVerifyKVMFeatures(def, cpu) < 0 ||
-+        qemuProcessVerifyHypervFeatures(def, cpu) < 0)
-+        return -1;
-+
-+    if (!def->cpu ||
-+        (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
-+         !def->cpu->model))
-+        return 0;
-+
-+    if (qemuProcessVerifyCPUFeatures(def, cpu) < 0)
-+        return -1;
-+
-+    return 0;
-+}
-+
-+
-+static int
- qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-                               virDomainObjPtr vm,
-                               qemuDomainAsyncJob asyncJob)
-@@ -3961,11 +3986,10 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-     if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < 0)
-         goto cleanup;
- 
--    if (cpu) {
--        if (qemuProcessVerifyKVMFeatures(def, cpu) < 0 ||
--            qemuProcessVerifyHypervFeatures(def, cpu) < 0)
--            goto cleanup;
-+    if (qemuProcessVerifyCPU(vm, cpu) < 0)
-+        goto cleanup;
- 
-+    if (cpu) {
-         if (!def->cpu ||
-             (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
-              !def->cpu->model)) {
-@@ -3973,9 +3997,6 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-             goto cleanup;
-         }
- 
--        if (qemuProcessVerifyCPUFeatures(def, cpu) < 0)
--            goto cleanup;
--
-         if (!(orig = virCPUDefCopy(def->cpu)))
-             goto cleanup;
- 
--- 
-2.13.2
-
diff --git a/SOURCES/libvirt-qemu-Add-support-for-guest-CPU-cache.patch b/SOURCES/libvirt-qemu-Add-support-for-guest-CPU-cache.patch
deleted file mode 100644
index e9c0308..0000000
--- a/SOURCES/libvirt-qemu-Add-support-for-guest-CPU-cache.patch
+++ /dev/null
@@ -1,667 +0,0 @@
-From b34dc87751a8667f22ea78730a5b678f5bd469a4 Mon Sep 17 00:00:00 2001
-Message-Id: <b34dc87751a8667f22ea78730a5b678f5bd469a4@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 25 Apr 2017 19:07:19 +0200
-Subject: [PATCH] qemu: Add support for guest CPU cache
-
-This patch maps /domain/cpu/cache element into -cpu parameters:
-
-- <cache mode='passthrough'/> is translated to host-cache-info=on
-- <cache level='3' mode='emulate'/> is transformed into l3-cache=on
-- <cache mode='disable'/> is turned in host-cache-info=off,l3-cache=off
-
-Any other <cache> element is forbidden.
-
-The tricky part is detecting whether QEMU supports the CPU properties.
-
-The 'host-cache-info' property is introduced in v2.4.0-1389-ge265e3e480,
-earlier QEMU releases enabled host-cache-info by default and had no way
-to disable it. If the property is present, it defaults to 'off' for any
-QEMU until at least 2.9.0.
-
-The 'l3-cache' property was introduced later by v2.7.0-200-g14c985cffa.
-Earlier versions worked as if l3-cache=off was passed. For any QEMU
-until at least 2.9.0 l3-cache is 'off' by default.
-
-QEMU 2.9.0 was the first release which supports probing both properties
-by running device-list-properties with typename=host-x86_64-cpu. Older
-QEMU releases did not support device-list-properties command for CPU
-devices. Thus we can't really rely on probing them and we can just use
-query-cpu-model-expansion QMP command as a witness.
-
-Because the cache property probing is only reliable for QEMU >= 2.9.0
-when both are already supported for quite a few releases, we let QEMU
-report an error if a specific cache mode is explicitly requested. The
-other mode (or both if a user requested CPU cache to be disabled) is
-explicitly turned off for QEMU >= 2.9.0 to avoid any surprises in case
-the QEMU defaults change. Any older QEMU already turns them off so not
-doing so explicitly does not make any harm.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit df13c0b477ffda460eed259c3b8aab7255f11199)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1428952
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c                       |  5 ++
- src/qemu/qemu_capabilities.h                       |  1 +
- src/qemu/qemu_command.c                            | 39 ++++++++++++++++
- src/qemu/qemu_domain.c                             | 54 ++++++++++++++++++++++
- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  1 +
- .../qemuxml2argv-cpu-cache-disable.args            | 21 +++++++++
- .../qemuxml2argv-cpu-cache-disable.xml             | 20 ++++++++
- .../qemuxml2argv-cpu-cache-disable2.args           | 21 +++++++++
- .../qemuxml2argv-cpu-cache-disable2.xml            | 20 ++++++++
- .../qemuxml2argv-cpu-cache-disable3.args           | 22 +++++++++
- .../qemuxml2argv-cpu-cache-disable3.xml            | 20 ++++++++
- .../qemuxml2argv-cpu-cache-emulate-l2.xml          | 20 ++++++++
- .../qemuxml2argv-cpu-cache-emulate-l3.args         | 21 +++++++++
- .../qemuxml2argv-cpu-cache-emulate-l3.xml          | 20 ++++++++
- .../qemuxml2argv-cpu-cache-passthrough-l3.xml      | 20 ++++++++
- .../qemuxml2argv-cpu-cache-passthrough.args        | 21 +++++++++
- .../qemuxml2argv-cpu-cache-passthrough.xml         | 20 ++++++++
- .../qemuxml2argv-cpu-cache-passthrough2.args       | 21 +++++++++
- .../qemuxml2argv-cpu-cache-passthrough2.xml        | 20 ++++++++
- .../qemuxml2argv-cpu-cache-passthrough3.xml        | 20 ++++++++
- tests/qemuxml2argvtest.c                           | 10 ++++
- 21 files changed, 417 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l2.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough-l3.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough3.xml
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 950a42bae..2c845853a 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -364,6 +364,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
-               "query-cpu-definitions", /* 250 */
-               "block-write-threshold",
-               "query-named-block-nodes",
-+              "cpu-cache",
-     );
- 
- 
-@@ -4648,6 +4649,10 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
-         virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM))
-         virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM);
- 
-+    if (ARCH_IS_X86(qemuCaps->arch) &&
-+        virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
-+        virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_CACHE);
-+
-     ret = 0;
-  cleanup:
-     return ret;
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index 24e2f38ee..c466a63e7 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -401,6 +401,7 @@ typedef enum {
-     QEMU_CAPS_QUERY_CPU_DEFINITIONS, /* qmp query-cpu-definitions */
-     QEMU_CAPS_BLOCK_WRITE_THRESHOLD, /* BLOCK_WRITE_THRESHOLD event */
-     QEMU_CAPS_QUERY_NAMED_BLOCK_NODES, /* qmp query-named-block-nodes */
-+    QEMU_CAPS_CPU_CACHE, /* -cpu supports host-cache-info and l3-cache properties */
- 
-     QEMU_CAPS_LAST /* this must always be the last item */
- } virQEMUCapsFlags;
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index ff7f47e06..2105cde58 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -7071,6 +7071,45 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
-         have_cpu = true;
-     }
- 
-+    if (def->cpu && def->cpu->cache) {
-+        virCPUCacheDefPtr cache = def->cpu->cache;
-+        bool hostOff = false;
-+        bool l3Off = false;
-+
-+        if (!have_cpu) {
-+            virBufferAdd(&buf, default_model, -1);
-+            have_cpu = true;
-+        }
-+
-+        switch (cache->mode) {
-+        case VIR_CPU_CACHE_MODE_EMULATE:
-+            virBufferAddLit(&buf, ",l3-cache=on");
-+            hostOff = true;
-+            break;
-+
-+        case VIR_CPU_CACHE_MODE_PASSTHROUGH:
-+            virBufferAddLit(&buf, ",host-cache-info=on");
-+            l3Off = true;
-+            break;
-+
-+        case VIR_CPU_CACHE_MODE_DISABLE:
-+            hostOff = l3Off = true;
-+            break;
-+
-+        case VIR_CPU_CACHE_MODE_LAST:
-+            break;
-+        }
-+
-+        if (hostOff &&
-+            def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH &&
-+            virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_CACHE))
-+            virBufferAddLit(&buf, ",host-cache-info=off");
-+
-+        if (l3Off &&
-+            virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_CACHE))
-+            virBufferAddLit(&buf, ",l3-cache=off");
-+    }
-+
-     if (virBufferCheckError(&buf) < 0)
-         goto cleanup;
- 
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 9c09ced0c..d31645fd1 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -2688,6 +2688,60 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def)
-     if (!def->cpu)
-         return 0;
- 
-+    if (def->cpu->cache) {
-+        virCPUCacheDefPtr cache = def->cpu->cache;
-+
-+        if (!ARCH_IS_X86(def->os.arch)) {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                           _("CPU cache specification is not supported "
-+                             "for '%s' architecture"),
-+                           virArchToString(def->os.arch));
-+            return -1;
-+        }
-+
-+        switch (cache->mode) {
-+        case VIR_CPU_CACHE_MODE_EMULATE:
-+            if (cache->level != 3) {
-+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                               _("CPU cache mode '%s' can only be used with "
-+                                 "level='3'"),
-+                               virCPUCacheModeTypeToString(cache->mode));
-+                return -1;
-+            }
-+            break;
-+
-+        case VIR_CPU_CACHE_MODE_PASSTHROUGH:
-+            if (def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH) {
-+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                               _("CPU cache mode '%s' can only be used with "
-+                                 "'%s' CPUs"),
-+                               virCPUCacheModeTypeToString(cache->mode),
-+                               virCPUModeTypeToString(VIR_CPU_MODE_HOST_PASSTHROUGH));
-+                return -1;
-+            }
-+
-+            if (cache->level != -1) {
-+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                               _("unsupported CPU cache level for mode '%s'"),
-+                               virCPUCacheModeTypeToString(cache->mode));
-+                return -1;
-+            }
-+            break;
-+
-+        case VIR_CPU_CACHE_MODE_DISABLE:
-+            if (cache->level != -1) {
-+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                               _("unsupported CPU cache level for mode '%s'"),
-+                               virCPUCacheModeTypeToString(cache->mode));
-+                return -1;
-+            }
-+            break;
-+
-+        case VIR_CPU_CACHE_MODE_LAST:
-+            break;
-+        }
-+    }
-+
-     /* Nothing to be done if only CPU topology is specified. */
-     if (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
-         !def->cpu->model)
-diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-index 6386c4ed0..496c9ceb8 100644
---- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-@@ -207,6 +207,7 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='cpu-cache'/>
-   <version>2008090</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.9.0-rc0-142-g940a8ce)</package>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.args
-new file mode 100644
-index 000000000..386e38d37
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.args
-@@ -0,0 +1,21 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/kvm \
-+-name foo \
-+-S \
-+-M pc \
-+-cpu host,host-cache-info=off,l3-cache=off \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-foo/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-usb \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.xml
-new file mode 100644
-index 000000000..e6f39951c
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-passthrough'>
-+    <cache mode='disable'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.args
-new file mode 100644
-index 000000000..9348e01f8
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.args
-@@ -0,0 +1,21 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/kvm \
-+-name foo \
-+-S \
-+-M pc \
-+-cpu host \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-foo/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-usb \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.xml
-new file mode 100644
-index 000000000..e6f39951c
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-passthrough'>
-+    <cache mode='disable'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.args
-new file mode 100644
-index 000000000..b882710c1
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.args
-@@ -0,0 +1,22 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/kvm \
-+-name foo \
-+-S \
-+-M pc \
-+-cpu core2duo,+ds,+acpi,+ss,+ht,+tm,+pbe,+ds_cpl,+vmx,+est,+tm2,+cx16,+xtpr,\
-++lahf_lm,l3-cache=off \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-foo/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-usb \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.xml
-new file mode 100644
-index 000000000..17078a1e8
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-model'>
-+    <cache mode='disable'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l2.xml
-new file mode 100644
-index 000000000..4757e85ea
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l2.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-model' check='full'>
-+    <cache level='2' mode='emulate'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.args
-new file mode 100644
-index 000000000..c2f5d19e1
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.args
-@@ -0,0 +1,21 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/kvm \
-+-name foo \
-+-S \
-+-M pc \
-+-cpu host,l3-cache=on,host-cache-info=off \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-foo/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-usb \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.xml
-new file mode 100644
-index 000000000..17019c673
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-passthrough'>
-+    <cache level='3' mode='emulate'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough-l3.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough-l3.xml
-new file mode 100644
-index 000000000..3471115ea
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough-l3.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-passthrough'>
-+    <cache level='3' mode='passthrough'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.args
-new file mode 100644
-index 000000000..1d824f6dd
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.args
-@@ -0,0 +1,21 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/kvm \
-+-name foo \
-+-S \
-+-M pc \
-+-cpu host,host-cache-info=on,l3-cache=off \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-foo/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-usb \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.xml
-new file mode 100644
-index 000000000..74846fdd3
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-passthrough'>
-+    <cache mode='passthrough'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.args
-new file mode 100644
-index 000000000..d7863ba2e
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.args
-@@ -0,0 +1,21 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/kvm \
-+-name foo \
-+-S \
-+-M pc \
-+-cpu host,host-cache-info=on \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-foo/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-usb \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.xml
-new file mode 100644
-index 000000000..74846fdd3
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-passthrough'>
-+    <cache mode='passthrough'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough3.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough3.xml
-new file mode 100644
-index 000000000..6ad65700b
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough3.xml
-@@ -0,0 +1,20 @@
-+<domain type='kvm'>
-+  <name>foo</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu mode='host-model'>
-+    <cache mode='passthrough'/>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 94be771d3..81cd2a6ec 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -2521,6 +2521,16 @@ mymain(void)
-     DO_TEST("cpu-check-default-partial", QEMU_CAPS_KVM);
-     DO_TEST("cpu-check-default-partial2", QEMU_CAPS_KVM);
- 
-+    DO_TEST("cpu-cache-disable", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
-+    DO_TEST("cpu-cache-disable2", QEMU_CAPS_KVM);
-+    DO_TEST("cpu-cache-disable3", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
-+    DO_TEST("cpu-cache-passthrough", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
-+    DO_TEST("cpu-cache-passthrough2", QEMU_CAPS_KVM);
-+    DO_TEST("cpu-cache-emulate-l3", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
-+    DO_TEST_PARSE_ERROR("cpu-cache-emulate-l2", QEMU_CAPS_KVM);
-+    DO_TEST_PARSE_ERROR("cpu-cache-passthrough3", QEMU_CAPS_KVM);
-+    DO_TEST_PARSE_ERROR("cpu-cache-passthrough-l3", QEMU_CAPS_KVM);
-+
-     qemuTestDriverFree(&driver);
- 
-     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Add-support-for-resctrl.patch b/SOURCES/libvirt-qemu-Add-support-for-resctrl.patch
new file mode 100644
index 0000000..7ba1797
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Add-support-for-resctrl.patch
@@ -0,0 +1,120 @@
+From 72285626fa7b899ceb9c8d4358b4b1b3fa7081a4 Mon Sep 17 00:00:00 2001
+Message-Id: <72285626fa7b899ceb9c8d4358b4b1b3fa7081a4@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:32 +0100
+Subject: [PATCH] qemu: Add support for resctrl
+
+We've been building up to this.  This adds support for cputune/cachetune
+settings for domains in the QEMU driver.  The addition into
+qemuProcessSetupVcpu() automatically adds support for hotplug.  For hot-unplug
+we need to remove the allocation only if all the vCPUs were unplugged.  But
+since the threads are left running, we can't really do much about it now.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 9a2fc2db8fe18da41c274d52b6e52316a4bbe52d)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/qemu/qemu_process.c | 60 ++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 55 insertions(+), 5 deletions(-)
+
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index c64088e4ca..57faf9cd79 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -2504,6 +2504,32 @@ qemuProcessSetupEmulator(virDomainObjPtr vm)
+ }
+ 
+ 
++static int
++qemuProcessResctrlCreate(virQEMUDriverPtr driver,
++                         virDomainObjPtr vm)
++{
++    int ret = -1;
++    size_t i = 0;
++    virCapsPtr caps = virQEMUDriverGetCapabilities(driver, false);
++    qemuDomainObjPrivatePtr priv = vm->privateData;
++
++    if (!caps)
++        return -1;
++
++    for (i = 0; i < vm->def->ncachetunes; i++) {
++        if (virResctrlAllocCreate(caps->host.resctrl,
++                                  vm->def->cachetunes[i]->alloc,
++                                  priv->machineName) < 0)
++            goto cleanup;
++    }
++
++    ret = 0;
++ cleanup:
++    virObjectUnref(caps);
++    return ret;
++}
++
++
+ static int
+ qemuProcessInitPasswords(virConnectPtr conn,
+                          virQEMUDriverPtr driver,
+@@ -5015,12 +5041,26 @@ qemuProcessSetupVcpu(virDomainObjPtr vm,
+ {
+     pid_t vcpupid = qemuDomainGetVcpuPid(vm, vcpuid);
+     virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, vcpuid);
++    size_t i = 0;
+ 
+-    return qemuProcessSetupPid(vm, vcpupid, VIR_CGROUP_THREAD_VCPU,
+-                               vcpuid, vcpu->cpumask,
+-                               vm->def->cputune.period,
+-                               vm->def->cputune.quota,
+-                               &vcpu->sched);
++    if (qemuProcessSetupPid(vm, vcpupid, VIR_CGROUP_THREAD_VCPU,
++                            vcpuid, vcpu->cpumask,
++                            vm->def->cputune.period,
++                            vm->def->cputune.quota,
++                            &vcpu->sched) < 0)
++        return -1;
++
++    for (i = 0; i < vm->def->ncachetunes; i++) {
++        virDomainCachetuneDefPtr ct = vm->def->cachetunes[i];
++
++        if (virBitmapIsBitSet(ct->vcpus, vcpuid)) {
++            if (virResctrlAllocAddPID(ct->alloc, vcpupid) < 0)
++                return -1;
++            break;
++        }
++    }
++
++    return 0;
+ }
+ 
+ 
+@@ -5892,6 +5932,10 @@ qemuProcessLaunch(virConnectPtr conn,
+     if (qemuProcessSetupEmulator(vm) < 0)
+         goto cleanup;
+ 
++    VIR_DEBUG("Setting up resctrlfs");
++    if (qemuProcessResctrlCreate(driver, vm) < 0)
++        goto cleanup;
++
+     VIR_DEBUG("Setting domain security labels");
+     if (qemuSecuritySetAllLabel(driver,
+                                 vm,
+@@ -6540,6 +6584,12 @@ void qemuProcessStop(virQEMUDriverPtr driver,
+                  vm->def->name);
+     }
+ 
++    /* Remove resctrl allocation after cgroups are cleaned up which makes it
++     * kind of safer (although removing the allocation should work even with
++     * pids in tasks file */
++    for (i = 0; i < vm->def->ncachetunes; i++)
++        virResctrlAllocRemove(vm->def->cachetunes[i]->alloc);
++
+     qemuProcessRemoveDomainStatus(driver, vm);
+ 
+     /* Remove VNC and Spice ports from port reservation bitmap, but only if
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-Advertise-ACPI-support-for-aarch64-guests.patch b/SOURCES/libvirt-qemu-Advertise-ACPI-support-for-aarch64-guests.patch
deleted file mode 100644
index 7abbd4f..0000000
--- a/SOURCES/libvirt-qemu-Advertise-ACPI-support-for-aarch64-guests.patch
+++ /dev/null
@@ -1,139 +0,0 @@
-From 2106b821cd1eef809853f7424edf8660732b1303 Mon Sep 17 00:00:00 2001
-Message-Id: <2106b821cd1eef809853f7424edf8660732b1303@dist-git>
-From: Andrea Bolognani <abologna@redhat.com>
-Date: Tue, 4 Apr 2017 14:59:30 +0200
-Subject: [PATCH] qemu: Advertise ACPI support for aarch64 guests
-
-So far, libvirt has assumed that only x86 supports ACPI,
-but that's inaccurate since aarch64 supports it too.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
-
-(cherry picked from commit 560335c35c830344329c16cb1f25f887344bdfd8)
-Signed-off-by: Andrea Bolognani <abologna@redhat.com>
----
- src/qemu/qemu_capabilities.c                       | 28 ++++++++++++++++------
- .../caps_2.6.0-gicv2.aarch64.xml                   |  1 +
- .../caps_2.6.0-gicv3.aarch64.xml                   |  1 +
- .../qemuxml2argv-aarch64-gic-host.args             |  1 +
- .../qemuxml2argv-aarch64-gic-v2.args               |  1 +
- .../qemuxml2argv-aarch64-gic-v3.args               |  1 +
- 6 files changed, 26 insertions(+), 7 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 9d0a29732..a8125102c 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -1043,13 +1043,17 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
- 
-         machines = NULL;
-         nmachines = 0;
-+    }
- 
-+    if ((ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64) &&
-+        virCapabilitiesAddGuestFeature(guest, "acpi", true, true) == NULL) {
-+        goto cleanup;
-     }
- 
-     if (ARCH_IS_X86(guestarch) &&
--        (virCapabilitiesAddGuestFeature(guest, "acpi", true, true) == NULL ||
--         virCapabilitiesAddGuestFeature(guest, "apic", true, false) == NULL))
-+        virCapabilitiesAddGuestFeature(guest, "apic", true, false) == NULL) {
-         goto cleanup;
-+    }
- 
-     if ((guestarch == VIR_ARCH_I686) &&
-         (virCapabilitiesAddGuestFeature(guest, "pae", true, false) == NULL ||
-@@ -4181,10 +4185,15 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid, const c
-                                 qmperr) < 0)
-         goto cleanup;
- 
--    /* -no-acpi is not supported on non-x86
--     * even if qemu reports it in -help */
--    if (!ARCH_IS_X86(qemuCaps->arch))
-+    /* Older QEMU versions reported -no-acpi in the output of -help even
-+     * though it was not supported by the architecture. The issue has since
-+     * been fixed, but to maintain compatibility with all release we still
-+     * need to filter out the capability for architectures that we know
-+     * don't support the feature, eg. anything but x86 and aarch64 */
-+    if (!ARCH_IS_X86(qemuCaps->arch) &&
-+        qemuCaps->arch != VIR_ARCH_AARCH64) {
-         virQEMUCapsClear(qemuCaps, QEMU_CAPS_NO_ACPI);
-+    }
- 
-     /* virQEMUCapsExtractDeviceStr will only set additional caps if qemu
-      * understands the 0.13.0+ notion of "-device driver,".  */
-@@ -4305,9 +4314,14 @@ virQEMUCapsInitQMPArch(virQEMUCapsPtr qemuCaps,
- void
- virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps)
- {
--    /* ACPI/HPET/KVM PIT are x86 specific */
--    if (ARCH_IS_X86(qemuCaps->arch)) {
-+    /* ACPI only works on x86 and aarch64 */
-+    if (ARCH_IS_X86(qemuCaps->arch) ||
-+        qemuCaps->arch == VIR_ARCH_AARCH64) {
-         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI);
-+    }
-+
-+    /* HPET and KVM PIT are x86 specific */
-+    if (ARCH_IS_X86(qemuCaps->arch)) {
-         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_HPET);
-         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT);
-     }
-diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
-index c1e46794a..af3a8e7cb 100644
---- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
-@@ -40,6 +40,7 @@
-   <flag name='no-shutdown'/>
-   <flag name='cache-unsafe'/>
-   <flag name='ich9-ahci'/>
-+  <flag name='no-acpi'/>
-   <flag name='fsdev-readonly'/>
-   <flag name='virtio-blk-pci.scsi'/>
-   <flag name='drive-copy-on-read'/>
-diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
-index 20dfda216..4402ffa6f 100644
---- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
-@@ -40,6 +40,7 @@
-   <flag name='no-shutdown'/>
-   <flag name='cache-unsafe'/>
-   <flag name='ich9-ahci'/>
-+  <flag name='no-acpi'/>
-   <flag name='fsdev-readonly'/>
-   <flag name='virtio-blk-pci.scsi'/>
-   <flag name='drive-copy-on-read'/>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args
-index 5fdaa08ef..23276ad71 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args
-@@ -15,4 +15,5 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
-+-no-acpi \
- -boot c
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args
-index 2caf1b92c..f79c1c60e 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args
-@@ -15,4 +15,5 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
-+-no-acpi \
- -boot c
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args
-index 3ae8e5f86..fce9308b0 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args
-@@ -15,4 +15,5 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
-+-no-acpi \
- -boot c
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Allow-live-updates-of-coalesce-settings.patch b/SOURCES/libvirt-qemu-Allow-live-updates-of-coalesce-settings.patch
deleted file mode 100644
index 10ba09c..0000000
--- a/SOURCES/libvirt-qemu-Allow-live-updates-of-coalesce-settings.patch
+++ /dev/null
@@ -1,220 +0,0 @@
-From ec733f7eb1f88d9d030952c764c1ee635ab9060b Mon Sep 17 00:00:00 2001
-Message-Id: <ec733f7eb1f88d9d030952c764c1ee635ab9060b@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Fri, 16 Jun 2017 13:45:30 +0200
-Subject: [PATCH] qemu: Allow live-updates of coalesce settings
-
-Change the settings from qemuDomainUpdateDeviceLive() as otherwise the
-call would succeed even though nothing has changed.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1414627
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-(cherry picked from commit 307a205e25ad7db7c895c42ab2e8f59f3839c058)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-
- Conflicts:
-	src/util/virnetdev.c - non-Linux stubs
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_hotplug.c | 13 +++++++
- src/util/virnetdev.c    | 93 ++++++++++++++++++++++++++++++++-----------------
- src/util/virnetdev.h    |  3 +-
- src/util/virnetdevtap.c |  2 +-
- 4 files changed, 77 insertions(+), 34 deletions(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index ab23a575d8..fbc9177669 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -3005,6 +3005,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
-     bool needLinkStateChange = false;
-     bool needReplaceDevDef = false;
-     bool needBandwidthSet = false;
-+    bool needCoalesceChange = false;
-     int ret = -1;
-     int changeidx = -1;
- 
-@@ -3293,6 +3294,12 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
-                                  virDomainNetGetActualBandwidth(newdev)))
-         needBandwidthSet = true;
- 
-+    if (!!olddev->coalesce != !!newdev->coalesce ||
-+        (olddev->coalesce && newdev->coalesce &&
-+         !memcmp(olddev->coalesce, newdev->coalesce,
-+                 sizeof(*olddev->coalesce))))
-+        needCoalesceChange = true;
-+
-     /* FINALLY - actually perform the required actions */
- 
-     if (needReconnect) {
-@@ -3328,6 +3335,12 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
-         needReplaceDevDef = true;
-     }
- 
-+    if (needCoalesceChange) {
-+        if (virNetDevSetCoalesce(newdev->ifname, newdev->coalesce, true) < 0)
-+            goto cleanup;
-+        needReplaceDevDef = true;
-+    }
-+
-     if (needLinkStateChange &&
-         qemuDomainChangeNetLinkState(driver, vm, olddev, newdev->linkstate) < 0) {
-         goto cleanup;
-diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
-index eb97b705e2..2beb39bb60 100644
---- a/src/util/virnetdev.c
-+++ b/src/util/virnetdev.c
-@@ -3093,7 +3093,8 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap ATTRIBUTE_UNUSED,
- /**
-  * virNetDevSetCoalesce:
-  * @ifname: interface name to modify
-- * @coalesce: Coalesce settings to set and update
-+ * @coalesce: Coalesce settings to set or update
-+ * @update: Whether this is an update for existing settings or not
-  *
-  * This function sets the various coalesce settings for a given interface
-  * @ifname and updates them back into @coalesce.
-@@ -3101,40 +3102,44 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap ATTRIBUTE_UNUSED,
-  * Returns 0 in case of success or -1 on failure
-  */
- int virNetDevSetCoalesce(const char *ifname,
--                         virNetDevCoalescePtr coalesce)
-+                         virNetDevCoalescePtr coalesce,
-+                         bool update)
- {
-     int fd = -1;
-     int ret = -1;
-     struct ifreq ifr;
-     struct ethtool_coalesce coal = {0};
- 
--    if (!coalesce)
-+    if (!coalesce && !update)
-         return 0;
- 
--    coal = (struct ethtool_coalesce) {
--        .cmd = ETHTOOL_SCOALESCE,
--        .rx_max_coalesced_frames = coalesce->rx_max_coalesced_frames,
--        .rx_coalesce_usecs_irq = coalesce->rx_coalesce_usecs_irq,
--        .rx_max_coalesced_frames_irq = coalesce->rx_max_coalesced_frames_irq,
--        .tx_coalesce_usecs = coalesce->tx_coalesce_usecs,
--        .tx_max_coalesced_frames = coalesce->tx_max_coalesced_frames,
--        .tx_coalesce_usecs_irq = coalesce->tx_coalesce_usecs_irq,
--        .tx_max_coalesced_frames_irq = coalesce->tx_max_coalesced_frames_irq,
--        .stats_block_coalesce_usecs = coalesce->stats_block_coalesce_usecs,
--        .use_adaptive_rx_coalesce = coalesce->use_adaptive_rx_coalesce,
--        .use_adaptive_tx_coalesce = coalesce->use_adaptive_tx_coalesce,
--        .pkt_rate_low = coalesce->pkt_rate_low,
--        .rx_coalesce_usecs_low = coalesce->rx_coalesce_usecs_low,
--        .rx_max_coalesced_frames_low = coalesce->rx_max_coalesced_frames_low,
--        .tx_coalesce_usecs_low = coalesce->tx_coalesce_usecs_low,
--        .tx_max_coalesced_frames_low = coalesce->tx_max_coalesced_frames_low,
--        .pkt_rate_high = coalesce->pkt_rate_high,
--        .rx_coalesce_usecs_high = coalesce->rx_coalesce_usecs_high,
--        .rx_max_coalesced_frames_high = coalesce->rx_max_coalesced_frames_high,
--        .tx_coalesce_usecs_high = coalesce->tx_coalesce_usecs_high,
--        .tx_max_coalesced_frames_high = coalesce->tx_max_coalesced_frames_high,
--        .rate_sample_interval = coalesce->rate_sample_interval,
--    };
-+    if (coalesce) {
-+        coal = (struct ethtool_coalesce) {
-+            .rx_max_coalesced_frames = coalesce->rx_max_coalesced_frames,
-+            .rx_coalesce_usecs_irq = coalesce->rx_coalesce_usecs_irq,
-+            .rx_max_coalesced_frames_irq = coalesce->rx_max_coalesced_frames_irq,
-+            .tx_coalesce_usecs = coalesce->tx_coalesce_usecs,
-+            .tx_max_coalesced_frames = coalesce->tx_max_coalesced_frames,
-+            .tx_coalesce_usecs_irq = coalesce->tx_coalesce_usecs_irq,
-+            .tx_max_coalesced_frames_irq = coalesce->tx_max_coalesced_frames_irq,
-+            .stats_block_coalesce_usecs = coalesce->stats_block_coalesce_usecs,
-+            .use_adaptive_rx_coalesce = coalesce->use_adaptive_rx_coalesce,
-+            .use_adaptive_tx_coalesce = coalesce->use_adaptive_tx_coalesce,
-+            .pkt_rate_low = coalesce->pkt_rate_low,
-+            .rx_coalesce_usecs_low = coalesce->rx_coalesce_usecs_low,
-+            .rx_max_coalesced_frames_low = coalesce->rx_max_coalesced_frames_low,
-+            .tx_coalesce_usecs_low = coalesce->tx_coalesce_usecs_low,
-+            .tx_max_coalesced_frames_low = coalesce->tx_max_coalesced_frames_low,
-+            .pkt_rate_high = coalesce->pkt_rate_high,
-+            .rx_coalesce_usecs_high = coalesce->rx_coalesce_usecs_high,
-+            .rx_max_coalesced_frames_high = coalesce->rx_max_coalesced_frames_high,
-+            .tx_coalesce_usecs_high = coalesce->tx_coalesce_usecs_high,
-+            .tx_max_coalesced_frames_high = coalesce->tx_max_coalesced_frames_high,
-+            .rate_sample_interval = coalesce->rate_sample_interval,
-+        };
-+    }
-+
-+    coal.cmd = ETHTOOL_SCOALESCE;
- 
-     if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
-         return -1;
-@@ -3148,12 +3153,36 @@ int virNetDevSetCoalesce(const char *ifname,
-         goto cleanup;
-     }
- 
--    coal = (struct ethtool_coalesce) {
--        .cmd = ETHTOOL_GCOALESCE,
--    };
-+    if (coalesce) {
-+        coal = (struct ethtool_coalesce) {
-+            .cmd = ETHTOOL_GCOALESCE,
-+        };
- 
--    /* Don't fail if the update itself fails */
--    virNetDevSendEthtoolIoctl(fd, &ifr);
-+        /* Don't fail if the update itself fails */
-+        if (virNetDevSendEthtoolIoctl(fd, &ifr) == 0) {
-+            coalesce->rx_max_coalesced_frames = coal.rx_max_coalesced_frames;
-+            coalesce->rx_coalesce_usecs_irq = coal.rx_coalesce_usecs_irq;
-+            coalesce->rx_max_coalesced_frames_irq = coal.rx_max_coalesced_frames_irq;
-+            coalesce->tx_coalesce_usecs = coal.tx_coalesce_usecs;
-+            coalesce->tx_max_coalesced_frames = coal.tx_max_coalesced_frames;
-+            coalesce->tx_coalesce_usecs_irq = coal.tx_coalesce_usecs_irq;
-+            coalesce->tx_max_coalesced_frames_irq = coal.tx_max_coalesced_frames_irq;
-+            coalesce->stats_block_coalesce_usecs = coal.stats_block_coalesce_usecs;
-+            coalesce->use_adaptive_rx_coalesce = coal.use_adaptive_rx_coalesce;
-+            coalesce->use_adaptive_tx_coalesce = coal.use_adaptive_tx_coalesce;
-+            coalesce->pkt_rate_low = coal.pkt_rate_low;
-+            coalesce->rx_coalesce_usecs_low = coal.rx_coalesce_usecs_low;
-+            coalesce->rx_max_coalesced_frames_low = coal.rx_max_coalesced_frames_low;
-+            coalesce->tx_coalesce_usecs_low = coal.tx_coalesce_usecs_low;
-+            coalesce->tx_max_coalesced_frames_low = coal.tx_max_coalesced_frames_low;
-+            coalesce->pkt_rate_high = coal.pkt_rate_high;
-+            coalesce->rx_coalesce_usecs_high = coal.rx_coalesce_usecs_high;
-+            coalesce->rx_max_coalesced_frames_high = coal.rx_max_coalesced_frames_high;
-+            coalesce->tx_coalesce_usecs_high = coal.tx_coalesce_usecs_high;
-+            coalesce->tx_max_coalesced_frames_high = coal.tx_max_coalesced_frames_high;
-+            coalesce->rate_sample_interval = coal.rate_sample_interval;
-+        }
-+    }
- 
-     ret = 0;
-  cleanup:
-diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
-index 97236c170d..c2c09af636 100644
---- a/src/util/virnetdev.h
-+++ b/src/util/virnetdev.h
-@@ -180,7 +180,8 @@ int virNetDevRestoreMacAddress(const char *linkdev,
-     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
- 
- int virNetDevSetCoalesce(const char *ifname,
--                         virNetDevCoalescePtr coalesce)
-+                         virNetDevCoalescePtr coalesce,
-+                         bool update)
-     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
- 
- int virNetDevSetMTU(const char *ifname,
-diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
-index c8dacfe27b..175dc2bfaa 100644
---- a/src/util/virnetdevtap.c
-+++ b/src/util/virnetdevtap.c
-@@ -663,7 +663,7 @@ int virNetDevTapCreateInBridgePort(const char *brname,
-     if (virNetDevSetOnline(*ifname, !!(flags & VIR_NETDEV_TAP_CREATE_IFUP)) < 0)
-         goto error;
- 
--    if (virNetDevSetCoalesce(*ifname, coalesce) < 0)
-+    if (virNetDevSetCoalesce(*ifname, coalesce, false) < 0)
-         goto error;
- 
-     return 0;
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Allow-memAccess-for-hugepages-again.patch b/SOURCES/libvirt-qemu-Allow-memAccess-for-hugepages-again.patch
deleted file mode 100644
index cc85976..0000000
--- a/SOURCES/libvirt-qemu-Allow-memAccess-for-hugepages-again.patch
+++ /dev/null
@@ -1,243 +0,0 @@
-From 7c4ee4b1708fcd1b9fbfcb9de1be66c8294e6bbb Mon Sep 17 00:00:00 2001
-Message-Id: <7c4ee4b1708fcd1b9fbfcb9de1be66c8294e6bbb@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Tue, 13 Jun 2017 18:12:13 +0200
-Subject: [PATCH] qemu: Allow memAccess for hugepages again
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1214369
-https://bugzilla.redhat.com/show_bug.cgi?id=1458638
-
-Historically, we've always supported memAccess for domains backed
-by hugepages. However, somewhere along the way we've regressed
-and stopped allowing such configuration. Fix it.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-(cherry picked from commit 671d18594f42f24f7cb3f1b2c574ff4ddba0b183)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_command.c                            | 18 ++-----
- .../qemuxml2argv-fd-memory-numa-topology2.args     |  2 +-
- .../qemuxml2argv-hugepages-memaccess.args          | 42 +++++++++++++++
- .../qemuxml2argv-hugepages-memaccess.xml           | 62 ++++++++++++++++++++++
- tests/qemuxml2argvtest.c                           |  3 ++
- .../qemuxml2xmlout-hugepages-memaccess.xml         |  1 +
- tests/qemuxml2xmltest.c                            |  1 +
- 7 files changed, 114 insertions(+), 15 deletions(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.xml
- create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess.xml
-
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index e220bf5ba0..c791214528 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -3345,6 +3345,9 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
-         memAccess = virDomainNumaGetNodeMemoryAccessMode(def->numa, mem->targetNode);
-     }
- 
-+    if (memAccess == VIR_DOMAIN_MEMORY_ACCESS_DEFAULT)
-+        memAccess = def->mem.access;
-+
-     if (virDomainNumatuneGetMode(def->numa, mem->targetNode, &mode) < 0 &&
-         virDomainNumatuneGetMode(def->numa, -1, &mode) < 0)
-         mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
-@@ -3402,7 +3405,7 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
-     if (!(props = virJSONValueNewObject()))
-         return -1;
- 
--    if (pagesize || mem->nvdimmPath ||
-+    if (pagesize || mem->nvdimmPath || memAccess ||
-         def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
-         *backendType = "memory-backend-file";
- 
-@@ -3439,23 +3442,10 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
-             break;
- 
-         case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
--            if (def->mem.access == VIR_DOMAIN_MEMORY_ACCESS_SHARED) {
--                if (virJSONValueObjectAdd(props, "b:share", true, NULL) < 0)
--                    goto cleanup;
--            }
--            break;
--
-         case VIR_DOMAIN_MEMORY_ACCESS_LAST:
-             break;
-         }
-     } else {
--        if (memAccess) {
--            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
--                           _("Shared memory mapping is supported "
--                             "only with hugepages"));
--            goto cleanup;
--        }
--
-         *backendType = "memory-backend-ram";
-     }
- 
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args
-index 4420b9ab22..e36f98b907 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args
-@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
- -mem-prealloc \
- -smp 20,sockets=1,cores=8,threads=1 \
- -object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
--size=15032385536 \
-+share=no,size=15032385536 \
- -numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
- -object memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,\
- share=yes,size=15032385536 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.args
-new file mode 100644
-index 0000000000..d584d465b5
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.args
-@@ -0,0 +1,42 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-i686 \
-+-name QEMUGuest1 \
-+-S \
-+-M pc \
-+-m size=4194304k,slots=16,maxmem=8388608k \
-+-smp 4,sockets=4,cores=1,threads=1 \
-+-object memory-backend-file,id=ram-node0,prealloc=yes,\
-+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,share=no,size=1073741824,\
-+host-nodes=0-3,policy=bind \
-+-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
-+-object memory-backend-file,id=ram-node1,prealloc=yes,\
-+mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=1073741824,\
-+host-nodes=0-3,policy=bind \
-+-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
-+-object memory-backend-file,id=ram-node2,prealloc=yes,\
-+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,share=no,size=1073741824,\
-+host-nodes=0-3,policy=bind \
-+-numa node,nodeid=2,cpus=2,memdev=ram-node2 \
-+-object memory-backend-file,id=ram-node3,prealloc=yes,\
-+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,share=no,size=1073741824,\
-+host-nodes=3,policy=bind \
-+-numa node,nodeid=3,cpus=3,memdev=ram-node3 \
-+-object memory-backend-file,id=memdimm0,prealloc=yes,\
-+mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=536870912,\
-+host-nodes=0-3,policy=bind \
-+-device pc-dimm,node=1,memdev=memdimm0,id=dimm0,slot=0,addr=4294967296 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-usb \
-+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.xml
-new file mode 100644
-index 0000000000..db9b9430e1
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.xml
-@@ -0,0 +1,62 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <maxMemory slots='16' unit='KiB'>8388608</maxMemory>
-+  <memory unit='KiB'>4194304</memory>
-+  <currentMemory unit='KiB'>4194304</currentMemory>
-+  <memoryBacking>
-+    <hugepages>
-+      <page size='2048' unit='KiB' nodeset='1'/>
-+      <page size='1048576' unit='KiB' nodeset='0,2-3'/>
-+    </hugepages>
-+    <access mode='private'/>
-+  </memoryBacking>
-+  <vcpu placement='static'>4</vcpu>
-+  <numatune>
-+    <memory mode='strict' nodeset='0-3'/>
-+    <memnode cellid='3' mode='strict' nodeset='3'/>
-+  </numatune>
-+  <os>
-+    <type arch='i686' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu>
-+    <numa>
-+      <cell id='0' cpus='0' memory='1048576' unit='KiB'/>
-+      <cell id='1' cpus='1' memory='1048576' unit='KiB' memAccess='shared'/>
-+      <cell id='2' cpus='2' memory='1048576' unit='KiB' memAccess='private'/>
-+      <cell id='3' cpus='3' memory='1048576' unit='KiB'/>
-+    </numa>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-i686</emulator>
-+    <disk type='block' device='disk'>
-+      <source dev='/dev/HostVG/QEMUGuest1'/>
-+      <target dev='hda' bus='ide'/>
-+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
-+    </disk>
-+    <controller type='usb' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
-+    </controller>
-+    <controller type='ide' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
-+    </controller>
-+    <controller type='pci' index='0' model='pci-root'/>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <memballoon model='virtio'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
-+    </memballoon>
-+    <memory model='dimm'>
-+      <target>
-+        <size unit='KiB'>524288</size>
-+        <node>1</node>
-+      </target>
-+      <address type='dimm' slot='0' base='0x100000000'/>
-+    </memory>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 175037bf96..77e52bd33b 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -827,6 +827,9 @@ mymain(void)
-             QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
-     DO_TEST("hugepages-pages5", QEMU_CAPS_MEM_PATH);
-     DO_TEST("hugepages-pages6", NONE);
-+    DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE,
-+            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
-+            QEMU_CAPS_NUMA);
-     DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
-     DO_TEST("disk-cdrom", NONE);
-     DO_TEST("disk-iscsi", NONE);
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess.xml
-new file mode 120000
-index 0000000000..23cef8e67d
---- /dev/null
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess.xml
-@@ -0,0 +1 @@
-+../qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.xml
-\ No newline at end of file
-diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
-index 72eac5e716..511d1b3fb9 100644
---- a/tests/qemuxml2xmltest.c
-+++ b/tests/qemuxml2xmltest.c
-@@ -420,6 +420,7 @@ mymain(void)
-     DO_TEST("hugepages-pages2", NONE);
-     DO_TEST("hugepages-pages3", NONE);
-     DO_TEST("hugepages-shared", NONE);
-+    DO_TEST("hugepages-memaccess", NONE);
-     DO_TEST("nosharepages", NONE);
-     DO_TEST("restore-v2", NONE);
-     DO_TEST("migrate", NONE);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Always-reset-TLS-in-qemuProcessRecoverMigrationOut.patch b/SOURCES/libvirt-qemu-Always-reset-TLS-in-qemuProcessRecoverMigrationOut.patch
deleted file mode 100644
index 98ee89c..0000000
--- a/SOURCES/libvirt-qemu-Always-reset-TLS-in-qemuProcessRecoverMigrationOut.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From 4b3819d67eaf7c9ed31a2d306968d24fecae68ea Mon Sep 17 00:00:00 2001
-Message-Id: <4b3819d67eaf7c9ed31a2d306968d24fecae68ea@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 5 Apr 2017 12:04:09 +0200
-Subject: [PATCH] qemu: Always reset TLS in qemuProcessRecoverMigrationOut
-
-qemuProcessRecoverMigrationOut doesn't explicitly call
-qemuMigrationResetTLS relying on two things:
-
-    - qemuMigrationCancel resets TLS parameters
-    - our migration code resets TLS before entering
-      QEMU_MIGRATION_PHASE_PERFORM3_DONE phase
-
-But this is not obvious and the assumptions will be broken soon. Let's
-explicitly reset TLS parameters on all paths which do not kill the
-domain.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 9d677e6a6ba075f489f791b6922a5dadf0e0c79f)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1425003
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 70b06a28f..2e0f859ce 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3077,6 +3077,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr driver,
-         }
-     }
- 
-+    qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_NONE, NULL, NULL);
-     return 0;
- }
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Always-send-persistent-XML-during-migration.patch b/SOURCES/libvirt-qemu-Always-send-persistent-XML-during-migration.patch
deleted file mode 100644
index cc3fa9d..0000000
--- a/SOURCES/libvirt-qemu-Always-send-persistent-XML-during-migration.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From d3df2456cfc82cba6afdb2f44dca91f6f553ac76 Mon Sep 17 00:00:00 2001
-Message-Id: <d3df2456cfc82cba6afdb2f44dca91f6f553ac76@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 7 Jun 2017 09:35:25 +0200
-Subject: [PATCH] qemu: Always send persistent XML during migration
-
-When persistent migration of a transient domain is requested but no
-custom XML is passed to the migration API we would just let the
-destination daemon make a persistent definition from the live definition
-itself. This is not a problem now, but once the destination daemon
-starts replacing the original CPU definition with the one from migration
-cookie before starting a domain, it would need to add more ugly hacks to
-reverse the operation. Let's just always send the persistent definition
-in the cookie to make things a bit cleaner.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit b0a16641fa648de23d1fd05a3e89987799550c44)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index ec5af7a612..a7c90a09e8 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -3613,8 +3613,9 @@ qemuMigrationRun(virQEMUDriverPtr driver,
-             if (!(persistDef = qemuMigrationPrepareDef(driver, persist_xml,
-                                                        NULL, NULL)))
-                 goto cleanup;
--        } else if (vm->newDef) {
--            if (!(persistDef = qemuDomainDefCopy(driver, vm->newDef,
-+        } else {
-+            virDomainDefPtr def = vm->newDef ? vm->newDef : vm->def;
-+            if (!(persistDef = qemuDomainDefCopy(driver, def,
-                                                  VIR_DOMAIN_XML_SECURE |
-                                                  VIR_DOMAIN_XML_MIGRATABLE)))
-                 goto cleanup;
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Avoid-comparing-size_t-with-1.patch b/SOURCES/libvirt-qemu-Avoid-comparing-size_t-with-1.patch
new file mode 100644
index 0000000..057aa65
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Avoid-comparing-size_t-with-1.patch
@@ -0,0 +1,36 @@
+From a29ee6823d600aaf40c06c67e954233c36624774 Mon Sep 17 00:00:00 2001
+Message-Id: <a29ee6823d600aaf40c06c67e954233c36624774@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Mon, 11 Dec 2017 14:34:20 +0100
+Subject: [PATCH] qemu: Avoid comparing size_t with -1
+
+ncpus would be -1 on error and the cleanup for loop would not be skipped
+in this case.
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit fd754cb69cb073d370d73b9eab65db8ce1400096)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1521202
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 4af1b6c662..165fdbc5ea 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -2965,7 +2965,7 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon)
+     size_t i;
+ 
+     if ((ncpus = qemuMonitorGetCPUDefinitions(mon, &cpus)) < 0)
+-        goto error;
++        return NULL;
+ 
+     if (!(models = virDomainCapsCPUModelsNew(ncpus)))
+         goto error;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Break-endless-loop-if-qemuMigrationResetTLS-fails.patch b/SOURCES/libvirt-qemu-Break-endless-loop-if-qemuMigrationResetTLS-fails.patch
deleted file mode 100644
index 315f05c..0000000
--- a/SOURCES/libvirt-qemu-Break-endless-loop-if-qemuMigrationResetTLS-fails.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From e2f2737b6f9aa4ba8399e87e2eecbfbc77f9b2a4 Mon Sep 17 00:00:00 2001
-Message-Id: <e2f2737b6f9aa4ba8399e87e2eecbfbc77f9b2a4@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 4 Apr 2017 12:46:37 +0200
-Subject: [PATCH] qemu: Break endless loop if qemuMigrationResetTLS fails
-
-Jumping to "endjob" label from a code after this label is not a very
-good idea.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit d658c8594e05d286de6af22ea88689d1d5e2a82b)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1300769
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 4 +---
- 1 file changed, 1 insertion(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index fcd3a38a1..992b6bd4a 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -5356,9 +5356,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
-                                  QEMU_ASYNC_JOB_MIGRATION_IN);
-     }
- 
--    if (qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
--                              NULL, NULL) < 0)
--        goto endjob;
-+    qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, NULL, NULL);
- 
-     qemuMigrationJobFinish(driver, vm);
-     if (!virDomainObjIsActive(vm))
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Change-coalesce-settings-on-hotplug-when-they-are-different.patch b/SOURCES/libvirt-qemu-Change-coalesce-settings-on-hotplug-when-they-are-different.patch
deleted file mode 100644
index 713189e..0000000
--- a/SOURCES/libvirt-qemu-Change-coalesce-settings-on-hotplug-when-they-are-different.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From 1ed2c3a16d7a4eaffafa07edf66a5148230726bf Mon Sep 17 00:00:00 2001
-Message-Id: <1ed2c3a16d7a4eaffafa07edf66a5148230726bf@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Wed, 21 Jun 2017 09:46:25 +0200
-Subject: [PATCH] qemu: Change coalesce settings on hotplug when they are
- different
-
-Part of the condition was reverted so no value update was propagated
-through.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1414627
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-(cherry picked from commit ff7bae6e4fb74a52239d53af3672900c69801508)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_hotplug.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index fbc9177669..a6274273dd 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -3296,8 +3296,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
- 
-     if (!!olddev->coalesce != !!newdev->coalesce ||
-         (olddev->coalesce && newdev->coalesce &&
--         !memcmp(olddev->coalesce, newdev->coalesce,
--                 sizeof(*olddev->coalesce))))
-+         memcmp(olddev->coalesce, newdev->coalesce,
-+                sizeof(*olddev->coalesce))))
-         needCoalesceChange = true;
- 
-     /* FINALLY - actually perform the required actions */
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Conditionally-allow-block-copy-for-persistent-domains.patch b/SOURCES/libvirt-qemu-Conditionally-allow-block-copy-for-persistent-domains.patch
deleted file mode 100644
index 1a784c0..0000000
--- a/SOURCES/libvirt-qemu-Conditionally-allow-block-copy-for-persistent-domains.patch
+++ /dev/null
@@ -1,90 +0,0 @@
-From e88d64a75a55dcd0173ba35b6f100d2ec5fcf312 Mon Sep 17 00:00:00 2001
-Message-Id: <e88d64a75a55dcd0173ba35b6f100d2ec5fcf312@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Wed, 7 Jun 2017 13:31:21 +0200
-Subject: [PATCH] qemu: Conditionally allow block-copy for persistent domains
-
-Allow starting the block-copy job for a persistent domain if a user
-declares by using a flag that the job will not be recovered if the VM is
-switched off while the job is active.
-
-This allows to use the block-copy job with persistent VMs under the same
-conditions as would apply to transient domains.
-
-(cherry picked from commit b7e534c651bfa28c65f7b11661b478613c96598c)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1459113
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- include/libvirt/libvirt-domain.h | 3 +++
- src/libvirt-domain.c             | 4 ++++
- src/qemu/qemu_driver.c           | 9 ++++++---
- 3 files changed, 13 insertions(+), 3 deletions(-)
-
-diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
-index 720db32f76..45f939a8cc 100644
---- a/include/libvirt/libvirt-domain.h
-+++ b/include/libvirt/libvirt-domain.h
-@@ -2428,6 +2428,9 @@ typedef enum {
-                                                  backing chain */
-     VIR_DOMAIN_BLOCK_COPY_REUSE_EXT = 1 << 1, /* Reuse existing external
-                                                  file for a copy */
-+    VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB = 1 << 2, /* Don't force usage of
-+                                                     recoverable job for the
-+                                                     copy operation */
- } virDomainBlockCopyFlags;
- 
- /**
-diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
-index 4670c54e5e..0adc9e8cbe 100644
---- a/src/libvirt-domain.c
-+++ b/src/libvirt-domain.c
-@@ -10026,6 +10026,10 @@ virDomainBlockRebase(virDomainPtr dom, const char *disk,
-  * or virDomainDetachDevice(), while a copy job is active; they may
-  * also restrict a copy job to transient domains.
-  *
-+ * If @flags contains VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB the job will not be
-+ * recoverable if the VM is turned off while job is active. This flag will
-+ * remove the restriction of copy jobs to transient domains.
-+ *
-  * The @disk parameter is either an unambiguous source name of the
-  * block device (the <source file='...'/> sub-element, such as
-  * "/path/to/image"), or the device target shorthand (the
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index a9ac06a63c..354329fe64 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -16509,7 +16509,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
- 
-     /* Preliminaries: find the disk we are editing, sanity checks */
-     virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW |
--                  VIR_DOMAIN_BLOCK_COPY_REUSE_EXT, -1);
-+                  VIR_DOMAIN_BLOCK_COPY_REUSE_EXT |
-+                  VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB, -1);
- 
-     priv = vm->privateData;
-     cfg = virQEMUDriverGetConfig(driver);
-@@ -16548,7 +16549,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
-                        _("block copy is not supported with this QEMU binary"));
-         goto endjob;
-     }
--    if (vm->persistent) {
-+    if (!(flags & VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB) &&
-+        vm->persistent) {
-         /* XXX if qemu ever lets us start a new domain with mirroring
-          * already active, we can relax this; but for now, the risk of
-          * 'managedsave' due to libvirt-guests means we can't risk
-@@ -16775,7 +16777,8 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
-     size_t i;
- 
-     virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW |
--                  VIR_DOMAIN_BLOCK_COPY_REUSE_EXT, -1);
-+                  VIR_DOMAIN_BLOCK_COPY_REUSE_EXT |
-+                  VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB, -1);
-     if (virTypedParamsValidate(params, nparams,
-                                VIR_DOMAIN_BLOCK_COPY_BANDWIDTH,
-                                VIR_TYPED_PARAM_ULLONG,
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Destroy-whole-memory-tree.patch b/SOURCES/libvirt-qemu-Destroy-whole-memory-tree.patch
new file mode 100644
index 0000000..2e55cb3
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Destroy-whole-memory-tree.patch
@@ -0,0 +1,42 @@
+From 7207faf95b38811cbf0d19df02066cc06a138822 Mon Sep 17 00:00:00 2001
+Message-Id: <7207faf95b38811cbf0d19df02066cc06a138822@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Thu, 9 Nov 2017 16:06:46 +0100
+Subject: [PATCH] qemu: Destroy whole memory tree
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1461214
+
+When removing path where huge pages are call virFileDeleteTree
+instead of plain rmdir(). The reason is that in the near future
+there's going to be more in the path than just files - some
+subdirs. Therefore plain rmdir() is not going to be enough.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit bb3de478a66edafd130ecca9a45a4d506ca727a0)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_process.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index 605f280d0c..3324cc61f1 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -3348,10 +3348,8 @@ qemuProcessBuildDestroyMemoryPathsImpl(virQEMUDriverPtr driver,
+             return -1;
+         }
+     } else {
+-        if (rmdir(path) < 0 &&
+-            errno != ENOENT)
+-            VIR_WARN("Unable to remove hugepage path: %s (errno=%d)",
+-                     path, errno);
++        if (virFileDeleteTree(path) < 0)
++            return -1;
+     }
+ 
+     return 0;
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Disallow-pivot-of-shared-disks-to-unsupported-storage.patch b/SOURCES/libvirt-qemu-Disallow-pivot-of-shared-disks-to-unsupported-storage.patch
new file mode 100644
index 0000000..c6a2dfd
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Disallow-pivot-of-shared-disks-to-unsupported-storage.patch
@@ -0,0 +1,40 @@
+From 9911807f7cf94ab328916fd9f00f20cc09a6455a Mon Sep 17 00:00:00 2001
+Message-Id: <9911807f7cf94ab328916fd9f00f20cc09a6455a@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:21 +0100
+Subject: [PATCH] qemu: Disallow pivot of shared disks to unsupported storage
+
+Pivoting to a unsupported storage type might break the assumption that
+shared disks will not corrupt metadata.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511480
+(cherry picked from commit 2b41c86294786c07f53afa633fe3dce703debc3c)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_driver.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
+index 620028fe07..d0d29747cf 100644
+--- a/src/qemu/qemu_driver.c
++++ b/src/qemu/qemu_driver.c
+@@ -16509,6 +16509,16 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
+         goto cleanup;
+     }
+ 
++    /* When pivoting to a shareable disk we need to make sure that the disk can
++     * be safely shared, since block copy might have changed the format. */
++    if (disk->src->shared && !disk->src->readonly &&
++        !qemuBlockStorageSourceSupportsConcurrentAccess(disk->mirror)) {
++        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
++                       _("can't pivot a shared disk to a storage volume not "
++                         "supporting sharing"));
++        goto cleanup;
++    }
++
+     /* For active commit, the mirror is part of the already labeled
+      * chain.  For blockcopy, we previously labeled only the top-level
+      * image; but if the user is reusing an external image that
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Do-not-skip-virCPUUpdateLive-if-priv-origCPU-is-set.patch b/SOURCES/libvirt-qemu-Do-not-skip-virCPUUpdateLive-if-priv-origCPU-is-set.patch
deleted file mode 100644
index 8e78a3c..0000000
--- a/SOURCES/libvirt-qemu-Do-not-skip-virCPUUpdateLive-if-priv-origCPU-is-set.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-From 6d2400987412f61857070407a43dc88705cf34f6 Mon Sep 17 00:00:00 2001
-Message-Id: <6d2400987412f61857070407a43dc88705cf34f6@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 21 Jun 2017 15:31:38 +0200
-Subject: [PATCH] qemu: Do not skip virCPUUpdateLive if priv->origCPU is set
-
-Even though we got both the original CPU (used for starting a domain)
-and the updated version (the CPU really provided by QEMU) during
-incoming migration, restore, or snapshot revert, we still need to update
-the CPU according to the data we got from the freshly started QEMU.
-Otherwise we don't know whether the CPU we got from QEMU matches the one
-before migration. We just need to keep the original CPU in
-priv->origCPU.
-
-Messed up by me in v3.4.0-58-g8e34f4781.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit eabb0002ca0bba3c5a94d16fb385783de7b144a5)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_process.c | 12 ++++--------
- 1 file changed, 4 insertions(+), 8 deletions(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index a7abfc720e..4d7c8d8e40 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3946,20 +3946,16 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-         if (qemuProcessVerifyCPUFeatures(def, cpu) < 0)
-             goto cleanup;
- 
--        /* Don't update the CPU if we already did so when starting a domain
--         * during migration, restore or snapshot revert. */
--        if (priv->origCPU) {
--            ret = 0;
--            goto cleanup;
--        }
--
-         if (!(orig = virCPUDefCopy(def->cpu)))
-             goto cleanup;
- 
-         if ((rc = virCPUUpdateLive(def->os.arch, def->cpu, cpu, disabled)) < 0) {
-             goto cleanup;
-         } else if (rc == 0) {
--            if (!virCPUDefIsEqual(def->cpu, orig, false))
-+            /* Store the original CPU in priv if QEMU changed it and we didn't
-+             * get the original CPU via migration, restore, or snapshot revert.
-+             */
-+            if (!priv->origCPU && !virCPUDefIsEqual(def->cpu, orig, false))
-                 VIR_STEAL_PTR(priv->origCPU, orig);
- 
-             def->cpu->check = VIR_CPU_CHECK_FULL;
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Don-t-error-out-if-allocation-info-can-t-be-queried.patch b/SOURCES/libvirt-qemu-Don-t-error-out-if-allocation-info-can-t-be-queried.patch
deleted file mode 100644
index 10f0c04..0000000
--- a/SOURCES/libvirt-qemu-Don-t-error-out-if-allocation-info-can-t-be-queried.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From bd25ad4689524e4212a72c7d40a18e91071cfa35 Mon Sep 17 00:00:00 2001
-Message-Id: <bd25ad4689524e4212a72c7d40a18e91071cfa35@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Fri, 2 Jun 2017 12:52:56 +0200
-Subject: [PATCH] qemu: Don't error out if allocation info can't be queried
-
-qemuDomainGetBlockInfo would error out if qemu did not report
-'wr_highest_offset'. This usually does not happen, but can happen
-briefly during active layer block commit. There's no need to report the
-error, we can simply report that the disk is fully alocated at that
-point.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1452045
-(cherry picked from commit c245f558369de5eb404e54728bf69ad27942e912)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 8 --------
- 1 file changed, 8 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index b741c1b5a6..fdfa4a50e1 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -11555,14 +11555,6 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
-     }
- 
-     if (!entry->wr_highest_offset_valid) {
--        if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_BLOCK &&
--            disk->src->format != VIR_STORAGE_FILE_RAW) {
--            virReportError(VIR_ERR_INTERNAL_ERROR,
--                           _("failed to query the maximum written offset of "
--                             "block device '%s'"), disk->dst);
--            goto endjob;
--        }
--
-         info->allocation = entry->physical;
-     } else {
-         if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_FILE &&
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Don-t-fail-if-physical-size-can-t-be-updated-in-qemuDomainGetBlockInfo.patch b/SOURCES/libvirt-qemu-Don-t-fail-if-physical-size-can-t-be-updated-in-qemuDomainGetBlockInfo.patch
deleted file mode 100644
index 50a2865..0000000
--- a/SOURCES/libvirt-qemu-Don-t-fail-if-physical-size-can-t-be-updated-in-qemuDomainGetBlockInfo.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From 19acba61eef5c5caf17e5b75b4e2ea30458a18b3 Mon Sep 17 00:00:00 2001
-Message-Id: <19acba61eef5c5caf17e5b75b4e2ea30458a18b3@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Fri, 28 Apr 2017 10:37:00 +0200
-Subject: [PATCH] qemu: Don't fail if physical size can't be updated in
- qemuDomainGetBlockInfo
-
-Since commit c5f6151390 qemuDomainBlockInfo tries to update the
-"physical" storage size for all network storage and not only block
-devices.
-
-Since the storage driver APIs to do this are not implemented for certain
-storage types (RBD, iSCSI, ...) the code would fail to retrieve any data
-since the failure of qemuDomainStorageUpdatePhysical is fatal.
-
-Since it's desired to return data even if the total size can't be
-updated we need to ignore errors from that function and return plausible
-data.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1442344
-(cherry picked from commit 9f16bb7386939c400a7522d2489245f1e6831bae)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 10 ++++++----
- 1 file changed, 6 insertions(+), 4 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 3f3eca440..2fcf4612e 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -11567,10 +11567,12 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
-         if (info->allocation == 0)
-             info->allocation = entry->physical;
- 
--        if (qemuDomainStorageUpdatePhysical(driver, cfg, vm, disk->src) < 0)
--            goto endjob;
--
--        info->physical = disk->src->physical;
-+        if (qemuDomainStorageUpdatePhysical(driver, cfg, vm, disk->src) == 0) {
-+            info->physical = disk->src->physical;
-+        } else {
-+            virResetLastError();
-+            info->physical = entry->physical;
-+        }
-     } else {
-         info->physical = entry->physical;
-     }
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Don-t-initialize-struct-utsname.patch b/SOURCES/libvirt-qemu-Don-t-initialize-struct-utsname.patch
new file mode 100644
index 0000000..5ed49ef
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Don-t-initialize-struct-utsname.patch
@@ -0,0 +1,34 @@
+From 27e59af45b7e283b94617330e3327eff4bd91bdb Mon Sep 17 00:00:00 2001
+Message-Id: <27e59af45b7e283b94617330e3327eff4bd91bdb@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Mon, 22 Jan 2018 14:51:11 +0100
+Subject: [PATCH] qemu: Don't initialize struct utsname
+
+It breaks the build and it is not really useful for anything.
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+(cherry picked from commit ba9ea2ad7dd15d9a2e9c7a5b9a8a3e7066351015)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1525182
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index af4875f82e..bd80edc978 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -5416,7 +5416,7 @@ virQEMUCapsCacheNew(const char *libDir,
+     char *capsCacheDir = NULL;
+     virFileCachePtr cache = NULL;
+     virQEMUCapsCachePrivPtr priv = NULL;
+-    struct utsname uts = { 0 };
++    struct utsname uts;
+ 
+     if (virAsprintf(&capsCacheDir, "%s/capabilities", cacheDir) < 0)
+         goto error;
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-Don-t-overwrite-existing-error-in-qemuMigrationReset.patch b/SOURCES/libvirt-qemu-Don-t-overwrite-existing-error-in-qemuMigrationReset.patch
deleted file mode 100644
index 9e86a07..0000000
--- a/SOURCES/libvirt-qemu-Don-t-overwrite-existing-error-in-qemuMigrationReset.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 28079e51b504ad2e5849d38dc994c41d319bf133 Mon Sep 17 00:00:00 2001
-Message-Id: <28079e51b504ad2e5849d38dc994c41d319bf133@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Thu, 6 Apr 2017 09:23:18 +0200
-Subject: [PATCH] qemu: Don't overwrite existing error in qemuMigrationReset
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439130
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 45b639bdbabe59056a6fc89ee4189fe695d6fae2)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 13 ++++++++++---
- 1 file changed, 10 insertions(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index ae0ab368d..8c6d1385e 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -5871,15 +5871,22 @@ qemuMigrationReset(virQEMUDriverPtr driver,
-                    qemuDomainAsyncJob job)
- {
-     qemuMonitorMigrationCaps cap;
-+    virErrorPtr err = virSaveLastError();
- 
-     if (!virDomainObjIsActive(vm))
--        return;
-+        goto cleanup;
- 
-     if (qemuMigrationResetTLS(driver, vm, job) < 0)
--        return;
-+        goto cleanup;
- 
-     for (cap = 0; cap < QEMU_MONITOR_MIGRATION_CAPS_LAST; cap++) {
-         if (qemuMigrationSetOption(driver, vm, cap, false, job) < 0)
--            return;
-+            goto cleanup;
-+    }
-+
-+ cleanup:
-+    if (err) {
-+        virSetError(err);
-+        virFreeError(err);
-     }
- }
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Don-t-reset-TLS-in-qemuMigrationCancel.patch b/SOURCES/libvirt-qemu-Don-t-reset-TLS-in-qemuMigrationCancel.patch
deleted file mode 100644
index 187a2c4..0000000
--- a/SOURCES/libvirt-qemu-Don-t-reset-TLS-in-qemuMigrationCancel.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 4060e79aee023bf56323ad6daf82c4aa1bde308b Mon Sep 17 00:00:00 2001
-Message-Id: <4060e79aee023bf56323ad6daf82c4aa1bde308b@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 5 Apr 2017 14:44:26 +0200
-Subject: [PATCH] qemu: Don't reset TLS in qemuMigrationCancel
-
-Migration parameters are either reset by the main migration code path or
-from qemuProcessRecoverMigration* in case libvirtd is restarted during
-migration.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 133c73e75f278c4943cbe03333bb9a7ee897c23f)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1425003
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 3 ---
- 1 file changed, 3 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index d8d89b011..6c9f14245 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -5560,9 +5560,6 @@ qemuMigrationCancel(virQEMUDriverPtr driver,
-     if (qemuDomainObjExitMonitor(driver, vm) < 0 || (storage && !blockJobs))
-         goto endsyncjob;
- 
--    ignore_value(qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_NONE,
--                                       NULL, NULL));
--
-     if (!storage) {
-         ret = 0;
-         goto cleanup;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Don-t-reset-TLS-in-qemuMigrationRun.patch b/SOURCES/libvirt-qemu-Don-t-reset-TLS-in-qemuMigrationRun.patch
deleted file mode 100644
index 546f10f..0000000
--- a/SOURCES/libvirt-qemu-Don-t-reset-TLS-in-qemuMigrationRun.patch
+++ /dev/null
@@ -1,66 +0,0 @@
-From 0811efa2bcaae69e59fe09432083224e77eafa1d Mon Sep 17 00:00:00 2001
-Message-Id: <0811efa2bcaae69e59fe09432083224e77eafa1d@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 5 Apr 2017 10:24:47 +0200
-Subject: [PATCH] qemu: Don't reset TLS in qemuMigrationRun
-
-Finished qemuMigrationRun does not mean the migration itself finished
-(it might have just switched to post-copy mode). While resetting TLS
-parameters is probably OK at this point even if migration is still
-running, we want to consolidate the code which resets various migration
-parameters. Thus qemuMigrationResetTLS will be called from the Confirm
-phase (or at the end of the Perform phase in case of v2 protocol), when
-migration is either canceled or finished.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit a88c250d8693ae198d42cf26e2b7b1e190e94637)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1425003
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 14 ++++++++++----
- 1 file changed, 10 insertions(+), 4 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 992b6bd4a..d8d89b011 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -3216,6 +3216,9 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
-             qemuDomainEventQueue(driver, event);
-         }
- 
-+        qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
-+                              NULL, NULL);
-+
-         if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
-             VIR_WARN("Failed to save status on vm %s", vm->def->name);
-     }
-@@ -3848,10 +3851,6 @@ qemuMigrationRun(virQEMUDriverPtr driver,
-             ret = -1;
-     }
- 
--    if (qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
--                              tlsAlias, secAlias) < 0)
--        ret = -1;
--
-     VIR_FREE(tlsAlias);
-     VIR_FREE(secAlias);
-     virObjectUnref(cfg);
-@@ -4827,6 +4826,13 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
-     if (ret < 0)
-         orig_err = virSaveLastError();
- 
-+    /* v2 proto has no confirm phase so we need to reset migration parameters
-+     * here
-+     */
-+    if (!v3proto && ret < 0)
-+        qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
-+                              NULL, NULL);
-+
-     if (qemuMigrationRestoreDomainState(conn, vm)) {
-         event = virDomainEventLifecycleNewFromObj(vm,
-                                          VIR_DOMAIN_EVENT_RESUMED,
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Don-t-reset-events-migration-capability.patch b/SOURCES/libvirt-qemu-Don-t-reset-events-migration-capability.patch
deleted file mode 100644
index 32c4544..0000000
--- a/SOURCES/libvirt-qemu-Don-t-reset-events-migration-capability.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From e94894df02d97bac7169433fdcf595bd526eafd1 Mon Sep 17 00:00:00 2001
-Message-Id: <e94894df02d97bac7169433fdcf595bd526eafd1@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 28 Apr 2017 15:56:44 +0200
-Subject: [PATCH] qemu: Don't reset "events" migration capability
-
-When creating v3.2.0-77-g8be3ccd04 commit, I completely forgot that one
-migration capability is very special. It's the "events" capability which
-tells QEMU to report "MIGRATION" events. Since libvirt always wants the
-events, it is enabled in qemuConnectMonitor and the rest of the code
-should not touch it.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439841
-https://bugzilla.redhat.com/show_bug.cgi?id=1441165
-
-Messed-up-by: Jiri Denemark <jdenemar@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit fc48fc7930f560c4341f4afe1285848dfdb60278)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index cadbf9b97..ac7e27319 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -5888,6 +5888,11 @@ qemuMigrationReset(virQEMUDriverPtr driver,
-         goto cleanup;
- 
-     for (cap = 0; cap < QEMU_MONITOR_MIGRATION_CAPS_LAST; cap++) {
-+        /* "events" capability is set (when supported) in qemuConnectMonitor
-+         * and should never be cleared */
-+        if (cap == QEMU_MONITOR_MIGRATION_CAPS_EVENTS)
-+            continue;
-+
-         if (qemuMigrationSetOption(driver, vm, cap, false, job) < 0)
-             goto cleanup;
-     }
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Don-t-try-to-use-hugepages-if-not-enabled.patch b/SOURCES/libvirt-qemu-Don-t-try-to-use-hugepages-if-not-enabled.patch
deleted file mode 100644
index 3c17996..0000000
--- a/SOURCES/libvirt-qemu-Don-t-try-to-use-hugepages-if-not-enabled.patch
+++ /dev/null
@@ -1,101 +0,0 @@
-From 893ebcda06c14d25dd195f53a1467fb243b43838 Mon Sep 17 00:00:00 2001
-Message-Id: <893ebcda06c14d25dd195f53a1467fb243b43838@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Wed, 14 Jun 2017 16:58:13 +0200
-Subject: [PATCH] qemu: Don't try to use hugepages if not enabled
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1214369
-
-My fix 671d18594f4 was incomplete. If domain doesn't have
-hugepages enabled, because of missing condition we would still be
-putting hugepages path onto qemu cmd line. Clean up the
-conditions so that it's more visible next time.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-(cherry picked from commit 1e8d6c6ef07a33ab338c2bf38fa017d4f2123335)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_command.c                            | 12 +++++-----
- .../qemuxml2argv-cpu-numa-memshared.args           | 26 ++++++++++++++++++++++
- tests/qemuxml2argvtest.c                           |  1 +
- 3 files changed, 33 insertions(+), 6 deletions(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
-
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 5013d3149d..88223babeb 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -3409,19 +3409,19 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
-         def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
-         *backendType = "memory-backend-file";
- 
--        if (mem->nvdimmPath) {
-+        if (pagesize) {
-+            if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0)
-+                goto cleanup;
-+            prealloc = true;
-+        } else if (mem->nvdimmPath) {
-             if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0)
-                 goto cleanup;
-             prealloc = true;
--        } else if (!pagesize && def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
-+        } else {
-             /* We can have both pagesize and mem source. If that's the case,
-              * prefer hugepages as those are more specific. */
-             if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0)
-                 goto cleanup;
--        } else {
--            if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0)
--                goto cleanup;
--            prealloc = true;
-         }
- 
-         if (virJSONValueObjectAdd(props,
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
-new file mode 100644
-index 0000000000..677e17e7df
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
-@@ -0,0 +1,26 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu \
-+-name QEMUGuest1 \
-+-S \
-+-M pc \
-+-m 214 \
-+-smp 16,sockets=2,cores=4,threads=2 \
-+-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
-+share=yes,size=112197632 \
-+-numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
-+-object memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,\
-+share=no,size=112197632 \
-+-numa node,nodeid=1,cpus=8-15,memdev=ram-node1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot n \
-+-usb \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 98e70033ec..0745d3807a 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -1549,6 +1549,7 @@ mymain(void)
-     DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
-     DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_RAM);
-     DO_TEST_FAILURE("cpu-numa-memshared", NONE);
-+    DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
-     DO_TEST("cpu-host-model", NONE);
-     DO_TEST("cpu-host-model-vendor", NONE);
-     skipLegacyCPUs = true;
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Don-t-update-CPU-when-checking-ABI-stability.patch b/SOURCES/libvirt-qemu-Don-t-update-CPU-when-checking-ABI-stability.patch
deleted file mode 100644
index 85a5901..0000000
--- a/SOURCES/libvirt-qemu-Don-t-update-CPU-when-checking-ABI-stability.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From d260867d18aa20c4d79f4319b82453120d209eae Mon Sep 17 00:00:00 2001
-Message-Id: <d260867d18aa20c4d79f4319b82453120d209eae@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 27 Jun 2017 15:06:10 +0200
-Subject: [PATCH] qemu: Don't update CPU when checking ABI stability
-
-When checking ABI stability between two domain definitions, we first
-make migratable copies of them. However, we also asked for the guest CPU
-to be updated, even though the updated CPU is supposed to be already
-included in the original definitions. Moreover, if we do this on the
-destination host during migration, we're potentially updating the
-definition with according to an incompatible host CPU.
-
-While updating the CPU when checking ABI stability doesn't make any
-sense, it actually just worked because updating the CPU doesn't do
-anything for custom CPUs (only host-model CPUs are affected) and we
-updated both definitions in the same way.
-
-Less then a year ago commit v2.3.0-rc1~42 stopped updating the CPU in
-the definition we got internally and only the user supplied definition
-was updated. However, the same commit started updating host-model CPUs
-to custom CPUs which are not affected by the request to update the CPU.
-So it still seemed to work right, unless a user upgraded libvirt 2.2.0
-to a newer version while there were some domains with host-model CPUs
-running on the host. Such domains couldn't be migrated with a user
-supplied XML since libvirt would complain:
-
-    Target CPU mode custom does not match source host-model
-
-The fix is pretty straightforward, we just need to stop updating the CPU
-when checking ABI stability.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1463957
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit ee68bb391efb684341edb6286a1278631167f08c)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1470582
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_domain.c | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 1528c6a137..6ccc9f6f5b 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -5910,7 +5910,6 @@ qemuDomainMigratableDefCheckABIStability(virQEMUDriverPtr driver,
- 
- 
- #define COPY_FLAGS (VIR_DOMAIN_XML_SECURE | \
--                    VIR_DOMAIN_XML_UPDATE_CPU | \
-                     VIR_DOMAIN_XML_MIGRATABLE)
- 
- bool
--- 
-2.13.2
-
diff --git a/SOURCES/libvirt-qemu-Drop-resume-label-in-qemuProcessRecoverMigrationOut.patch b/SOURCES/libvirt-qemu-Drop-resume-label-in-qemuProcessRecoverMigrationOut.patch
deleted file mode 100644
index 65cb35b..0000000
--- a/SOURCES/libvirt-qemu-Drop-resume-label-in-qemuProcessRecoverMigrationOut.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-From 7e2bb20a6318c5e7a42b0fe417b6e12862c65d64 Mon Sep 17 00:00:00 2001
-Message-Id: <7e2bb20a6318c5e7a42b0fe417b6e12862c65d64@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 4 Apr 2017 20:54:57 +0200
-Subject: [PATCH] qemu: Drop resume label in qemuProcessRecoverMigrationOut
-
-Let's use a bool variable to create a single shared path returning 0.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 3e803176a3d9242f6833687e305aebd7353ffaa3)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1425003
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 31 ++++++++++++++++---------------
- 1 file changed, 16 insertions(+), 15 deletions(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 0b9b4f76a..70b06a28f 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -2998,6 +2998,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr driver,
-     bool postcopy = state == VIR_DOMAIN_PAUSED &&
-                     (reason == VIR_DOMAIN_PAUSED_POSTCOPY ||
-                      reason == VIR_DOMAIN_PAUSED_POSTCOPY_FAILED);
-+    bool resume = false;
- 
-     switch (phase) {
-     case QEMU_MIGRATION_PHASE_NONE:
-@@ -3028,7 +3029,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr driver,
-                 VIR_WARN("Could not cancel ongoing migration of domain %s",
-                          vm->def->name);
-             }
--            goto resume;
-+            resume = true;
-         }
-         break;
- 
-@@ -3051,7 +3052,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr driver,
-         } else {
-             VIR_DEBUG("Resuming domain %s after failed migration",
-                       vm->def->name);
--            goto resume;
-+            resume = true;
-         }
-         break;
- 
-@@ -3061,21 +3062,21 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr driver,
-         return -1;
-     }
- 
--    return 0;
--
-- resume:
--    /* resume the domain but only if it was paused as a result of
--     * migration
--     */
--    if (state == VIR_DOMAIN_PAUSED &&
--        (reason == VIR_DOMAIN_PAUSED_MIGRATION ||
--         reason == VIR_DOMAIN_PAUSED_UNKNOWN)) {
--        if (qemuProcessStartCPUs(driver, vm, conn,
--                                 VIR_DOMAIN_RUNNING_UNPAUSED,
--                                 QEMU_ASYNC_JOB_NONE) < 0) {
--            VIR_WARN("Could not resume domain %s", vm->def->name);
-+    if (resume) {
-+        /* resume the domain but only if it was paused as a result of
-+         * migration
-+         */
-+        if (state == VIR_DOMAIN_PAUSED &&
-+            (reason == VIR_DOMAIN_PAUSED_MIGRATION ||
-+             reason == VIR_DOMAIN_PAUSED_UNKNOWN)) {
-+            if (qemuProcessStartCPUs(driver, vm, conn,
-+                                     VIR_DOMAIN_RUNNING_UNPAUSED,
-+                                     QEMU_ASYNC_JOB_NONE) < 0) {
-+                VIR_WARN("Could not resume domain %s", vm->def->name);
-+            }
-         }
-     }
-+
-     return 0;
- }
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Enable-configuration-of-HPT-resizing-for-pSeries-guests.patch b/SOURCES/libvirt-qemu-Enable-configuration-of-HPT-resizing-for-pSeries-guests.patch
new file mode 100644
index 0000000..e5a971b
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Enable-configuration-of-HPT-resizing-for-pSeries-guests.patch
@@ -0,0 +1,299 @@
+From 6d24efd64d6de00d29f8bf2329940c427f5cc6f9 Mon Sep 17 00:00:00 2001
+Message-Id: <6d24efd64d6de00d29f8bf2329940c427f5cc6f9@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 15 Nov 2017 10:28:54 +0100
+Subject: [PATCH] qemu: Enable configuration of HPT resizing for pSeries guests
+
+Most of the time it's okay to leave this up to negotiation between
+the guest and the host, but in some situations it can be useful to
+manually decide the behavior, especially to enforce its availability.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1308743
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 85b2ae96dfcf7dc324d6782f64c848fa412443e4)
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/schemas/domaincommon.rng                    | 15 ++++++++
+ src/conf/domain_conf.c                           | 46 +++++++++++++++++++++++-
+ src/conf/domain_conf.h                           | 12 +++++++
+ src/libvirt_private.syms                         |  1 +
+ src/qemu/qemu_capabilities.c                     |  8 +++++
+ src/qemu/qemu_capabilities.h                     |  1 +
+ src/qemu/qemu_command.c                          | 20 +++++++++++
+ src/qemu/qemu_domain.c                           |  8 +++++
+ tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml |  1 +
+ 9 files changed, 111 insertions(+), 1 deletion(-)
+
+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
+index 710b3af7f7..367861c1ea 100644
+--- a/docs/schemas/domaincommon.rng
++++ b/docs/schemas/domaincommon.rng
+@@ -4722,6 +4722,9 @@
+           <optional>
+             <ref name="ioapic"/>
+           </optional>
++          <optional>
++            <ref name="hpt"/>
++          </optional>
+         </interleave>
+       </element>
+     </optional>
+@@ -4910,6 +4913,18 @@
+     </element>
+   </define>
+ 
++  <define name="hpt">
++    <element name="hpt">
++      <attribute name="resizing">
++        <choice>
++          <value>enabled</value>
++          <value>disabled</value>
++          <value>required</value>
++        </choice>
++      </attribute>
++    </element>
++  </define>
++
+   <define name="address">
+     <element name="address">
+       <choice>
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index ca5d0bcc54..641a978f07 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -148,7 +148,9 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
+               "vmport",
+               "gic",
+               "smm",
+-              "ioapic")
++              "ioapic",
++              "hpt",
++);
+ 
+ VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
+               "default",
+@@ -877,6 +879,13 @@ VIR_ENUM_IMPL(virDomainIOAPIC,
+               "qemu",
+               "kvm")
+ 
++VIR_ENUM_IMPL(virDomainHPTResizing,
++              VIR_DOMAIN_HPT_RESIZING_LAST,
++              "enabled",
++              "disabled",
++              "required",
++);
++
+ /* Internal mapping: subset of block job types that can be present in
+  * <mirror> XML (remaining types are not two-phase). */
+ VIR_ENUM_DECL(virDomainBlockJob)
+@@ -18765,6 +18774,22 @@ virDomainDefParseXML(xmlDocPtr xml,
+             }
+             break;
+ 
++        case VIR_DOMAIN_FEATURE_HPT:
++            tmp = virXMLPropString(nodes[i], "resizing");
++            if (tmp) {
++                int value = virDomainHPTResizingTypeFromString(tmp);
++                if (value < 0) {
++                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                                   _("Unknown HPT resizing setting: %s"),
++                                   tmp);
++                    goto error;
++                }
++                def->hpt_resizing = value;
++                def->features[val] = VIR_TRISTATE_SWITCH_ON;
++                VIR_FREE(tmp);
++            }
++            break;
++
+         /* coverity[dead_error_begin] */
+         case VIR_DOMAIN_FEATURE_LAST:
+             break;
+@@ -20955,6 +20980,18 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
+         return false;
+     }
+ 
++    /* HPT resizing */
++    if (src->features[VIR_DOMAIN_FEATURE_HPT] == VIR_TRISTATE_SWITCH_ON) {
++        if (src->hpt_resizing != dst->hpt_resizing) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                           _("HPT resizing configuration differs: "
++                             "source: '%s', destination: '%s'"),
++                           virDomainHPTResizingTypeToString(src->hpt_resizing),
++                           virDomainHPTResizingTypeToString(dst->hpt_resizing));
++            return false;
++        }
++    }
++
+     return true;
+ }
+ 
+@@ -26204,6 +26241,13 @@ virDomainDefFormatInternal(virDomainDefPtr def,
+                 }
+                 break;
+ 
++            case VIR_DOMAIN_FEATURE_HPT:
++                if (def->features[i] == VIR_TRISTATE_SWITCH_ON) {
++                    virBufferAsprintf(buf, "<hpt resizing='%s'/>\n",
++                                      virDomainHPTResizingTypeToString(def->hpt_resizing));
++                }
++                break;
++
+             /* coverity[dead_error_begin] */
+             case VIR_DOMAIN_FEATURE_LAST:
+                 break;
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 388fa92dda..f967e603d1 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -1715,6 +1715,7 @@ typedef enum {
+     VIR_DOMAIN_FEATURE_GIC,
+     VIR_DOMAIN_FEATURE_SMM,
+     VIR_DOMAIN_FEATURE_IOAPIC,
++    VIR_DOMAIN_FEATURE_HPT,
+ 
+     VIR_DOMAIN_FEATURE_LAST
+ } virDomainFeature;
+@@ -1843,6 +1844,16 @@ typedef enum {
+ 
+ VIR_ENUM_DECL(virDomainIOAPIC);
+ 
++typedef enum {
++    VIR_DOMAIN_HPT_RESIZING_ENABLED = 0,
++    VIR_DOMAIN_HPT_RESIZING_DISABLED,
++    VIR_DOMAIN_HPT_RESIZING_REQUIRED,
++
++    VIR_DOMAIN_HPT_RESIZING_LAST
++} virDomainHPTResizing;
++
++VIR_ENUM_DECL(virDomainHPTResizing);
++
+ /* Operating system configuration data & machine / arch */
+ typedef struct _virDomainOSEnv virDomainOSEnv;
+ typedef virDomainOSEnv *virDomainOSEnvPtr;
+@@ -2315,6 +2326,7 @@ struct _virDomainDef {
+     virGICVersion gic_version;
+     char *hyperv_vendor_id;
+     virDomainIOAPIC ioapic;
++    virDomainHPTResizing hpt_resizing;
+ 
+     /* These options are of type virTristateSwitch: ON = keep, OFF = drop */
+     int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 6653f95722..8d1d4a896b 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -385,6 +385,7 @@ virDomainHostdevModeTypeToString;
+ virDomainHostdevRemove;
+ virDomainHostdevSubsysPCIBackendTypeToString;
+ virDomainHostdevSubsysTypeToString;
++virDomainHPTResizingTypeToString;
+ virDomainHubTypeFromString;
+ virDomainHubTypeToString;
+ virDomainHypervTypeFromString;
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 37a58b3640..3793f16590 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -443,6 +443,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
+               /* 270 */
+               "vxhs",
+               "virtio-blk.num-queues",
++              "machine.pseries.resize-hpt",
+     );
+ 
+ 
+@@ -4780,6 +4781,13 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
+     if (qemuCaps->version >= 2006000)
+         virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT);
+ 
++    /* HPT resizing is supported since QEMU 2.10 on ppc64; unfortunately
++     * there's no sane way to probe for it */
++    if (qemuCaps->version >= 2010000 &&
++        ARCH_IS_PPC64(qemuCaps->arch)) {
++        virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
++    }
++
+     if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0)
+         goto cleanup;
+ 
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index cacc2b77ed..f0e2e9016f 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -429,6 +429,7 @@ typedef enum {
+     /* 270 */
+     QEMU_CAPS_VXHS, /* -drive file.driver=vxhs via query-qmp-schema */
+     QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES, /* virtio-blk-*.num-queues */
++    QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT, /* -machine pseries,resize-hpt */
+ 
+     QEMU_CAPS_LAST /* this must always be the last item */
+ } virQEMUCapsFlags;
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index e60f93083f..aa7079229f 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -7566,6 +7566,26 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
+             }
+         }
+ 
++        if (def->features[VIR_DOMAIN_FEATURE_HPT] == VIR_TRISTATE_SWITCH_ON) {
++            const char *str;
++
++            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT)) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                               _("HTP resizing is not supported by this "
++                                 "QEMU binary"));
++                goto cleanup;
++            }
++
++            str = virDomainHPTResizingTypeToString(def->hpt_resizing);
++            if (!str) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                               _("Invalid setting for HPT resizing"));
++                goto cleanup;
++            }
++
++            virBufferAsprintf(&buf, ",resize-hpt=%s", str);
++        }
++
+         if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
+             virQEMUCapsGet(qemuCaps, QEMU_CAPS_LOADPARM))
+             qemuAppendLoadparmMachineParm(&buf, def);
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 81f45516af..485e085cea 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3109,6 +3109,14 @@ qemuDomainDefVerifyFeatures(const virDomainDef *def)
+         return -1;
+     }
+ 
++    if (def->features[VIR_DOMAIN_FEATURE_HPT] == VIR_TRISTATE_SWITCH_ON &&
++        !qemuDomainIsPSeries(def)) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       "%s",
++                       _("HPT tuning is only supported for pSeries guests"));
++        return -1;
++    }
++
+     return 0;
+ }
+ 
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+index 0dfa20726c..b0ee3f1523 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+@@ -177,6 +177,7 @@
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='vxhs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='machine.pseries.resize-hpt'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.10.0)</package>
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Enforce-ACPI-UEFI-requirements.patch b/SOURCES/libvirt-qemu-Enforce-ACPI-UEFI-requirements.patch
deleted file mode 100644
index ea7dca6..0000000
--- a/SOURCES/libvirt-qemu-Enforce-ACPI-UEFI-requirements.patch
+++ /dev/null
@@ -1,411 +0,0 @@
-From 00e9313798b4e830b372d0069fc211019d67f978 Mon Sep 17 00:00:00 2001
-Message-Id: <00e9313798b4e830b372d0069fc211019d67f978@dist-git>
-From: Andrea Bolognani <abologna@redhat.com>
-Date: Tue, 4 Apr 2017 14:59:31 +0200
-Subject: [PATCH] qemu: Enforce ACPI, UEFI requirements
-
-Depending on the architecture, requirements for ACPI and UEFI can
-be different; more specifically, while on x86 UEFI requires ACPI,
-on aarch64 it's the other way around.
-
-Enforce these requirements when validating the domain, and make
-the error message more accurate by mentioning that they're not
-necessarily applicable to all architectures.
-
-Several aarch64 test cases had to be tweaked because they would
-have failed the validation step otherwise.
-
-(cherry picked from commit 396ca36cb0be87bdf6c337bbc8098920eddea065)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
-
-Signed-off-by: Andrea Bolognani <abologna@redhat.com>
----
- src/qemu/qemu_command.c                              | 20 ++++----------------
- src/qemu/qemu_domain.c                               | 20 ++++++++++++++++++++
- .../qemuxml2argv-aarch64-aavmf-virtio-mmio.args      |  1 +
- .../qemuxml2argv-aarch64-aavmf-virtio-mmio.xml       |  1 -
- .../qemuxml2argv-aarch64-cpu-passthrough.args        |  1 +
- .../qemuxml2argv-aarch64-cpu-passthrough.xml         |  1 -
- .../qemuxml2argv-aarch64-video-virtio-gpu-pci.args   |  1 +
- .../qemuxml2argv-aarch64-video-virtio-gpu-pci.xml    |  3 ---
- ...xml2argv-aarch64-virt-2.6-virtio-pci-default.args |  1 +
- ...uxml2argv-aarch64-virt-2.6-virtio-pci-default.xml |  1 -
- .../qemuxml2argv-aarch64-virt-default-nic.args       |  1 +
- .../qemuxml2argv-aarch64-virt-default-nic.xml        |  3 ---
- .../qemuxml2argv-aarch64-virt-virtio.args            |  1 +
- .../qemuxml2argv-aarch64-virt-virtio.xml             |  1 -
- .../qemuxml2argv-aarch64-virtio-pci-default.args     |  1 +
- .../qemuxml2argv-aarch64-virtio-pci-default.xml      |  1 -
- ...xml2argv-aarch64-virtio-pci-manual-addresses.args |  1 +
- ...uxml2argv-aarch64-virtio-pci-manual-addresses.xml |  1 -
- .../qemuxml2argv-balloon-mmio-deflate.args           |  1 +
- .../qemuxml2argv-balloon-mmio-deflate.xml            |  1 -
- .../qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml     |  1 -
- .../qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml  |  1 -
- .../qemuxml2xmlout-aarch64-virtio-pci-default.xml    |  1 -
- ...ml2xmlout-aarch64-virtio-pci-manual-addresses.xml |  1 -
- 24 files changed, 33 insertions(+), 33 deletions(-)
-
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 59fedaaaf..8ec4ec3a6 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -9346,18 +9346,16 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
- }
- 
- 
--static int
-+static void
- qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
--                                 virDomainDefPtr def,
--                                 virQEMUCapsPtr qemuCaps)
-+                                 virDomainDefPtr def)
- {
--    int ret = -1;
-     virDomainLoaderDefPtr loader = def->os.loader;
-     virBuffer buf = VIR_BUFFER_INITIALIZER;
-     int unit = 0;
- 
-     if (!loader)
--        return 0;
-+        return;
- 
-     switch ((virDomainLoader) loader->type) {
-     case VIR_DOMAIN_LOADER_TYPE_ROM:
-@@ -9366,12 +9364,6 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
-         break;
- 
-     case VIR_DOMAIN_LOADER_TYPE_PFLASH:
--        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_ACPI) &&
--            def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
--            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
--                           _("ACPI must be enabled in order to use UEFI"));
--            goto cleanup;
--        }
- 
-         if (loader->secure == VIR_TRISTATE_BOOL_YES) {
-             virCommandAddArgList(cmd,
-@@ -9409,10 +9401,7 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
-         break;
-     }
- 
--    ret = 0;
-- cleanup:
-     virBufferFreeAndReset(&buf);
--    return ret;
- }
- 
- 
-@@ -9849,8 +9838,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
-     if (qemuBuildCpuCommandLine(cmd, driver, def, qemuCaps) < 0)
-         goto error;
- 
--    if (qemuBuildDomainLoaderCommandLine(cmd, def, qemuCaps) < 0)
--        goto error;
-+    qemuBuildDomainLoaderCommandLine(cmd, def);
- 
-     if (!migrateURI && !snapshot && qemuDomainAlignMemorySizes(def) < 0)
-         goto error;
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 9f165c1da..f383a6cf2 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -2884,6 +2884,26 @@ qemuDomainDefValidate(const virDomainDef *def,
-         goto cleanup;
-     }
- 
-+    /* On x86, UEFI requires ACPI */
-+    if (def->os.loader &&
-+        def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH &&
-+        ARCH_IS_X86(def->os.arch) &&
-+        def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                       _("UEFI requires ACPI on this architecture"));
-+        goto cleanup;
-+    }
-+
-+    /* On aarch64, ACPI requires UEFI */
-+    if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON &&
-+        def->os.arch == VIR_ARCH_AARCH64 &&
-+        (!def->os.loader ||
-+         def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH)) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                       _("ACPI requires UEFI on this architecture"));
-+        goto cleanup;
-+    }
-+
-     if (def->os.loader &&
-         def->os.loader->secure == VIR_TRISTATE_BOOL_YES) {
-         /* These are the QEMU implementation limitations. But we
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.args
-index bf4b2f793..68fb61b1e 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.args
-@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
- -nodefconfig \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
-+-no-acpi \
- -boot c \
- -kernel /aarch64.kernel \
- -initrd /aarch64.initrd \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.xml
-index 8c7428cf8..5d7217307 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.xml
-@@ -13,7 +13,6 @@
-     <boot dev='hd'/>
-   </os>
-   <features>
--    <acpi/>
-     <apic/>
-     <pae/>
-     <gic version='2'/>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args
-index 52d2112b8..9c8c001f1 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args
-@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
- -nodefconfig \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
-+-no-acpi \
- -boot c \
- -drive file=/aarch64.raw,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml
-index 4cdf387f3..0dda09504 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml
-@@ -8,7 +8,6 @@
-     <type arch="aarch64" machine="virt">hvm</type>
-   </os>
-   <features>
--    <acpi/>
-     <apic/>
-     <pae/>
-   </features>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.args
-index 76ee977a3..2f8c51610 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.args
-@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
- -nodefconfig \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64-vgpu/monitor.sock,server,nowait \
-+-no-acpi \
- -device ioh3420,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\
- addr=0x1 \
- -device ioh3420,port=0x9,chassis=2,id=pci.2,bus=pcie.0,multifunction=on,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.xml
-index 4b52a731b..d9a012893 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.xml
-@@ -7,9 +7,6 @@
-   <os>
-     <type arch='aarch64' machine='virt'>hvm</type>
-   </os>
--  <features>
--    <acpi/>
--  </features>
-   <cpu mode='custom' match='exact'>
-     <model fallback='allow'>cortex-a57</model>
-   </cpu>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args
-index df03c6e02..e99d412a7 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args
-@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
- -nodefconfig \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
-+-no-acpi \
- -boot c \
- -kernel /aarch64.kernel \
- -initrd /aarch64.initrd \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.xml
-index e745101f1..43bc0089c 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.xml
-@@ -12,7 +12,6 @@
-     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
-   </os>
-   <features>
--    <acpi/>
-     <apic/>
-     <pae/>
-   </features>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.args
-index 29f65f6b9..47d77618b 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.args
-@@ -17,6 +17,7 @@ QEMU_AUDIO_DRV=none \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64-virt-default/monitor.sock,server,\
- nowait \
-+-no-acpi \
- -boot c \
- -kernel /aarch64.kernel \
- -initrd /aarch64.initrd \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.xml
-index 3a6f098d0..17ddc9096 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.xml
-@@ -4,9 +4,6 @@
-   <memory>1048576</memory>
-   <currentMemory>1048576</currentMemory>
-   <vcpu>1</vcpu>
--  <features>
--    <acpi/>
--  </features>
-   <cpu match='exact'>
-     <model>cortex-a53</model>
-   </cpu>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
-index b5b010ca4..5fef3b488 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
-@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
- -nodefconfig \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
-+-no-acpi \
- -boot c \
- -kernel /aarch64.kernel \
- -initrd /aarch64.initrd \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml
-index ad3461512..2692e61c4 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml
-@@ -12,7 +12,6 @@
-     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
-   </os>
-   <features>
--    <acpi/>
-     <apic/>
-     <pae/>
-   </features>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args
-index 46ac51d50..23a5fffd0 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args
-@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
- -nodefconfig \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
-+-no-acpi \
- -boot c \
- -kernel /aarch64.kernel \
- -initrd /aarch64.initrd \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.xml
-index 2a84a9669..72bf0c95c 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.xml
-@@ -12,7 +12,6 @@
-     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
-   </os>
-   <features>
--    <acpi/>
-     <apic/>
-     <pae/>
-   </features>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args
-index 06403996e..54244fdcf 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args
-@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
- -nodefconfig \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
-+-no-acpi \
- -boot c \
- -kernel /aarch64.kernel \
- -initrd /aarch64.initrd \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml
-index 5e1b494ed..fee32588f 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml
-@@ -13,7 +13,6 @@
-     <boot dev='hd'/>
-   </os>
-   <features>
--    <acpi/>
-     <apic/>
-     <pae/>
-   </features>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args
-index 10d136258..e568e3c39 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args
-@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
- -nodefconfig \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
-+-no-acpi \
- -boot c \
- -kernel /aarch64.kernel \
- -initrd /aarch64.initrd \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml
-index 1b5b48c42..49b7d2c60 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml
-@@ -12,7 +12,6 @@
-     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
-   </os>
-   <features>
--    <acpi/>
-     <apic/>
-     <pae/>
-   </features>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml
-index bea65990e..9e728300e 100644
---- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml
-@@ -13,7 +13,6 @@
-     <boot dev='hd'/>
-   </os>
-   <features>
--    <acpi/>
-     <apic/>
-     <pae/>
-     <gic version='2'/>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml
-index 2c765e7c3..8590f485e 100644
---- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml
-@@ -8,7 +8,6 @@
-     <type arch='aarch64' machine='virt'>hvm</type>
-   </os>
-   <features>
--    <acpi/>
-     <gic version='2'/>
-   </features>
-   <cpu mode='custom' match='exact' check='none'>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
-index 88a6a6a0c..e5496424b 100644
---- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
-@@ -13,7 +13,6 @@
-     <boot dev='hd'/>
-   </os>
-   <features>
--    <acpi/>
-     <apic/>
-     <pae/>
-     <gic version='2'/>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml
-index 83cf0d1f5..83d8dcc4a 100644
---- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml
-@@ -13,7 +13,6 @@
-     <boot dev='hd'/>
-   </os>
-   <features>
--    <acpi/>
-     <apic/>
-     <pae/>
-     <gic version='2'/>
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Export-virQEMUCapsGuestIsNative.patch b/SOURCES/libvirt-qemu-Export-virQEMUCapsGuestIsNative.patch
deleted file mode 100644
index 75fc214..0000000
--- a/SOURCES/libvirt-qemu-Export-virQEMUCapsGuestIsNative.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From b06befbc433e1b6dc1a8ee5ee0814a20a2288685 Mon Sep 17 00:00:00 2001
-Message-Id: <b06befbc433e1b6dc1a8ee5ee0814a20a2288685@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 11 Jul 2017 15:15:01 +0200
-Subject: [PATCH] qemu: Export virQEMUCapsGuestIsNative
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit ee4180bef124cbc08a702689dda6fd95b21b1387)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1470582
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_capabilities.c | 2 +-
- src/qemu/qemu_capabilities.h | 3 +++
- 2 files changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index eea57e4c9c..f22c11941c 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -491,7 +491,7 @@ static const char *virQEMUCapsArchToString(virArch arch)
- 
- /* Checks whether a domain with @guest arch can run natively on @host.
-  */
--static bool
-+bool
- virQEMUCapsGuestIsNative(virArch host,
-                          virArch guest)
- {
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index bbc6f6812f..c28c80d40a 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -569,4 +569,7 @@ int virQEMUCapsFillDomainCaps(virCapsPtr caps,
-                               virFirmwarePtr *firmwares,
-                               size_t nfirmwares);
- 
-+bool virQEMUCapsGuestIsNative(virArch host,
-+                              virArch guest);
-+
- #endif /* __QEMU_CAPABILITIES_H__*/
--- 
-2.13.2
-
diff --git a/SOURCES/libvirt-qemu-Filter-CPU-features-when-using-host-CPU.patch b/SOURCES/libvirt-qemu-Filter-CPU-features-when-using-host-CPU.patch
deleted file mode 100644
index 49a5404..0000000
--- a/SOURCES/libvirt-qemu-Filter-CPU-features-when-using-host-CPU.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From f05df8ca745a00a1c8bc783dcf25f648cbe5d508 Mon Sep 17 00:00:00 2001
-Message-Id: <f05df8ca745a00a1c8bc783dcf25f648cbe5d508@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 6 Oct 2017 13:23:36 +0200
-Subject: [PATCH] qemu: Filter CPU features when using host CPU
-
-When reconnecting to a domain started with a host-model CPU which was
-started by old libvirt that did not replace host-model with the real CPU
-definition, libvirt replaces the host-model CPU with the CPU from
-capabilities (because this is what the old libvirt did when it started
-the domain). Without this patch libvirt could use features unknown to
-QEMU in the CPU definition which replaced the original host-model CPU.
-Such domain would keep running just fine, but any attempt to migrate it
-will fail and once the domain is saved or snapshotted, restoring it
-would fail too.
-
-In other words whenever we want to use the CPU definition from host
-capabilities as a guest CPU definition, we have to filter the unknown
-features.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1495171
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit e26cc8f82ff346c9ec90409bac06581b64e42b20)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1508549
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 10 +++++++++-
- 1 file changed, 9 insertions(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 4a8c4421a3..0bed084381 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -6668,6 +6668,7 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
- {
-     virCapsPtr caps = virQEMUDriverGetCapabilities(driver, false);
-     virCPUDefPtr host = NULL;
-+    virCPUDefPtr cpu = NULL;
-     int ret = -1;
- 
-     if (!caps)
-@@ -6689,7 +6690,13 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
-         if (!(host = virCPUCopyMigratable(caps->host.cpu->arch, caps->host.cpu)))
-             goto cleanup;
- 
--        if (virCPUUpdate(vm->def->os.arch, vm->def->cpu, host) < 0)
-+        if (!(cpu = virCPUDefCopyWithoutModel(host)) ||
-+            virCPUDefCopyModelFilter(cpu, host, false,
-+                                     virQEMUCapsCPUFilterFeatures,
-+                                     &caps->host.cpu->arch) < 0)
-+            goto cleanup;
-+
-+        if (virCPUUpdate(vm->def->os.arch, vm->def->cpu, cpu) < 0)
-             goto cleanup;
- 
-         if (qemuProcessUpdateCPU(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
-@@ -6699,6 +6706,7 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
-     ret = 0;
- 
-  cleanup:
-+    virCPUDefFree(cpu);
-     virCPUDefFree(host);
-     virObjectUnref(caps);
-     return ret;
--- 
-2.15.0
-
diff --git a/SOURCES/libvirt-qemu-Fix-CPU-model-broken-by-older-libvirt.patch b/SOURCES/libvirt-qemu-Fix-CPU-model-broken-by-older-libvirt.patch
deleted file mode 100644
index a67107f..0000000
--- a/SOURCES/libvirt-qemu-Fix-CPU-model-broken-by-older-libvirt.patch
+++ /dev/null
@@ -1,194 +0,0 @@
-From e7f6fc0ea19e73e1ecd9a54f12ac9f2df7cb30cf Mon Sep 17 00:00:00 2001
-Message-Id: <e7f6fc0ea19e73e1ecd9a54f12ac9f2df7cb30cf@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 6 Oct 2017 14:49:07 +0200
-Subject: [PATCH] qemu: Fix CPU model broken by older libvirt
-
-When libvirt older than 3.9.0 reconnected to a running domain started by
-old libvirt it could have messed up the expansion of host-model by
-adding features QEMU does not support (such as cmt). Thus whenever we
-reconnect to a running domain, revert to an active snapshot, or restore
-a saved domain we need to check the guest CPU model and remove the
-CPU features unknown to QEMU. We can do this because we know the domain
-was successfully started, which means the CPU did not contain the
-features when libvirt started the domain.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1495171
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 6a6f6b91e0e76480ea961f83135efcb4faf3284a)
-
-Conflicts:
-	src/qemu/qemu_domain.c,
-	src/qemu/qemu_domain.h -- context, one more function new
-            function upstream
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1508549
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c  | 75 +++++++++++++++++++++++++++++++++++++++++++++++++
- src/qemu/qemu_domain.h  |  4 +++
- src/qemu/qemu_driver.c  | 14 +++++++++
- src/qemu/qemu_process.c |  9 ++++++
- 4 files changed, 102 insertions(+)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index a41657099f..68c1f3b7c5 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -9324,3 +9324,78 @@ qemuDomainUpdateCPU(virDomainObjPtr vm,
- 
-     return 0;
- }
-+
-+
-+/**
-+ * qemuDomainFixupCPUS:
-+ * @vm: domain object
-+ * @origCPU: original CPU used when the domain was started
-+ *
-+ * Libvirt older than 3.9.0 could have messed up the expansion of host-model
-+ * CPU when reconnecting to a running domain by adding features QEMU does not
-+ * support (such as cmt). This API fixes both the actual CPU provided by QEMU
-+ * (stored in the domain object) and the @origCPU used when starting the
-+ * domain.
-+ *
-+ * This is safe even if the original CPU definition used mode='custom' (rather
-+ * than host-model) since we know QEMU was able to start the domain and thus
-+ * the CPU definitions do not contain any features unknown to QEMU.
-+ *
-+ * This function can only be used on an active domain or when restoring a
-+ * domain which was running.
-+ *
-+ * Returns 0 on success, -1 on error.
-+ */
-+int
-+qemuDomainFixupCPUs(virDomainObjPtr vm,
-+                    virCPUDefPtr *origCPU)
-+{
-+    virCPUDefPtr fixedCPU = NULL;
-+    virCPUDefPtr fixedOrig = NULL;
-+    virArch arch = vm->def->os.arch;
-+    int ret = 0;
-+
-+    if (!ARCH_IS_X86(arch))
-+        return 0;
-+
-+    if (!vm->def->cpu ||
-+        vm->def->cpu->mode != VIR_CPU_MODE_CUSTOM ||
-+        !vm->def->cpu->model)
-+        return 0;
-+
-+    /* Missing origCPU means QEMU created exactly the same virtual CPU which
-+     * we asked for or libvirt was too old to mess up the translation from
-+     * host-model.
-+     */
-+    if (!*origCPU)
-+        return 0;
-+
-+    if (virCPUDefFindFeature(vm->def->cpu, "cmt") &&
-+        (!(fixedCPU = virCPUDefCopyWithoutModel(vm->def->cpu)) ||
-+         virCPUDefCopyModelFilter(fixedCPU, vm->def->cpu, false,
-+                                  virQEMUCapsCPUFilterFeatures, &arch) < 0))
-+        goto cleanup;
-+
-+    if (virCPUDefFindFeature(*origCPU, "cmt") &&
-+        (!(fixedOrig = virCPUDefCopyWithoutModel(*origCPU)) ||
-+         virCPUDefCopyModelFilter(fixedOrig, *origCPU, false,
-+                                  virQEMUCapsCPUFilterFeatures, &arch) < 0))
-+        goto cleanup;
-+
-+    if (fixedCPU) {
-+        virCPUDefFree(vm->def->cpu);
-+        VIR_STEAL_PTR(vm->def->cpu, fixedCPU);
-+    }
-+
-+    if (fixedOrig) {
-+        virCPUDefFree(*origCPU);
-+        VIR_STEAL_PTR(*origCPU, fixedOrig);
-+    }
-+
-+    ret = 0;
-+
-+ cleanup:
-+    virCPUDefFree(fixedCPU);
-+    virCPUDefFree(fixedOrig);
-+    return ret;
-+}
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 7ad34e563e..1a658bcf7e 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -930,4 +930,8 @@ qemuDomainUpdateCPU(virDomainObjPtr vm,
-                     virCPUDefPtr cpu,
-                     virCPUDefPtr *origCPU);
- 
-+int
-+qemuDomainFixupCPUs(virDomainObjPtr vm,
-+                    virCPUDefPtr *origCPU);
-+
- #endif /* __QEMU_DOMAIN_H__ */
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index b6d72303ca..bfd7ff6c09 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -6500,6 +6500,13 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
-         }
-     }
- 
-+    /* No cookie means libvirt which saved the domain was too old to mess up
-+     * the CPU definitions.
-+     */
-+    if (cookie &&
-+        qemuDomainFixupCPUs(vm, &cookie->cpu) < 0)
-+        goto cleanup;
-+
-     if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL,
-                          asyncJob, "stdio", *fd, path, NULL,
-                          VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
-@@ -15520,6 +15527,13 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-             if (config)
-                 virDomainObjAssignDef(vm, config, false, NULL);
- 
-+            /* No cookie means libvirt which saved the domain was too old to
-+             * mess up the CPU definitions.
-+             */
-+            if (cookie &&
-+                qemuDomainFixupCPUs(vm, &cookie->cpu) < 0)
-+                goto cleanup;
-+
-             rc = qemuProcessStart(snapshot->domain->conn, driver, vm,
-                                   cookie ? cookie->cpu : NULL,
-                                   QEMU_ASYNC_JOB_START, NULL, -1, NULL, snap,
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 0bed084381..5802a553cf 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -6667,6 +6667,7 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
-                       virDomainObjPtr vm)
- {
-     virCapsPtr caps = virQEMUDriverGetCapabilities(driver, false);
-+    qemuDomainObjPrivatePtr priv = vm->privateData;
-     virCPUDefPtr host = NULL;
-     virCPUDefPtr cpu = NULL;
-     int ret = -1;
-@@ -6701,6 +6702,14 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
- 
-         if (qemuProcessUpdateCPU(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
-             goto cleanup;
-+    } else if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) {
-+        /* We only try to fix CPUs when the libvirt/QEMU combo used to start
-+         * the domain did not know about query-cpu-model-expansion in which
-+         * case the host-model is known to not contain features which QEMU
-+         * doesn't know about.
-+         */
-+        if (qemuDomainFixupCPUs(vm, &priv->origCPU) < 0)
-+            goto cleanup;
-     }
- 
-     ret = 0;
--- 
-2.15.0
-
diff --git a/SOURCES/libvirt-qemu-Fix-crash-in-offline-migration.patch b/SOURCES/libvirt-qemu-Fix-crash-in-offline-migration.patch
index 11da599..d2997ea 100644
--- a/SOURCES/libvirt-qemu-Fix-crash-in-offline-migration.patch
+++ b/SOURCES/libvirt-qemu-Fix-crash-in-offline-migration.patch
@@ -1,7 +1,7 @@
-From 3a47e083b2e118cb338442721a73ed8506e4c0ed Mon Sep 17 00:00:00 2001
-Message-Id: <3a47e083b2e118cb338442721a73ed8506e4c0ed@dist-git>
+From e41b2f83ca98fe352e9901d99b5cb9bf62d79845 Mon Sep 17 00:00:00 2001
+Message-Id: <e41b2f83ca98fe352e9901d99b5cb9bf62d79845@dist-git>
 From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 19 Jan 2018 10:32:44 +0100
+Date: Fri, 19 Jan 2018 14:33:16 +0100
 Subject: [PATCH] qemu: Fix crash in offline migration
 
 When migrating a shutoff domain (i.e., offline migration), we have no
@@ -15,19 +15,16 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1536351
 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
 Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
 (cherry picked from commit bcc5710708ec90146b71bdb00d8705cb4a9e0088)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530130
-
 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
 ---
  src/qemu/qemu_migration.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
 
 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 120b79415e..2b1e8dd9fd 100644
+index b814cc6608..a50bb7206c 100644
 --- a/src/qemu/qemu_migration.c
 +++ b/src/qemu/qemu_migration.c
-@@ -5372,8 +5372,10 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
+@@ -5459,8 +5459,10 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
      }
  
      if (dom) {
@@ -41,5 +38,5 @@ index 120b79415e..2b1e8dd9fd 100644
          if (qemuMigrationBakeCookie(mig, driver, vm, cookieout, cookieoutlen,
                                      QEMU_MIGRATION_COOKIE_STATS) < 0)
 -- 
-2.16.0
+2.16.1
 
diff --git a/SOURCES/libvirt-qemu-Fix-mdev-checking-for-VFIO-support.patch b/SOURCES/libvirt-qemu-Fix-mdev-checking-for-VFIO-support.patch
deleted file mode 100644
index 535da81..0000000
--- a/SOURCES/libvirt-qemu-Fix-mdev-checking-for-VFIO-support.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-From 0642cb0d5040df1e483752e15ba724fe04b3afca Mon Sep 17 00:00:00 2001
-Message-Id: <0642cb0d5040df1e483752e15ba724fe04b3afca@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Wed, 12 Apr 2017 13:07:14 +0200
-Subject: [PATCH] qemu: Fix mdev checking for VFIO support
-
-Commit a4a39d90 added a check that checks for VFIO support with mediated
-devices. The problem is that the hostdev preparing functions behave like
-a fallthrough if device of that specific type doesn't exist. However,
-the check for VFIO support was independent of the existence of a mdev
-device which caused the guest to fail to start with any device to be
-directly assigned if VFIO was disabled/unavailable in the kernel.
-The proposed change first ensures that it makes sense to check for VFIO
-support in the first place, and only then performs the VFIO support check
-itself.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1441291
-
-(cherry picked from commit b4c2ac8d56124428d9329643a68625465094c5a7)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
----
- src/qemu/qemu_hostdev.c | 17 +++++++++++++----
- 1 file changed, 13 insertions(+), 4 deletions(-)
-
-diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
-index 685bf5b59..73d26f4c6 100644
---- a/src/qemu/qemu_hostdev.c
-+++ b/src/qemu/qemu_hostdev.c
-@@ -330,11 +330,20 @@ qemuHostdevPrepareMediatedDevices(virQEMUDriverPtr driver,
-                                   int nhostdevs)
- {
-     virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
-+    bool supportsVFIO = qemuHostdevHostSupportsPassthroughVFIO();
-+    size_t i;
- 
--    if (!qemuHostdevHostSupportsPassthroughVFIO()) {
--        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
--                       _("host doesn't support VFIO PCI interface"));
--        return -1;
-+    for (i = 0; i < nhostdevs; i++) {
-+        if (hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
-+            hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) {
-+            if (!supportsVFIO) {
-+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                               _("Mediated host device assignment requires "
-+                                 "VFIO support"));
-+                return -1;
-+            }
-+            break;
-+        }
-     }
- 
-     return virHostdevPrepareMediatedDevices(hostdev_mgr, QEMU_DRIVER_NAME,
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Fix-memory-leaks-in-qemuDomainSaveImageOpen.patch b/SOURCES/libvirt-qemu-Fix-memory-leaks-in-qemuDomainSaveImageOpen.patch
deleted file mode 100644
index f9384ea..0000000
--- a/SOURCES/libvirt-qemu-Fix-memory-leaks-in-qemuDomainSaveImageOpen.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From a72554edcb64726b27ea51b4983ec8d9aaec4eaa Mon Sep 17 00:00:00 2001
-Message-Id: <a72554edcb64726b27ea51b4983ec8d9aaec4eaa@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 6 Jun 2017 22:27:57 +0200
-Subject: [PATCH] qemu: Fix memory leaks in qemuDomainSaveImageOpen
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit ac793bd7195ab99445cf6c6d6053439c56cef922)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 14 ++++++++------
- 1 file changed, 8 insertions(+), 6 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index c8a84503c1..5db92b04a1 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -6229,12 +6229,13 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-                 virReportSystemError(errno,
-                                      _("cannot remove corrupt file: %s"),
-                                      path);
--                goto error;
-+            } else {
-+                fd = -3;
-             }
--            return -3;
-+        } else {
-+            virReportError(VIR_ERR_OPERATION_FAILED,
-+                           "%s", _("failed to read qemu header"));
-         }
--        virReportError(VIR_ERR_OPERATION_FAILED,
--                       "%s", _("failed to read qemu header"));
-         goto error;
-     }
- 
-@@ -6249,9 +6250,10 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-                     virReportSystemError(errno,
-                                          _("cannot remove corrupt file: %s"),
-                                          path);
--                    goto error;
-+                } else {
-+                    fd = -3;
-                 }
--                return -3;
-+                goto error;
-             }
-         }
-         virReportError(VIR_ERR_OPERATION_FAILED, "%s", msg);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Fix-persistent-migration-of-transient-domains.patch b/SOURCES/libvirt-qemu-Fix-persistent-migration-of-transient-domains.patch
deleted file mode 100644
index 2aa645f..0000000
--- a/SOURCES/libvirt-qemu-Fix-persistent-migration-of-transient-domains.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From 82a4218a06697ee5beaa6ba76704b0156b1a806c Mon Sep 17 00:00:00 2001
-Message-Id: <82a4218a06697ee5beaa6ba76704b0156b1a806c@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 2 May 2017 18:56:06 +0200
-Subject: [PATCH] qemu: Fix persistent migration of transient domains
-
-While fixing a bug with incorrectly freed memory in commit
-v3.1.0-399-g5498aa29a, I accidentally broke persistent migration of
-transient domains. Before adding qemuDomainDefCopy in the path, the code
-just took NULL from vm->newDef and used it as the persistent def, which
-resulted in no persistent XML being sent in the migration cookie. This
-scenario is perfectly valid and the destination correctly handles it by
-using the incoming live definition and storing it as the persistent one.
-
-After the mentioned commit libvirtd would just segfault in the described
-scenario.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1446205
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 59307fade86fb74db1f8f572433962233f7ac123)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 16 ++++++++--------
- 1 file changed, 8 insertions(+), 8 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index ac7e27319..5bf9bd10f 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -3609,15 +3609,15 @@ qemuMigrationRun(virQEMUDriverPtr driver,
- 
-     if (flags & VIR_MIGRATE_PERSIST_DEST) {
-         if (persist_xml) {
--            persistDef = qemuMigrationPrepareDef(driver, persist_xml,
--                                                 NULL, NULL);
--        } else {
--            persistDef = qemuDomainDefCopy(driver, vm->newDef,
--                                           VIR_DOMAIN_XML_SECURE |
--                                           VIR_DOMAIN_XML_MIGRATABLE);
-+            if (!(persistDef = qemuMigrationPrepareDef(driver, persist_xml,
-+                                                       NULL, NULL)))
-+                goto cleanup;
-+        } else if (vm->newDef) {
-+            if (!(persistDef = qemuDomainDefCopy(driver, vm->newDef,
-+                                                 VIR_DOMAIN_XML_SECURE |
-+                                                 VIR_DOMAIN_XML_MIGRATABLE)))
-+                goto cleanup;
-         }
--        if (!persistDef)
--            goto cleanup;
-     }
- 
-     mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Fix-qemuDomainGetBlockInfo-allocation-value-setting.patch b/SOURCES/libvirt-qemu-Fix-qemuDomainGetBlockInfo-allocation-value-setting.patch
deleted file mode 100644
index eb82b29..0000000
--- a/SOURCES/libvirt-qemu-Fix-qemuDomainGetBlockInfo-allocation-value-setting.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 0220b2fed9ab4b07f32e8ebe4ab048d64a27e948 Mon Sep 17 00:00:00 2001
-Message-Id: <0220b2fed9ab4b07f32e8ebe4ab048d64a27e948@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Wed, 12 Jul 2017 16:31:10 +0200
-Subject: [PATCH] qemu: Fix qemuDomainGetBlockInfo allocation value setting
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1467826
-
-Commit id 'b9b1aa639' was supposed to add logic to set the allocation
-for sparse files when wr_highest_offset was zero; however, an unconditional
-setting was done just prior. For block devices, this means allocation is
-always returning 0 since 'actual-size' will be zero.
-
-Remove the unconditional setting and add the note about it being possible
-to still be zero for block devices. As soon as the guest starts writing to
-the volume, the allocation value will then be obtainable from qemu via
-the wr_highest_offset.
-
-(cherry picked from commit fde654be5307a570b7b0f31537e18e70a274cd50)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1470127 [7.4.z - 0day]
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 3 +--
- 1 file changed, 1 insertion(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index a2fb41b91a..b6d72303ca 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -11715,10 +11715,9 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
-      * Additionally, if qemu hasn't written to the file yet, then set the
-      * allocation to whatever qemu returned for physical (e.g. the "actual-
-      * size" from the json query) as that will match the expected allocation
--     * value for this API. */
-+     * value for this API. NB: May still be 0 for block. */
-     if (entry->physical == 0 || info->allocation == 0 ||
-         info->allocation == entry->physical) {
--        info->allocation = entry->physical;
-         if (info->allocation == 0)
-             info->allocation = entry->physical;
- 
--- 
-2.13.3
-
diff --git a/SOURCES/libvirt-qemu-Fix-regression-when-hyperv-vendor_id-feature-is-used.patch b/SOURCES/libvirt-qemu-Fix-regression-when-hyperv-vendor_id-feature-is-used.patch
deleted file mode 100644
index 488fc3d..0000000
--- a/SOURCES/libvirt-qemu-Fix-regression-when-hyperv-vendor_id-feature-is-used.patch
+++ /dev/null
@@ -1,78 +0,0 @@
-From 552fbd4c0707d08e4b67b64a462f0d1609a5ac38 Mon Sep 17 00:00:00 2001
-Message-Id: <552fbd4c0707d08e4b67b64a462f0d1609a5ac38@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Thu, 6 Apr 2017 13:52:30 +0200
-Subject: [PATCH] qemu: Fix regression when hyperv/vendor_id feature is used
-
-qemuProcessVerifyHypervFeatures is supposed to check whether all
-requested hyperv features were actually honored by QEMU/KVM. This is
-done by checking the corresponding CPUID bits reported by the virtual
-CPU. In other words, it doesn't work for string properties, such as
-VIR_DOMAIN_HYPERV_VENDOR_ID (there is no CPUID bit we could check). We
-could theoretically check all 96 bits corresponding to the vendor
-string, but luckily we don't have to check the feature at all. If QEMU
-is too old to support hyperv features, the domain won't even start.
-Otherwise, it is always supported.
-
-Without this patch, libvirt refuses to start a domain which contains
-
-  <features>
-    <hyperv>
-      <vendor_id state='on' value='...'/>
-    </hyperv>
-  </features>
-
-reporting internal error: "unknown CPU feature __kvm_hv_vendor_id.
-
-This regression was introduced by commit v3.1.0-186-ge9dbe7011, which
-(by fixing the virCPUDataCheckFeature condition in
-qemuProcessVerifyHypervFeatures) revealed an old bug in the feature
-verification code. It's been there ever since the verification was
-implemented by commit v1.3.3-rc1-5-g95bbe4bf5, which effectively did not
-check VIR_DOMAIN_HYPERV_VENDOR_ID at all.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439424
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit ae102b5d7bccd29bc6015a3e0acefeaa90d097ac)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439736
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 6 +++++-
- 1 file changed, 5 insertions(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index a20beb13c..039b3911c 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3793,6 +3793,10 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
-     int rc;
- 
-     for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) {
-+        /* always supported string property */
-+        if (i == VIR_DOMAIN_HYPERV_VENDOR_ID)
-+            continue;
-+
-         if (def->hyperv_features[i] != VIR_TRISTATE_SWITCH_ON)
-             continue;
- 
-@@ -3821,13 +3825,13 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
-         case VIR_DOMAIN_HYPERV_SYNIC:
-         case VIR_DOMAIN_HYPERV_STIMER:
-         case VIR_DOMAIN_HYPERV_RESET:
--        case VIR_DOMAIN_HYPERV_VENDOR_ID:
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                            _("host doesn't support hyperv '%s' feature"),
-                            virDomainHypervTypeToString(i));
-             return -1;
- 
-         /* coverity[dead_error_begin] */
-+        case VIR_DOMAIN_HYPERV_VENDOR_ID:
-         case VIR_DOMAIN_HYPERV_LAST:
-             break;
-         }
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Fix-resource-leak-in-qemuDomainAddChardevTLSObjects-error-path.patch b/SOURCES/libvirt-qemu-Fix-resource-leak-in-qemuDomainAddChardevTLSObjects-error-path.patch
deleted file mode 100644
index aa7ab0d..0000000
--- a/SOURCES/libvirt-qemu-Fix-resource-leak-in-qemuDomainAddChardevTLSObjects-error-path.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From f032a2a22052128bd0b3d41d2b5574ce27259eef Mon Sep 17 00:00:00 2001
-Message-Id: <f032a2a22052128bd0b3d41d2b5574ce27259eef@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Mon, 3 Apr 2017 12:53:33 -0400
-Subject: [PATCH] qemu: Fix resource leak in qemuDomainAddChardevTLSObjects
- error path
-
-On any failure, call virJSONValueFree for the *Props.
-
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-(cherry picked from commit 2e8c60958ac32624296eee263bf34bb21a32360c)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1300769
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 11 ++++++++---
- 1 file changed, 8 insertions(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index dabfe10c0..fcd3a38a1 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -213,7 +213,7 @@ qemuMigrationAddTLSObjects(virQEMUDriverPtr driver,
-                                 cfg->migrateTLSx509verify,
-                                 QEMU_MIGRATION_TLS_ALIAS_BASE,
-                                 &tlsProps, tlsAlias, &secProps, secAlias) < 0)
--        return -1;
-+        goto error;
- 
-     /* Ensure the domain doesn't already have the TLS objects defined...
-      * This should prevent any issues just in case some cleanup wasn't
-@@ -223,12 +223,17 @@ qemuMigrationAddTLSObjects(virQEMUDriverPtr driver,
- 
-     if (qemuDomainAddTLSObjects(driver, vm, asyncJob, *secAlias, &secProps,
-                                 *tlsAlias, &tlsProps) < 0)
--        return -1;
-+        goto error;
- 
-     if (VIR_STRDUP(migParams->migrateTLSAlias, *tlsAlias) < 0)
--        return -1;
-+        goto error;
- 
-     return 0;
-+
-+ error:
-+    virJSONValueFree(tlsProps);
-+    virJSONValueFree(secProps);
-+    return -1;
- }
- 
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Fix-serial-stub-console-allocation.patch b/SOURCES/libvirt-qemu-Fix-serial-stub-console-allocation.patch
deleted file mode 100644
index 1cd4a56..0000000
--- a/SOURCES/libvirt-qemu-Fix-serial-stub-console-allocation.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From 096f83e7910c2c8553044d27918955b278e5ab8d Mon Sep 17 00:00:00 2001
-Message-Id: <096f83e7910c2c8553044d27918955b278e5ab8d@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Wed, 7 Jun 2017 14:29:29 +0200
-Subject: [PATCH] qemu: Fix serial stub console allocation
-
-When adding the aliased serial stub console, the structure wasn't
-properly allocated (VIR_ALLOC instead of virDomainChrDefNew) which then
-resulted in SIGSEGV in virDomainChrSourceIsEqual during a serial device
-coldplug.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1434278
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit ff6e94de60b081ae7e9d304e38c63346828c5dbe)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_hotplug.c | 12 +++++++-----
- 1 file changed, 7 insertions(+), 5 deletions(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index cdeb0617a7..094a5644e0 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -1802,15 +1802,17 @@ qemuDomainChrPreInsert(virDomainDefPtr vmdef,
-     if (virDomainChrPreAlloc(vmdef, chr) < 0)
-         return -1;
- 
--    /* Due to some crazy backcompat stuff, the first serial device is an alias
--     * to the first console too. If this is the case, the definition must be
--     * duplicated as first console device. */
-+    /* Due to historical reasons, the first console is an alias to the
-+     * first serial device (if such exists). If this is the case, we need to
-+     * create an object for the first console as well.
-+     */
-     if (vmdef->nserials == 0 && vmdef->nconsoles == 0 &&
-         chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
-         if (!vmdef->consoles && VIR_ALLOC(vmdef->consoles) < 0)
-             return -1;
- 
--        if (VIR_ALLOC(vmdef->consoles[0]) < 0) {
-+        /* We'll be dealing with serials[0] directly, so NULL is fine here. */
-+        if (!(vmdef->consoles[0] = virDomainChrDefNew(NULL))) {
-             VIR_FREE(vmdef->consoles);
-             return -1;
-         }
-@@ -1841,7 +1843,7 @@ qemuDomainChrInsertPreAllocCleanup(virDomainDefPtr vmdef,
-     /* Remove the stub console added by qemuDomainChrPreInsert */
-     if (vmdef->nserials == 0 && vmdef->nconsoles == 1 &&
-         chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
--        VIR_FREE(vmdef->consoles[0]);
-+        virDomainChrDefFree(vmdef->consoles[0]);
-         VIR_FREE(vmdef->consoles);
-         vmdef->nconsoles = 0;
-     }
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Fix-type-of-a-completed-job.patch b/SOURCES/libvirt-qemu-Fix-type-of-a-completed-job.patch
index 1f5cd14..e473be6 100644
--- a/SOURCES/libvirt-qemu-Fix-type-of-a-completed-job.patch
+++ b/SOURCES/libvirt-qemu-Fix-type-of-a-completed-job.patch
@@ -1,5 +1,5 @@
-From 684d747a6c5ea03dc05e6324ff8cba42b5873a15 Mon Sep 17 00:00:00 2001
-Message-Id: <684d747a6c5ea03dc05e6324ff8cba42b5873a15@dist-git>
+From 92867e9b9ff1d9a163c6c166e710ba7c444be520 Mon Sep 17 00:00:00 2001
+Message-Id: <92867e9b9ff1d9a163c6c166e710ba7c444be520@dist-git>
 From: Jiri Denemark <jdenemar@redhat.com>
 Date: Thu, 11 Jan 2018 20:47:50 +0100
 Subject: [PATCH] qemu: Fix type of a completed job
@@ -20,20 +20,17 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1523036
 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
 Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
 (cherry picked from commit e8784e7868d44a2ce796b376cf78f0f6c61c114a)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530130
-
 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
 ---
  src/qemu/qemu_migration.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
 
 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index aabd0913ad..120b79415e 100644
+index af744661f4..b814cc6608 100644
 --- a/src/qemu/qemu_migration.c
 +++ b/src/qemu/qemu_migration.c
-@@ -1590,8 +1590,10 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
- 
+@@ -1623,8 +1623,10 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
+     qemuDomainJobInfoUpdateTime(jobInfo);
      qemuDomainJobInfoUpdateDowntime(jobInfo);
      VIR_FREE(priv->job.completed);
 -    if (VIR_ALLOC(priv->job.completed) == 0)
@@ -44,7 +41,7 @@ index aabd0913ad..120b79415e 100644
  
      if (asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT &&
          jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED)
-@@ -5370,8 +5372,9 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
+@@ -5457,8 +5459,9 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
      }
  
      if (dom) {
diff --git a/SOURCES/libvirt-qemu-Format-targetModel-for-serial-devices.patch b/SOURCES/libvirt-qemu-Format-targetModel-for-serial-devices.patch
new file mode 100644
index 0000000..4e3fa17
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Format-targetModel-for-serial-devices.patch
@@ -0,0 +1,78 @@
+From 506c50ee610cae51d09bf7e26af850a395da0e1f Mon Sep 17 00:00:00 2001
+Message-Id: <506c50ee610cae51d09bf7e26af850a395da0e1f@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:10 +0100
+Subject: [PATCH] qemu: Format targetModel for serial devices
+
+Now that we've created a distinction between target type and target
+model, with the latter being the concrete device name, it's time to
+switch to formatting the model instead of the type.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 7c76c30465ff6038df3b7aa27b40a3348ec599c9)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 8142834afd..7fd2afb1e0 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -10346,8 +10346,8 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+                               serial->info.alias);
+         }
+     } else {
+-        switch ((virDomainChrSerialTargetType) serial->targetType) {
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
++        switch ((virDomainChrSerialTargetModel) serial->targetModel) {
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
+             if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_SERIAL)) {
+                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                _("usb-serial is not supported in this QEMU binary"));
+@@ -10355,10 +10355,10 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+             }
+             break;
+ 
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+             break;
+ 
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
+             if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_SERIAL)) {
+                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                _("pci-serial is not supported with this QEMU binary"));
+@@ -10366,19 +10366,19 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+             }
+             break;
+ 
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+             /* Except from _LAST, which is just a guard value and will never
+              * be used, all of the above are platform devices, which means
+              * qemuBuildSerialCommandLine() will have taken the appropriate
+              * branch and we will not have ended up here. */
+             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+-                           _("Invalid target type for serial device"));
++                           _("Invalid target model for serial device"));
+             goto error;
+         }
+ 
+         virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s",
+-                          virDomainChrSerialTargetTypeToString(serial->targetType),
++                          virDomainChrSerialTargetModelTypeToString(serial->targetModel),
+                           serial->info.alias, serial->info.alias);
+     }
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Ignore-fallback-CPU-attribute-on-reconnect.patch b/SOURCES/libvirt-qemu-Ignore-fallback-CPU-attribute-on-reconnect.patch
new file mode 100644
index 0000000..650b157
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Ignore-fallback-CPU-attribute-on-reconnect.patch
@@ -0,0 +1,40 @@
+From 267d4074f4c6a543643e1fe8cd726953273a5bc6 Mon Sep 17 00:00:00 2001
+Message-Id: <267d4074f4c6a543643e1fe8cd726953273a5bc6@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Wed, 10 Jan 2018 15:56:21 +0100
+Subject: [PATCH] qemu: Ignore fallback CPU attribute on reconnect
+
+When reconnecting to a running domain with host-model CPU started by old
+libvirt which did not store the actual CPU in the status XML, we need to
+ignore the fallback attribute to make sure we can translate the detected
+host CPU model to a model which is supported by the running QEMU.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1532980
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 237f045d9a9d84a52e645b490d14ad0b66e5b8ed)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_process.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index 701528c42c..c64088e4ca 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -3884,6 +3884,11 @@ qemuProcessUpdateCPU(virQEMUDriverPtr driver,
+     virDomainCapsCPUModelsPtr models = NULL;
+     int ret = -1;
+ 
++    /* The host CPU model comes from host caps rather than QEMU caps so
++     * fallback must be allowed no matter what the user specified in the XML.
++     */
++    vm->def->cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
++
+     if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < 0)
+         goto cleanup;
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Ignore-missing-query-migrate-parameters.patch b/SOURCES/libvirt-qemu-Ignore-missing-query-migrate-parameters.patch
deleted file mode 100644
index f178208..0000000
--- a/SOURCES/libvirt-qemu-Ignore-missing-query-migrate-parameters.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 2d8e0d2cc979534be0149841e8bed07c0a4ba048 Mon Sep 17 00:00:00 2001
-Message-Id: <2d8e0d2cc979534be0149841e8bed07c0a4ba048@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Thu, 27 Apr 2017 10:38:41 +0200
-Subject: [PATCH] qemu: Ignore missing query-migrate-parameters
-
-Migration with old QEMU which does not support query-migrate-parameters
-would fail because the QMP command is called unconditionally since the
-introduction of TLS migration. Previously it was only called if the user
-explicitly requested a feature which uses QEMU migration parameters. And
-even then the situation was not ideal, instead of reporting an
-unsupported feature we'd just complain about missing QMP command.
-
-Trivially no migration parameters are supported when
-query-migrate-parameters QMP command is missing. There's no need to
-report an error if it is missing, the callers will report better error
-if needed.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441934
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit ac58c036065ff1d53bc05b796093287c27c71762)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_monitor_json.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
-index 405f79fec..601aa3e74 100644
---- a/src/qemu/qemu_monitor_json.c
-+++ b/src/qemu/qemu_monitor_json.c
-@@ -2666,6 +2666,11 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
-     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-         goto cleanup;
- 
-+    if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
-+        ret = 0;
-+        goto cleanup;
-+    }
-+
-     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-         goto cleanup;
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Implement-virSaveCookie-object-and-callbacks.patch b/SOURCES/libvirt-qemu-Implement-virSaveCookie-object-and-callbacks.patch
deleted file mode 100644
index fa0ffbe..0000000
--- a/SOURCES/libvirt-qemu-Implement-virSaveCookie-object-and-callbacks.patch
+++ /dev/null
@@ -1,166 +0,0 @@
-From e43851128b407dea2a55a813bdbefc5a639f1914 Mon Sep 17 00:00:00 2001
-Message-Id: <e43851128b407dea2a55a813bdbefc5a639f1914@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 2 Jun 2017 22:50:18 +0200
-Subject: [PATCH] qemu: Implement virSaveCookie object and callbacks
-
-This patch implements a new save cookie object and callbacks for qemu
-driver. The actual useful content will be added in the object later.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 215476b64226275ac090ca0e957bfca76ba1549e)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Conflicts:
-	src/qemu/qemu_domain.c - no qemuDomainLogContextClass in 7.4
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_conf.c   |  2 +-
- src/qemu/qemu_domain.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++
- src/qemu/qemu_domain.h |  9 ++++++
- 3 files changed, 93 insertions(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
-index 96956b7779..51a42883dc 100644
---- a/src/qemu/qemu_conf.c
-+++ b/src/qemu/qemu_conf.c
-@@ -909,7 +909,7 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver)
-                                  &virQEMUDriverPrivateDataCallbacks,
-                                  &virQEMUDriverDomainXMLNamespace,
-                                  &virQEMUDriverDomainABIStability,
--                                 NULL);
-+                                 &virQEMUDriverDomainSaveCookie);
- }
- 
- 
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 09903bdd5f..63fcde8024 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -120,6 +120,24 @@ struct _qemuDomainLogContext {
-     virLogManagerPtr manager;
- };
- 
-+static virClassPtr qemuDomainSaveCookieClass;
-+
-+static void qemuDomainSaveCookieDispose(void *obj);
-+
-+static int
-+qemuDomainOnceInit(void)
-+{
-+    if (!(qemuDomainSaveCookieClass = virClassNew(virClassForObject(),
-+                                                  "qemuDomainSaveCookie",
-+                                                  sizeof(qemuDomainSaveCookie),
-+                                                  qemuDomainSaveCookieDispose)))
-+        return -1;
-+
-+    return 0;
-+}
-+
-+VIR_ONCE_GLOBAL_INIT(qemuDomain)
-+
- const char *
- qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
-                                 int phase ATTRIBUTE_UNUSED)
-@@ -9080,3 +9098,68 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr,
-     VIR_FREE(target);
-     return src;
- }
-+
-+
-+static void
-+qemuDomainSaveCookieDispose(void *obj)
-+{
-+    qemuDomainSaveCookiePtr cookie = obj;
-+
-+    VIR_DEBUG("cookie=%p", cookie);
-+}
-+
-+
-+qemuDomainSaveCookiePtr
-+qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED)
-+{
-+    qemuDomainSaveCookiePtr cookie = NULL;
-+
-+    if (qemuDomainInitialize() < 0)
-+        goto error;
-+
-+    if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
-+        goto error;
-+
-+    VIR_DEBUG("Save cookie %p", cookie);
-+
-+    return cookie;
-+
-+ error:
-+    virObjectUnref(cookie);
-+    return NULL;
-+}
-+
-+
-+static int
-+qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED,
-+                          virObjectPtr *obj)
-+{
-+    qemuDomainSaveCookiePtr cookie = NULL;
-+
-+    if (qemuDomainInitialize() < 0)
-+        goto error;
-+
-+    if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
-+        goto error;
-+
-+    *obj = (virObjectPtr) cookie;
-+    return 0;
-+
-+ error:
-+    virObjectUnref(cookie);
-+    return -1;
-+}
-+
-+
-+static int
-+qemuDomainSaveCookieFormat(virBufferPtr buf ATTRIBUTE_UNUSED,
-+                           virObjectPtr obj ATTRIBUTE_UNUSED)
-+{
-+    return 0;
-+}
-+
-+
-+virSaveCookieCallbacks virQEMUDriverDomainSaveCookie = {
-+    .parse = qemuDomainSaveCookieParse,
-+    .format = qemuDomainSaveCookieFormat,
-+};
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 4db92fac8a..80d80e4554 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -416,6 +416,14 @@ struct qemuProcessEvent {
- typedef struct _qemuDomainLogContext qemuDomainLogContext;
- typedef qemuDomainLogContext *qemuDomainLogContextPtr;
- 
-+typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie;
-+typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr;
-+struct _qemuDomainSaveCookie {
-+    virObject parent;
-+};
-+
-+qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm);
-+
- const char *qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
-                                             int phase);
- int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
-@@ -640,6 +648,7 @@ extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
- extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
- extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
- extern virDomainABIStability virQEMUDriverDomainABIStability;
-+extern virSaveCookieCallbacks virQEMUDriverDomainSaveCookie;
- 
- int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
-                                virDomainObjPtr vm, int asyncJob);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Improve-qemuDomainChrTargetDefValidate.patch b/SOURCES/libvirt-qemu-Improve-qemuDomainChrTargetDefValidate.patch
new file mode 100644
index 0000000..f14a292
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Improve-qemuDomainChrTargetDefValidate.patch
@@ -0,0 +1,104 @@
+From 04e24e8cb39c0a3b3d3203985fa0ec824195d1ab Mon Sep 17 00:00:00 2001
+Message-Id: <04e24e8cb39c0a3b3d3203985fa0ec824195d1ab@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:06 +0100
+Subject: [PATCH] qemu: Improve qemuDomainChrTargetDefValidate()
+
+Instead of validating each target type / address type combination
+separately, create a small helper to perform the matching and
+collapse all existing checks into a single one.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 9ae116eadf7578282d284635fa23a4265b8db734)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 50 ++++++++++++++++++++++++++++++--------------------
+ 1 file changed, 30 insertions(+), 20 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 35eb19ca32..bb25255b94 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3456,43 +3456,53 @@ qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def)
+ }
+ 
+ 
++static int
++qemuDomainChrSerialTargetTypeToAddressType(int targetType)
++{
++    switch ((virDomainChrSerialTargetType) targetType) {
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
++        return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
++        return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
++        return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
++        break;
++    }
++
++    return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
++}
++
++
+ static int
+ qemuDomainChrTargetDefValidate(const virDomainDef *def,
+                                const virDomainChrDef *chr)
+ {
++    int expected;
++
+     switch ((virDomainChrDeviceType) chr->deviceType) {
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
+ 
+         /* Validate target type */
+         switch ((virDomainChrSerialTargetType) chr->targetType) {
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
++
+             /* Hack required until we have a proper type for pSeries
+              * serial consoles */
+             if (qemuDomainIsPSeries(def))
+                 return 0;
+ 
+-            if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+-                chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("isa-serial requires address of isa type"));
+-                return -1;
+-            }
+-            break;
++            expected = qemuDomainChrSerialTargetTypeToAddressType(chr->targetType);
+ 
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
+             if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+-                chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("usb-serial requires address of usb type"));
+-                return -1;
+-            }
+-            break;
+-
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
+-            if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+-                chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("pci-serial requires address of pci type"));
++                chr->info.type != expected) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                               _("Target type '%s' requires address type '%s'"),
++                               virDomainChrSerialTargetTypeToString(chr->targetType),
++                               virDomainDeviceAddressTypeToString(expected));
+                 return -1;
+             }
+             break;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Introduce-functions-for-input-device-cgroup-manipulation.patch b/SOURCES/libvirt-qemu-Introduce-functions-for-input-device-cgroup-manipulation.patch
new file mode 100644
index 0000000..47d5789
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Introduce-functions-for-input-device-cgroup-manipulation.patch
@@ -0,0 +1,85 @@
+From 0a7264a2f791329f1c041594dfc17328040b8299 Mon Sep 17 00:00:00 2001
+Message-Id: <0a7264a2f791329f1c041594dfc17328040b8299@dist-git>
+From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
+Date: Mon, 27 Nov 2017 14:21:00 +0100
+Subject: [PATCH] qemu: Introduce functions for input device cgroup
+ manipulation
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Export qemuSetupInputCgroup and introduce qemuTeardownInputCgroup
+for hotunplug.
+
+(cherry picked from commit f29612fd353db074a0b963ed53ef9c29c562bb36)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1509866
+
+Signed-off-by: Ján Tomko <jtomko@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_cgroup.c | 25 ++++++++++++++++++++++++-
+ src/qemu/qemu_cgroup.h |  4 ++++
+ 2 files changed, 28 insertions(+), 1 deletion(-)
+
+diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
+index 0f75e22f98..19252ea239 100644
+--- a/src/qemu/qemu_cgroup.c
++++ b/src/qemu/qemu_cgroup.c
+@@ -246,7 +246,7 @@ qemuSetupTPMCgroup(virDomainObjPtr vm)
+ }
+ 
+ 
+-static int
++int
+ qemuSetupInputCgroup(virDomainObjPtr vm,
+                      virDomainInputDefPtr dev)
+ {
+@@ -269,6 +269,29 @@ qemuSetupInputCgroup(virDomainObjPtr vm,
+ }
+ 
+ 
++int
++qemuTeardownInputCgroup(virDomainObjPtr vm,
++                        virDomainInputDefPtr dev)
++{
++    qemuDomainObjPrivatePtr priv = vm->privateData;
++    int ret = 0;
++
++    if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES))
++        return 0;
++
++    switch (dev->type) {
++    case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
++        VIR_DEBUG("Process path '%s' for input device", dev->source.evdev);
++        ret = virCgroupDenyDevicePath(priv->cgroup, dev->source.evdev,
++                                      VIR_CGROUP_DEVICE_RWM, false);
++        virDomainAuditCgroupPath(vm, priv->cgroup, "deny", dev->source.evdev, "rwm", ret == 0);
++        break;
++    }
++
++    return ret;
++}
++
++
+ int
+ qemuSetupHostdevCgroup(virDomainObjPtr vm,
+                        virDomainHostdevDefPtr dev)
+diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
+index 3fc1583612..3b8ff6055d 100644
+--- a/src/qemu/qemu_cgroup.h
++++ b/src/qemu/qemu_cgroup.h
+@@ -37,6 +37,10 @@ int qemuSetupDiskCgroup(virDomainObjPtr vm,
+                         virDomainDiskDefPtr disk);
+ int qemuTeardownDiskCgroup(virDomainObjPtr vm,
+                            virDomainDiskDefPtr disk);
++int qemuSetupInputCgroup(virDomainObjPtr vm,
++                         virDomainInputDefPtr dev);
++int qemuTeardownInputCgroup(virDomainObjPtr vm,
++                            virDomainInputDefPtr dev);
+ int qemuSetupHostdevCgroup(virDomainObjPtr vm,
+                            virDomainHostdevDefPtr dev)
+    ATTRIBUTE_RETURN_CHECK;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Introduce-qemuDomainChrDefPostParse.patch b/SOURCES/libvirt-qemu-Introduce-qemuDomainChrDefPostParse.patch
new file mode 100644
index 0000000..966ace4
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Introduce-qemuDomainChrDefPostParse.patch
@@ -0,0 +1,108 @@
+From 06cb6ae1254842377d0b17f9fdd52e0d2b6b23eb Mon Sep 17 00:00:00 2001
+Message-Id: <06cb6ae1254842377d0b17f9fdd52e0d2b6b23eb@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:22:56 +0100
+Subject: [PATCH] qemu: Introduce qemuDomainChrDefPostParse()
+
+Having a separate function for char device handling is better than
+adding even more code to qemuDomainDeviceDefPostParse().
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
+(cherry picked from commit f4b50cc1b994e44c793f4dea59489ba51e2d1fe0)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 57 ++++++++++++++++++++++++++++++--------------------
+ 1 file changed, 34 insertions(+), 23 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 138f773c22..b15d994774 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -4082,6 +4082,35 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
+     return 0;
+ }
+ 
++static int
++qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
++                          const virDomainDef *def,
++                          virQEMUDriverPtr driver,
++                          unsigned int parseFlags)
++{
++    /* set the default console type for S390 arches */
++    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
++        chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
++        ARCH_IS_S390(def->os.arch)) {
++        chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
++    }
++
++    /* clear auto generated unix socket path for inactive definitions */
++    if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
++        if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0)
++            return -1;
++
++        /* For UNIX chardev if no path is provided we generate one.
++         * This also implies that the mode is 'bind'. */
++        if (chr->source &&
++            chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX &&
++            !chr->source->data.nix.path) {
++            chr->source->data.nix.listen = true;
++        }
++    }
++
++    return 0;
++}
+ 
+ static int
+ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+@@ -4142,29 +4171,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+         }
+     }
+ 
+-    /* set the default console type for S390 arches */
+-    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
+-        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+-        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
+-        ARCH_IS_S390(def->os.arch))
+-        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
+-
+-    /* clear auto generated unix socket path for inactive definitions */
+-    if ((parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
+-        dev->type == VIR_DOMAIN_DEVICE_CHR) {
+-        virDomainChrDefPtr chr = dev->data.chr;
+-        if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0)
+-            goto cleanup;
+-
+-        /* For UNIX chardev if no path is provided we generate one.
+-         * This also implies that the mode is 'bind'. */
+-        if (chr->source &&
+-            chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX &&
+-            !chr->source->data.nix.path) {
+-            chr->source->data.nix.listen = true;
+-        }
+-    }
+-
+     if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
+         if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
+             if ARCH_IS_PPC64(def->os.arch)
+@@ -4200,6 +4206,11 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+         qemuDomainShmemDefPostParse(dev->data.shmem) < 0)
+         goto cleanup;
+ 
++    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
++        qemuDomainChrDefPostParse(dev->data.chr, def, driver, parseFlags) < 0) {
++        goto cleanup;
++    }
++
+     ret = 0;
+ 
+  cleanup:
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Introduce-qemuDomainChrTargetDefValidate.patch b/SOURCES/libvirt-qemu-Introduce-qemuDomainChrTargetDefValidate.patch
new file mode 100644
index 0000000..b5555be
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Introduce-qemuDomainChrTargetDefValidate.patch
@@ -0,0 +1,151 @@
+From 9ec1516a227445872bf5bcb8a535c1a71f644739 Mon Sep 17 00:00:00 2001
+Message-Id: <9ec1516a227445872bf5bcb8a535c1a71f644739@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:05 +0100
+Subject: [PATCH] qemu: Introduce qemuDomainChrTargetDefValidate()
+
+Instead of waiting until we get to command line generation, we can
+validate the target for a char device much earlier.
+
+Move all the checks out of qemuBuildSerialChrDeviceStr() and into
+the new fuction. This will later allow us to validate the target
+for platform devices.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 81e14caf60ac28acf9b7147617ef26bb99955757)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c | 20 ----------------
+ src/qemu/qemu_domain.c  | 62 +++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 62 insertions(+), 20 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index d593e60198..8142834afd 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -10353,22 +10353,9 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+                                _("usb-serial is not supported in this QEMU binary"));
+                 goto error;
+             }
+-
+-            if (serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+-                serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("usb-serial requires address of usb type"));
+-                goto error;
+-            }
+             break;
+ 
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
+-            if (serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+-                serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("isa-serial requires address of isa type"));
+-                goto error;
+-            }
+             break;
+ 
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
+@@ -10377,13 +10364,6 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+                                _("pci-serial is not supported with this QEMU binary"));
+                 goto error;
+             }
+-
+-            if (serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+-                serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("pci-serial requires address of pci type"));
+-                goto error;
+-            }
+             break;
+ 
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index e43f7496c2..35eb19ca32 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3456,6 +3456,65 @@ qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def)
+ }
+ 
+ 
++static int
++qemuDomainChrTargetDefValidate(const virDomainDef *def,
++                               const virDomainChrDef *chr)
++{
++    switch ((virDomainChrDeviceType) chr->deviceType) {
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
++
++        /* Validate target type */
++        switch ((virDomainChrSerialTargetType) chr->targetType) {
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
++            /* Hack required until we have a proper type for pSeries
++             * serial consoles */
++            if (qemuDomainIsPSeries(def))
++                return 0;
++
++            if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
++                chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                               _("isa-serial requires address of isa type"));
++                return -1;
++            }
++            break;
++
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
++            if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
++                chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                               _("usb-serial requires address of usb type"));
++                return -1;
++            }
++            break;
++
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
++            if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
++                chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                               _("pci-serial requires address of pci type"));
++                return -1;
++            }
++            break;
++
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
++            break;
++        }
++        break;
++
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
++    case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
++        /* Nothing to do */
++        break;
++    }
++
++    return 0;
++}
++
++
+ static int
+ qemuDomainChrDefValidate(const virDomainChrDef *dev,
+                          const virDomainDef *def)
+@@ -3463,6 +3522,9 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev,
+     if (qemuDomainChrSourceDefValidate(dev->source) < 0)
+         return -1;
+ 
++    if (qemuDomainChrTargetDefValidate(def, dev) < 0)
++        return -1;
++
+     if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL &&
+         (ARCH_IS_S390(def->os.arch) || qemuDomainIsPSeries(def))) {
+             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Introduce-qemuDomainDefFromXML-helper.patch b/SOURCES/libvirt-qemu-Introduce-qemuDomainDefFromXML-helper.patch
deleted file mode 100644
index c7692ca..0000000
--- a/SOURCES/libvirt-qemu-Introduce-qemuDomainDefFromXML-helper.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From 0085fabfc81c097d0307b307ac0441c2448fbb16 Mon Sep 17 00:00:00 2001
-Message-Id: <0085fabfc81c097d0307b307ac0441c2448fbb16@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 14 Jun 2017 13:42:16 +0200
-Subject: [PATCH] qemu: Introduce qemuDomainDefFromXML helper
-
-The main goal of this function is to enable reusing the parsing code
-from qemuDomainDefCopy.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 0810d4f5e0d77354cdf7ad56e1e8b7748bdb1501)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1460952
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 33 +++++++++++++++++++++------------
- 1 file changed, 21 insertions(+), 12 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 82dacb3c9c..ce75105afa 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -4146,6 +4146,25 @@ void qemuDomainObjExitRemote(virDomainObjPtr obj)
- }
- 
- 
-+static virDomainDefPtr
-+qemuDomainDefFromXML(virQEMUDriverPtr driver,
-+                     const char *xml)
-+{
-+    virCapsPtr caps;
-+    virDomainDefPtr def;
-+
-+    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-+        return NULL;
-+
-+    def = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
-+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE |
-+                                  VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
-+
-+    virObjectUnref(caps);
-+    return def;
-+}
-+
-+
- virDomainDefPtr
- qemuDomainDefCopy(virQEMUDriverPtr driver,
-                   virDomainDefPtr src,
-@@ -4153,25 +4172,15 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,
- {
-     virBuffer buf = VIR_BUFFER_INITIALIZER;
-     virDomainDefPtr ret = NULL;
--    virCapsPtr caps = NULL;
-     char *xml = NULL;
- 
-     if (qemuDomainDefFormatBuf(driver, src, flags, &buf) < 0)
--        goto cleanup;
-+        return NULL;
- 
-     xml = virBufferContentAndReset(&buf);
-+    ret = qemuDomainDefFromXML(driver, xml);
- 
--    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
--        goto cleanup;
--
--    if (!(ret = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
--                                        VIR_DOMAIN_DEF_PARSE_INACTIVE |
--                                        VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
--        goto cleanup;
--
-- cleanup:
-     VIR_FREE(xml);
--    virObjectUnref(caps);
-     return ret;
- }
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Introduce-qemuMigrationReset.patch b/SOURCES/libvirt-qemu-Introduce-qemuMigrationReset.patch
deleted file mode 100644
index 8a73a17..0000000
--- a/SOURCES/libvirt-qemu-Introduce-qemuMigrationReset.patch
+++ /dev/null
@@ -1,129 +0,0 @@
-From 0c3a8fd16a2081ba0a07bf8c8bfdf26e4922da31 Mon Sep 17 00:00:00 2001
-Message-Id: <0c3a8fd16a2081ba0a07bf8c8bfdf26e4922da31@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 5 Apr 2017 14:48:43 +0200
-Subject: [PATCH] qemu: Introduce qemuMigrationReset
-
-This new API is supposed to reset all migration parameters to make sure
-future migrations won't accidentally use them. This patch makes the
-first step and moves qemuMigrationResetTLS call inside
-qemuMigrationReset.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 439a1795fd3dc8a47ad794bf10a4c86a3ee14e61)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1425003
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 31 +++++++++++++++++++++++--------
- src/qemu/qemu_migration.h |  5 +++++
- src/qemu/qemu_process.c   |  4 ++--
- 3 files changed, 30 insertions(+), 10 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 6c9f14245..27156cc78 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -2836,9 +2836,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
-     return ret;
- 
-  stopjob:
--    ignore_value(qemuMigrationResetTLS(driver, vm,
--                                       QEMU_ASYNC_JOB_MIGRATION_IN,
--                                       tlsAlias, secAlias));
-+    qemuMigrationReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN);
- 
-     if (stopProcess) {
-         unsigned int stopFlags = VIR_QEMU_PROCESS_STOP_MIGRATED;
-@@ -3216,8 +3214,7 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
-             qemuDomainEventQueue(driver, event);
-         }
- 
--        qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
--                              NULL, NULL);
-+        qemuMigrationReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT);
- 
-         if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
-             VIR_WARN("Failed to save status on vm %s", vm->def->name);
-@@ -4830,8 +4827,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
-      * here
-      */
-     if (!v3proto && ret < 0)
--        qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
--                              NULL, NULL);
-+        qemuMigrationReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT);
- 
-     if (qemuMigrationRestoreDomainState(conn, vm)) {
-         event = virDomainEventLifecycleNewFromObj(vm,
-@@ -5362,7 +5358,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
-                                  QEMU_ASYNC_JOB_MIGRATION_IN);
-     }
- 
--    qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, NULL, NULL);
-+    qemuMigrationReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN);
- 
-     qemuMigrationJobFinish(driver, vm);
-     if (!virDomainObjIsActive(vm))
-@@ -5875,3 +5871,22 @@ qemuMigrationCompressionDump(qemuMigrationCompressionPtr compression,
- 
-     return 0;
- }
-+
-+
-+/*
-+ * qemuMigrationReset:
-+ *
-+ * Reset all migration parameters so that the next job which internally uses
-+ * migration (save, managedsave, snapshots, dump) will not try to use them.
-+ */
-+void
-+qemuMigrationReset(virQEMUDriverPtr driver,
-+                   virDomainObjPtr vm,
-+                   qemuDomainAsyncJob job)
-+{
-+    if (!virDomainObjIsActive(vm))
-+        return;
-+
-+    if (qemuMigrationResetTLS(driver, vm, job, NULL, NULL) < 0)
-+        return;
-+}
-diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
-index 5248f399d..28eb55056 100644
---- a/src/qemu/qemu_migration.h
-+++ b/src/qemu/qemu_migration.h
-@@ -285,4 +285,9 @@ qemuMigrationResetTLS(virQEMUDriverPtr driver,
-                       char *in_tlsAlias,
-                       char *in_secAlias);
- 
-+void
-+qemuMigrationReset(virQEMUDriverPtr driver,
-+                   virDomainObjPtr vm,
-+                   qemuDomainAsyncJob job);
-+
- #endif /* __QEMU_MIGRATION_H__ */
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 2e0f859ce..027c831e6 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -2982,7 +2982,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriverPtr driver,
-         break;
-     }
- 
--    qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_NONE, NULL, NULL);
-+    qemuMigrationReset(driver, vm, QEMU_ASYNC_JOB_NONE);
-     return 0;
- }
- 
-@@ -3077,7 +3077,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr driver,
-         }
-     }
- 
--    qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_NONE, NULL, NULL);
-+    qemuMigrationReset(driver, vm, QEMU_ASYNC_JOB_NONE);
-     return 0;
- }
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Introduce-virQEMUCapsHostCPUDataClear.patch b/SOURCES/libvirt-qemu-Introduce-virQEMUCapsHostCPUDataClear.patch
deleted file mode 100644
index 5afde71..0000000
--- a/SOURCES/libvirt-qemu-Introduce-virQEMUCapsHostCPUDataClear.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-From 393675b4e08f2ff8a685d9bd02a83079d32e6eee Mon Sep 17 00:00:00 2001
-Message-Id: <393675b4e08f2ff8a685d9bd02a83079d32e6eee@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 7 Apr 2017 17:43:59 +0200
-Subject: [PATCH] qemu: Introduce virQEMUCapsHostCPUDataClear
-
-To keep freeing of host CPU data in one place.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit b0605e848724c5dc478382398b734398abff674c)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 30 +++++++++++++++++-------------
- 1 file changed, 17 insertions(+), 13 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 98a9a0f1d..8e7cbb590 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -2112,6 +2112,21 @@ virQEMUCapsHostCPUDataCopy(virQEMUCapsPtr dst,
- }
- 
- 
-+static void
-+virQEMUCapsHostCPUDataClear(virQEMUCapsPtr qemuCaps)
-+{
-+    qemuMonitorCPUModelInfoFree(qemuCaps->kvmCPUModelInfo);
-+    qemuMonitorCPUModelInfoFree(qemuCaps->tcgCPUModelInfo);
-+    qemuCaps->kvmCPUModelInfo = NULL;
-+    qemuCaps->tcgCPUModelInfo = NULL;
-+
-+    virCPUDefFree(qemuCaps->kvmCPUModel);
-+    virCPUDefFree(qemuCaps->tcgCPUModel);
-+    qemuCaps->kvmCPUModel = NULL;
-+    qemuCaps->tcgCPUModel = NULL;
-+}
-+
-+
- virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
- {
-     virQEMUCapsPtr ret = virQEMUCapsNew();
-@@ -2198,10 +2213,7 @@ void virQEMUCapsDispose(void *obj)
- 
-     VIR_FREE(qemuCaps->gicCapabilities);
- 
--    qemuMonitorCPUModelInfoFree(qemuCaps->kvmCPUModelInfo);
--    qemuMonitorCPUModelInfoFree(qemuCaps->tcgCPUModelInfo);
--    virCPUDefFree(qemuCaps->kvmCPUModel);
--    virCPUDefFree(qemuCaps->tcgCPUModel);
-+    virQEMUCapsHostCPUDataClear(qemuCaps);
- }
- 
- void
-@@ -4074,15 +4086,7 @@ virQEMUCapsReset(virQEMUCapsPtr qemuCaps)
-     VIR_FREE(qemuCaps->gicCapabilities);
-     qemuCaps->ngicCapabilities = 0;
- 
--    qemuMonitorCPUModelInfoFree(qemuCaps->kvmCPUModelInfo);
--    qemuMonitorCPUModelInfoFree(qemuCaps->tcgCPUModelInfo);
--    qemuCaps->kvmCPUModelInfo = NULL;
--    qemuCaps->tcgCPUModelInfo = NULL;
--
--    virCPUDefFree(qemuCaps->kvmCPUModel);
--    virCPUDefFree(qemuCaps->tcgCPUModel);
--    qemuCaps->kvmCPUModel = NULL;
--    qemuCaps->tcgCPUModel = NULL;
-+    virQEMUCapsHostCPUDataClear(qemuCaps);
- }
- 
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Introduce-virQEMUCapsSetHostModel.patch b/SOURCES/libvirt-qemu-Introduce-virQEMUCapsSetHostModel.patch
deleted file mode 100644
index b25cf96..0000000
--- a/SOURCES/libvirt-qemu-Introduce-virQEMUCapsSetHostModel.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-From 08d9d5f63f03898772fd8c636d217d2d00e14919 Mon Sep 17 00:00:00 2001
-Message-Id: <08d9d5f63f03898772fd8c636d217d2d00e14919@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 7 Apr 2017 17:03:38 +0200
-Subject: [PATCH] qemu: Introduce virQEMUCapsSetHostModel
-
-A simple helper as a complement to virQEMUCapsGetHostModel.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit bffc3b9fe501ff122ad81ddf42ecdb69f70ff70a)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 17 +++++++++++++----
- 1 file changed, 13 insertions(+), 4 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index eb6b674b4..2bbc9253a 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -2425,6 +2425,18 @@ virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
- }
- 
- 
-+static void
-+virQEMUCapsSetHostModel(virQEMUCapsPtr qemuCaps,
-+                        virDomainVirtType type,
-+                        virCPUDefPtr cpu)
-+{
-+    if (type == VIR_DOMAIN_VIRT_KVM)
-+        qemuCaps->kvmCPUModel = cpu;
-+    else
-+        qemuCaps->tcgCPUModel = cpu;
-+}
-+
-+
- bool
- virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
-                               virCapsPtr caps,
-@@ -3301,10 +3313,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-             goto error;
-     }
- 
--    if (type == VIR_DOMAIN_VIRT_KVM)
--        qemuCaps->kvmCPUModel = cpu;
--    else
--        qemuCaps->tcgCPUModel = cpu;
-+    virQEMUCapsSetHostModel(qemuCaps, type, cpu);
- 
-  cleanup:
-     virCPUDefFree(hostCPU);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Introduce-virQEMUSaveData-New-Free.patch b/SOURCES/libvirt-qemu-Introduce-virQEMUSaveData-New-Free.patch
deleted file mode 100644
index 6356951..0000000
--- a/SOURCES/libvirt-qemu-Introduce-virQEMUSaveData-New-Free.patch
+++ /dev/null
@@ -1,405 +0,0 @@
-From d37bad5cb5da2804d51cd6c45903f538d9ec85c5 Mon Sep 17 00:00:00 2001
-Message-Id: <d37bad5cb5da2804d51cd6c45903f538d9ec85c5@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 6 Jun 2017 22:29:24 +0200
-Subject: [PATCH] qemu: Introduce virQEMUSaveData{New,Free}
-
-This is a preparation for creating a new virQEMUSaveData structure which
-will encapsulate all save image header data.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit a2d2aae148980f00dd83093d61b1aa06c54fbe96)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 128 ++++++++++++++++++++++++++++++++-----------------
- 1 file changed, 83 insertions(+), 45 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 5db92b04a1..4a05793339 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -2826,6 +2826,36 @@ bswap_header(virQEMUSaveHeaderPtr hdr)
- }
- 
- 
-+static void
-+virQEMUSaveDataFree(virQEMUSaveHeaderPtr header)
-+{
-+    if (!header)
-+        return;
-+
-+    VIR_FREE(header);
-+}
-+
-+
-+static virQEMUSaveHeaderPtr
-+virQEMUSaveDataNew(char *domXML,
-+                   bool running,
-+                   int compressed)
-+{
-+    virQEMUSaveHeaderPtr header = NULL;
-+
-+    if (VIR_ALLOC(header) < 0)
-+        return NULL;
-+
-+    memcpy(header->magic, QEMU_SAVE_PARTIAL, sizeof(header->magic));
-+    header->version = QEMU_SAVE_VERSION;
-+    header->was_running = running ? 1 : 0;
-+    header->compressed = compressed;
-+    header->data_len = strlen(domXML) + 1;
-+
-+    return header;
-+}
-+
-+
- /* return -errno on failure, or 0 on success */
- static int
- qemuDomainSaveHeader(int fd, const char *path, const char *xml,
-@@ -3048,13 +3078,11 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
-                      virDomainObjPtr vm,
-                      const char *path,
-                      const char *domXML,
--                     int compressed,
-+                     virQEMUSaveHeaderPtr header,
-                      const char *compressedpath,
--                     bool was_running,
-                      unsigned int flags,
-                      qemuDomainAsyncJob asyncJob)
- {
--    virQEMUSaveHeader header;
-     bool bypassSecurityDriver = false;
-     bool needUnlink = false;
-     int ret = -1;
-@@ -3063,13 +3091,6 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
-     virFileWrapperFdPtr wrapperFd = NULL;
-     unsigned int wrapperFlags = VIR_FILE_WRAPPER_NON_BLOCKING;
- 
--    memset(&header, 0, sizeof(header));
--    memcpy(header.magic, QEMU_SAVE_PARTIAL, sizeof(header.magic));
--    header.version = QEMU_SAVE_VERSION;
--    header.was_running = was_running ? 1 : 0;
--    header.compressed = compressed;
--    header.data_len = strlen(domXML) + 1;
--
-     /* Obtain the file handle.  */
-     if ((flags & VIR_DOMAIN_SAVE_BYPASS_CACHE)) {
-         wrapperFlags |= VIR_FILE_WRAPPER_BYPASS_CACHE;
-@@ -3093,7 +3114,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
-         goto cleanup;
- 
-     /* Write header to file, followed by XML */
--    if (qemuDomainSaveHeader(fd, path, domXML, &header) < 0)
-+    if (qemuDomainSaveHeader(fd, path, domXML, header) < 0)
-         goto cleanup;
- 
-     /* Perform the migration */
-@@ -3117,7 +3138,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
-     if ((fd = qemuOpenFile(driver, vm, path, O_WRONLY, NULL, NULL)) < 0)
-         goto cleanup;
- 
--    memcpy(header.magic, QEMU_SAVE_MAGIC, sizeof(header.magic));
-+    memcpy(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic));
- 
-     if (safewrite(fd, &header, sizeof(header)) != sizeof(header)) {
-         virReportSystemError(errno, _("unable to write %s"), path);
-@@ -3158,6 +3179,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-     virObjectEventPtr event = NULL;
-     qemuDomainObjPrivatePtr priv = vm->privateData;
-     virCapsPtr caps;
-+    virQEMUSaveHeaderPtr header = NULL;
- 
-     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-         goto cleanup;
-@@ -3223,9 +3245,11 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-         goto endjob;
-     }
- 
--    ret = qemuDomainSaveMemory(driver, vm, path, xml, compressed,
--                               compressedpath, was_running, flags,
--                               QEMU_ASYNC_JOB_SAVE);
-+    if (!(header = virQEMUSaveDataNew(xml, was_running, compressed)))
-+        goto endjob;
-+
-+    ret = qemuDomainSaveMemory(driver, vm, path, xml, header, compressedpath,
-+                               flags, QEMU_ASYNC_JOB_SAVE);
-     if (ret < 0)
-         goto endjob;
- 
-@@ -3258,6 +3282,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
- 
-  cleanup:
-     VIR_FREE(xml);
-+    virQEMUSaveDataFree(header);
-     qemuDomainEventQueue(driver, event);
-     virObjectUnref(caps);
-     return ret;
-@@ -6189,7 +6214,7 @@ static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
- qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-                         const char *path,
-                         virDomainDefPtr *ret_def,
--                        virQEMUSaveHeaderPtr ret_header,
-+                        virQEMUSaveHeaderPtr *ret_header,
-                         char **xmlout,
-                         bool bypass_cache,
-                         virFileWrapperFdPtr *wrapperFd,
-@@ -6197,8 +6222,8 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-                         bool unlink_corrupt)
- {
-     int fd = -1;
--    virQEMUSaveHeader header;
-     char *xml = NULL;
-+    virQEMUSaveHeaderPtr header = NULL;
-     virDomainDefPtr def = NULL;
-     int oflags = open_write ? O_RDWR : O_RDONLY;
-     virCapsPtr caps = NULL;
-@@ -6223,7 +6248,10 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-                                            VIR_FILE_WRAPPER_BYPASS_CACHE)))
-         goto error;
- 
--    if (saferead(fd, &header, sizeof(header)) != sizeof(header)) {
-+    if (VIR_ALLOC(header) < 0)
-+        goto error;
-+
-+    if (saferead(fd, header, sizeof(*header)) != sizeof(*header)) {
-         if (unlink_corrupt) {
-             if (VIR_CLOSE(fd) < 0 || unlink(path) < 0) {
-                 virReportSystemError(errno,
-@@ -6239,11 +6267,11 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-         goto error;
-     }
- 
--    if (memcmp(header.magic, QEMU_SAVE_MAGIC, sizeof(header.magic)) != 0) {
-+    if (memcmp(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic)) != 0) {
-         const char *msg = _("image magic is incorrect");
- 
--        if (memcmp(header.magic, QEMU_SAVE_PARTIAL,
--                   sizeof(header.magic)) == 0) {
-+        if (memcmp(header->magic, QEMU_SAVE_PARTIAL,
-+                   sizeof(header->magic)) == 0) {
-             msg = _("save image is incomplete");
-             if (unlink_corrupt) {
-                 if (VIR_CLOSE(fd) < 0 || unlink(path) < 0) {
-@@ -6260,28 +6288,28 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-         goto error;
-     }
- 
--    if (header.version > QEMU_SAVE_VERSION) {
-+    if (header->version > QEMU_SAVE_VERSION) {
-         /* convert endianess and try again */
--        bswap_header(&header);
-+        bswap_header(header);
-     }
- 
--    if (header.version > QEMU_SAVE_VERSION) {
-+    if (header->version > QEMU_SAVE_VERSION) {
-         virReportError(VIR_ERR_OPERATION_FAILED,
-                        _("image version is not supported (%d > %d)"),
--                       header.version, QEMU_SAVE_VERSION);
-+                       header->version, QEMU_SAVE_VERSION);
-         goto error;
-     }
- 
--    if (header.data_len <= 0) {
-+    if (header->data_len <= 0) {
-         virReportError(VIR_ERR_OPERATION_FAILED,
--                       _("invalid XML length: %d"), header.data_len);
-+                       _("invalid XML length: %d"), header->data_len);
-         goto error;
-     }
- 
--    if (VIR_ALLOC_N(xml, header.data_len) < 0)
-+    if (VIR_ALLOC_N(xml, header->data_len) < 0)
-         goto error;
- 
--    if (saferead(fd, xml, header.data_len) != header.data_len) {
-+    if (saferead(fd, xml, header->data_len) != header->data_len) {
-         virReportError(VIR_ERR_OPERATION_FAILED,
-                        "%s", _("failed to read XML"));
-         goto error;
-@@ -6308,6 +6336,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-  error:
-     virDomainDefFree(def);
-     VIR_FREE(xml);
-+    virQEMUSaveDataFree(header);
-     VIR_FORCE_CLOSE(fd);
-     virObjectUnref(caps);
- 
-@@ -6319,7 +6348,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
-                            virQEMUDriverPtr driver,
-                            virDomainObjPtr vm,
-                            int *fd,
--                           const virQEMUSaveHeader *header,
-+                           virQEMUSaveHeaderPtr header,
-                            const char *path,
-                            bool start_paused,
-                            qemuDomainAsyncJob asyncJob)
-@@ -6445,7 +6474,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
-     const char *newxml = dxml;
-     int fd = -1;
-     int ret = -1;
--    virQEMUSaveHeader header;
-+    virQEMUSaveHeaderPtr header = NULL;
-     virFileWrapperFdPtr wrapperFd = NULL;
-     bool hook_taint = false;
- 
-@@ -6502,9 +6531,9 @@ qemuDomainRestoreFlags(virConnectPtr conn,
-     def = NULL;
- 
-     if (flags & VIR_DOMAIN_SAVE_RUNNING)
--        header.was_running = 1;
-+        header->was_running = 1;
-     else if (flags & VIR_DOMAIN_SAVE_PAUSED)
--        header.was_running = 0;
-+        header->was_running = 0;
- 
-     if (hook_taint) {
-         priv = vm->privateData;
-@@ -6514,7 +6543,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
-     if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_RESTORE) < 0)
-         goto cleanup;
- 
--    ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, &header, path,
-+    ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, header, path,
-                                      false, QEMU_ASYNC_JOB_START);
-     if (virFileWrapperFdClose(wrapperFd) < 0)
-         VIR_WARN("Failed to close %s", path);
-@@ -6525,6 +6554,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
-     virDomainDefFree(def);
-     VIR_FORCE_CLOSE(fd);
-     VIR_FREE(xml);
-+    virQEMUSaveDataFree(header);
-     VIR_FREE(xmlout);
-     virFileWrapperFdFree(wrapperFd);
-     if (vm && ret < 0)
-@@ -6549,7 +6579,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
-     char *ret = NULL;
-     virDomainDefPtr def = NULL;
-     int fd = -1;
--    virQEMUSaveHeader header;
-+    virQEMUSaveHeaderPtr header = NULL;
- 
-     /* We only take subset of virDomainDefFormat flags.  */
-     virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
-@@ -6566,6 +6596,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
-     ret = qemuDomainDefFormatXML(driver, def, flags);
- 
-  cleanup:
-+    virQEMUSaveDataFree(header);
-     virDomainDefFree(def);
-     VIR_FORCE_CLOSE(fd);
-     return ret;
-@@ -6580,9 +6611,9 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-     virDomainDefPtr def = NULL;
-     virDomainDefPtr newdef = NULL;
-     int fd = -1;
--    virQEMUSaveHeader header;
-     char *xml = NULL;
-     size_t len;
-+    virQEMUSaveHeaderPtr header = NULL;
-     int state = -1;
- 
-     virCheckFlags(VIR_DOMAIN_SAVE_RUNNING |
-@@ -6603,14 +6634,14 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-         goto cleanup;
- 
-     if (STREQ(xml, dxml) &&
--        (state < 0 || state == header.was_running)) {
-+        (state < 0 || state == header->was_running)) {
-         /* no change to the XML */
-         ret = 0;
-         goto cleanup;
-     }
- 
-     if (state >= 0)
--        header.was_running = state;
-+        header->was_running = state;
- 
-     if (!(newdef = qemuDomainSaveImageUpdateDef(driver, def, dxml)))
-         goto cleanup;
-@@ -6625,12 +6656,12 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-         goto cleanup;
-     len = strlen(xml) + 1;
- 
--    if (len > header.data_len) {
-+    if (len > header->data_len) {
-         virReportError(VIR_ERR_OPERATION_FAILED, "%s",
-                        _("new xml too large to fit in file"));
-         goto cleanup;
-     }
--    if (VIR_EXPAND_N(xml, len, header.data_len - len) < 0)
-+    if (VIR_EXPAND_N(xml, len, header->data_len - len) < 0)
-         goto cleanup;
- 
-     if (lseek(fd, 0, SEEK_SET) != 0) {
-@@ -6651,6 +6682,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-     virDomainDefFree(newdef);
-     VIR_FORCE_CLOSE(fd);
-     VIR_FREE(xml);
-+    virQEMUSaveDataFree(header);
-     return ret;
- }
- 
-@@ -6671,7 +6703,7 @@ qemuDomainObjRestore(virConnectPtr conn,
-     int ret = -1;
-     char *xml = NULL;
-     char *xmlout = NULL;
--    virQEMUSaveHeader header;
-+    virQEMUSaveHeaderPtr header = NULL;
-     virFileWrapperFdPtr wrapperFd = NULL;
- 
-     fd = qemuDomainSaveImageOpen(driver, path, &def, &header, &xml,
-@@ -6722,13 +6754,14 @@ qemuDomainObjRestore(virConnectPtr conn,
-     virDomainObjAssignDef(vm, def, true, NULL);
-     def = NULL;
- 
--    ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, &header, path,
-+    ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, header, path,
-                                      start_paused, asyncJob);
-     if (virFileWrapperFdClose(wrapperFd) < 0)
-         VIR_WARN("Failed to close %s", path);
- 
-  cleanup:
-     VIR_FREE(xml);
-+    virQEMUSaveDataFree(header);
-     VIR_FREE(xmlout);
-     virDomainDefFree(def);
-     VIR_FORCE_CLOSE(fd);
-@@ -14301,6 +14334,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
-     virQEMUDriverConfigPtr cfg = NULL;
-     int compressed;
-     char *compressedpath = NULL;
-+    virQEMUSaveHeaderPtr header = NULL;
- 
-     /* If quiesce was requested, then issue a freeze command, and a
-      * counterpart thaw command when it is actually sent to agent.
-@@ -14372,9 +14406,12 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
-         if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)))
-             goto cleanup;
- 
--        if ((ret = qemuDomainSaveMemory(driver, vm, snap->def->file, xml,
--                                        compressed, compressedpath, resume,
--                                        0, QEMU_ASYNC_JOB_SNAPSHOT)) < 0)
-+        if (!(header = virQEMUSaveDataNew(xml, resume, compressed)))
-+            goto cleanup;
-+
-+        if ((ret = qemuDomainSaveMemory(driver, vm, snap->def->file, xml, header,
-+                                        compressedpath, 0,
-+                                        QEMU_ASYNC_JOB_SNAPSHOT)) < 0)
-             goto cleanup;
- 
-         /* the memory image was created, remove it on errors */
-@@ -14442,6 +14479,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
-             ret = -1;
-     }
- 
-+    virQEMUSaveDataFree(header);
-     VIR_FREE(xml);
-     VIR_FREE(compressedpath);
-     virObjectUnref(cfg);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Introduce-virQEMUSaveData-structure.patch b/SOURCES/libvirt-qemu-Introduce-virQEMUSaveData-structure.patch
deleted file mode 100644
index 59b0e46..0000000
--- a/SOURCES/libvirt-qemu-Introduce-virQEMUSaveData-structure.patch
+++ /dev/null
@@ -1,534 +0,0 @@
-From 56a60bd1b230c86195778e4fda2f44052faae10c Mon Sep 17 00:00:00 2001
-Message-Id: <56a60bd1b230c86195778e4fda2f44052faae10c@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 7 Jun 2017 00:08:25 +0200
-Subject: [PATCH] qemu: Introduce virQEMUSaveData structure
-
-The new structure encapsulates save image header and associated data
-(domain XML).
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 47e60ac306273559b8c14527ea15a92c6ac6dd91)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 165 ++++++++++++++++++++++++++-----------------------
- 1 file changed, 86 insertions(+), 79 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 1629f27470..7ce0f01f70 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -2816,6 +2816,14 @@ struct _virQEMUSaveHeader {
-     uint32_t unused[15];
- };
- 
-+typedef struct _virQEMUSaveData virQEMUSaveData;
-+typedef virQEMUSaveData *virQEMUSaveDataPtr;
-+struct _virQEMUSaveData {
-+    virQEMUSaveHeader header;
-+    char *xml;
-+};
-+
-+
- static inline void
- bswap_header(virQEMUSaveHeaderPtr hdr)
- {
-@@ -2827,31 +2835,39 @@ bswap_header(virQEMUSaveHeaderPtr hdr)
- 
- 
- static void
--virQEMUSaveDataFree(virQEMUSaveHeaderPtr header)
-+virQEMUSaveDataFree(virQEMUSaveDataPtr data)
- {
--    if (!header)
-+    if (!data)
-         return;
- 
--    VIR_FREE(header);
-+    VIR_FREE(data->xml);
-+    VIR_FREE(data);
- }
- 
- 
--static virQEMUSaveHeaderPtr
--virQEMUSaveDataNew(char *domXML ATTRIBUTE_UNUSED,
-+/**
-+ * This function steals @domXML on success.
-+ */
-+static virQEMUSaveDataPtr
-+virQEMUSaveDataNew(char *domXML,
-                    bool running,
-                    int compressed)
- {
--    virQEMUSaveHeaderPtr header = NULL;
-+    virQEMUSaveDataPtr data = NULL;
-+    virQEMUSaveHeaderPtr header;
- 
--    if (VIR_ALLOC(header) < 0)
-+    if (VIR_ALLOC(data) < 0)
-         return NULL;
- 
-+    VIR_STEAL_PTR(data->xml, domXML);
-+
-+    header = &data->header;
-     memcpy(header->magic, QEMU_SAVE_PARTIAL, sizeof(header->magic));
-     header->version = QEMU_SAVE_VERSION;
-     header->was_running = running ? 1 : 0;
-     header->compressed = compressed;
- 
--    return header;
-+    return data;
- }
- 
- 
-@@ -2865,17 +2881,17 @@ virQEMUSaveDataNew(char *domXML ATTRIBUTE_UNUSED,
-  * Returns -1 on failure, or 0 on success.
-  */
- static int
--virQEMUSaveDataWrite(virQEMUSaveHeaderPtr header,
--                     const char *xml,
-+virQEMUSaveDataWrite(virQEMUSaveDataPtr data,
-                      int fd,
-                      const char *path)
- {
-+    virQEMUSaveHeaderPtr header = &data->header;
-     size_t len;
-     int ret = -1;
-     size_t zerosLen = 0;
-     char *zeros = NULL;
- 
--    len = strlen(xml) + 1;
-+    len = strlen(data->xml) + 1;
- 
-     if (header->data_len > 0) {
-         if (len > header->data_len) {
-@@ -2898,7 +2914,7 @@ virQEMUSaveDataWrite(virQEMUSaveHeaderPtr header,
-         goto cleanup;
-     }
- 
--    if (safewrite(fd, xml, header->data_len) != header->data_len ||
-+    if (safewrite(fd, data->xml, header->data_len) != header->data_len ||
-         safewrite(fd, zeros, zerosLen) != zerosLen) {
-         virReportSystemError(errno,
-                              _("failed to write domain xml to '%s'"),
-@@ -2915,10 +2931,12 @@ virQEMUSaveDataWrite(virQEMUSaveHeaderPtr header,
- 
- 
- static int
--virQEMUSaveDataFinish(virQEMUSaveHeaderPtr header,
-+virQEMUSaveDataFinish(virQEMUSaveDataPtr data,
-                       int *fd,
-                       const char *path)
- {
-+    virQEMUSaveHeaderPtr header = &data->header;
-+
-     memcpy(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic));
- 
-     if (safewrite(*fd, header, sizeof(*header)) != sizeof(*header) ||
-@@ -3128,8 +3146,7 @@ static int
- qemuDomainSaveMemory(virQEMUDriverPtr driver,
-                      virDomainObjPtr vm,
-                      const char *path,
--                     const char *domXML,
--                     virQEMUSaveHeaderPtr header,
-+                     virQEMUSaveDataPtr data,
-                      const char *compressedpath,
-                      unsigned int flags,
-                      qemuDomainAsyncJob asyncJob)
-@@ -3164,7 +3181,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
-     if (!(wrapperFd = virFileWrapperFdNew(&fd, path, wrapperFlags)))
-         goto cleanup;
- 
--    if (virQEMUSaveDataWrite(header, domXML, fd, path) < 0)
-+    if (virQEMUSaveDataWrite(data, fd, path) < 0)
-         goto cleanup;
- 
-     /* Perform the migration */
-@@ -3186,7 +3203,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
-         goto cleanup;
- 
-     if ((fd = qemuOpenFile(driver, vm, path, O_WRONLY, NULL, NULL)) < 0 ||
--        virQEMUSaveDataFinish(header, &fd, path) < 0)
-+        virQEMUSaveDataFinish(data, &fd, path) < 0)
-         goto cleanup;
- 
-     ret = 0;
-@@ -3218,7 +3235,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-     virObjectEventPtr event = NULL;
-     qemuDomainObjPrivatePtr priv = vm->privateData;
-     virCapsPtr caps;
--    virQEMUSaveHeaderPtr header = NULL;
-+    virQEMUSaveDataPtr data = NULL;
- 
-     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-         goto cleanup;
-@@ -3284,10 +3301,11 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-         goto endjob;
-     }
- 
--    if (!(header = virQEMUSaveDataNew(xml, was_running, compressed)))
-+    if (!(data = virQEMUSaveDataNew(xml, was_running, compressed)))
-         goto endjob;
-+    xml = NULL;
- 
--    ret = qemuDomainSaveMemory(driver, vm, path, xml, header, compressedpath,
-+    ret = qemuDomainSaveMemory(driver, vm, path, data, compressedpath,
-                                flags, QEMU_ASYNC_JOB_SAVE);
-     if (ret < 0)
-         goto endjob;
-@@ -3321,7 +3339,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
- 
-  cleanup:
-     VIR_FREE(xml);
--    virQEMUSaveDataFree(header);
-+    virQEMUSaveDataFree(data);
-     qemuDomainEventQueue(driver, event);
-     virObjectUnref(caps);
-     return ret;
-@@ -6238,8 +6256,7 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
-  * @driver: qemu driver data
-  * @path: path of the save image
-  * @ret_def: returns domain definition created from the XML stored in the image
-- * @ret_header: returns structure filled with data from the image header
-- * @xmlout: returns the XML from the image file (may be NULL)
-+ * @ret_data: returns structure filled with data from the image header
-  * @bypass_cache: bypass cache when opening the file
-  * @wrapperFd: returns the file wrapper structure
-  * @open_write: open the file for writing (for updates)
-@@ -6253,16 +6270,15 @@ static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
- qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-                         const char *path,
-                         virDomainDefPtr *ret_def,
--                        virQEMUSaveHeaderPtr *ret_header,
--                        char **xmlout,
-+                        virQEMUSaveDataPtr *ret_data,
-                         bool bypass_cache,
-                         virFileWrapperFdPtr *wrapperFd,
-                         bool open_write,
-                         bool unlink_corrupt)
- {
-     int fd = -1;
--    char *xml = NULL;
--    virQEMUSaveHeaderPtr header = NULL;
-+    virQEMUSaveDataPtr data = NULL;
-+    virQEMUSaveHeaderPtr header;
-     virDomainDefPtr def = NULL;
-     int oflags = open_write ? O_RDWR : O_RDONLY;
-     virCapsPtr caps = NULL;
-@@ -6287,9 +6303,10 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-                                            VIR_FILE_WRAPPER_BYPASS_CACHE)))
-         goto error;
- 
--    if (VIR_ALLOC(header) < 0)
-+    if (VIR_ALLOC(data) < 0)
-         goto error;
- 
-+    header = &data->header;
-     if (saferead(fd, header, sizeof(*header)) != sizeof(*header)) {
-         if (unlink_corrupt) {
-             if (VIR_CLOSE(fd) < 0 || unlink(path) < 0) {
-@@ -6341,32 +6358,27 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
- 
-     if (header->data_len <= 0) {
-         virReportError(VIR_ERR_OPERATION_FAILED,
--                       _("invalid XML length: %d"), header->data_len);
-+                       _("invalid header data length: %d"), header->data_len);
-         goto error;
-     }
- 
--    if (VIR_ALLOC_N(xml, header->data_len) < 0)
-+    if (VIR_ALLOC_N(data->xml, header->data_len) < 0)
-         goto error;
- 
--    if (saferead(fd, xml, header->data_len) != header->data_len) {
-+    if (saferead(fd, data->xml, header->data_len) != header->data_len) {
-         virReportError(VIR_ERR_OPERATION_FAILED,
--                       "%s", _("failed to read XML"));
-+                       "%s", _("failed to read domain XML"));
-         goto error;
-     }
- 
-     /* Create a domain from this XML */
--    if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
-+    if (!(def = virDomainDefParseString(data->xml, caps, driver->xmlopt, NULL,
-                                         VIR_DOMAIN_DEF_PARSE_INACTIVE |
-                                         VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
-         goto error;
- 
--    if (xmlout)
--        *xmlout = xml;
--    else
--        VIR_FREE(xml);
--
-     *ret_def = def;
--    *ret_header = header;
-+    *ret_data = data;
- 
-     virObjectUnref(caps);
- 
-@@ -6374,8 +6386,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
- 
-  error:
-     virDomainDefFree(def);
--    VIR_FREE(xml);
--    virQEMUSaveDataFree(header);
-+    virQEMUSaveDataFree(data);
-     VIR_FORCE_CLOSE(fd);
-     virObjectUnref(caps);
- 
-@@ -6387,7 +6398,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
-                            virQEMUDriverPtr driver,
-                            virDomainObjPtr vm,
-                            int *fd,
--                           virQEMUSaveHeaderPtr header,
-+                           virQEMUSaveDataPtr data,
-                            const char *path,
-                            bool start_paused,
-                            qemuDomainAsyncJob asyncJob)
-@@ -6399,6 +6410,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
-     virCommandPtr cmd = NULL;
-     char *errbuf = NULL;
-     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-+    virQEMUSaveHeaderPtr header = &data->header;
- 
-     if ((header->version == 2) &&
-         (header->compressed != QEMU_SAVE_FORMAT_RAW)) {
-@@ -6508,12 +6520,11 @@ qemuDomainRestoreFlags(virConnectPtr conn,
-     qemuDomainObjPrivatePtr priv = NULL;
-     virDomainDefPtr def = NULL;
-     virDomainObjPtr vm = NULL;
--    char *xml = NULL;
-     char *xmlout = NULL;
-     const char *newxml = dxml;
-     int fd = -1;
-     int ret = -1;
--    virQEMUSaveHeaderPtr header = NULL;
-+    virQEMUSaveDataPtr data = NULL;
-     virFileWrapperFdPtr wrapperFd = NULL;
-     bool hook_taint = false;
- 
-@@ -6524,7 +6535,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
- 
-     virNWFilterReadLockFilterUpdates();
- 
--    fd = qemuDomainSaveImageOpen(driver, path, &def, &header, &xml,
-+    fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
-                                  (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) != 0,
-                                  &wrapperFd, false, false);
-     if (fd < 0)
-@@ -6540,7 +6551,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
-                                    VIR_HOOK_QEMU_OP_RESTORE,
-                                    VIR_HOOK_SUBOP_BEGIN,
-                                    NULL,
--                                   dxml ? dxml : xml,
-+                                   dxml ? dxml : data->xml,
-                                    &xmlout)) < 0)
-             goto cleanup;
- 
-@@ -6570,9 +6581,9 @@ qemuDomainRestoreFlags(virConnectPtr conn,
-     def = NULL;
- 
-     if (flags & VIR_DOMAIN_SAVE_RUNNING)
--        header->was_running = 1;
-+        data->header.was_running = 1;
-     else if (flags & VIR_DOMAIN_SAVE_PAUSED)
--        header->was_running = 0;
-+        data->header.was_running = 0;
- 
-     if (hook_taint) {
-         priv = vm->privateData;
-@@ -6582,7 +6593,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
-     if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_RESTORE) < 0)
-         goto cleanup;
- 
--    ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, header, path,
-+    ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, data, path,
-                                      false, QEMU_ASYNC_JOB_START);
-     if (virFileWrapperFdClose(wrapperFd) < 0)
-         VIR_WARN("Failed to close %s", path);
-@@ -6592,8 +6603,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
-  cleanup:
-     virDomainDefFree(def);
-     VIR_FORCE_CLOSE(fd);
--    VIR_FREE(xml);
--    virQEMUSaveDataFree(header);
-+    virQEMUSaveDataFree(data);
-     VIR_FREE(xmlout);
-     virFileWrapperFdFree(wrapperFd);
-     if (vm && ret < 0)
-@@ -6618,12 +6628,12 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
-     char *ret = NULL;
-     virDomainDefPtr def = NULL;
-     int fd = -1;
--    virQEMUSaveHeaderPtr header = NULL;
-+    virQEMUSaveDataPtr data = NULL;
- 
-     /* We only take subset of virDomainDefFormat flags.  */
-     virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
- 
--    fd = qemuDomainSaveImageOpen(driver, path, &def, &header, NULL,
-+    fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
-                                  false, NULL, false, false);
- 
-     if (fd < 0)
-@@ -6635,7 +6645,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
-     ret = qemuDomainDefFormatXML(driver, def, flags);
- 
-  cleanup:
--    virQEMUSaveDataFree(header);
-+    virQEMUSaveDataFree(data);
-     virDomainDefFree(def);
-     VIR_FORCE_CLOSE(fd);
-     return ret;
-@@ -6650,8 +6660,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-     virDomainDefPtr def = NULL;
-     virDomainDefPtr newdef = NULL;
-     int fd = -1;
--    char *xml = NULL;
--    virQEMUSaveHeaderPtr header = NULL;
-+    virQEMUSaveDataPtr data = NULL;
-     int state = -1;
- 
-     virCheckFlags(VIR_DOMAIN_SAVE_RUNNING |
-@@ -6662,7 +6671,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-     else if (flags & VIR_DOMAIN_SAVE_PAUSED)
-         state = 0;
- 
--    fd = qemuDomainSaveImageOpen(driver, path, &def, &header, &xml,
-+    fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
-                                  false, NULL, true, false);
- 
-     if (fd < 0)
-@@ -6671,25 +6680,25 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-     if (virDomainSaveImageDefineXMLEnsureACL(conn, def) < 0)
-         goto cleanup;
- 
--    if (STREQ(xml, dxml) &&
--        (state < 0 || state == header->was_running)) {
-+    if (STREQ(data->xml, dxml) &&
-+        (state < 0 || state == data->header.was_running)) {
-         /* no change to the XML */
-         ret = 0;
-         goto cleanup;
-     }
- 
-     if (state >= 0)
--        header->was_running = state;
-+        data->header.was_running = state;
- 
-     if (!(newdef = qemuDomainSaveImageUpdateDef(driver, def, dxml)))
-         goto cleanup;
- 
--    VIR_FREE(xml);
-+    VIR_FREE(data->xml);
- 
--    if (!(xml = qemuDomainDefFormatXML(driver, newdef,
--                                       VIR_DOMAIN_XML_INACTIVE |
--                                       VIR_DOMAIN_XML_SECURE |
--                                       VIR_DOMAIN_XML_MIGRATABLE)))
-+    if (!(data->xml = qemuDomainDefFormatXML(driver, newdef,
-+                                             VIR_DOMAIN_XML_INACTIVE |
-+                                             VIR_DOMAIN_XML_SECURE |
-+                                             VIR_DOMAIN_XML_MIGRATABLE)))
-         goto cleanup;
- 
-     if (lseek(fd, 0, SEEK_SET) != 0) {
-@@ -6697,7 +6706,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-         goto cleanup;
-     }
- 
--    if (virQEMUSaveDataWrite(header, xml, fd, path) < 0)
-+    if (virQEMUSaveDataWrite(data, fd, path) < 0)
-         goto cleanup;
- 
-     if (VIR_CLOSE(fd) < 0) {
-@@ -6711,8 +6720,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-     virDomainDefFree(def);
-     virDomainDefFree(newdef);
-     VIR_FORCE_CLOSE(fd);
--    VIR_FREE(xml);
--    virQEMUSaveDataFree(header);
-+    virQEMUSaveDataFree(data);
-     return ret;
- }
- 
-@@ -6731,12 +6739,11 @@ qemuDomainObjRestore(virConnectPtr conn,
-     qemuDomainObjPrivatePtr priv = vm->privateData;
-     int fd = -1;
-     int ret = -1;
--    char *xml = NULL;
-     char *xmlout = NULL;
--    virQEMUSaveHeaderPtr header = NULL;
-+    virQEMUSaveDataPtr data = NULL;
-     virFileWrapperFdPtr wrapperFd = NULL;
- 
--    fd = qemuDomainSaveImageOpen(driver, path, &def, &header, &xml,
-+    fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
-                                  bypass_cache, &wrapperFd, false, true);
-     if (fd < 0) {
-         if (fd == -3)
-@@ -6750,7 +6757,7 @@ qemuDomainObjRestore(virConnectPtr conn,
-         if ((hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, def->name,
-                                    VIR_HOOK_QEMU_OP_RESTORE,
-                                    VIR_HOOK_SUBOP_BEGIN,
--                                   NULL, xml, &xmlout)) < 0)
-+                                   NULL, data->xml, &xmlout)) < 0)
-             goto cleanup;
- 
-         if (hookret == 0 && !virStringIsEmpty(xmlout)) {
-@@ -6784,14 +6791,13 @@ qemuDomainObjRestore(virConnectPtr conn,
-     virDomainObjAssignDef(vm, def, true, NULL);
-     def = NULL;
- 
--    ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, header, path,
-+    ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, data, path,
-                                      start_paused, asyncJob);
-     if (virFileWrapperFdClose(wrapperFd) < 0)
-         VIR_WARN("Failed to close %s", path);
- 
-  cleanup:
--    VIR_FREE(xml);
--    virQEMUSaveDataFree(header);
-+    virQEMUSaveDataFree(data);
-     VIR_FREE(xmlout);
-     virDomainDefFree(def);
-     VIR_FORCE_CLOSE(fd);
-@@ -14364,7 +14370,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
-     virQEMUDriverConfigPtr cfg = NULL;
-     int compressed;
-     char *compressedpath = NULL;
--    virQEMUSaveHeaderPtr header = NULL;
-+    virQEMUSaveDataPtr data = NULL;
- 
-     /* If quiesce was requested, then issue a freeze command, and a
-      * counterpart thaw command when it is actually sent to agent.
-@@ -14436,10 +14442,11 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
-         if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)))
-             goto cleanup;
- 
--        if (!(header = virQEMUSaveDataNew(xml, resume, compressed)))
-+        if (!(data = virQEMUSaveDataNew(xml, resume, compressed)))
-             goto cleanup;
-+        xml = NULL;
- 
--        if ((ret = qemuDomainSaveMemory(driver, vm, snap->def->file, xml, header,
-+        if ((ret = qemuDomainSaveMemory(driver, vm, snap->def->file, data,
-                                         compressedpath, 0,
-                                         QEMU_ASYNC_JOB_SNAPSHOT)) < 0)
-             goto cleanup;
-@@ -14509,7 +14516,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
-             ret = -1;
-     }
- 
--    virQEMUSaveDataFree(header);
-+    virQEMUSaveDataFree(data);
-     VIR_FREE(xml);
-     VIR_FREE(compressedpath);
-     virObjectUnref(cfg);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Introduce-virQEMUSaveDataFinish.patch b/SOURCES/libvirt-qemu-Introduce-virQEMUSaveDataFinish.patch
deleted file mode 100644
index 507c98d..0000000
--- a/SOURCES/libvirt-qemu-Introduce-virQEMUSaveDataFinish.patch
+++ /dev/null
@@ -1,77 +0,0 @@
-From 81bbd5e5673d2ed1b10b3a54876ed7945cd5f97c Mon Sep 17 00:00:00 2001
-Message-Id: <81bbd5e5673d2ed1b10b3a54876ed7945cd5f97c@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 6 Jun 2017 22:49:11 +0200
-Subject: [PATCH] qemu: Introduce virQEMUSaveDataFinish
-
-The function is supposed to update the save image header after a
-successful migration to the save image file.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit ec986bc5727b88b0631236ad0cdecb0a8568d5cd)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 34 +++++++++++++++++++++-------------
- 1 file changed, 21 insertions(+), 13 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 4a05793339..a0b607b419 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -2882,6 +2882,25 @@ qemuDomainSaveHeader(int fd, const char *path, const char *xml,
- }
- 
- 
-+static int
-+virQEMUSaveDataFinish(virQEMUSaveHeaderPtr header,
-+                      int *fd,
-+                      const char *path)
-+{
-+    memcpy(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic));
-+
-+    if (safewrite(*fd, header, sizeof(*header)) != sizeof(*header) ||
-+        VIR_CLOSE(*fd) < 0) {
-+        virReportSystemError(errno,
-+                             _("failed to write header to domain save file '%s'"),
-+                             path);
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+
- static virCommandPtr
- qemuCompressGetCommand(virQEMUSaveFormat compression)
- {
-@@ -3135,21 +3154,10 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
-     if (virFileWrapperFdClose(wrapperFd) < 0)
-         goto cleanup;
- 
--    if ((fd = qemuOpenFile(driver, vm, path, O_WRONLY, NULL, NULL)) < 0)
-+    if ((fd = qemuOpenFile(driver, vm, path, O_WRONLY, NULL, NULL)) < 0 ||
-+        virQEMUSaveDataFinish(header, &fd, path) < 0)
-         goto cleanup;
- 
--    memcpy(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic));
--
--    if (safewrite(fd, &header, sizeof(header)) != sizeof(header)) {
--        virReportSystemError(errno, _("unable to write %s"), path);
--        goto cleanup;
--    }
--
--    if (VIR_CLOSE(fd) < 0) {
--        virReportSystemError(errno, _("unable to close %s"), path);
--        goto cleanup;
--    }
--
-     ret = 0;
- 
-  cleanup:
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Limit-refresh-of-CPU-halted-state-to-s390.patch b/SOURCES/libvirt-qemu-Limit-refresh-of-CPU-halted-state-to-s390.patch
new file mode 100644
index 0000000..1ca212e
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Limit-refresh-of-CPU-halted-state-to-s390.patch
@@ -0,0 +1,37 @@
+From bda9cc7585816a5233beba2661510ecc4d69c4e2 Mon Sep 17 00:00:00 2001
+Message-Id: <bda9cc7585816a5233beba2661510ecc4d69c4e2@dist-git>
+From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
+Date: Wed, 7 Feb 2018 14:16:02 +0100
+Subject: [PATCH] qemu: Limit refresh of CPU halted state to s390
+
+Refreshing the halted state can cause VM performance issues. Since
+s390 is currently the only architecture with a known interest in
+the halted state, we're avoiding to call QEMU on other platforms.
+
+Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
+(cherry picked from commit 818a29e0c7d6840e87e9ca6019b9f0bc1983566e)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1534585
+---
+ src/qemu/qemu_domain.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index e87c7d030c..0f7f3b7f50 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -7989,6 +7989,11 @@ qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
+     if (vm->def->virtType == VIR_DOMAIN_VIRT_QEMU)
+         return 0;
+ 
++    /* The halted state is interresting only on s390(x). On other platforms
++     * the data would be stale at the time when it would be used. */
++    if (!ARCH_IS_S390(vm->def->os.arch))
++        return 0;
++
+     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
+         return -1;
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-Make-sure-host-model-uses-CPU-model-supported-by-QEMU.patch b/SOURCES/libvirt-qemu-Make-sure-host-model-uses-CPU-model-supported-by-QEMU.patch
new file mode 100644
index 0000000..2dd998d
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Make-sure-host-model-uses-CPU-model-supported-by-QEMU.patch
@@ -0,0 +1,85 @@
+From dbdc7ec536154af91ae897663d82c57d11500d23 Mon Sep 17 00:00:00 2001
+Message-Id: <dbdc7ec536154af91ae897663d82c57d11500d23@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Thu, 7 Dec 2017 11:23:50 +0100
+Subject: [PATCH] qemu: Make sure host-model uses CPU model supported by QEMU
+
+When reconnecting to a running domain started by old libvirt, which did
+not change host-model into a custom CPU definition, we replace the CPU
+definition with a specific CPU model from host capabilities. However,
+that CPU model may not be supported by the running qemu process. We need
+to translate the CPU model to one of the models which libvirt could have
+used when starting the domain.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1521202
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+(cherry picked from commit ce73de441d35e17a29b83b8741e668a6ddc013ba)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_process.c | 30 ++++++++++++++++++++++++++++++
+ 1 file changed, 30 insertions(+)
+
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index 91426ad3c3..701528c42c 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -3850,6 +3850,30 @@ qemuProcessUpdateAndVerifyCPU(virQEMUDriverPtr driver,
+ }
+ 
+ 
++static virDomainCapsCPUModelsPtr
++qemuProcessFetchCPUDefinitions(virQEMUDriverPtr driver,
++                               virDomainObjPtr vm,
++                               qemuDomainAsyncJob asyncJob)
++{
++    qemuDomainObjPrivatePtr priv = vm->privateData;
++    virDomainCapsCPUModelsPtr models = NULL;
++
++    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
++        goto error;
++
++    models = virQEMUCapsFetchCPUDefinitions(priv->mon);
++
++    if (qemuDomainObjExitMonitor(driver, vm) < 0)
++        goto error;
++
++    return models;
++
++ error:
++    virObjectUnref(models);
++    return NULL;
++}
++
++
+ static int
+ qemuProcessUpdateCPU(virQEMUDriverPtr driver,
+                      virDomainObjPtr vm,
+@@ -3857,6 +3881,7 @@ qemuProcessUpdateCPU(virQEMUDriverPtr driver,
+ {
+     virCPUDataPtr cpu = NULL;
+     virCPUDataPtr disabled = NULL;
++    virDomainCapsCPUModelsPtr models = NULL;
+     int ret = -1;
+ 
+     if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < 0)
+@@ -3865,11 +3890,16 @@ qemuProcessUpdateCPU(virQEMUDriverPtr driver,
+     if (qemuProcessUpdateLiveGuestCPU(vm, cpu, disabled) < 0)
+         goto cleanup;
+ 
++    if (!(models = qemuProcessFetchCPUDefinitions(driver, vm, asyncJob)) ||
++        virCPUTranslate(vm->def->os.arch, vm->def->cpu, models) < 0)
++        goto cleanup;
++
+     ret = 0;
+ 
+  cleanup:
+     virCPUDataFree(cpu);
+     virCPUDataFree(disabled);
++    virObjectUnref(models);
+     return ret;
+ }
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Move-common-code-in-virQEMUCapsInitCPUModel-one-layer-up.patch b/SOURCES/libvirt-qemu-Move-common-code-in-virQEMUCapsInitCPUModel-one-layer-up.patch
deleted file mode 100644
index 540e4d9..0000000
--- a/SOURCES/libvirt-qemu-Move-common-code-in-virQEMUCapsInitCPUModel-one-layer-up.patch
+++ /dev/null
@@ -1,87 +0,0 @@
-From 739fd2eac238497276f752689a7e619e298cb746 Mon Sep 17 00:00:00 2001
-Message-Id: <739fd2eac238497276f752689a7e619e298cb746@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Thu, 30 Mar 2017 13:50:44 +0200
-Subject: [PATCH] qemu: Move common code in virQEMUCapsInitCPUModel one layer
- up
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit d84b93fad51b190238e18b1daac82ea6e28869e9)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 25 ++++++++++---------------
- 1 file changed, 10 insertions(+), 15 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 2c845853a..b71de9633 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -3117,17 +3117,11 @@ virQEMUCapsCPUFilterFeatures(const char *name,
-  */
- static int
- virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
--                            virDomainVirtType type,
-+                            qemuMonitorCPUModelInfoPtr modelInfo,
-                             virCPUDefPtr cpu)
- {
--    qemuMonitorCPUModelInfoPtr modelInfo;
-     size_t i;
- 
--    if (type == VIR_DOMAIN_VIRT_KVM)
--        modelInfo = qemuCaps->kvmCPUModelInfo;
--    else
--        modelInfo = qemuCaps->tcgCPUModelInfo;
--
-     if (!modelInfo) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-                        _("missing host CPU model info from QEMU capabilities "
-@@ -3169,9 +3163,9 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
- static int
- virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
-                            virDomainVirtType type,
-+                           qemuMonitorCPUModelInfoPtr model,
-                            virCPUDefPtr cpu)
- {
--    qemuMonitorCPUModelInfoPtr model;
-     virCPUDataPtr data = NULL;
-     unsigned long long sigFamily = 0;
-     unsigned long long sigModel = 0;
-@@ -3180,11 +3174,6 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
-     int ret = -1;
-     size_t i;
- 
--    if (type == VIR_DOMAIN_VIRT_KVM)
--        model = qemuCaps->kvmCPUModelInfo;
--    else
--        model = qemuCaps->tcgCPUModelInfo;
--
-     if (!model)
-         return 1;
- 
-@@ -3245,12 +3234,18 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
-                         virDomainVirtType type,
-                         virCPUDefPtr cpu)
- {
-+    qemuMonitorCPUModelInfoPtr model;
-     int ret = 1;
- 
-+    if (type == VIR_DOMAIN_VIRT_KVM)
-+        model = qemuCaps->kvmCPUModelInfo;
-+    else
-+        model = qemuCaps->tcgCPUModelInfo;
-+
-     if (ARCH_IS_S390(qemuCaps->arch))
--        ret = virQEMUCapsInitCPUModelS390(qemuCaps, type, cpu);
-+        ret = virQEMUCapsInitCPUModelS390(qemuCaps, model, cpu);
-     else if (ARCH_IS_X86(qemuCaps->arch))
--        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, cpu);
-+        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, model, cpu);
- 
-     if (ret == 0)
-         cpu->fallback = VIR_CPU_FALLBACK_FORBID;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Move-memPath-generation-from-memoryBackingDir-to-a-separate-function.patch b/SOURCES/libvirt-qemu-Move-memPath-generation-from-memoryBackingDir-to-a-separate-function.patch
new file mode 100644
index 0000000..6b12efc
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Move-memPath-generation-from-memoryBackingDir-to-a-separate-function.patch
@@ -0,0 +1,78 @@
+From f6772178504ef0c3f02a3d18208bf7ab88402f81 Mon Sep 17 00:00:00 2001
+Message-Id: <f6772178504ef0c3f02a3d18208bf7ab88402f81@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Thu, 9 Nov 2017 16:06:43 +0100
+Subject: [PATCH] qemu: Move memPath generation from memoryBackingDir to a
+ separate function
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1461214
+
+In near future we will need more than just a plain VIR_STRDUP().
+Better implement that in a separate function and in
+qemuBuildMemoryBackendStr() which is complicated enough already.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit ae1b5d47e5f032a9a11688105e70198a0a160a50)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c |  2 +-
+ src/qemu/qemu_conf.c    | 18 ++++++++++++++++++
+ src/qemu/qemu_conf.h    |  3 +++
+ 3 files changed, 22 insertions(+), 1 deletion(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 365555ca87..9f346c3649 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -3439,7 +3439,7 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
+         } else {
+             /* We can have both pagesize and mem source. If that's the case,
+              * prefer hugepages as those are more specific. */
+-            if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0)
++            if (qemuGetMemoryBackingPath(cfg, &memPath) < 0)
+                 goto cleanup;
+         }
+ 
+diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
+index 66f9761eea..3b670a68c5 100644
+--- a/src/qemu/qemu_conf.c
++++ b/src/qemu/qemu_conf.c
+@@ -1765,3 +1765,21 @@ qemuGetDomainHupageMemPath(const virDomainDef *def,
+ 
+     return 0;
+ }
++
++
++/**
++ * qemuGetMemoryBackingPath:
++ * @cfg: the driver config
++ * @memPath: constructed path
++ *
++ * Constructs path to memory backing dir and stores it at @memPath.
++ *
++ * Returns: 0 on success,
++ *          -1 otherwise (with error reported).
++ */
++int
++qemuGetMemoryBackingPath(virQEMUDriverConfigPtr cfg,
++                         char **memPath)
++{
++    return VIR_STRDUP(*memPath, cfg->memoryBackingDir);
++}
+diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
+index 13b6f818a2..9d6866816f 100644
+--- a/src/qemu/qemu_conf.h
++++ b/src/qemu/qemu_conf.h
+@@ -363,4 +363,7 @@ int qemuGetDomainHupageMemPath(const virDomainDef *def,
+                                virQEMUDriverConfigPtr cfg,
+                                unsigned long long pagesize,
+                                char **memPath);
++
++int qemuGetMemoryBackingPath(virQEMUDriverConfigPtr cfg,
++                             char **memPath);
+ #endif /* __QEMUD_CONF_H */
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Move-qemuCaps-CPU-data-copying-into-a-separate-function.patch b/SOURCES/libvirt-qemu-Move-qemuCaps-CPU-data-copying-into-a-separate-function.patch
deleted file mode 100644
index 1446740..0000000
--- a/SOURCES/libvirt-qemu-Move-qemuCaps-CPU-data-copying-into-a-separate-function.patch
+++ /dev/null
@@ -1,79 +0,0 @@
-From e10845824c98d0996ced6a8eac5d62ac99ceedd3 Mon Sep 17 00:00:00 2001
-Message-Id: <e10845824c98d0996ced6a8eac5d62ac99ceedd3@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 7 Apr 2017 17:40:31 +0200
-Subject: [PATCH] qemu: Move qemuCaps CPU data copying into a separate function
-
-This introduces virQEMUCapsHostCPUDataCopy which will later be
-refactored a bit and called twice from virQEMUCapsNewCopy.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 8be4346ca5ae4b568b3e8ce3de9cf46f2e94b416)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 39 +++++++++++++++++++++++++--------------
- 1 file changed, 25 insertions(+), 14 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 2bbc9253a..98a9a0f1d 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -2088,6 +2088,30 @@ virQEMUCapsNew(void)
- }
- 
- 
-+static int
-+virQEMUCapsHostCPUDataCopy(virQEMUCapsPtr dst,
-+                           virQEMUCapsPtr src)
-+{
-+    if (src->kvmCPUModel &&
-+        !(dst->kvmCPUModel = virCPUDefCopy(src->kvmCPUModel)))
-+        return -1;
-+
-+    if (src->tcgCPUModel &&
-+        !(dst->tcgCPUModel = virCPUDefCopy(src->tcgCPUModel)))
-+        return -1;
-+
-+    if (src->kvmCPUModelInfo &&
-+        !(dst->kvmCPUModelInfo = qemuMonitorCPUModelInfoCopy(src->kvmCPUModelInfo)))
-+        return -1;
-+
-+    if (src->tcgCPUModelInfo &&
-+        !(dst->tcgCPUModelInfo = qemuMonitorCPUModelInfoCopy(src->tcgCPUModelInfo)))
-+        return -1;
-+
-+    return 0;
-+}
-+
-+
- virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
- {
-     virQEMUCapsPtr ret = virQEMUCapsNew();
-@@ -2125,20 +2149,7 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
-             goto error;
-     }
- 
--    if (qemuCaps->kvmCPUModel &&
--        !(ret->kvmCPUModel = virCPUDefCopy(qemuCaps->kvmCPUModel)))
--        goto error;
--
--    if (qemuCaps->tcgCPUModel &&
--        !(ret->tcgCPUModel = virCPUDefCopy(qemuCaps->tcgCPUModel)))
--        goto error;
--
--    if (qemuCaps->kvmCPUModelInfo &&
--        !(ret->kvmCPUModelInfo = qemuMonitorCPUModelInfoCopy(qemuCaps->kvmCPUModelInfo)))
--        goto error;
--
--    if (qemuCaps->tcgCPUModelInfo &&
--        !(ret->tcgCPUModelInfo = qemuMonitorCPUModelInfoCopy(qemuCaps->tcgCPUModelInfo)))
-+    if (virQEMUCapsHostCPUDataCopy(ret, qemuCaps) < 0)
-         goto error;
- 
-     if (VIR_ALLOC_N(ret->machineTypes, qemuCaps->nmachineTypes) < 0)
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Move-qemuCaps-host-CPU-data-in-a-struct.patch b/SOURCES/libvirt-qemu-Move-qemuCaps-host-CPU-data-in-a-struct.patch
deleted file mode 100644
index 23e4e06..0000000
--- a/SOURCES/libvirt-qemu-Move-qemuCaps-host-CPU-data-in-a-struct.patch
+++ /dev/null
@@ -1,350 +0,0 @@
-From 988e2340fa307179fc6f896af33c4376187b90f8 Mon Sep 17 00:00:00 2001
-Message-Id: <988e2340fa307179fc6f896af33c4376187b90f8@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 7 Apr 2017 18:15:26 +0200
-Subject: [PATCH] qemu: Move qemuCaps host CPU data in a struct
-
-We need to store several CPU related data structure for both KVM and
-TCG. So instead of keeping two different copies of everything let's
-make a virQEMUCapsHostCPUData struct and use it twice.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit b0a84ffb7f38f990120c231cfb74956a0ed10d95)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 166 +++++++++++++++++++++----------------------
- 1 file changed, 81 insertions(+), 85 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 8e7cbb590..0db149018 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -374,6 +374,19 @@ struct virQEMUCapsMachineType {
-     unsigned int maxCpus;
-     bool hotplugCpus;
- };
-+
-+typedef struct _virQEMUCapsHostCPUData virQEMUCapsHostCPUData;
-+typedef virQEMUCapsHostCPUData *virQEMUCapsHostCPUDataPtr;
-+struct _virQEMUCapsHostCPUData {
-+    /* Only the "info" part is stored in the capabilities cache, the rest is
-+     * re-computed from other fields and external data sources everytime we
-+     * probe QEMU or load the cache.
-+     */
-+    qemuMonitorCPUModelInfoPtr info;
-+    /* Host CPU definition reported in domain capabilities. */
-+    virCPUDefPtr reported;
-+};
-+
- /*
-  * Update the XML parser/formatter when adding more
-  * information to this struct so that it gets cached
-@@ -408,15 +421,8 @@ struct _virQEMUCaps {
-     size_t ngicCapabilities;
-     virGICCapability *gicCapabilities;
- 
--    qemuMonitorCPUModelInfoPtr kvmCPUModelInfo;
--    qemuMonitorCPUModelInfoPtr tcgCPUModelInfo;
--
--    /* Anything below is not stored in the cache since the values are
--     * re-computed from the other fields or external data sources every
--     * time we probe QEMU or load the results from the cache.
--     */
--    virCPUDefPtr kvmCPUModel;
--    virCPUDefPtr tcgCPUModel;
-+    virQEMUCapsHostCPUData kvmCPU;
-+    virQEMUCapsHostCPUData tcgCPU;
- };
- 
- struct virQEMUCapsSearchData {
-@@ -2089,23 +2095,15 @@ virQEMUCapsNew(void)
- 
- 
- static int
--virQEMUCapsHostCPUDataCopy(virQEMUCapsPtr dst,
--                           virQEMUCapsPtr src)
-+virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUDataPtr dst,
-+                           virQEMUCapsHostCPUDataPtr src)
- {
--    if (src->kvmCPUModel &&
--        !(dst->kvmCPUModel = virCPUDefCopy(src->kvmCPUModel)))
-+    if (src->info &&
-+        !(dst->info = qemuMonitorCPUModelInfoCopy(src->info)))
-         return -1;
- 
--    if (src->tcgCPUModel &&
--        !(dst->tcgCPUModel = virCPUDefCopy(src->tcgCPUModel)))
--        return -1;
--
--    if (src->kvmCPUModelInfo &&
--        !(dst->kvmCPUModelInfo = qemuMonitorCPUModelInfoCopy(src->kvmCPUModelInfo)))
--        return -1;
--
--    if (src->tcgCPUModelInfo &&
--        !(dst->tcgCPUModelInfo = qemuMonitorCPUModelInfoCopy(src->tcgCPUModelInfo)))
-+    if (src->reported &&
-+        !(dst->reported = virCPUDefCopy(src->reported)))
-         return -1;
- 
-     return 0;
-@@ -2113,17 +2111,12 @@ virQEMUCapsHostCPUDataCopy(virQEMUCapsPtr dst,
- 
- 
- static void
--virQEMUCapsHostCPUDataClear(virQEMUCapsPtr qemuCaps)
-+virQEMUCapsHostCPUDataClear(virQEMUCapsHostCPUDataPtr cpuData)
- {
--    qemuMonitorCPUModelInfoFree(qemuCaps->kvmCPUModelInfo);
--    qemuMonitorCPUModelInfoFree(qemuCaps->tcgCPUModelInfo);
--    qemuCaps->kvmCPUModelInfo = NULL;
--    qemuCaps->tcgCPUModelInfo = NULL;
-+    qemuMonitorCPUModelInfoFree(cpuData->info);
-+    virCPUDefFree(cpuData->reported);
- 
--    virCPUDefFree(qemuCaps->kvmCPUModel);
--    virCPUDefFree(qemuCaps->tcgCPUModel);
--    qemuCaps->kvmCPUModel = NULL;
--    qemuCaps->tcgCPUModel = NULL;
-+    memset(cpuData, 0, sizeof(*cpuData));
- }
- 
- 
-@@ -2164,7 +2157,8 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
-             goto error;
-     }
- 
--    if (virQEMUCapsHostCPUDataCopy(ret, qemuCaps) < 0)
-+    if (virQEMUCapsHostCPUDataCopy(&ret->kvmCPU, &qemuCaps->kvmCPU) < 0 ||
-+        virQEMUCapsHostCPUDataCopy(&ret->tcgCPU, &qemuCaps->tcgCPU) < 0)
-         goto error;
- 
-     if (VIR_ALLOC_N(ret->machineTypes, qemuCaps->nmachineTypes) < 0)
-@@ -2213,7 +2207,8 @@ void virQEMUCapsDispose(void *obj)
- 
-     VIR_FREE(qemuCaps->gicCapabilities);
- 
--    virQEMUCapsHostCPUDataClear(qemuCaps);
-+    virQEMUCapsHostCPUDataClear(&qemuCaps->kvmCPU);
-+    virQEMUCapsHostCPUDataClear(&qemuCaps->tcgCPU);
- }
- 
- void
-@@ -2437,14 +2432,24 @@ virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
- }
- 
- 
-+static virQEMUCapsHostCPUDataPtr
-+virQEMUCapsGetHostCPUData(virQEMUCapsPtr qemuCaps,
-+                          virDomainVirtType type)
-+{
-+    if (type == VIR_DOMAIN_VIRT_KVM)
-+        return &qemuCaps->kvmCPU;
-+    else
-+        return &qemuCaps->tcgCPU;
-+}
-+
-+
- virCPUDefPtr
- virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
-                         virDomainVirtType type)
- {
--    if (type == VIR_DOMAIN_VIRT_KVM)
--        return qemuCaps->kvmCPUModel;
--    else
--        return qemuCaps->tcgCPUModel;
-+    virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
-+
-+    return cpuData->reported;
- }
- 
- 
-@@ -2453,10 +2458,9 @@ virQEMUCapsSetHostModel(virQEMUCapsPtr qemuCaps,
-                         virDomainVirtType type,
-                         virCPUDefPtr cpu)
- {
--    if (type == VIR_DOMAIN_VIRT_KVM)
--        qemuCaps->kvmCPUModel = cpu;
--    else
--        qemuCaps->tcgCPUModel = cpu;
-+    virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
-+
-+    cpuData->reported = cpu;
- }
- 
- 
-@@ -2847,24 +2851,28 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
-                            qemuMonitorPtr mon,
-                            bool tcg)
- {
--    qemuMonitorCPUModelInfoPtr *modelInfo;
-+    qemuMonitorCPUModelInfoPtr modelInfo = NULL;
-     qemuMonitorCPUModelInfoPtr nonMigratable = NULL;
-     virHashTablePtr hash = NULL;
-     const char *model;
-     qemuMonitorCPUModelExpansionType type;
-+    virDomainVirtType virtType;
-+    virQEMUCapsHostCPUDataPtr cpuData;
-     int ret = -1;
- 
-     if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
-         return 0;
- 
-     if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
--        modelInfo = &qemuCaps->tcgCPUModelInfo;
-+        virtType = VIR_DOMAIN_VIRT_QEMU;
-         model = "max";
-     } else {
--        modelInfo = &qemuCaps->kvmCPUModelInfo;
-+        virtType = VIR_DOMAIN_VIRT_KVM;
-         model = "host";
-     }
- 
-+    cpuData = virQEMUCapsGetHostCPUData(qemuCaps, virtType);
-+
-     /* Some x86_64 features defined in cpu_map.xml use spelling which differ
-      * from the one preferred by QEMU. Static expansion would give us only the
-      * preferred spelling, thus we need to do a full expansion on the result of
-@@ -2875,14 +2883,14 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
-     else
-         type = QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC;
- 
--    if (qemuMonitorGetCPUModelExpansion(mon, type, model, true, modelInfo) < 0)
--        return -1;
-+    if (qemuMonitorGetCPUModelExpansion(mon, type, model, true, &modelInfo) < 0)
-+        goto cleanup;
- 
-     /* Try to check migratability of each feature. */
--    if (*modelInfo &&
-+    if (modelInfo &&
-         qemuMonitorGetCPUModelExpansion(mon, type, model, false,
-                                         &nonMigratable) < 0)
--        goto error;
-+        goto cleanup;
- 
-     if (nonMigratable) {
-         qemuMonitorCPUPropertyPtr prop;
-@@ -2890,12 +2898,12 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
-         size_t i;
- 
-         if (!(hash = virHashCreate(0, NULL)))
--            goto error;
-+            goto cleanup;
- 
--        for (i = 0; i < (*modelInfo)->nprops; i++) {
--            prop = (*modelInfo)->props + i;
-+        for (i = 0; i < modelInfo->nprops; i++) {
-+            prop = modelInfo->props + i;
-             if (virHashAddEntry(hash, prop->name, prop) < 0)
--                goto error;
-+                goto cleanup;
-         }
- 
-         for (i = 0; i < nonMigratable->nprops; i++) {
-@@ -2913,21 +2921,18 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
-             }
-         }
- 
--        (*modelInfo)->migratability = true;
-+        modelInfo->migratability = true;
-     }
- 
-+    VIR_STEAL_PTR(cpuData->info, modelInfo);
-     ret = 0;
- 
-  cleanup:
-     virHashFree(hash);
-     qemuMonitorCPUModelInfoFree(nonMigratable);
-+    qemuMonitorCPUModelInfoFree(modelInfo);
- 
-     return ret;
--
-- error:
--    qemuMonitorCPUModelInfoFree(*modelInfo);
--    *modelInfo = NULL;
--    goto cleanup;
- }
- 
- struct tpmTypeToCaps {
-@@ -3280,21 +3285,19 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
-                         virCPUDefPtr cpu,
-                         bool migratable)
- {
--    qemuMonitorCPUModelInfoPtr model;
-+    virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
-     int ret = 1;
- 
--    if (type == VIR_DOMAIN_VIRT_KVM)
--        model = qemuCaps->kvmCPUModelInfo;
--    else
--        model = qemuCaps->tcgCPUModelInfo;
--
--    if (migratable && model && !model->migratability)
-+    if (migratable && cpuData->info && !cpuData->info->migratability)
-         return 1;
- 
--    if (ARCH_IS_S390(qemuCaps->arch))
--        ret = virQEMUCapsInitCPUModelS390(qemuCaps, model, cpu, migratable);
--    else if (ARCH_IS_X86(qemuCaps->arch))
--        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, model, cpu, migratable);
-+    if (ARCH_IS_S390(qemuCaps->arch)) {
-+        ret = virQEMUCapsInitCPUModelS390(qemuCaps, cpuData->info,
-+                                          cpu, migratable);
-+    } else if (ARCH_IS_X86(qemuCaps->arch)) {
-+        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, cpuData->info,
-+                                         cpu, migratable);
-+    }
- 
-     if (ret == 0)
-         cpu->fallback = VIR_CPU_FALLBACK_FORBID;
-@@ -3354,10 +3357,9 @@ virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
-                            virDomainVirtType type,
-                            qemuMonitorCPUModelInfoPtr modelInfo)
- {
--    if (type == VIR_DOMAIN_VIRT_KVM)
--        qemuCaps->kvmCPUModelInfo = modelInfo;
--    else
--        qemuCaps->tcgCPUModelInfo = modelInfo;
-+    virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
-+
-+    cpuData->info = modelInfo;
- }
- 
- 
-@@ -3816,18 +3818,11 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
-                                   virBufferPtr buf,
-                                   virDomainVirtType type)
- {
--    qemuMonitorCPUModelInfoPtr model;
--    const char *typeStr;
-+    virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
-+    qemuMonitorCPUModelInfoPtr model = cpuData->info;
-+    const char *typeStr = type == VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg";
-     size_t i;
- 
--    if (type == VIR_DOMAIN_VIRT_KVM) {
--        typeStr = "kvm";
--        model = qemuCaps->kvmCPUModelInfo;
--    } else {
--        typeStr = "tcg";
--        model = qemuCaps->tcgCPUModelInfo;
--    }
--
-     if (!model)
-         return;
- 
-@@ -4086,7 +4081,8 @@ virQEMUCapsReset(virQEMUCapsPtr qemuCaps)
-     VIR_FREE(qemuCaps->gicCapabilities);
-     qemuCaps->ngicCapabilities = 0;
- 
--    virQEMUCapsHostCPUDataClear(qemuCaps);
-+    virQEMUCapsHostCPUDataClear(&qemuCaps->kvmCPU);
-+    virQEMUCapsHostCPUDataClear(&qemuCaps->tcgCPU);
- }
- 
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Move-qemuProcessReconnect-to-the-end-of-qemu_process.c.patch b/SOURCES/libvirt-qemu-Move-qemuProcessReconnect-to-the-end-of-qemu_process.c.patch
deleted file mode 100644
index facaf96..0000000
--- a/SOURCES/libvirt-qemu-Move-qemuProcessReconnect-to-the-end-of-qemu_process.c.patch
+++ /dev/null
@@ -1,687 +0,0 @@
-From 6f532f2e3615bb573a186cfcfddf8fcc1eec7efd Mon Sep 17 00:00:00 2001
-Message-Id: <6f532f2e3615bb573a186cfcfddf8fcc1eec7efd@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 11 Jul 2017 15:53:58 +0200
-Subject: [PATCH] qemu: Move qemuProcessReconnect to the end of qemu_process.c
-
-qemuProcessReconnect will need to call additional functions which were
-originally defined further in qemu_process.c.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit aad362f93b4451e2f3c98923e5e44c4fe6d26d75)
-
-Conflicts:
-	src/qemu/qemu_process.c
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1470582
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_process.c | 645 ++++++++++++++++++++++++------------------------
- 1 file changed, 323 insertions(+), 322 deletions(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 9df463094e..e6f56dc484 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3331,328 +3331,6 @@ qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver,
- }
- 
- 
--struct qemuProcessReconnectData {
--    virConnectPtr conn;
--    virQEMUDriverPtr driver;
--    virDomainObjPtr obj;
--};
--/*
-- * Open an existing VM's monitor, re-detect VCPU threads
-- * and re-reserve the security labels in use
-- *
-- * We own the virConnectPtr we are passed here - whoever started
-- * this thread function has increased the reference counter to it
-- * so that we now have to close it.
-- *
-- * This function also inherits a locked and ref'd domain object.
-- *
-- * This function needs to:
-- * 1. Enter job
-- * 1. just before monitor reconnect do lightweight MonitorEnter
-- *    (increase VM refcount and unlock VM)
-- * 2. reconnect to monitor
-- * 3. do lightweight MonitorExit (lock VM)
-- * 4. continue reconnect process
-- * 5. EndJob
-- *
-- * We can't do normal MonitorEnter & MonitorExit because these two lock the
-- * monitor lock, which does not exists in this early phase.
-- */
--static void
--qemuProcessReconnect(void *opaque)
--{
--    struct qemuProcessReconnectData *data = opaque;
--    virQEMUDriverPtr driver = data->driver;
--    virDomainObjPtr obj = data->obj;
--    qemuDomainObjPrivatePtr priv;
--    virConnectPtr conn = data->conn;
--    struct qemuDomainJobObj oldjob;
--    int state;
--    int reason;
--    virQEMUDriverConfigPtr cfg;
--    size_t i;
--    unsigned int stopFlags = 0;
--    bool jobStarted = false;
--    virCapsPtr caps = NULL;
--
--    VIR_FREE(data);
--
--    qemuDomainObjRestoreJob(obj, &oldjob);
--    if (oldjob.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN)
--        stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
--
--    cfg = virQEMUDriverGetConfig(driver);
--    priv = obj->privateData;
--
--    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
--        goto error;
--
--    if (qemuDomainObjBeginJob(driver, obj, QEMU_JOB_MODIFY) < 0)
--        goto error;
--    jobStarted = true;
--
--    /* XXX If we ever gonna change pid file pattern, come up with
--     * some intelligence here to deal with old paths. */
--    if (!(priv->pidfile = virPidFileBuildPath(cfg->stateDir, obj->def->name)))
--        goto error;
--
--    /* Restore the masterKey */
--    if (qemuDomainMasterKeyReadFile(priv) < 0)
--        goto error;
--
--    virNWFilterReadLockFilterUpdates();
--
--    VIR_DEBUG("Reconnect monitor to %p '%s'", obj, obj->def->name);
--
--    /* XXX check PID liveliness & EXE path */
--    if (qemuConnectMonitor(driver, obj, QEMU_ASYNC_JOB_NONE, NULL) < 0)
--        goto error;
--
--    if (qemuHostdevUpdateActiveDomainDevices(driver, obj->def) < 0)
--        goto error;
--
--    if (qemuConnectCgroup(driver, obj) < 0)
--        goto error;
--
--    if (qemuDomainPerfRestart(obj) < 0)
--        goto error;
--
--    /* XXX: Need to change as long as lock is introduced for
--     * qemu_driver->sharedDevices.
--     */
--    for (i = 0; i < obj->def->ndisks; i++) {
--        virDomainDeviceDef dev;
--
--        if (virStorageTranslateDiskSourcePool(conn, obj->def->disks[i]) < 0)
--            goto error;
--
--        /* XXX we should be able to restore all data from XML in the future.
--         * This should be the only place that calls qemuDomainDetermineDiskChain
--         * with @report_broken == false to guarantee best-effort domain
--         * reconnect */
--        if (qemuDomainDetermineDiskChain(driver, obj, obj->def->disks[i],
--                                         true, false) < 0)
--            goto error;
--
--        dev.type = VIR_DOMAIN_DEVICE_DISK;
--        dev.data.disk = obj->def->disks[i];
--        if (qemuAddSharedDevice(driver, &dev, obj->def->name) < 0)
--            goto error;
--    }
--
--    if (qemuProcessUpdateState(driver, obj) < 0)
--        goto error;
--
--    state = virDomainObjGetState(obj, &reason);
--    if (state == VIR_DOMAIN_SHUTOFF ||
--        (state == VIR_DOMAIN_PAUSED &&
--         reason == VIR_DOMAIN_PAUSED_STARTING_UP)) {
--        VIR_DEBUG("Domain '%s' wasn't fully started yet, killing it",
--                  obj->def->name);
--        goto error;
--    }
--
--    /* If upgrading from old libvirtd we won't have found any
--     * caps in the domain status, so re-query them
--     */
--    if (!priv->qemuCaps &&
--        !(priv->qemuCaps = virQEMUCapsCacheLookupCopy(caps,
--                                                      driver->qemuCapsCache,
--                                                      obj->def->emulator,
--                                                      obj->def->os.machine)))
--        goto error;
--
--    /* In case the domain shutdown while we were not running,
--     * we need to finish the shutdown process. And we need to do it after
--     * we have virQEMUCaps filled in.
--     */
--    if (state == VIR_DOMAIN_SHUTDOWN ||
--        (state == VIR_DOMAIN_PAUSED &&
--         reason == VIR_DOMAIN_PAUSED_SHUTTING_DOWN)) {
--        VIR_DEBUG("Finishing shutdown sequence for domain %s",
--                  obj->def->name);
--        qemuProcessShutdownOrReboot(driver, obj);
--        goto cleanup;
--    }
--
--    if (qemuProcessBuildDestroyHugepagesPath(driver, obj, true) < 0)
--        goto error;
--
--    if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps,
--                                   driver, obj, false)) < 0) {
--        goto error;
--    }
--
--    /* if domain requests security driver we haven't loaded, report error, but
--     * do not kill the domain
--     */
--    ignore_value(qemuSecurityCheckAllLabel(driver->securityManager,
--                                           obj->def));
--
--    if (qemuDomainRefreshVcpuInfo(driver, obj, QEMU_ASYNC_JOB_NONE, true) < 0)
--        goto error;
--
--    qemuDomainVcpuPersistOrder(obj->def);
--
--    if (qemuSecurityReserveLabel(driver->securityManager, obj->def, obj->pid) < 0)
--        goto error;
--
--    qemuProcessNotifyNets(obj->def);
--
--    if (qemuProcessFiltersInstantiate(obj->def))
--        goto error;
--
--    if (qemuProcessRefreshDisks(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
--        goto error;
--
--    if (qemuBlockNodeNamesDetect(driver, obj) < 0)
--        goto error;
--
--    if (qemuRefreshVirtioChannelState(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
--        goto error;
--
--    /* If querying of guest's RTC failed, report error, but do not kill the domain. */
--    qemuRefreshRTC(driver, obj);
--
--    if (qemuProcessRefreshBalloonState(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
--        goto error;
--
--    if (qemuProcessRecoverJob(driver, obj, conn, &oldjob, &stopFlags) < 0)
--        goto error;
--
--    if (qemuProcessUpdateDevices(driver, obj) < 0)
--        goto error;
--
--    qemuProcessReconnectCheckMemAliasOrderMismatch(obj);
--
--    if (qemuConnectAgent(driver, obj) < 0)
--        goto error;
--
--    /* update domain state XML with possibly updated state in virDomainObj */
--    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, obj, driver->caps) < 0)
--        goto error;
--
--    /* Run an hook to allow admins to do some magic */
--    if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
--        char *xml = qemuDomainDefFormatXML(driver, obj->def, 0);
--        int hookret;
--
--        hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, obj->def->name,
--                              VIR_HOOK_QEMU_OP_RECONNECT, VIR_HOOK_SUBOP_BEGIN,
--                              NULL, xml, NULL);
--        VIR_FREE(xml);
--
--        /*
--         * If the script raised an error abort the launch
--         */
--        if (hookret < 0)
--            goto error;
--    }
--
--    if (virAtomicIntInc(&driver->nactive) == 1 && driver->inhibitCallback)
--        driver->inhibitCallback(true, driver->inhibitOpaque);
--
-- cleanup:
--    if (jobStarted)
--        qemuDomainObjEndJob(driver, obj);
--    if (!virDomainObjIsActive(obj))
--        qemuDomainRemoveInactive(driver, obj);
--    virDomainObjEndAPI(&obj);
--    virObjectUnref(conn);
--    virObjectUnref(cfg);
--    virObjectUnref(caps);
--    virNWFilterUnlockFilterUpdates();
--    return;
--
-- error:
--    if (virDomainObjIsActive(obj)) {
--        /* We can't get the monitor back, so must kill the VM
--         * to remove danger of it ending up running twice if
--         * user tries to start it again later
--         */
--        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NO_SHUTDOWN)) {
--            /* If we couldn't get the monitor and qemu supports
--             * no-shutdown, we can safely say that the domain
--             * crashed ... */
--            state = VIR_DOMAIN_SHUTOFF_CRASHED;
--        } else {
--            /* ... but if it doesn't we can't say what the state
--             * really is and FAILED means "failed to start" */
--            state = VIR_DOMAIN_SHUTOFF_UNKNOWN;
--        }
--        /* If BeginJob failed, we jumped here without a job, let's hope another
--         * thread didn't have a chance to start playing with the domain yet
--         * (it's all we can do anyway).
--         */
--        qemuProcessStop(driver, obj, state, QEMU_ASYNC_JOB_NONE, stopFlags);
--    }
--    goto cleanup;
--}
--
--static int
--qemuProcessReconnectHelper(virDomainObjPtr obj,
--                           void *opaque)
--{
--    virThread thread;
--    struct qemuProcessReconnectData *src = opaque;
--    struct qemuProcessReconnectData *data;
--
--    /* If the VM was inactive, we don't need to reconnect */
--    if (!obj->pid)
--        return 0;
--
--    if (VIR_ALLOC(data) < 0)
--        return -1;
--
--    memcpy(data, src, sizeof(*data));
--    data->obj = obj;
--
--    /* this lock and reference will be eventually transferred to the thread
--     * that handles the reconnect */
--    virObjectLock(obj);
--    virObjectRef(obj);
--
--    /* Since we close the connection later on, we have to make sure that the
--     * threads we start see a valid connection throughout their lifetime. We
--     * simply increase the reference counter here.
--     */
--    virObjectRef(data->conn);
--
--    if (virThreadCreate(&thread, false, qemuProcessReconnect, data) < 0) {
--        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
--                       _("Could not create thread. QEMU initialization "
--                         "might be incomplete"));
--        /* We can't spawn a thread and thus connect to monitor. Kill qemu.
--         * It's safe to call qemuProcessStop without a job here since there
--         * is no thread that could be doing anything else with the same domain
--         * object.
--         */
--        qemuProcessStop(src->driver, obj, VIR_DOMAIN_SHUTOFF_FAILED,
--                        QEMU_ASYNC_JOB_NONE, 0);
--        qemuDomainRemoveInactive(src->driver, obj);
--
--        virDomainObjEndAPI(&obj);
--        virObjectUnref(data->conn);
--        VIR_FREE(data);
--        return -1;
--    }
--
--    return 0;
--}
--
--/**
-- * qemuProcessReconnectAll
-- *
-- * Try to re-open the resources for live VMs that we care
-- * about.
-- */
--void
--qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver)
--{
--    struct qemuProcessReconnectData data = {.conn = conn, .driver = driver};
--    virDomainObjListForEach(driver->domains, qemuProcessReconnectHelper, &data);
--}
--
- static int
- qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
-                             virDomainGraphicsDefPtr graphics,
-@@ -6958,3 +6636,326 @@ qemuProcessRefreshDisks(virQEMUDriverPtr driver,
-     virHashFree(table);
-     return ret;
- }
-+
-+
-+struct qemuProcessReconnectData {
-+    virConnectPtr conn;
-+    virQEMUDriverPtr driver;
-+    virDomainObjPtr obj;
-+};
-+/*
-+ * Open an existing VM's monitor, re-detect VCPU threads
-+ * and re-reserve the security labels in use
-+ *
-+ * We own the virConnectPtr we are passed here - whoever started
-+ * this thread function has increased the reference counter to it
-+ * so that we now have to close it.
-+ *
-+ * This function also inherits a locked and ref'd domain object.
-+ *
-+ * This function needs to:
-+ * 1. Enter job
-+ * 1. just before monitor reconnect do lightweight MonitorEnter
-+ *    (increase VM refcount and unlock VM)
-+ * 2. reconnect to monitor
-+ * 3. do lightweight MonitorExit (lock VM)
-+ * 4. continue reconnect process
-+ * 5. EndJob
-+ *
-+ * We can't do normal MonitorEnter & MonitorExit because these two lock the
-+ * monitor lock, which does not exists in this early phase.
-+ */
-+static void
-+qemuProcessReconnect(void *opaque)
-+{
-+    struct qemuProcessReconnectData *data = opaque;
-+    virQEMUDriverPtr driver = data->driver;
-+    virDomainObjPtr obj = data->obj;
-+    qemuDomainObjPrivatePtr priv;
-+    virConnectPtr conn = data->conn;
-+    struct qemuDomainJobObj oldjob;
-+    int state;
-+    int reason;
-+    virQEMUDriverConfigPtr cfg;
-+    size_t i;
-+    unsigned int stopFlags = 0;
-+    bool jobStarted = false;
-+    virCapsPtr caps = NULL;
-+
-+    VIR_FREE(data);
-+
-+    qemuDomainObjRestoreJob(obj, &oldjob);
-+    if (oldjob.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN)
-+        stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
-+
-+    cfg = virQEMUDriverGetConfig(driver);
-+    priv = obj->privateData;
-+
-+    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-+        goto error;
-+
-+    if (qemuDomainObjBeginJob(driver, obj, QEMU_JOB_MODIFY) < 0)
-+        goto error;
-+    jobStarted = true;
-+
-+    /* XXX If we ever gonna change pid file pattern, come up with
-+     * some intelligence here to deal with old paths. */
-+    if (!(priv->pidfile = virPidFileBuildPath(cfg->stateDir, obj->def->name)))
-+        goto error;
-+
-+    /* Restore the masterKey */
-+    if (qemuDomainMasterKeyReadFile(priv) < 0)
-+        goto error;
-+
-+    virNWFilterReadLockFilterUpdates();
-+
-+    VIR_DEBUG("Reconnect monitor to %p '%s'", obj, obj->def->name);
-+
-+    /* XXX check PID liveliness & EXE path */
-+    if (qemuConnectMonitor(driver, obj, QEMU_ASYNC_JOB_NONE, NULL) < 0)
-+        goto error;
-+
-+    if (qemuHostdevUpdateActiveDomainDevices(driver, obj->def) < 0)
-+        goto error;
-+
-+    if (qemuConnectCgroup(driver, obj) < 0)
-+        goto error;
-+
-+    if (qemuDomainPerfRestart(obj) < 0)
-+        goto error;
-+
-+    /* XXX: Need to change as long as lock is introduced for
-+     * qemu_driver->sharedDevices.
-+     */
-+    for (i = 0; i < obj->def->ndisks; i++) {
-+        virDomainDeviceDef dev;
-+
-+        if (virStorageTranslateDiskSourcePool(conn, obj->def->disks[i]) < 0)
-+            goto error;
-+
-+        /* XXX we should be able to restore all data from XML in the future.
-+         * This should be the only place that calls qemuDomainDetermineDiskChain
-+         * with @report_broken == false to guarantee best-effort domain
-+         * reconnect */
-+        if (qemuDomainDetermineDiskChain(driver, obj, obj->def->disks[i],
-+                                         true, false) < 0)
-+            goto error;
-+
-+        dev.type = VIR_DOMAIN_DEVICE_DISK;
-+        dev.data.disk = obj->def->disks[i];
-+        if (qemuAddSharedDevice(driver, &dev, obj->def->name) < 0)
-+            goto error;
-+    }
-+
-+    if (qemuProcessUpdateState(driver, obj) < 0)
-+        goto error;
-+
-+    state = virDomainObjGetState(obj, &reason);
-+    if (state == VIR_DOMAIN_SHUTOFF ||
-+        (state == VIR_DOMAIN_PAUSED &&
-+         reason == VIR_DOMAIN_PAUSED_STARTING_UP)) {
-+        VIR_DEBUG("Domain '%s' wasn't fully started yet, killing it",
-+                  obj->def->name);
-+        goto error;
-+    }
-+
-+    /* If upgrading from old libvirtd we won't have found any
-+     * caps in the domain status, so re-query them
-+     */
-+    if (!priv->qemuCaps &&
-+        !(priv->qemuCaps = virQEMUCapsCacheLookupCopy(caps,
-+                                                      driver->qemuCapsCache,
-+                                                      obj->def->emulator,
-+                                                      obj->def->os.machine)))
-+        goto error;
-+
-+    /* In case the domain shutdown while we were not running,
-+     * we need to finish the shutdown process. And we need to do it after
-+     * we have virQEMUCaps filled in.
-+     */
-+    if (state == VIR_DOMAIN_SHUTDOWN ||
-+        (state == VIR_DOMAIN_PAUSED &&
-+         reason == VIR_DOMAIN_PAUSED_SHUTTING_DOWN)) {
-+        VIR_DEBUG("Finishing shutdown sequence for domain %s",
-+                  obj->def->name);
-+        qemuProcessShutdownOrReboot(driver, obj);
-+        goto cleanup;
-+    }
-+
-+    if (qemuProcessBuildDestroyHugepagesPath(driver, obj, true) < 0)
-+        goto error;
-+
-+    if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps,
-+                                   driver, obj, false)) < 0) {
-+        goto error;
-+    }
-+
-+    /* if domain requests security driver we haven't loaded, report error, but
-+     * do not kill the domain
-+     */
-+    ignore_value(qemuSecurityCheckAllLabel(driver->securityManager,
-+                                           obj->def));
-+
-+    if (qemuDomainRefreshVcpuInfo(driver, obj, QEMU_ASYNC_JOB_NONE, true) < 0)
-+        goto error;
-+
-+    qemuDomainVcpuPersistOrder(obj->def);
-+
-+    if (qemuSecurityReserveLabel(driver->securityManager, obj->def, obj->pid) < 0)
-+        goto error;
-+
-+    qemuProcessNotifyNets(obj->def);
-+
-+    if (qemuProcessFiltersInstantiate(obj->def))
-+        goto error;
-+
-+    if (qemuProcessRefreshDisks(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
-+        goto error;
-+
-+    if (qemuBlockNodeNamesDetect(driver, obj) < 0)
-+        goto error;
-+
-+    if (qemuRefreshVirtioChannelState(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
-+        goto error;
-+
-+    /* If querying of guest's RTC failed, report error, but do not kill the domain. */
-+    qemuRefreshRTC(driver, obj);
-+
-+    if (qemuProcessRefreshBalloonState(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
-+        goto error;
-+
-+    if (qemuProcessRecoverJob(driver, obj, conn, &oldjob, &stopFlags) < 0)
-+        goto error;
-+
-+    if (qemuProcessUpdateDevices(driver, obj) < 0)
-+        goto error;
-+
-+    qemuProcessReconnectCheckMemAliasOrderMismatch(obj);
-+
-+    if (qemuConnectAgent(driver, obj) < 0)
-+        goto error;
-+
-+    /* update domain state XML with possibly updated state in virDomainObj */
-+    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, obj, driver->caps) < 0)
-+        goto error;
-+
-+    /* Run an hook to allow admins to do some magic */
-+    if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
-+        char *xml = qemuDomainDefFormatXML(driver, obj->def, 0);
-+        int hookret;
-+
-+        hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, obj->def->name,
-+                              VIR_HOOK_QEMU_OP_RECONNECT, VIR_HOOK_SUBOP_BEGIN,
-+                              NULL, xml, NULL);
-+        VIR_FREE(xml);
-+
-+        /*
-+         * If the script raised an error abort the launch
-+         */
-+        if (hookret < 0)
-+            goto error;
-+    }
-+
-+    if (virAtomicIntInc(&driver->nactive) == 1 && driver->inhibitCallback)
-+        driver->inhibitCallback(true, driver->inhibitOpaque);
-+
-+ cleanup:
-+    if (jobStarted)
-+        qemuDomainObjEndJob(driver, obj);
-+    if (!virDomainObjIsActive(obj))
-+        qemuDomainRemoveInactive(driver, obj);
-+    virDomainObjEndAPI(&obj);
-+    virObjectUnref(conn);
-+    virObjectUnref(cfg);
-+    virObjectUnref(caps);
-+    virNWFilterUnlockFilterUpdates();
-+    return;
-+
-+ error:
-+    if (virDomainObjIsActive(obj)) {
-+        /* We can't get the monitor back, so must kill the VM
-+         * to remove danger of it ending up running twice if
-+         * user tries to start it again later
-+         */
-+        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NO_SHUTDOWN)) {
-+            /* If we couldn't get the monitor and qemu supports
-+             * no-shutdown, we can safely say that the domain
-+             * crashed ... */
-+            state = VIR_DOMAIN_SHUTOFF_CRASHED;
-+        } else {
-+            /* ... but if it doesn't we can't say what the state
-+             * really is and FAILED means "failed to start" */
-+            state = VIR_DOMAIN_SHUTOFF_UNKNOWN;
-+        }
-+        /* If BeginJob failed, we jumped here without a job, let's hope another
-+         * thread didn't have a chance to start playing with the domain yet
-+         * (it's all we can do anyway).
-+         */
-+        qemuProcessStop(driver, obj, state, QEMU_ASYNC_JOB_NONE, stopFlags);
-+    }
-+    goto cleanup;
-+}
-+
-+static int
-+qemuProcessReconnectHelper(virDomainObjPtr obj,
-+                           void *opaque)
-+{
-+    virThread thread;
-+    struct qemuProcessReconnectData *src = opaque;
-+    struct qemuProcessReconnectData *data;
-+
-+    /* If the VM was inactive, we don't need to reconnect */
-+    if (!obj->pid)
-+        return 0;
-+
-+    if (VIR_ALLOC(data) < 0)
-+        return -1;
-+
-+    memcpy(data, src, sizeof(*data));
-+    data->obj = obj;
-+
-+    /* this lock and reference will be eventually transferred to the thread
-+     * that handles the reconnect */
-+    virObjectLock(obj);
-+    virObjectRef(obj);
-+
-+    /* Since we close the connection later on, we have to make sure that the
-+     * threads we start see a valid connection throughout their lifetime. We
-+     * simply increase the reference counter here.
-+     */
-+    virObjectRef(data->conn);
-+
-+    if (virThreadCreate(&thread, false, qemuProcessReconnect, data) < 0) {
-+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-+                       _("Could not create thread. QEMU initialization "
-+                         "might be incomplete"));
-+        /* We can't spawn a thread and thus connect to monitor. Kill qemu.
-+         * It's safe to call qemuProcessStop without a job here since there
-+         * is no thread that could be doing anything else with the same domain
-+         * object.
-+         */
-+        qemuProcessStop(src->driver, obj, VIR_DOMAIN_SHUTOFF_FAILED,
-+                        QEMU_ASYNC_JOB_NONE, 0);
-+        qemuDomainRemoveInactive(src->driver, obj);
-+
-+        virDomainObjEndAPI(&obj);
-+        virObjectUnref(data->conn);
-+        VIR_FREE(data);
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+/**
-+ * qemuProcessReconnectAll
-+ *
-+ * Try to re-open the resources for live VMs that we care
-+ * about.
-+ */
-+void
-+qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver)
-+{
-+    struct qemuProcessReconnectData data = {.conn = conn, .driver = driver};
-+    virDomainObjListForEach(driver->domains, qemuProcessReconnectHelper, &data);
-+}
--- 
-2.13.2
-
diff --git a/SOURCES/libvirt-qemu-Move-snapshot-disk-validation-functions-into-one.patch b/SOURCES/libvirt-qemu-Move-snapshot-disk-validation-functions-into-one.patch
new file mode 100644
index 0000000..6a163ae
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Move-snapshot-disk-validation-functions-into-one.patch
@@ -0,0 +1,185 @@
+From 53d9458b2d6095e376f2b5cacf30da7b2227f69d Mon Sep 17 00:00:00 2001
+Message-Id: <53d9458b2d6095e376f2b5cacf30da7b2227f69d@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:13 +0100
+Subject: [PATCH] qemu: Move snapshot disk validation functions into one
+
+Move the code so that both the new image and old image can be verified
+in the same function.
+
+(cherry picked from commit 8ffdeed455650557df531aafc66c20b31bd4e0c4)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1511480
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_driver.c | 91 ++++++++++++++++++++------------------------------
+ 1 file changed, 36 insertions(+), 55 deletions(-)
+
+diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
+index b35ab6d30e..aa6a326bb4 100644
+--- a/src/qemu/qemu_driver.c
++++ b/src/qemu/qemu_driver.c
+@@ -13953,17 +13953,19 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
+ 
+ 
+ static int
+-qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
++qemuDomainSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDefPtr snapdisk,
++                                              virDomainDiskDefPtr domdisk)
+ {
+-    int actualType = virStorageSourceGetActualType(disk->src);
++    int domDiskType = virStorageSourceGetActualType(domdisk->src);
++    int snapDiskType = virStorageSourceGetActualType(snapdisk->src);
+ 
+-    switch ((virStorageType) actualType) {
++    switch ((virStorageType) domDiskType) {
+     case VIR_STORAGE_TYPE_BLOCK:
+     case VIR_STORAGE_TYPE_FILE:
+-        return 0;
++        break;
+ 
+     case VIR_STORAGE_TYPE_NETWORK:
+-        switch ((virStorageNetProtocol) disk->src->protocol) {
++        switch ((virStorageNetProtocol) domdisk->src->protocol) {
+         case VIR_STORAGE_NET_PROTOCOL_NONE:
+         case VIR_STORAGE_NET_PROTOCOL_NBD:
+         case VIR_STORAGE_NET_PROTOCOL_RBD:
+@@ -13981,7 +13983,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
+             virReportError(VIR_ERR_INTERNAL_ERROR,
+                            _("external inactive snapshots are not supported on "
+                              "'network' disks using '%s' protocol"),
+-                           virStorageNetProtocolTypeToString(disk->src->protocol));
++                           virStorageNetProtocolTypeToString(domdisk->src->protocol));
+             return -1;
+         }
+         break;
+@@ -13992,7 +13994,23 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
+     case VIR_STORAGE_TYPE_LAST:
+         virReportError(VIR_ERR_INTERNAL_ERROR,
+                        _("external inactive snapshots are not supported on "
+-                         "'%s' disks"), virStorageTypeToString(actualType));
++                         "'%s' disks"), virStorageTypeToString(domDiskType));
++        return -1;
++    }
++
++    switch ((virStorageType) snapDiskType) {
++    case VIR_STORAGE_TYPE_BLOCK:
++    case VIR_STORAGE_TYPE_FILE:
++        break;
++
++    case VIR_STORAGE_TYPE_NETWORK:
++    case VIR_STORAGE_TYPE_DIR:
++    case VIR_STORAGE_TYPE_VOLUME:
++    case VIR_STORAGE_TYPE_NONE:
++    case VIR_STORAGE_TYPE_LAST:
++        virReportError(VIR_ERR_INTERNAL_ERROR,
++                       _("external inactive snapshots are not supported on "
++                         "'%s' disks"), virStorageTypeToString(snapDiskType));
+         return -1;
+     }
+ 
+@@ -14001,33 +14019,27 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
+ 
+ 
+ static int
+-qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr disk)
++qemuDomainSnapshotPrepareDiskExternalActive(virDomainSnapshotDiskDefPtr snapdisk,
++                                            virDomainDiskDefPtr domdisk)
+ {
+-    if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
++    int actualType = virStorageSourceGetActualType(snapdisk->src);
++
++    if (domdisk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
+         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                        _("external active snapshots are not supported on scsi "
+                          "passthrough devices"));
+         return -1;
+     }
+ 
+-    return 0;
+-}
+-
+-
+-static int
+-qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr disk)
+-{
+-    int actualType = virStorageSourceGetActualType(disk->src);
+-
+     switch ((virStorageType) actualType) {
+     case VIR_STORAGE_TYPE_BLOCK:
+     case VIR_STORAGE_TYPE_FILE:
+-        return 0;
++        break;
+ 
+     case VIR_STORAGE_TYPE_NETWORK:
+-        switch ((virStorageNetProtocol) disk->src->protocol) {
++        switch ((virStorageNetProtocol) snapdisk->src->protocol) {
+         case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
+-            return 0;
++            break;
+ 
+         case VIR_STORAGE_NET_PROTOCOL_NONE:
+         case VIR_STORAGE_NET_PROTOCOL_NBD:
+@@ -14045,7 +14057,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr d
+             virReportError(VIR_ERR_INTERNAL_ERROR,
+                            _("external active snapshots are not supported on "
+                              "'network' disks using '%s' protocol"),
+-                           virStorageNetProtocolTypeToString(disk->src->protocol));
++                           virStorageNetProtocolTypeToString(snapdisk->src->protocol));
+             return -1;
+ 
+         }
+@@ -14065,31 +14077,6 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr d
+ }
+ 
+ 
+-static int
+-qemuDomainSnapshotPrepareDiskExternalOverlayInactive(virDomainSnapshotDiskDefPtr disk)
+-{
+-    int actualType = virStorageSourceGetActualType(disk->src);
+-
+-    switch ((virStorageType) actualType) {
+-    case VIR_STORAGE_TYPE_BLOCK:
+-    case VIR_STORAGE_TYPE_FILE:
+-        return 0;
+-
+-    case VIR_STORAGE_TYPE_NETWORK:
+-    case VIR_STORAGE_TYPE_DIR:
+-    case VIR_STORAGE_TYPE_VOLUME:
+-    case VIR_STORAGE_TYPE_NONE:
+-    case VIR_STORAGE_TYPE_LAST:
+-        virReportError(VIR_ERR_INTERNAL_ERROR,
+-                       _("external inactive snapshots are not supported on "
+-                         "'%s' disks"), virStorageTypeToString(actualType));
+-        return -1;
+-    }
+-
+-    return 0;
+-}
+-
+-
+ static int
+ qemuDomainSnapshotPrepareDiskExternal(virConnectPtr conn,
+                                       virDomainDiskDefPtr disk,
+@@ -14107,16 +14094,10 @@ qemuDomainSnapshotPrepareDiskExternal(virConnectPtr conn,
+         if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
+             return -1;
+ 
+-        if (qemuDomainSnapshotPrepareDiskExternalBackingInactive(disk) < 0)
+-            return -1;
+-
+-        if (qemuDomainSnapshotPrepareDiskExternalOverlayInactive(snapdisk) < 0)
++        if (qemuDomainSnapshotPrepareDiskExternalInactive(snapdisk, disk) < 0)
+             return -1;
+     } else {
+-        if (qemuDomainSnapshotPrepareDiskExternalBackingActive(disk) < 0)
+-            return -1;
+-
+-        if (qemuDomainSnapshotPrepareDiskExternalOverlayActive(snapdisk) < 0)
++        if (qemuDomainSnapshotPrepareDiskExternalActive(snapdisk, disk) < 0)
+             return -1;
+     }
+ 
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Pass-migratable-host-CPU-model-to-virCPUUpdate.patch b/SOURCES/libvirt-qemu-Pass-migratable-host-CPU-model-to-virCPUUpdate.patch
deleted file mode 100644
index 2ce3f7e..0000000
--- a/SOURCES/libvirt-qemu-Pass-migratable-host-CPU-model-to-virCPUUpdate.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-From ea1a18cc0a5722b64c37c79bee7b9ed3c220ca01 Mon Sep 17 00:00:00 2001
-Message-Id: <ea1a18cc0a5722b64c37c79bee7b9ed3c220ca01@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 29 Mar 2017 15:31:17 +0200
-Subject: [PATCH] qemu: Pass migratable host CPU model to virCPUUpdate
-
-We already know from QEMU which CPU features will block migration. Let's
-use this information to make a migratable copy of the host CPU model and
-use it for updating guest CPU specification. This will allow us to drop
-feature filtering from virCPUUpdate where it was just a hack.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 56bd7edcb5dc878beffb80d4e6a9cfb812378ded)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 57 +++++++++++++++++++++++++++++++++++++-------
- src/qemu/qemu_capabilities.h |  2 ++
- src/qemu/qemu_process.c      |  2 +-
- tests/cputest.c              |  7 +++++-
- 4 files changed, 57 insertions(+), 11 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index e84de9f5b..ec773971e 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -385,6 +385,8 @@ struct _virQEMUCapsHostCPUData {
-     qemuMonitorCPUModelInfoPtr info;
-     /* Host CPU definition reported in domain capabilities. */
-     virCPUDefPtr reported;
-+    /* Migratable host CPU definition used for updating guest CPU. */
-+    virCPUDefPtr migratable;
- };
- 
- /*
-@@ -2106,6 +2108,10 @@ virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUDataPtr dst,
-         !(dst->reported = virCPUDefCopy(src->reported)))
-         return -1;
- 
-+    if (src->migratable &&
-+        !(dst->migratable = virCPUDefCopy(src->migratable)))
-+        return -1;
-+
-     return 0;
- }
- 
-@@ -2115,6 +2121,7 @@ virQEMUCapsHostCPUDataClear(virQEMUCapsHostCPUDataPtr cpuData)
- {
-     qemuMonitorCPUModelInfoFree(cpuData->info);
-     virCPUDefFree(cpuData->reported);
-+    virCPUDefFree(cpuData->migratable);
- 
-     memset(cpuData, 0, sizeof(*cpuData));
- }
-@@ -2453,6 +2460,9 @@ virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
-     switch (cpuType) {
-     case VIR_QEMU_CAPS_HOST_CPU_REPORTED:
-         return cpuData->reported;
-+
-+    case VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE:
-+        return cpuData->migratable;
-     }
- 
-     return NULL;
-@@ -2462,11 +2472,13 @@ virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
- static void
- virQEMUCapsSetHostModel(virQEMUCapsPtr qemuCaps,
-                         virDomainVirtType type,
--                        virCPUDefPtr cpu)
-+                        virCPUDefPtr reported,
-+                        virCPUDefPtr migratable)
- {
-     virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
- 
--    cpuData->reported = cpu;
-+    cpuData->reported = reported;
-+    cpuData->migratable = migratable;
- }
- 
- 
-@@ -3313,26 +3325,39 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
- }
- 
- 
-+static virCPUDefPtr
-+virQEMUCapsNewHostCPUModel(void)
-+{
-+    virCPUDefPtr cpu;
-+
-+    if (VIR_ALLOC(cpu) < 0)
-+        return NULL;
-+
-+    cpu->type = VIR_CPU_TYPE_GUEST;
-+    cpu->mode = VIR_CPU_MODE_CUSTOM;
-+    cpu->match = VIR_CPU_MATCH_EXACT;
-+    cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
-+
-+    return cpu;
-+}
-+
-+
- void
- virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-                             virCapsPtr caps,
-                             virDomainVirtType type)
- {
-     virCPUDefPtr cpu = NULL;
-+    virCPUDefPtr migCPU = NULL;
-     virCPUDefPtr hostCPU = NULL;
-     int rc;
- 
-     if (!caps || !virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch))
-         return;
- 
--    if (VIR_ALLOC(cpu) < 0)
-+    if (!(cpu = virQEMUCapsNewHostCPUModel()))
-         goto error;
- 
--    cpu->type = VIR_CPU_TYPE_GUEST;
--    cpu->mode = VIR_CPU_MODE_CUSTOM;
--    cpu->match = VIR_CPU_MATCH_EXACT;
--    cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
--
-     if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) {
-         goto error;
-     } else if (rc == 1) {
-@@ -3346,7 +3371,20 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-             goto error;
-     }
- 
--    virQEMUCapsSetHostModel(qemuCaps, type, cpu);
-+    if (!(migCPU = virQEMUCapsNewHostCPUModel()))
-+        goto error;
-+
-+    if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, migCPU, true)) < 0) {
-+        goto error;
-+    } else if (rc == 1) {
-+        VIR_DEBUG("CPU migratability not provided by QEMU");
-+
-+        virCPUDefFree(migCPU);
-+        if (!(migCPU = virCPUCopyMigratable(qemuCaps->arch, cpu)))
-+            goto error;
-+    }
-+
-+    virQEMUCapsSetHostModel(qemuCaps, type, cpu, migCPU);
- 
-  cleanup:
-     virCPUDefFree(hostCPU);
-@@ -3354,6 +3392,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
- 
-  error:
-     virCPUDefFree(cpu);
-+    virCPUDefFree(migCPU);
-     virResetLastError();
-     goto cleanup;
- }
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index 50333fc26..16fe044cc 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -454,6 +454,8 @@ int virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
- typedef enum {
-     /* Host CPU definition reported in domain capabilities. */
-     VIR_QEMU_CAPS_HOST_CPU_REPORTED,
-+    /* Migratable host CPU definition used for updating guest CPU. */
-+    VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE,
- } virQEMUCapsHostCPUType;
- 
- virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index dc073891a..c81389ef2 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -5313,7 +5313,7 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def,
- 
-     if (virCPUUpdate(def->os.arch, def->cpu,
-                      virQEMUCapsGetHostModel(qemuCaps, def->virtType,
--                                             VIR_QEMU_CAPS_HOST_CPU_REPORTED)) < 0)
-+                                             VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE)) < 0)
-         goto cleanup;
- 
-     if (virQEMUCapsGetCPUDefinitions(qemuCaps, def->virtType,
-diff --git a/tests/cputest.c b/tests/cputest.c
-index 8c07cf4f6..efa891dc1 100644
---- a/tests/cputest.c
-+++ b/tests/cputest.c
-@@ -393,6 +393,7 @@ cpuTestUpdate(const void *arg)
-     const struct data *data = arg;
-     int ret = -1;
-     virCPUDefPtr host = NULL;
-+    virCPUDefPtr migHost = NULL;
-     virCPUDefPtr cpu = NULL;
-     char *result = NULL;
- 
-@@ -400,7 +401,10 @@ cpuTestUpdate(const void *arg)
-         !(cpu = cpuTestLoadXML(data->arch, data->name)))
-         goto cleanup;
- 
--    if (virCPUUpdate(host->arch, cpu, host) < 0)
-+    if (!(migHost = virCPUCopyMigratable(data->arch, host)))
-+        goto cleanup;
-+
-+    if (virCPUUpdate(host->arch, cpu, migHost) < 0)
-         goto cleanup;
- 
-     if (virAsprintf(&result, "%s+%s", data->host, data->name) < 0)
-@@ -411,6 +415,7 @@ cpuTestUpdate(const void *arg)
-  cleanup:
-     virCPUDefFree(host);
-     virCPUDefFree(cpu);
-+    virCPUDefFree(migHost);
-     VIR_FREE(result);
-     return ret;
- }
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Pass-the-number-of-heads-even-with-vga-qxl.patch b/SOURCES/libvirt-qemu-Pass-the-number-of-heads-even-with-vga-qxl.patch
deleted file mode 100644
index 1d7743f..0000000
--- a/SOURCES/libvirt-qemu-Pass-the-number-of-heads-even-with-vga-qxl.patch
+++ /dev/null
@@ -1,157 +0,0 @@
-From 7f85f27f9f14683fb784ffd9aecb545d7d39194d Mon Sep 17 00:00:00 2001
-Message-Id: <7f85f27f9f14683fb784ffd9aecb545d7d39194d@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Mon, 19 Jun 2017 15:40:17 +0200
-Subject: [PATCH] qemu: Pass the number of heads even with -vga qxl
-
-When added in multiple previous commits, it was used only with -device
-qxl(-vga), but for some QEMUs (< 1.6) we need to add this
-functionality when using -vga qxl as well.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1283207
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-(cherry picked from commit d23410449fc9f91ceeeacb19d915a6db2f17f3be)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_command.c                            |  7 ++++
- .../qemuxml2argv-video-vga-qxl-heads.args          | 30 ++++++++++++++
- .../qemuxml2argv-video-vga-qxl-heads.xml           | 47 ++++++++++++++++++++++
- tests/qemuxml2argvtest.c                           |  3 ++
- 4 files changed, 87 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml
-
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 88223babeb..a4184b7378 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -4585,6 +4585,7 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd,
-         unsigned int vram = video->vram;
-         unsigned int vram64 = video->vram64;
-         unsigned int vgamem = video->vgamem;
-+        unsigned int heads = video->heads;
- 
-         if (ram) {
-             virCommandAddArg(cmd, "-global");
-@@ -4608,6 +4609,12 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd,
-             virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
-                                    dev, vgamem / 1024);
-         }
-+        if (heads &&
-+            virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_MAX_OUTPUTS)) {
-+            virCommandAddArg(cmd, "-global");
-+            virCommandAddArgFormat(cmd, "%s.max_outputs=%u",
-+                                   dev, heads);
-+        }
-     }
- 
-     if (video->vram &&
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args
-new file mode 100644
-index 0000000000..411a2eedbc
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.args
-@@ -0,0 +1,30 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-i686 \
-+-name QEMUGuest1 \
-+-S \
-+-M pc \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-usb \
-+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-+-vga qxl \
-+-global qxl-vga.ram_size=67108864 \
-+-global qxl-vga.vram_size=67108864 \
-+-global qxl-vga.max_outputs=1 \
-+-device qxl,id=video1,ram_size=67108864,vram_size=33554432,max_outputs=3,\
-+bus=pci.0,addr=0x4 \
-+-device qxl,id=video2,ram_size=67108864,vram_size=67108864,max_outputs=7,\
-+bus=pci.0,addr=0x5 \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml
-new file mode 100644
-index 0000000000..d878ddcd6d
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-qxl-heads.xml
-@@ -0,0 +1,47 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='i686' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-i686</emulator>
-+    <disk type='block' device='disk'>
-+      <source dev='/dev/HostVG/QEMUGuest1'/>
-+      <target dev='hda' bus='ide'/>
-+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
-+    </disk>
-+    <controller type='usb' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
-+    </controller>
-+    <controller type='ide' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
-+    </controller>
-+    <controller type='pci' index='0' model='pci-root'/>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <video>
-+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='3'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
-+    </video>
-+    <video>
-+      <model type='qxl' ram='65536' vram='65536' vgamem='8192' heads='7'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
-+    </video>
-+    <video>
-+      <model type='qxl' ram='65536' vram='65536' vgamem='8192' heads='1' primary='yes'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
-+    </video>
-+    <memballoon model='virtio'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
-+    </memballoon>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 0745d3807a..5ca27f105d 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -1736,6 +1736,9 @@ mymain(void)
-             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
-             QEMU_CAPS_DEVICE_QXL,
-             QEMU_CAPS_QXL_MAX_OUTPUTS);
-+    DO_TEST("video-vga-qxl-heads",
-+            QEMU_CAPS_DEVICE_QXL,
-+            QEMU_CAPS_QXL_MAX_OUTPUTS);
-     DO_TEST("video-qxl-noheads",
-             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
-             QEMU_CAPS_DEVICE_QXL,
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Pass-virArch-to-virQEMUCapsCPUFilterFeatures.patch b/SOURCES/libvirt-qemu-Pass-virArch-to-virQEMUCapsCPUFilterFeatures.patch
deleted file mode 100644
index 9677c31..0000000
--- a/SOURCES/libvirt-qemu-Pass-virArch-to-virQEMUCapsCPUFilterFeatures.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From cd16dea68be92cb8675d0fdd329be2cceb49b580 Mon Sep 17 00:00:00 2001
-Message-Id: <cd16dea68be92cb8675d0fdd329be2cceb49b580@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 13 Sep 2017 17:26:07 +0200
-Subject: [PATCH] qemu: Pass virArch * to virQEMUCapsCPUFilterFeatures
-
-The filter only needs to know the CPU architecture. Passing
-virQEMUCapsPtr as opaque is a bit overkill.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit b0b5c9c620bbd6ca806ba39a67516a2d48854132)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1508549
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 6f8b1ac735..3be56462d9 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -3239,9 +3239,9 @@ static bool
- virQEMUCapsCPUFilterFeatures(const char *name,
-                              void *opaque)
- {
--    virQEMUCapsPtr qemuCaps = opaque;
-+    virArch *arch = opaque;
- 
--    if (!ARCH_IS_X86(qemuCaps->arch))
-+    if (!ARCH_IS_X86(*arch))
-         return true;
- 
-     if (STREQ(name, "cmt") ||
-@@ -3453,7 +3453,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-         if (!hostCPU ||
-             virCPUDefCopyModelFilter(cpu, hostCPU, true,
-                                      virQEMUCapsCPUFilterFeatures,
--                                     qemuCaps) < 0)
-+                                     &qemuCaps->arch) < 0)
-             goto error;
-     } else if (type == VIR_DOMAIN_VIRT_KVM &&
-                virCPUGetHostIsSupported(qemuCaps->arch)) {
--- 
-2.15.0
-
diff --git a/SOURCES/libvirt-qemu-Prefer-hugepages-over-mem-source-file.patch b/SOURCES/libvirt-qemu-Prefer-hugepages-over-mem-source-file.patch
deleted file mode 100644
index 7b40e58..0000000
--- a/SOURCES/libvirt-qemu-Prefer-hugepages-over-mem-source-file.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-From 766ccea976922a5da2f76e26fc37e03ac14ecacd Mon Sep 17 00:00:00 2001
-Message-Id: <766ccea976922a5da2f76e26fc37e03ac14ecacd@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Wed, 14 Jun 2017 16:58:12 +0200
-Subject: [PATCH] qemu: Prefer hugepages over mem source='file'
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1214369
-
-Consider the following XML:
-
-  <memoryBacking>
-    <hugepages>
-      <page size='2048' unit='KiB' nodeset='1'/>
-    </hugepages>
-    <source type='file'/>
-    <access mode='shared'/>
-  </memoryBacking>
-
-  <numa>
-    <cell id='0' cpus='0-3' memory='512000' unit='KiB'/>
-    <cell id='1' cpus='4-7' memory='512000' unit='KiB'/>
-  </numa>
-
-The following cmd line is generated:
-
-  -object
-  memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,
-  share=yes,size=524288000 -numa node,nodeid=0,cpus=0-3,memdev=ram-node0
-  -object
-  memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,
-  share=yes,size=524288000 -numa node,nodeid=1,cpus=4-7,memdev=ram-node1
-
-This is obviously wrong as for node 1 hugepages should have been
-used. The hugepages configuration is more specific than <source
-type='file'/>.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-(cherry picked from commit 992bf863fccfe1fa1d0c5a5277b9cee50abc48ef)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_command.c                            |  6 +--
- .../qemuxml2argv-hugepages-memaccess2.args         | 39 ++++++++++++++
- .../qemuxml2argv-hugepages-memaccess2.xml          | 62 ++++++++++++++++++++++
- tests/qemuxml2argvtest.c                           |  3 ++
- .../qemuxml2xmlout-hugepages-memaccess2.xml        |  1 +
- tests/qemuxml2xmltest.c                            |  1 +
- 6 files changed, 109 insertions(+), 3 deletions(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml
- create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml
-
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index c791214528..5013d3149d 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -3413,9 +3413,9 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
-             if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0)
-                 goto cleanup;
-             prealloc = true;
--        } else if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
--            /* We can have both pagesize and mem source,
--             * then check mem source first. */
-+        } else if (!pagesize && def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
-+            /* We can have both pagesize and mem source. If that's the case,
-+             * prefer hugepages as those are more specific. */
-             if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0)
-                 goto cleanup;
-         } else {
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args
-new file mode 100644
-index 0000000000..11985232a7
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args
-@@ -0,0 +1,39 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-i686 \
-+-name QEMUGuest1 \
-+-S \
-+-M pc \
-+-m size=4194304k,slots=16,maxmem=8388608k \
-+-smp 4,sockets=4,cores=1,threads=1 \
-+-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
-+share=no,size=1073741824,host-nodes=0-3,policy=bind \
-+-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
-+-object memory-backend-file,id=ram-node1,prealloc=yes,\
-+mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=1073741824,\
-+host-nodes=0-3,policy=bind \
-+-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
-+-object memory-backend-file,id=ram-node2,mem-path=/var/lib/libvirt/qemu/ram,\
-+share=no,size=1073741824,host-nodes=0-3,policy=bind \
-+-numa node,nodeid=2,cpus=2,memdev=ram-node2 \
-+-object memory-backend-file,id=ram-node3,mem-path=/var/lib/libvirt/qemu/ram,\
-+share=no,size=1073741824,host-nodes=3,policy=bind \
-+-numa node,nodeid=3,cpus=3,memdev=ram-node3 \
-+-object memory-backend-file,id=memdimm0,prealloc=yes,\
-+mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=536870912,\
-+host-nodes=0-3,policy=bind \
-+-device pc-dimm,node=1,memdev=memdimm0,id=dimm0,slot=0,addr=4294967296 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-usb \
-+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml
-new file mode 100644
-index 0000000000..c0011285c2
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml
-@@ -0,0 +1,62 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <maxMemory slots='16' unit='KiB'>8388608</maxMemory>
-+  <memory unit='KiB'>4194304</memory>
-+  <currentMemory unit='KiB'>4194304</currentMemory>
-+  <memoryBacking>
-+    <hugepages>
-+      <page size='2048' unit='KiB' nodeset='1'/>
-+    </hugepages>
-+    <source type='file'/>
-+    <access mode='private'/>
-+  </memoryBacking>
-+  <vcpu placement='static'>4</vcpu>
-+  <numatune>
-+    <memory mode='strict' nodeset='0-3'/>
-+    <memnode cellid='3' mode='strict' nodeset='3'/>
-+  </numatune>
-+  <os>
-+    <type arch='i686' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <cpu>
-+    <numa>
-+      <cell id='0' cpus='0' memory='1048576' unit='KiB'/>
-+      <cell id='1' cpus='1' memory='1048576' unit='KiB' memAccess='shared'/>
-+      <cell id='2' cpus='2' memory='1048576' unit='KiB' memAccess='private'/>
-+      <cell id='3' cpus='3' memory='1048576' unit='KiB'/>
-+    </numa>
-+  </cpu>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-i686</emulator>
-+    <disk type='block' device='disk'>
-+      <source dev='/dev/HostVG/QEMUGuest1'/>
-+      <target dev='hda' bus='ide'/>
-+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
-+    </disk>
-+    <controller type='usb' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
-+    </controller>
-+    <controller type='ide' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
-+    </controller>
-+    <controller type='pci' index='0' model='pci-root'/>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <memballoon model='virtio'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
-+    </memballoon>
-+    <memory model='dimm'>
-+      <target>
-+        <size unit='KiB'>524288</size>
-+        <node>1</node>
-+      </target>
-+      <address type='dimm' slot='0' base='0x100000000'/>
-+    </memory>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 77e52bd33b..98e70033ec 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -830,6 +830,9 @@ mymain(void)
-     DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE,
-             QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
-             QEMU_CAPS_NUMA);
-+    DO_TEST("hugepages-memaccess2", QEMU_CAPS_OBJECT_MEMORY_FILE,
-+            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
-+            QEMU_CAPS_NUMA);
-     DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
-     DO_TEST("disk-cdrom", NONE);
-     DO_TEST("disk-iscsi", NONE);
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml
-new file mode 120000
-index 0000000000..3f7a38333f
---- /dev/null
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml
-@@ -0,0 +1 @@
-+../qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml
-\ No newline at end of file
-diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
-index 511d1b3fb9..f2abad00cf 100644
---- a/tests/qemuxml2xmltest.c
-+++ b/tests/qemuxml2xmltest.c
-@@ -421,6 +421,7 @@ mymain(void)
-     DO_TEST("hugepages-pages3", NONE);
-     DO_TEST("hugepages-shared", NONE);
-     DO_TEST("hugepages-memaccess", NONE);
-+    DO_TEST("hugepages-memaccess2", NONE);
-     DO_TEST("nosharepages", NONE);
-     DO_TEST("restore-v2", NONE);
-     DO_TEST("migrate", NONE);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Prepare-qemuCaps-for-multiple-host-CPU-defs.patch b/SOURCES/libvirt-qemu-Prepare-qemuCaps-for-multiple-host-CPU-defs.patch
deleted file mode 100644
index 440dc48..0000000
--- a/SOURCES/libvirt-qemu-Prepare-qemuCaps-for-multiple-host-CPU-defs.patch
+++ /dev/null
@@ -1,128 +0,0 @@
-From aadb80300ceec4ccded4a31992af12abde3860b5 Mon Sep 17 00:00:00 2001
-Message-Id: <aadb80300ceec4ccded4a31992af12abde3860b5@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 11 Apr 2017 11:14:30 +0200
-Subject: [PATCH] qemu: Prepare qemuCaps for multiple host CPU defs
-
-Soon we will need to store multiple host CPU definitions in
-virQEMUCapsHostCPUData and qemuCaps users will want to request the one
-they need. This patch introduces virQEMUCapsHostCPUType enum which will
-be used for specifying the requested CPU definition.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 1fe517c68df92eb7f379fa87cb0d29d566aad6f4)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 16 ++++++++++++----
- src/qemu/qemu_capabilities.h | 10 +++++++++-
- src/qemu/qemu_command.c      |  3 ++-
- src/qemu/qemu_process.c      |  6 ++++--
- 4 files changed, 27 insertions(+), 8 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 0db149018..e84de9f5b 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -2445,11 +2445,17 @@ virQEMUCapsGetHostCPUData(virQEMUCapsPtr qemuCaps,
- 
- virCPUDefPtr
- virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
--                        virDomainVirtType type)
-+                        virDomainVirtType type,
-+                        virQEMUCapsHostCPUType cpuType)
- {
-     virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
- 
--    return cpuData->reported;
-+    switch (cpuType) {
-+    case VIR_QEMU_CAPS_HOST_CPU_REPORTED:
-+        return cpuData->reported;
-+    }
-+
-+    return NULL;
- }
- 
- 
-@@ -2478,7 +2484,8 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
-                virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch);
- 
-     case VIR_CPU_MODE_HOST_MODEL:
--        return !!virQEMUCapsGetHostModel(qemuCaps, type);
-+        return !!virQEMUCapsGetHostModel(qemuCaps, type,
-+                                         VIR_QEMU_CAPS_HOST_CPU_REPORTED);
- 
-     case VIR_CPU_MODE_CUSTOM:
-         if (type == VIR_DOMAIN_VIRT_KVM)
-@@ -5499,7 +5506,8 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
- 
-     if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
-                                       VIR_CPU_MODE_HOST_MODEL)) {
--        virCPUDefPtr cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype);
-+        virCPUDefPtr cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype,
-+                                                   VIR_QEMU_CAPS_HOST_CPU_REPORTED);
-         domCaps->cpu.hostModel = virCPUDefCopy(cpu);
-     }
- 
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index c466a63e7..50333fc26 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -450,8 +450,16 @@ int virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
-                                  virDomainVirtType type,
-                                  char ***names,
-                                  size_t *count);
-+
-+typedef enum {
-+    /* Host CPU definition reported in domain capabilities. */
-+    VIR_QEMU_CAPS_HOST_CPU_REPORTED,
-+} virQEMUCapsHostCPUType;
-+
- virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
--                                     virDomainVirtType type);
-+                                     virDomainVirtType type,
-+                                     virQEMUCapsHostCPUType cpuType);
-+
- bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
-                                    virCapsPtr caps,
-                                    virDomainVirtType type,
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 2105cde58..9ce90c25b 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -6908,7 +6908,8 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
-             if (def->cpu->mode == VIR_CPU_MODE_CUSTOM)
-                 cpuDef = def->cpu;
-             else if (def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH)
--                cpuDef = virQEMUCapsGetHostModel(qemuCaps, def->virtType);
-+                cpuDef = virQEMUCapsGetHostModel(qemuCaps, def->virtType,
-+                                                 VIR_QEMU_CAPS_HOST_CPU_REPORTED);
- 
-             if (cpuDef) {
-                 int svm = virCPUCheckFeature(def->os.arch, cpuDef, "svm");
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index afd9dfb71..dc073891a 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -5306,12 +5306,14 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def,
- 
-     if (def->cpu->check == VIR_CPU_CHECK_PARTIAL &&
-         virCPUCompare(caps->host.arch,
--                      virQEMUCapsGetHostModel(qemuCaps, def->virtType),
-+                      virQEMUCapsGetHostModel(qemuCaps, def->virtType,
-+                                              VIR_QEMU_CAPS_HOST_CPU_REPORTED),
-                       def->cpu, true) < 0)
-         return -1;
- 
-     if (virCPUUpdate(def->os.arch, def->cpu,
--                     virQEMUCapsGetHostModel(qemuCaps, def->virtType)) < 0)
-+                     virQEMUCapsGetHostModel(qemuCaps, def->virtType,
-+                                             VIR_QEMU_CAPS_HOST_CPU_REPORTED)) < 0)
-         goto cleanup;
- 
-     if (virQEMUCapsGetCPUDefinitions(qemuCaps, def->virtType,
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Properly-check-return-value-of-VIR_STRDUP-in-qemuDomainGetBlockIoTune.patch b/SOURCES/libvirt-qemu-Properly-check-return-value-of-VIR_STRDUP-in-qemuDomainGetBlockIoTune.patch
deleted file mode 100644
index 3abf695..0000000
--- a/SOURCES/libvirt-qemu-Properly-check-return-value-of-VIR_STRDUP-in-qemuDomainGetBlockIoTune.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From f3e5eee71c29741d6d0230561fc1ceb26019629a Mon Sep 17 00:00:00 2001
-Message-Id: <f3e5eee71c29741d6d0230561fc1ceb26019629a@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Wed, 24 May 2017 12:48:06 +0200
-Subject: [PATCH] qemu: Properly check return value of VIR_STRDUP in
- qemuDomainGetBlockIoTune
-
-Setting the 'group_name' for a disk would falsely trigger a error path
-as in commit 4b57f76502 we did not properly check the return value of
-VIR_STRDUP.
-
-(cherry picked from commit 3fe624b2689d825a47e86ae3fb9735313e9105c3)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1433183
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index a0f641fd4..3241de4cb 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -17750,7 +17750,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
- 
-         /* Group name needs to be copied since qemuMonitorGetBlockIoThrottle
-          * allocates it as well */
--        if (VIR_STRDUP(reply.group_name, disk->blkdeviotune.group_name))
-+        if (VIR_STRDUP(reply.group_name, disk->blkdeviotune.group_name) < 0)
-             goto endjob;
-     }
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-Properly-label-and-create-evdev-on-input-device-hotplug.patch b/SOURCES/libvirt-qemu-Properly-label-and-create-evdev-on-input-device-hotplug.patch
new file mode 100644
index 0000000..2451c13
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Properly-label-and-create-evdev-on-input-device-hotplug.patch
@@ -0,0 +1,103 @@
+From 1cc1a4e1c069571d0db11848a5949da143c76166 Mon Sep 17 00:00:00 2001
+Message-Id: <1cc1a4e1c069571d0db11848a5949da143c76166@dist-git>
+From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
+Date: Mon, 27 Nov 2017 14:21:02 +0100
+Subject: [PATCH] qemu: Properly label and create evdev on input device hotplug
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Utilize all the newly introduced function to create the evdev node
+and label it on hotplug and destroy it on hotunplug.
+
+This was forgotten in commits bc9ffaf and 67486bb.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1509866
+(cherry picked from commit 2814f66f281064477815065bf3ddc5f5cec82062)
+Signed-off-by: Ján Tomko <jtomko@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_hotplug.c | 40 +++++++++++++++++++++++++++++++++++++---
+ 1 file changed, 37 insertions(+), 3 deletions(-)
+
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index edf07d0b65..56e8a93885 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -2746,7 +2746,11 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
+     qemuDomainObjPrivatePtr priv = vm->privateData;
+     virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_INPUT,
+                                { .input = input } };
++    virErrorPtr originalError = NULL;
+     bool releaseaddr = false;
++    bool teardowndevice = false;
++    bool teardownlabel = false;
++    bool teardowncgroup = false;
+ 
+     if (input->bus != VIR_DOMAIN_INPUT_BUS_USB &&
+         input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO) {
+@@ -2773,6 +2777,18 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
+     if (qemuBuildInputDevStr(&devstr, vm->def, input, priv->qemuCaps) < 0)
+         goto cleanup;
+ 
++    if (qemuDomainNamespaceSetupInput(vm, input) < 0)
++        goto cleanup;
++    teardowndevice = true;
++
++    if (qemuSetupInputCgroup(vm, input) < 0)
++        goto cleanup;
++    teardowncgroup = true;
++
++    if (qemuSecuritySetInputLabel(vm, input) < 0)
++        goto cleanup;
++    teardownlabel = true;
++
+     if (VIR_REALLOC_N(vm->def->inputs, vm->def->ninputs + 1) < 0)
+         goto cleanup;
+ 
+@@ -2788,14 +2804,23 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
+     VIR_APPEND_ELEMENT_COPY_INPLACE(vm->def->inputs, vm->def->ninputs, input);
+ 
+     ret = 0;
+-    releaseaddr = false;
+ 
+  audit:
+     virDomainAuditInput(vm, input, "attach", ret == 0);
+ 
+  cleanup:
+-    if (releaseaddr)
+-        qemuDomainReleaseDeviceAddress(vm, &input->info, NULL);
++    if (ret < 0) {
++        virErrorPreserveLast(&originalError);
++        if (teardownlabel)
++            qemuSecurityRestoreInputLabel(vm, input);
++        if (teardowncgroup)
++            qemuTeardownInputCgroup(vm, input);
++        if (teardowndevice)
++            qemuDomainNamespaceTeardownInput(vm, input);
++        if (releaseaddr)
++            qemuDomainReleaseDeviceAddress(vm, &input->info, NULL);
++        virErrorRestore(&originalError);
++    }
+ 
+     VIR_FREE(devstr);
+     return ret;
+@@ -4283,6 +4308,15 @@ qemuDomainRemoveInputDevice(virDomainObjPtr vm,
+             break;
+     }
+     qemuDomainReleaseDeviceAddress(vm, &dev->info, NULL);
++    if (qemuSecurityRestoreInputLabel(vm, dev) < 0)
++        VIR_WARN("Unable to restore security label on input device");
++
++    if (qemuTeardownInputCgroup(vm, dev) < 0)
++        VIR_WARN("Unable to remove input device cgroup ACL");
++
++    if (qemuDomainNamespaceTeardownInput(vm, dev) < 0)
++        VIR_WARN("Unable to remove input device from /dev");
++
+     virDomainInputDefFree(vm->def->inputs[i]);
+     VIR_DELETE_ELEMENT(vm->def->inputs, i, vm->def->ninputs);
+     return 0;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Properly-reset-TLS-in-qemuProcessRecoverMigrationIn.patch b/SOURCES/libvirt-qemu-Properly-reset-TLS-in-qemuProcessRecoverMigrationIn.patch
deleted file mode 100644
index 733b6d3..0000000
--- a/SOURCES/libvirt-qemu-Properly-reset-TLS-in-qemuProcessRecoverMigrationIn.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 93313904b77e40a1ebb7b0cf6fdcadf34d6cb175 Mon Sep 17 00:00:00 2001
-Message-Id: <93313904b77e40a1ebb7b0cf6fdcadf34d6cb175@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 4 Apr 2017 19:43:13 +0200
-Subject: [PATCH] qemu: Properly reset TLS in qemuProcessRecoverMigrationIn
-
-There is no async job running when a freshly started libvirtd is trying
-to recover from an interrupted incoming migration. While at it, let's
-call qemuMigrationResetTLS every time we don't kill the domain. This is
-not strictly necessary since TLS is not supported when v2 migration
-protocol is used, but doing so makes more sense.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 59b28ecab845adb6fefe3280675f95d1f2135e3b)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1425003
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 4 +---
- 1 file changed, 1 insertion(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 039b3911c..0b9b4f76a 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -2973,9 +2973,6 @@ qemuProcessRecoverMigrationIn(virQEMUDriverPtr driver,
-         /* migration finished, we started resuming the domain but didn't
-          * confirm success or failure yet; killing it seems safest unless
-          * we already started guest CPUs or we were in post-copy mode */
--        ignore_value(qemuMigrationResetTLS(driver, vm,
--                                           QEMU_ASYNC_JOB_MIGRATION_IN,
--                                           NULL, NULL));
-         if (postcopy) {
-             qemuMigrationPostcopyFailed(driver, vm);
-         } else if (state != VIR_DOMAIN_RUNNING) {
-@@ -2985,6 +2982,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriverPtr driver,
-         break;
-     }
- 
-+    qemuMigrationResetTLS(driver, vm, QEMU_ASYNC_JOB_NONE, NULL, NULL);
-     return 0;
- }
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Properly-reset-all-migration-capabilities.patch b/SOURCES/libvirt-qemu-Properly-reset-all-migration-capabilities.patch
deleted file mode 100644
index 8d79780..0000000
--- a/SOURCES/libvirt-qemu-Properly-reset-all-migration-capabilities.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From 0ab58cdf99dbb5f71e91ebd047a984d48c9f9e6e Mon Sep 17 00:00:00 2001
-Message-Id: <0ab58cdf99dbb5f71e91ebd047a984d48c9f9e6e@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 5 Apr 2017 13:05:25 +0200
-Subject: [PATCH] qemu: Properly reset all migration capabilities
-
-So far only QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY was reset, but only in
-a single code path leaving post-copy enabled in quite a few cases.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1425003
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 8be3ccd047e17c4998c669da2a63c3956e1f5225)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 10 +++++++---
- 1 file changed, 7 insertions(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 3e9c35e4c..ae0ab368d 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -5342,9 +5342,6 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
-          */
-         if (inPostCopy)
-             VIR_FREE(priv->job.completed);
--
--        qemuMigrationSetPostCopy(driver, vm, false,
--                                 QEMU_ASYNC_JOB_MIGRATION_IN);
-     }
- 
-     qemuMigrationReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN);
-@@ -5873,9 +5870,16 @@ qemuMigrationReset(virQEMUDriverPtr driver,
-                    virDomainObjPtr vm,
-                    qemuDomainAsyncJob job)
- {
-+    qemuMonitorMigrationCaps cap;
-+
-     if (!virDomainObjIsActive(vm))
-         return;
- 
-     if (qemuMigrationResetTLS(driver, vm, job) < 0)
-         return;
-+
-+    for (cap = 0; cap < QEMU_MONITOR_MIGRATION_CAPS_LAST; cap++) {
-+        if (qemuMigrationSetOption(driver, vm, cap, false, job) < 0)
-+            return;
-+    }
- }
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Properly-reset-non-p2p-migration.patch b/SOURCES/libvirt-qemu-Properly-reset-non-p2p-migration.patch
deleted file mode 100644
index 36e6859..0000000
--- a/SOURCES/libvirt-qemu-Properly-reset-non-p2p-migration.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 81d8546556f74d0052cbe2a2c3287bc9d796bf32 Mon Sep 17 00:00:00 2001
-Message-Id: <81d8546556f74d0052cbe2a2c3287bc9d796bf32@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Thu, 27 Apr 2017 14:08:40 +0200
-Subject: [PATCH] qemu: Properly reset non-p2p migration
-
-While peer-to-peer migration enters the Confirm phase even if the
-Perform phase fails, the client which initiated a non-p2p migration will
-never call virDomainMigrateConfirm* API if the Perform phase failed.
-Thus we need to explicitly reset migration before reporting a failure
-from the Perform phase API.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1425003
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit eeb2feb9fbb66ea9026edc6451018fb3b94ffa58)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 7 +++++--
- 1 file changed, 5 insertions(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 8c6d1385e..8cbad894c 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -4902,10 +4902,13 @@ qemuMigrationPerformPhase(virQEMUDriverPtr driver,
-         goto endjob;
- 
-  endjob:
--    if (ret < 0)
-+    if (ret < 0) {
-+        qemuMigrationReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT);
-         qemuMigrationJobFinish(driver, vm);
--    else
-+    } else {
-         qemuMigrationJobContinue(vm);
-+    }
-+
-     if (!virDomainObjIsActive(vm))
-         qemuDomainRemoveInactive(driver, vm);
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Properly-skip-char-device-redirected-to-in-QEMU-log.patch b/SOURCES/libvirt-qemu-Properly-skip-char-device-redirected-to-in-QEMU-log.patch
new file mode 100644
index 0000000..42994d9
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Properly-skip-char-device-redirected-to-in-QEMU-log.patch
@@ -0,0 +1,39 @@
+From 5071540b203f4e368506d4596b16484a8726d534 Mon Sep 17 00:00:00 2001
+Message-Id: <5071540b203f4e368506d4596b16484a8726d534@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Wed, 22 Nov 2017 10:19:12 +0100
+Subject: [PATCH] qemu: Properly skip "char device redirected to" in QEMU log
+
+When reading QEMU log for reporting it as an error message, we want to
+skip "char device redirected to" line. However, this string is not
+printed at the beginning of a line, which means STRPREFIX will never
+find it.
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 7e0cd26db475ed72257bd99be606ac8f2095231a)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1335534
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+---
+ src/qemu/qemu_process.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index 86a4dee88e..c5fa8cb4b2 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -1847,7 +1847,7 @@ qemuProcessReadLog(qemuDomainLogContextPtr logCtxt, char **msg)
+     while ((eol = strchr(filter_next, '\n'))) {
+         *eol = '\0';
+         if (virLogProbablyLogMessage(filter_next) ||
+-            STRPREFIX(filter_next, "char device redirected to")) {
++            strstr(filter_next, "char device redirected to")) {
+             size_t skip = (eol + 1) - filter_next;
+             memmove(filter_next, eol + 1, buf + got - eol);
+             got -= skip;
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Properly-store-microcode-version-in-QEMU-caps-cache.patch b/SOURCES/libvirt-qemu-Properly-store-microcode-version-in-QEMU-caps-cache.patch
deleted file mode 100644
index 3ff4a58..0000000
--- a/SOURCES/libvirt-qemu-Properly-store-microcode-version-in-QEMU-caps-cache.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From e3e7aa7c8ad6d687b9605b0da3b46ad0ef171157 Mon Sep 17 00:00:00 2001
-Message-Id: <e3e7aa7c8ad6d687b9605b0da3b46ad0ef171157@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 19 Dec 2017 08:36:49 +0100
-Subject: [PATCH] qemu: Properly store microcode version in QEMU caps cache
-
-This fixes a misplaced hunk in the backport of "qemu: capabilities:
-force update if the microcode version does not match". We need to make
-sure the microcode version is assigned to QEMU caps object before the
-caps get stored on a disk. Otherwise QEMU caps cached on a disk would
-always be considered invalid when libvirtd starts and tries to load
-them.
-
-CVE-2017-5715
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 504e2c9587..8f9b1493a5 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -5210,6 +5210,9 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
-             goto error;
-         }
- 
-+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
-+            qemuCaps->microcodeVersion = microcodeVersion;
-+
-         if (cacheDir &&
-             virQEMUCapsRememberCached(qemuCaps, cacheDir) < 0)
-             goto error;
-@@ -5218,9 +5221,6 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
-         virQEMUCapsInitHostCPUModel(qemuCaps, caps, VIR_DOMAIN_VIRT_QEMU);
-     }
- 
--    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
--        qemuCaps->microcodeVersion = microcodeVersion;
--
-  cleanup:
-     VIR_FREE(qmperr);
-     return qemuCaps;
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-Provide-a-much-clearer-message-on-device-hot-plug.patch b/SOURCES/libvirt-qemu-Provide-a-much-clearer-message-on-device-hot-plug.patch
deleted file mode 100644
index 1e4adc9..0000000
--- a/SOURCES/libvirt-qemu-Provide-a-much-clearer-message-on-device-hot-plug.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From ec386f59f68c4e66bb41f293f8c7f4e023cae9e0 Mon Sep 17 00:00:00 2001
-Message-Id: <ec386f59f68c4e66bb41f293f8c7f4e023cae9e0@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 11 May 2017 17:05:24 +0200
-Subject: [PATCH] qemu: Provide a much clearer message on device hot-plug
-
-Adjust the current message to make it clear, that it is the hotplug
-operation that is unsupported with the given host device type.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1450072
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit f4829df9aeb54d246ee9a816921a78e268ba7701)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_hotplug.c | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index 120bcdc62..6e5678f16 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -2694,7 +2694,7 @@ qemuDomainAttachHostDevice(virConnectPtr conn,
- {
-     if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
-         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("hostdev mode '%s' not supported"),
-+                       _("hotplug is not supported for hostdev mode '%s'"),
-                        virDomainHostdevModeTypeToString(hostdev->mode));
-         return -1;
-     }
-@@ -2725,7 +2725,7 @@ qemuDomainAttachHostDevice(virConnectPtr conn,
- 
-     default:
-         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("hostdev subsys type '%s' not supported"),
-+                       _("hotplug is not supported for hostdev subsys type '%s'"),
-                        virDomainHostdevSubsysTypeToString(hostdev->source.subsys.type));
-         goto error;
-     }
-@@ -4840,7 +4840,7 @@ qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver,
-         break;
-     default:
-         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("hostdev subsys type '%s' not supported"),
-+                       _("hot unplug is not supported for hostdev subsys type '%s'"),
-                        virDomainHostdevSubsysTypeToString(detach->source.subsys.type));
-         return -1;
-     }
-@@ -4872,7 +4872,7 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
- 
-     if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
-         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                       _("hostdev mode '%s' not supported"),
-+                       _("hot unplug is not supported for hostdev mode '%s'"),
-                        virDomainHostdevModeTypeToString(hostdev->mode));
-         return -1;
-     }
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-Publish-virQEMUCapsCPUFilterFeatures.patch b/SOURCES/libvirt-qemu-Publish-virQEMUCapsCPUFilterFeatures.patch
deleted file mode 100644
index 6e59334..0000000
--- a/SOURCES/libvirt-qemu-Publish-virQEMUCapsCPUFilterFeatures.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From 382aa0e08d2b12220506ca5522c6035c755e8acf Mon Sep 17 00:00:00 2001
-Message-Id: <382aa0e08d2b12220506ca5522c6035c755e8acf@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 13 Sep 2017 17:28:13 +0200
-Subject: [PATCH] qemu: Publish virQEMUCapsCPUFilterFeatures
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 399f91694f6e3245c0f6c8f37968266749964f2d)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1508549
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 2 +-
- src/qemu/qemu_capabilities.h | 3 +++
- 2 files changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 3be56462d9..a42f8d9988 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -3235,7 +3235,7 @@ virQEMUCapsProbeQMPGICCapabilities(virQEMUCapsPtr qemuCaps,
- }
- 
- 
--static bool
-+bool
- virQEMUCapsCPUFilterFeatures(const char *name,
-                              void *opaque)
- {
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index 281fe7d483..bc4ad44496 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -573,4 +573,7 @@ int virQEMUCapsFillDomainCaps(virCapsPtr caps,
- bool virQEMUCapsGuestIsNative(virArch host,
-                               virArch guest);
- 
-+bool virQEMUCapsCPUFilterFeatures(const char *name,
-+                                  void *opaque);
-+
- #endif /* __QEMU_CAPABILITIES_H__*/
--- 
-2.15.0
-
diff --git a/SOURCES/libvirt-qemu-Refactor-qemuDomainSaveHeader.patch b/SOURCES/libvirt-qemu-Refactor-qemuDomainSaveHeader.patch
deleted file mode 100644
index f87f275..0000000
--- a/SOURCES/libvirt-qemu-Refactor-qemuDomainSaveHeader.patch
+++ /dev/null
@@ -1,180 +0,0 @@
-From 4a304d9114e1b2e2f69fdb0857501ad8db03d17b Mon Sep 17 00:00:00 2001
-Message-Id: <4a304d9114e1b2e2f69fdb0857501ad8db03d17b@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 6 Jun 2017 23:41:57 +0200
-Subject: [PATCH] qemu: Refactor qemuDomainSaveHeader
-
-The function is now called virQEMUSaveDataWrite and it is now doing
-everything it needs to save both the save image header and domain XML to
-a file. Be it a new file or an existing file in which a user wants to
-change the domain XML.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 33ae270bee012fc89d7b8bb23986ce837ee21b0e)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 98 ++++++++++++++++++++++++++++++--------------------
- 1 file changed, 60 insertions(+), 38 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index a0b607b419..1629f27470 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -2837,7 +2837,7 @@ virQEMUSaveDataFree(virQEMUSaveHeaderPtr header)
- 
- 
- static virQEMUSaveHeaderPtr
--virQEMUSaveDataNew(char *domXML,
-+virQEMUSaveDataNew(char *domXML ATTRIBUTE_UNUSED,
-                    bool running,
-                    int compressed)
- {
-@@ -2850,34 +2850,66 @@ virQEMUSaveDataNew(char *domXML,
-     header->version = QEMU_SAVE_VERSION;
-     header->was_running = running ? 1 : 0;
-     header->compressed = compressed;
--    header->data_len = strlen(domXML) + 1;
- 
-     return header;
- }
- 
- 
--/* return -errno on failure, or 0 on success */
-+/* virQEMUSaveDataWrite:
-+ *
-+ * Writes libvirt's header (including domain XML) into a saved image of a
-+ * running domain. If @header has data_len filled in (because it was previously
-+ * read from the file), the function will make sure the new data will fit
-+ * within data_len.
-+ *
-+ * Returns -1 on failure, or 0 on success.
-+ */
- static int
--qemuDomainSaveHeader(int fd, const char *path, const char *xml,
--                     virQEMUSaveHeaderPtr header)
-+virQEMUSaveDataWrite(virQEMUSaveHeaderPtr header,
-+                     const char *xml,
-+                     int fd,
-+                     const char *path)
- {
--    int ret = 0;
-+    size_t len;
-+    int ret = -1;
-+    size_t zerosLen = 0;
-+    char *zeros = NULL;
-+
-+    len = strlen(xml) + 1;
-+
-+    if (header->data_len > 0) {
-+        if (len > header->data_len) {
-+            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
-+                           _("new xml too large to fit in file"));
-+            goto cleanup;
-+        }
-+
-+        zerosLen = header->data_len - len;
-+        if (VIR_ALLOC_N(zeros, zerosLen) < 0)
-+            goto cleanup;
-+    } else {
-+        header->data_len = len;
-+    }
- 
-     if (safewrite(fd, header, sizeof(*header)) != sizeof(*header)) {
--        ret = -errno;
--        virReportError(VIR_ERR_OPERATION_FAILED,
--                       _("failed to write header to domain save file '%s'"),
--                       path);
--        goto endjob;
-+        virReportSystemError(errno,
-+                             _("failed to write header to domain save file '%s'"),
-+                             path);
-+        goto cleanup;
-     }
- 
--    if (safewrite(fd, xml, header->data_len) != header->data_len) {
--        ret = -errno;
--        virReportError(VIR_ERR_OPERATION_FAILED,
--                       _("failed to write xml to '%s'"), path);
--        goto endjob;
-+    if (safewrite(fd, xml, header->data_len) != header->data_len ||
-+        safewrite(fd, zeros, zerosLen) != zerosLen) {
-+        virReportSystemError(errno,
-+                             _("failed to write domain xml to '%s'"),
-+                             path);
-+        goto cleanup;
-     }
-- endjob:
-+
-+    ret = 0;
-+
-+ cleanup:
-+    VIR_FREE(zeros);
-     return ret;
- }
- 
-@@ -3132,8 +3164,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
-     if (!(wrapperFd = virFileWrapperFdNew(&fd, path, wrapperFlags)))
-         goto cleanup;
- 
--    /* Write header to file, followed by XML */
--    if (qemuDomainSaveHeader(fd, path, domXML, header) < 0)
-+    if (virQEMUSaveDataWrite(header, domXML, fd, path) < 0)
-         goto cleanup;
- 
-     /* Perform the migration */
-@@ -6620,7 +6651,6 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-     virDomainDefPtr newdef = NULL;
-     int fd = -1;
-     char *xml = NULL;
--    size_t len;
-     virQEMUSaveHeaderPtr header = NULL;
-     int state = -1;
- 
-@@ -6656,30 +6686,22 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
- 
-     VIR_FREE(xml);
- 
--    xml = qemuDomainDefFormatXML(driver, newdef,
--                                 VIR_DOMAIN_XML_INACTIVE |
--                                 VIR_DOMAIN_XML_SECURE |
--                                 VIR_DOMAIN_XML_MIGRATABLE);
--    if (!xml)
--        goto cleanup;
--    len = strlen(xml) + 1;
--
--    if (len > header->data_len) {
--        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
--                       _("new xml too large to fit in file"));
--        goto cleanup;
--    }
--    if (VIR_EXPAND_N(xml, len, header->data_len - len) < 0)
-+    if (!(xml = qemuDomainDefFormatXML(driver, newdef,
-+                                       VIR_DOMAIN_XML_INACTIVE |
-+                                       VIR_DOMAIN_XML_SECURE |
-+                                       VIR_DOMAIN_XML_MIGRATABLE)))
-         goto cleanup;
- 
-     if (lseek(fd, 0, SEEK_SET) != 0) {
-         virReportSystemError(errno, _("cannot seek in '%s'"), path);
-         goto cleanup;
-     }
--    if (safewrite(fd, &header, sizeof(header)) != sizeof(header) ||
--        safewrite(fd, xml, len) != len ||
--        VIR_CLOSE(fd) < 0) {
--        virReportSystemError(errno, _("failed to write xml to '%s'"), path);
-+
-+    if (virQEMUSaveDataWrite(header, xml, fd, path) < 0)
-+        goto cleanup;
-+
-+    if (VIR_CLOSE(fd) < 0) {
-+        virReportSystemError(errno, _("failed to write header data to '%s'"), path);
-         goto cleanup;
-     }
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Refresh-capabilities-when-creating-resctrl-allocation.patch b/SOURCES/libvirt-qemu-Refresh-capabilities-when-creating-resctrl-allocation.patch
new file mode 100644
index 0000000..14ec72f
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Refresh-capabilities-when-creating-resctrl-allocation.patch
@@ -0,0 +1,46 @@
+From 606a93eac7434332c39c54015d1e774293e9605d Mon Sep 17 00:00:00 2001
+Message-Id: <606a93eac7434332c39c54015d1e774293e9605d@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Mon, 5 Feb 2018 13:39:20 +0100
+Subject: [PATCH] qemu: Refresh capabilities when creating resctrl allocation
+
+Since one of the things in capabilities (info from resctrl updated with data
+about caches) can be change on the system by remounting the /sys/fs/resctrl with
+different options, the capabilities need to be refreshed.  There is a better fix
+in the works, but it's going to be way bigger than this (hence the XXX note
+there), so for the time being let's workaround this.  And in order not to slow
+down the domain starting, only get the capabilities if there are any cachetunes.
+
+Relates-to: https://bugzilla.redhat.com/show_bug.cgi?id=1540780
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 3cac2a6c93c424d55b865a05635d96e0b1aa9d36)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/qemu/qemu_process.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index 3853112924..c86f7d3c5b 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -2511,9 +2511,15 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver,
+ {
+     int ret = -1;
+     size_t i = 0;
+-    virCapsPtr caps = virQEMUDriverGetCapabilities(driver, false);
++    virCapsPtr caps = NULL;
+     qemuDomainObjPrivatePtr priv = vm->privateData;
+ 
++    if (!vm->def->ncachetunes)
++        return 0;
++
++    /* Force capability refresh since resctrl info can change
++     * XXX: move cache info into virresctrl so caps are not needed */
++    caps = virQEMUDriverGetCapabilities(driver, true);
+     if (!caps)
+         return -1;
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-Refresh-caps-cache-after-booting-a-different-kernel.patch b/SOURCES/libvirt-qemu-Refresh-caps-cache-after-booting-a-different-kernel.patch
new file mode 100644
index 0000000..385e189
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Refresh-caps-cache-after-booting-a-different-kernel.patch
@@ -0,0 +1,212 @@
+From 098f56f335241d20ed220d8bb245a0dc9ab5fc39 Mon Sep 17 00:00:00 2001
+Message-Id: <098f56f335241d20ed220d8bb245a0dc9ab5fc39@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Mon, 22 Jan 2018 11:37:04 +0100
+Subject: [PATCH] qemu: Refresh caps cache after booting a different kernel
+
+Whenever a different kernel is booted, some capabilities related to KVM
+(such as CPUID bits) may change. We need to refresh the cache to see the
+changes.
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
+(cherry picked from commit 52b7d910b6b0ceeff50866774adba6efab55b2c0)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1525182
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c | 57 +++++++++++++++++++++++++++++++++++++-------
+ src/qemu/qemu_capspriv.h     |  1 +
+ tests/qemucapsprobe.c        |  2 +-
+ 3 files changed, 50 insertions(+), 10 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 09323d2580..af4875f82e 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -52,6 +52,7 @@
+ #include <unistd.h>
+ #include <sys/wait.h>
+ #include <stdarg.h>
++#include <sys/utsname.h>
+ 
+ #define VIR_FROM_THIS VIR_FROM_QEMU
+ 
+@@ -509,6 +510,7 @@ struct _virQEMUCaps {
+     unsigned int libvirtVersion;
+     unsigned int microcodeVersion;
+     char *package;
++    char *kernelVersion;
+ 
+     virArch arch;
+ 
+@@ -2302,6 +2304,9 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
+     if (VIR_STRDUP(ret->package, qemuCaps->package) < 0)
+         goto error;
+ 
++    if (VIR_STRDUP(ret->kernelVersion, qemuCaps->kernelVersion) < 0)
++        goto error;
++
+     ret->arch = qemuCaps->arch;
+ 
+     if (qemuCaps->kvmCPUModels) {
+@@ -2362,6 +2367,7 @@ void virQEMUCapsDispose(void *obj)
+     virBitmapFree(qemuCaps->flags);
+ 
+     VIR_FREE(qemuCaps->package);
++    VIR_FREE(qemuCaps->kernelVersion);
+     VIR_FREE(qemuCaps->binary);
+ 
+     VIR_FREE(qemuCaps->gicCapabilities);
+@@ -3822,6 +3828,7 @@ struct _virQEMUCapsCachePriv {
+     gid_t runGid;
+     virArch hostArch;
+     unsigned int microcodeVersion;
++    char *kernelVersion;
+ };
+ typedef struct _virQEMUCapsCachePriv virQEMUCapsCachePriv;
+ typedef virQEMUCapsCachePriv *virQEMUCapsCachePrivPtr;
+@@ -3833,6 +3840,7 @@ virQEMUCapsCachePrivFree(void *privData)
+     virQEMUCapsCachePrivPtr priv = privData;
+ 
+     VIR_FREE(priv->libDir);
++    VIR_FREE(priv->kernelVersion);
+     VIR_FREE(priv);
+ }
+ 
+@@ -3958,6 +3966,12 @@ virQEMUCapsLoadCache(virArch hostArch,
+             goto cleanup;
+     }
+ 
++    if (virXPathBoolean("boolean(./kernelVersion)", ctxt) > 0) {
++        qemuCaps->kernelVersion = virXPathString("string(./kernelVersion)", ctxt);
++        if (!qemuCaps->kernelVersion)
++            goto cleanup;
++    }
++
+     if (!(str = virXPathString("string(./arch)", ctxt))) {
+         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                        _("missing arch in QEMU capabilities cache"));
+@@ -4236,6 +4250,10 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
+         virBufferAsprintf(&buf, "<package>%s</package>\n",
+                           qemuCaps->package);
+ 
++    if (qemuCaps->kernelVersion)
++        virBufferAsprintf(&buf, "<kernelVersion>%s</kernelVersion>\n",
++                          qemuCaps->kernelVersion);
++
+     virBufferAsprintf(&buf, "<arch>%s</arch>\n",
+                       virArchToString(qemuCaps->arch));
+ 
+@@ -4373,14 +4391,24 @@ virQEMUCapsIsValid(void *data,
+         return false;
+     }
+ 
+-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
+-        priv->microcodeVersion != qemuCaps->microcodeVersion) {
+-        VIR_DEBUG("Outdated capabilities for '%s': microcode version changed "
+-                  "(%u vs %u)",
+-                  qemuCaps->binary,
+-                  priv->microcodeVersion,
+-                  qemuCaps->microcodeVersion);
+-        return false;
++    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
++        if (priv->microcodeVersion != qemuCaps->microcodeVersion) {
++            VIR_DEBUG("Outdated capabilities for '%s': microcode version "
++                      "changed (%u vs %u)",
++                      qemuCaps->binary,
++                      priv->microcodeVersion,
++                      qemuCaps->microcodeVersion);
++            return false;
++        }
++
++        if (STRNEQ_NULLABLE(priv->kernelVersion, qemuCaps->kernelVersion)) {
++            VIR_DEBUG("Outdated capabilities for '%s': kernel version changed "
++                      "('%s' vs '%s')",
++                      qemuCaps->binary,
++                      priv->kernelVersion,
++                      qemuCaps->kernelVersion);
++            return false;
++        }
+     }
+ 
+     return true;
+@@ -5213,6 +5241,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
+                                 uid_t runUid,
+                                 gid_t runGid,
+                                 unsigned int microcodeVersion,
++                                const char *kernelVersion,
+                                 bool qmpOnly)
+ {
+     virQEMUCapsPtr qemuCaps;
+@@ -5269,9 +5298,13 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
+     virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM);
+     virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU);
+ 
+-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
++    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
+         qemuCaps->microcodeVersion = microcodeVersion;
+ 
++        if (VIR_STRDUP(qemuCaps->kernelVersion, kernelVersion) < 0)
++            goto error;
++    }
++
+  cleanup:
+     VIR_FREE(qmperr);
+     return qemuCaps;
+@@ -5294,6 +5327,7 @@ virQEMUCapsNewData(const char *binary,
+                                            priv->runUid,
+                                            priv->runGid,
+                                            priv->microcodeVersion,
++                                           priv->kernelVersion,
+                                            false);
+ }
+ 
+@@ -5382,6 +5416,7 @@ virQEMUCapsCacheNew(const char *libDir,
+     char *capsCacheDir = NULL;
+     virFileCachePtr cache = NULL;
+     virQEMUCapsCachePrivPtr priv = NULL;
++    struct utsname uts = { 0 };
+ 
+     if (virAsprintf(&capsCacheDir, "%s/capabilities", cacheDir) < 0)
+         goto error;
+@@ -5402,6 +5437,10 @@ virQEMUCapsCacheNew(const char *libDir,
+     priv->runGid = runGid;
+     priv->microcodeVersion = microcodeVersion;
+ 
++    if (uname(&uts) == 0 &&
++        virAsprintf(&priv->kernelVersion, "%s %s", uts.release, uts.version) < 0)
++        goto error;
++
+  cleanup:
+     VIR_FREE(capsCacheDir);
+     return cache;
+diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
+index 98d163b920..222f3368e3 100644
+--- a/src/qemu/qemu_capspriv.h
++++ b/src/qemu/qemu_capspriv.h
+@@ -37,6 +37,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
+                                 uid_t runUid,
+                                 gid_t runGid,
+                                 unsigned int microcodeVersion,
++                                const char *kernelVersion,
+                                 bool qmpOnly);
+ 
+ int virQEMUCapsLoadCache(virArch hostArch,
+diff --git a/tests/qemucapsprobe.c b/tests/qemucapsprobe.c
+index a5f5a38b16..7d60246949 100644
+--- a/tests/qemucapsprobe.c
++++ b/tests/qemucapsprobe.c
+@@ -72,7 +72,7 @@ main(int argc, char **argv)
+         return EXIT_FAILURE;
+ 
+     if (!(caps = virQEMUCapsNewForBinaryInternal(VIR_ARCH_NONE, argv[1], "/tmp",
+-                                                 -1, -1, 0, true)))
++                                                 -1, -1, 0, NULL, true)))
+         return EXIT_FAILURE;
+ 
+     virObjectUnref(caps);
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-Remember-CPU-def-from-domain-start.patch b/SOURCES/libvirt-qemu-Remember-CPU-def-from-domain-start.patch
deleted file mode 100644
index 3cbfc59..0000000
--- a/SOURCES/libvirt-qemu-Remember-CPU-def-from-domain-start.patch
+++ /dev/null
@@ -1,132 +0,0 @@
-From f4038af76b0b8b4f8fb7b4ea7e957a6eb0614ea5 Mon Sep 17 00:00:00 2001
-Message-Id: <f4038af76b0b8b4f8fb7b4ea7e957a6eb0614ea5@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 16 May 2017 13:26:54 +0200
-Subject: [PATCH] qemu: Remember CPU def from domain start
-
-When starting a domain we update the guest CPU definition to match what
-QEMU actually provided (since it is allowed to add or removed some
-features unless check='full' is specified). Let's store the original CPU
-in domain private data so that we can use it to provide a backward
-compatible domain XML.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit ea6d89831198ae1854dca15b2bcf081df2d866a2)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/libvirt_private.syms |  2 ++
- src/qemu/qemu_domain.c   |  7 +++++++
- src/qemu/qemu_domain.h   |  4 ++++
- src/qemu/qemu_process.c  | 13 +++++++++++--
- 4 files changed, 24 insertions(+), 2 deletions(-)
-
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 88e3f4b8ac..8c088316c4 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -76,9 +76,11 @@ virCPUDefCopyModelFilter;
- virCPUDefCopyWithoutModel;
- virCPUDefFormat;
- virCPUDefFormatBuf;
-+virCPUDefFormatBufFull;
- virCPUDefFree;
- virCPUDefFreeFeatures;
- virCPUDefFreeModel;
-+virCPUDefIsEqual;
- virCPUDefParseXML;
- virCPUDefStealModel;
- virCPUDefUpdateFeature;
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 63fcde8024..89fd9f9abc 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -1705,6 +1705,8 @@ qemuDomainObjPrivateFree(void *data)
-     VIR_FREE(priv->migTLSAlias);
-     qemuDomainMasterKeyFree(priv);
- 
-+    virCPUDefFree(priv->origCPU);
-+
-     VIR_FREE(priv);
- }
- 
-@@ -1860,6 +1862,8 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
-     virBufferEscapeString(buf, "<channelTargetDir path='%s'/>\n",
-                           priv->channelTargetDir);
- 
-+    virCPUDefFormatBufFull(buf, priv->origCPU, NULL, false);
-+
-     return 0;
- }
- 
-@@ -2128,6 +2132,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
-     if (qemuDomainSetPrivatePathsOld(driver, vm) < 0)
-         goto error;
- 
-+    if (virCPUDefParseXML(ctxt, "./cpu", VIR_CPU_TYPE_GUEST, &priv->origCPU) < 0)
-+        goto error;
-+
-     return 0;
- 
-  error:
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 80d80e4554..0c5dad60e1 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -293,6 +293,10 @@ struct _qemuDomainObjPrivate {
-     /* Used when fetching/storing the current 'tls-creds' migration setting */
-     /* (not to be saved in our private XML). */
-     char *migTLSAlias;
-+
-+    /* CPU def used to start the domain when it differs from the one actually
-+     * provided by QEMU. */
-+    virCPUDefPtr origCPU;
- };
- 
- # define QEMU_DOMAIN_PRIVATE(vm)	\
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 7e51ca819a..79f780ed46 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3915,6 +3915,7 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-     qemuDomainObjPrivatePtr priv = vm->privateData;
-     int rc;
-     int ret = -1;
-+    virCPUDefPtr orig = NULL;
- 
-     if (ARCH_IS_X86(def->os.arch)) {
-         if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
-@@ -3945,10 +3946,17 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-         if (qemuProcessVerifyCPUFeatures(def, cpu) < 0)
-             goto cleanup;
- 
--        if ((rc = virCPUUpdateLive(def->os.arch, def->cpu, cpu, disabled)) < 0)
-+        if (!(orig = virCPUDefCopy(def->cpu)))
-             goto cleanup;
--        else if (rc == 0)
-+
-+        if ((rc = virCPUUpdateLive(def->os.arch, def->cpu, cpu, disabled)) < 0) {
-+            goto cleanup;
-+        } else if (rc == 0) {
-+            if (!virCPUDefIsEqual(def->cpu, orig, false))
-+                VIR_STEAL_PTR(priv->origCPU, orig);
-+
-             def->cpu->check = VIR_CPU_CHECK_FULL;
-+        }
-     }
- 
-     ret = 0;
-@@ -3956,6 +3964,7 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-  cleanup:
-     virCPUDataFree(cpu);
-     virCPUDataFree(disabled);
-+    virCPUDefFree(orig);
-     return ret;
- }
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Remove-redundancy-in-qemuBuildSerialChrDeviceStr.patch b/SOURCES/libvirt-qemu-Remove-redundancy-in-qemuBuildSerialChrDeviceStr.patch
new file mode 100644
index 0000000..f6f56ec
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Remove-redundancy-in-qemuBuildSerialChrDeviceStr.patch
@@ -0,0 +1,106 @@
+From 0d9354fe1bef822c515713a3ceb5b619f7eac00c Mon Sep 17 00:00:00 2001
+Message-Id: <0d9354fe1bef822c515713a3ceb5b619f7eac00c@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:11 +0100
+Subject: [PATCH] qemu: Remove redundancy in qemuBuildSerialChrDeviceStr()
+
+Instead duplicating the capability check for each possible target
+model, introduce a small helper that matches the target model with
+the corresponding capability and collapse all existing checks into
+a single one.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit fa96d3524296e7119acf5ad7b02653f4c062d030)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c | 40 +++++++++++++++++++++++++++++-----------
+ 1 file changed, 29 insertions(+), 11 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 7fd2afb1e0..f8d5d317cd 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9218,6 +9218,25 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
+     return 0;
+ }
+ 
++
++static virQEMUCapsFlags
++qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel)
++{
++    switch (targetModel) {
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
++        return QEMU_CAPS_DEVICE_USB_SERIAL;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
++        return QEMU_CAPS_DEVICE_PCI_SERIAL;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
++        break;
++    }
++
++    return 0;
++}
++
++
+ static int
+ qemuBuildChrDeviceCommandLine(virCommandPtr cmd,
+                               const virDomainDef *def,
+@@ -10322,6 +10341,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
+     return NULL;
+ }
+ 
++
+ /* This function generates the correct '-device' string for character
+  * devices of each architecture.
+  */
+@@ -10332,6 +10352,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+                             virQEMUCapsPtr qemuCaps)
+ {
+     virBuffer cmd = VIR_BUFFER_INITIALIZER;
++    virQEMUCapsFlags caps;
+ 
+     if (qemuDomainIsPSeries(def)) {
+         if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+@@ -10348,9 +10369,14 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+     } else {
+         switch ((virDomainChrSerialTargetModel) serial->targetModel) {
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
+-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_SERIAL)) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("usb-serial is not supported in this QEMU binary"));
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
++
++            caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
++
++            if (caps && !virQEMUCapsGet(qemuCaps, caps)) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                               _("'%s' is not supported in this QEMU binary"),
++                               virDomainChrSerialTargetModelTypeToString(serial->targetModel));
+                 goto error;
+             }
+             break;
+@@ -10358,14 +10384,6 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+             break;
+ 
+-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
+-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_SERIAL)) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("pci-serial is not supported with this QEMU binary"));
+-                goto error;
+-            }
+-            break;
+-
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+             /* Except from _LAST, which is just a guard value and will never
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Remove-redundant-capabilities.patch b/SOURCES/libvirt-qemu-Remove-redundant-capabilities.patch
deleted file mode 100644
index 693de55..0000000
--- a/SOURCES/libvirt-qemu-Remove-redundant-capabilities.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From 0494070eee0b3145ef3a0bfb4c29933aaa1a91af Mon Sep 17 00:00:00 2001
-Message-Id: <0494070eee0b3145ef3a0bfb4c29933aaa1a91af@dist-git>
-From: Andrea Bolognani <abologna@redhat.com>
-Date: Tue, 4 Apr 2017 14:59:29 +0200
-Subject: [PATCH] qemu: Remove redundant capabilities
-
-Now that the NO_ACPI and NO_HPET capabilities are set
-automatically by virQEMUCapsInitQMPBasicArch() if
-appropriate for the architecture, they shouldn't be
-used manually to avoid masking bugs.
-
-(cherry picked from commit 5fbb16ba5355ce4361bdd361bd200beb7627b7b9)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
-
-Signed-off-by: Andrea Bolognani <abologna@redhat.com>
----
- tests/qemuxml2argvtest.c | 10 ++++------
- 1 file changed, 4 insertions(+), 6 deletions(-)
-
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 731b793c4..5c0e1e8ab 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -762,9 +762,8 @@ mymain(void)
-     DO_TEST("clock-localtime-basis-localtime", QEMU_CAPS_RTC);
-     DO_TEST("clock-variable", QEMU_CAPS_RTC);
-     DO_TEST("clock-france", QEMU_CAPS_RTC);
--    DO_TEST("clock-hpet-off", QEMU_CAPS_RTC, QEMU_CAPS_NO_HPET,
--            QEMU_CAPS_NO_KVM_PIT);
--    DO_TEST("clock-catchup", QEMU_CAPS_RTC, QEMU_CAPS_NO_KVM_PIT);
-+    DO_TEST("clock-hpet-off", QEMU_CAPS_RTC);
-+    DO_TEST("clock-catchup", QEMU_CAPS_RTC);
-     DO_TEST("cpu-kvmclock", QEMU_CAPS_ENABLE_KVM);
-     DO_TEST("cpu-host-kvmclock", QEMU_CAPS_ENABLE_KVM);
-     DO_TEST("kvmclock", QEMU_CAPS_KVM);
-@@ -797,7 +796,7 @@ mymain(void)
-     DO_TEST("pmu-feature-off", NONE);
- 
-     DO_TEST("hugepages", QEMU_CAPS_MEM_PATH);
--    DO_TEST("hugepages-numa", QEMU_CAPS_RTC, QEMU_CAPS_NO_KVM_PIT,
-+    DO_TEST("hugepages-numa", QEMU_CAPS_RTC,
-             QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
-             QEMU_CAPS_VIRTIO_SCSI,
-             QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_PCI_MULTIFUNCTION,
-@@ -1990,7 +1989,6 @@ mymain(void)
-     DO_TEST("q35-virt-manager-basic",
-             QEMU_CAPS_KVM,
-             QEMU_CAPS_RTC,
--            QEMU_CAPS_NO_KVM_PIT,
-             QEMU_CAPS_ICH9_DISABLE_S3,
-             QEMU_CAPS_ICH9_DISABLE_S4,
-             QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
-@@ -2322,7 +2320,7 @@ mymain(void)
- 
-     DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY);
-     DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY);
--    DO_TEST("no-kvm-pit-device", QEMU_CAPS_NO_KVM_PIT);
-+    DO_TEST("no-kvm-pit-device", NONE);
- 
-     DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC,
-             QEMU_CAPS_NODEFCONFIG);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Remove-unused-cpuhalted-argument-from-qemuDomainHelperGetVcpus.patch b/SOURCES/libvirt-qemu-Remove-unused-cpuhalted-argument-from-qemuDomainHelperGetVcpus.patch
new file mode 100644
index 0000000..5398234
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Remove-unused-cpuhalted-argument-from-qemuDomainHelperGetVcpus.patch
@@ -0,0 +1,73 @@
+From 9daae960fbe9902f9db5ebc76ded1f197bb3e6ae Mon Sep 17 00:00:00 2001
+Message-Id: <9daae960fbe9902f9db5ebc76ded1f197bb3e6ae@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Wed, 7 Feb 2018 14:16:00 +0100
+Subject: [PATCH] qemu: Remove unused 'cpuhalted' argument from
+ qemuDomainHelperGetVcpus
+
+The halted state is no longer extracted using this helper so the
+argument can be removed.
+
+(cherry picked from commit 2222548b1e55257dc8806abdbefa71a87b22dea1)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1534585
+---
+ src/qemu/qemu_driver.c | 14 +++-----------
+ 1 file changed, 3 insertions(+), 11 deletions(-)
+
+diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
+index bfb3c3c4c5..b5bef7442e 100644
+--- a/src/qemu/qemu_driver.c
++++ b/src/qemu/qemu_driver.c
+@@ -1490,8 +1490,7 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm,
+                          unsigned long long *cpuwait,
+                          int maxinfo,
+                          unsigned char *cpumaps,
+-                         int maplen,
+-                         bool *cpuhalted)
++                         int maplen)
+ {
+     size_t ncpuinfo = 0;
+     size_t i;
+@@ -1511,9 +1510,6 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm,
+     if (cpumaps)
+         memset(cpumaps, 0, sizeof(*cpumaps) * maxinfo);
+ 
+-    if (cpuhalted)
+-        memset(cpuhalted, 0, sizeof(*cpuhalted) * maxinfo);
+-
+     for (i = 0; i < virDomainDefGetVcpusMax(vm->def) && ncpuinfo < maxinfo; i++) {
+         virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, i);
+         pid_t vcpupid = qemuDomainGetVcpuPid(vm, i);
+@@ -1551,9 +1547,6 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm,
+                 return -1;
+         }
+ 
+-        if (cpuhalted)
+-            cpuhalted[ncpuinfo] = qemuDomainGetVcpuHalted(vm, ncpuinfo);
+-
+         ncpuinfo++;
+     }
+ 
+@@ -5411,8 +5404,7 @@ qemuDomainGetVcpus(virDomainPtr dom,
+         goto cleanup;
+     }
+ 
+-    ret = qemuDomainHelperGetVcpus(vm, info, NULL, maxinfo, cpumaps, maplen,
+-                                   NULL);
++    ret = qemuDomainHelperGetVcpus(vm, info, NULL, maxinfo, cpumaps, maplen);
+ 
+  cleanup:
+     virDomainObjEndAPI(&vm);
+@@ -19567,7 +19559,7 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
+ 
+     if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait,
+                                  virDomainDefGetVcpus(dom->def),
+-                                 NULL, 0, NULL) < 0) {
++                                 NULL, 0) < 0) {
+         virResetLastError();
+         ret = 0; /* it's ok to be silent and go ahead */
+         goto cleanup;
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-Rename-qemuProcessBuildDestroyHugepagesPath.patch b/SOURCES/libvirt-qemu-Rename-qemuProcessBuildDestroyHugepagesPath.patch
new file mode 100644
index 0000000..d87238c
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Rename-qemuProcessBuildDestroyHugepagesPath.patch
@@ -0,0 +1,174 @@
+From aa138f5b99f7a05efee017401116d9513cb34b5e Mon Sep 17 00:00:00 2001
+Message-Id: <aa138f5b99f7a05efee017401116d9513cb34b5e@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Thu, 9 Nov 2017 16:06:45 +0100
+Subject: [PATCH] qemu: Rename qemuProcessBuildDestroyHugepagesPath
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1461214
+
+At the same time, move its internals into a separate function so
+that they can be reused.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit eff2b2edb147572b6d8f701f4b4f4a69580e17c8)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_hotplug.c |  2 +-
+ src/qemu/qemu_process.c | 76 +++++++++++++++++++++++++++++--------------------
+ src/qemu/qemu_process.h |  8 +++---
+ 3 files changed, 50 insertions(+), 36 deletions(-)
+
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index 91f7f9ed62..5701c033be 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -2077,7 +2077,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
+                                   priv->qemuCaps, vm->def, mem, NULL, true) < 0)
+         goto cleanup;
+ 
+-    if (qemuProcessBuildDestroyHugepagesPath(driver, vm, mem, true) < 0)
++    if (qemuProcessBuildDestroyMemoryPaths(driver, vm, mem, true) < 0)
+         goto cleanup;
+ 
+     if (qemuDomainNamespaceSetupMemory(driver, vm, mem) < 0)
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index fdc868912c..605f280d0c 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -3324,11 +3324,45 @@ qemuProcessNeedHugepagesPath(virDomainDefPtr def,
+ }
+ 
+ 
++static int
++qemuProcessBuildDestroyMemoryPathsImpl(virQEMUDriverPtr driver,
++                                       virDomainDefPtr def,
++                                       const char *path,
++                                       bool build)
++{
++    if (build) {
++        if (virFileExists(path))
++            return 0;
++
++        if (virFileMakePathWithMode(path, 0700) < 0) {
++            virReportSystemError(errno,
++                                 _("Unable to create %s"),
++                                 path);
++            return -1;
++        }
++
++        if (qemuSecurityDomainSetPathLabel(driver->securityManager,
++                                           def, path) < 0) {
++            virReportError(VIR_ERR_INTERNAL_ERROR,
++                            _("Unable to label %s"), path);
++            return -1;
++        }
++    } else {
++        if (rmdir(path) < 0 &&
++            errno != ENOENT)
++            VIR_WARN("Unable to remove hugepage path: %s (errno=%d)",
++                     path, errno);
++    }
++
++    return 0;
++}
++
++
+ int
+-qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver,
+-                                     virDomainObjPtr vm,
+-                                     virDomainMemoryDefPtr mem,
+-                                     bool build)
++qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
++                                   virDomainObjPtr vm,
++                                   virDomainMemoryDefPtr mem,
++                                   bool build)
+ {
+     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+     char *hugepagePath = NULL;
+@@ -3347,31 +3381,11 @@ qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver,
+             if (!hugepagePath)
+                 goto cleanup;
+ 
+-            if (build) {
+-                if (virFileExists(hugepagePath)) {
+-                    ret = 0;
+-                    goto cleanup;
+-                }
++            if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm->def,
++                                                       hugepagePath, build) < 0)
++                goto cleanup;
+ 
+-                if (virFileMakePathWithMode(hugepagePath, 0700) < 0) {
+-                    virReportSystemError(errno,
+-                                         _("Unable to create %s"),
+-                                         hugepagePath);
+-                    goto cleanup;
+-                }
+-
+-                if (qemuSecurityDomainSetPathLabel(driver->securityManager,
+-                                                   vm->def, hugepagePath) < 0) {
+-                    virReportError(VIR_ERR_INTERNAL_ERROR,
+-                                   "%s", _("Unable to set huge path in security driver"));
+-                    goto cleanup;
+-                }
+-            } else {
+-                if (rmdir(hugepagePath) < 0 &&
+-                    errno != ENOENT)
+-                    VIR_WARN("Unable to remove hugepage path: %s (errno=%d)",
+-                             hugepagePath, errno);
+-            }
++            VIR_FREE(hugepagePath);
+         }
+     }
+ 
+@@ -5550,7 +5564,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
+                                NULL) < 0)
+         goto cleanup;
+ 
+-    if (qemuProcessBuildDestroyHugepagesPath(driver, vm, NULL, true) < 0)
++    if (qemuProcessBuildDestroyMemoryPaths(driver, vm, NULL, true) < 0)
+         goto cleanup;
+ 
+     /* Ensure no historical cgroup for this VM is lying around bogus
+@@ -6254,7 +6268,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
+         goto endjob;
+     }
+ 
+-    qemuProcessBuildDestroyHugepagesPath(driver, vm, NULL, false);
++    qemuProcessBuildDestroyMemoryPaths(driver, vm, NULL, false);
+ 
+     vm->def->id = -1;
+ 
+@@ -7112,7 +7126,7 @@ qemuProcessReconnect(void *opaque)
+         goto cleanup;
+     }
+ 
+-    if (qemuProcessBuildDestroyHugepagesPath(driver, obj, NULL, true) < 0)
++    if (qemuProcessBuildDestroyMemoryPaths(driver, obj, NULL, true) < 0)
+         goto error;
+ 
+     if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps,
+diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
+index 814b86d8a7..cd9a720313 100644
+--- a/src/qemu/qemu_process.h
++++ b/src/qemu/qemu_process.h
+@@ -38,10 +38,10 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver,
+                         virDomainPausedReason reason,
+                         qemuDomainAsyncJob asyncJob);
+ 
+-int qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver,
+-                                         virDomainObjPtr vm,
+-                                         virDomainMemoryDefPtr mem,
+-                                         bool build);
++int qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
++                                       virDomainObjPtr vm,
++                                       virDomainMemoryDefPtr mem,
++                                       bool build);
+ 
+ void qemuProcessAutostartAll(virQEMUDriverPtr driver);
+ void qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver);
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Rename-qemuProcessUpdateLiveGuestCPU.patch b/SOURCES/libvirt-qemu-Rename-qemuProcessUpdateLiveGuestCPU.patch
deleted file mode 100644
index b4d8e50..0000000
--- a/SOURCES/libvirt-qemu-Rename-qemuProcessUpdateLiveGuestCPU.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From dfc345ac7bd7bc87c297fc9887453e8f3035191c Mon Sep 17 00:00:00 2001
-Message-Id: <dfc345ac7bd7bc87c297fc9887453e8f3035191c@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 11 Jul 2017 13:30:09 +0200
-Subject: [PATCH] qemu: Rename qemuProcessUpdateLiveGuestCPU
-
-In addition to updating a guest CPU definition the function verifies
-that all required features are provided to the guest. Let's make it
-obvious by calling it qemuProcessUpdateAndVerifyCPU.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit e6ed55e4e9c9ec21ca87573b69225d2fafc54272)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1470582
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_process.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 3f7a9f4c02..1e7724e784 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3971,7 +3971,7 @@ qemuProcessVerifyCPU(virDomainObjPtr vm,
- 
- 
- static int
--qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-+qemuProcessUpdateAndVerifyCPU(virQEMUDriverPtr driver,
-                               virDomainObjPtr vm,
-                               qemuDomainAsyncJob asyncJob)
- {
-@@ -5875,7 +5875,7 @@ qemuProcessLaunch(virConnectPtr conn,
-         goto cleanup;
- 
-     VIR_DEBUG("Verifying and updating provided guest CPU");
--    if (qemuProcessUpdateLiveGuestCPU(driver, vm, asyncJob) < 0)
-+    if (qemuProcessUpdateAndVerifyCPU(driver, vm, asyncJob) < 0)
-         goto cleanup;
- 
-     VIR_DEBUG("Setting up post-init cgroup restrictions");
--- 
-2.13.2
-
diff --git a/SOURCES/libvirt-qemu-Rename-xml_len-in-virQEMUSaveHeader-as-data_len.patch b/SOURCES/libvirt-qemu-Rename-xml_len-in-virQEMUSaveHeader-as-data_len.patch
deleted file mode 100644
index 2e516a5..0000000
--- a/SOURCES/libvirt-qemu-Rename-xml_len-in-virQEMUSaveHeader-as-data_len.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-From 3d7186eefc7db60a5f33776eb1873ea18b9c501a Mon Sep 17 00:00:00 2001
-Message-Id: <3d7186eefc7db60a5f33776eb1873ea18b9c501a@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 23 May 2017 20:32:07 +0200
-Subject: [PATCH] qemu: Rename xml_len in virQEMUSaveHeader as data_len
-
-Since virQEMUSaveHeader will be followed by more than just domain XML,
-the old name would be confusing as it was designed to describe the
-length of all data following the save image header.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit ec3e4bb75a8d06644ca5b758c5f04041cecc9d20)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 20 ++++++++++----------
- 1 file changed, 10 insertions(+), 10 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 2688c3eec7..c8a84503c1 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -2810,7 +2810,7 @@ typedef virQEMUSaveHeader *virQEMUSaveHeaderPtr;
- struct _virQEMUSaveHeader {
-     char magic[sizeof(QEMU_SAVE_MAGIC)-1];
-     uint32_t version;
--    uint32_t xml_len;
-+    uint32_t data_len;
-     uint32_t was_running;
-     uint32_t compressed;
-     uint32_t unused[15];
-@@ -2820,7 +2820,7 @@ static inline void
- bswap_header(virQEMUSaveHeaderPtr hdr)
- {
-     hdr->version = bswap_32(hdr->version);
--    hdr->xml_len = bswap_32(hdr->xml_len);
-+    hdr->data_len = bswap_32(hdr->data_len);
-     hdr->was_running = bswap_32(hdr->was_running);
-     hdr->compressed = bswap_32(hdr->compressed);
- }
-@@ -2841,7 +2841,7 @@ qemuDomainSaveHeader(int fd, const char *path, const char *xml,
-         goto endjob;
-     }
- 
--    if (safewrite(fd, xml, header->xml_len) != header->xml_len) {
-+    if (safewrite(fd, xml, header->data_len) != header->data_len) {
-         ret = -errno;
-         virReportError(VIR_ERR_OPERATION_FAILED,
-                        _("failed to write xml to '%s'"), path);
-@@ -3068,7 +3068,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
-     header.version = QEMU_SAVE_VERSION;
-     header.was_running = was_running ? 1 : 0;
-     header.compressed = compressed;
--    header.xml_len = strlen(domXML) + 1;
-+    header.data_len = strlen(domXML) + 1;
- 
-     /* Obtain the file handle.  */
-     if ((flags & VIR_DOMAIN_SAVE_BYPASS_CACHE)) {
-@@ -6270,16 +6270,16 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-         goto error;
-     }
- 
--    if (header.xml_len <= 0) {
-+    if (header.data_len <= 0) {
-         virReportError(VIR_ERR_OPERATION_FAILED,
--                       _("invalid XML length: %d"), header.xml_len);
-+                       _("invalid XML length: %d"), header.data_len);
-         goto error;
-     }
- 
--    if (VIR_ALLOC_N(xml, header.xml_len) < 0)
-+    if (VIR_ALLOC_N(xml, header.data_len) < 0)
-         goto error;
- 
--    if (saferead(fd, xml, header.xml_len) != header.xml_len) {
-+    if (saferead(fd, xml, header.data_len) != header.data_len) {
-         virReportError(VIR_ERR_OPERATION_FAILED,
-                        "%s", _("failed to read XML"));
-         goto error;
-@@ -6623,12 +6623,12 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
-         goto cleanup;
-     len = strlen(xml) + 1;
- 
--    if (len > header.xml_len) {
-+    if (len > header.data_len) {
-         virReportError(VIR_ERR_OPERATION_FAILED, "%s",
-                        _("new xml too large to fit in file"));
-         goto cleanup;
-     }
--    if (VIR_EXPAND_N(xml, len, header.xml_len - len) < 0)
-+    if (VIR_EXPAND_N(xml, len, header.data_len - len) < 0)
-         goto cleanup;
- 
-     if (lseek(fd, 0, SEEK_SET) != 0) {
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Report-VIR_DOMAIN_JOB_OPERATION.patch b/SOURCES/libvirt-qemu-Report-VIR_DOMAIN_JOB_OPERATION.patch
deleted file mode 100644
index 81aeac2..0000000
--- a/SOURCES/libvirt-qemu-Report-VIR_DOMAIN_JOB_OPERATION.patch
+++ /dev/null
@@ -1,285 +0,0 @@
-From 4db224dec8f4aeaadf95da115a57ed73244939a0 Mon Sep 17 00:00:00 2001
-Message-Id: <4db224dec8f4aeaadf95da115a57ed73244939a0@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 26 Apr 2017 12:00:09 +0200
-Subject: [PATCH] qemu: Report VIR_DOMAIN_JOB_OPERATION
-
-Not all async jobs are visible via virDomainGetJobStats (either they are
-too fast or getting the stats is not allowed during the job), but
-forcing all of them to advertise the operation is easier than hunting
-the jobs for which fetching statistics is allowed. And we won't need to
-think about this when we add support for getting stats for more jobs.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441563
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 2a978269fc9dc31c354a7c9132cb62d52e7613ef)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c    | 16 +++++++++++++---
- src/qemu/qemu_domain.h    |  4 +++-
- src/qemu/qemu_driver.c    | 32 ++++++++++++++++++++++----------
- src/qemu/qemu_migration.c | 19 ++++++++++++-------
- src/qemu/qemu_process.c   |  6 ++++--
- src/qemu/qemu_process.h   |  3 ++-
- 6 files changed, 56 insertions(+), 24 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index c43ff3d63..9c09ced0c 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -405,6 +405,11 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
-     int maxpar = 0;
-     int npar = 0;
- 
-+    if (virTypedParamsAddInt(&par, &npar, &maxpar,
-+                             VIR_DOMAIN_JOB_OPERATION,
-+                             jobInfo->operation) < 0)
-+        goto error;
-+
-     if (virTypedParamsAddULLong(&par, &npar, &maxpar,
-                                 VIR_DOMAIN_JOB_TIME_ELAPSED,
-                                 jobInfo->timeElapsed) < 0)
-@@ -3674,13 +3679,18 @@ int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
- 
- int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
-                                virDomainObjPtr obj,
--                               qemuDomainAsyncJob asyncJob)
-+                               qemuDomainAsyncJob asyncJob,
-+                               virDomainJobOperation operation)
- {
-+    qemuDomainObjPrivatePtr priv;
-+
-     if (qemuDomainObjBeginJobInternal(driver, obj, QEMU_JOB_ASYNC,
-                                       asyncJob) < 0)
-         return -1;
--    else
--        return 0;
-+
-+    priv = obj->privateData;
-+    priv->job.current->operation = operation;
-+    return 0;
- }
- 
- int
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 0e32bb9ea..f50330487 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -103,6 +103,7 @@ typedef struct _qemuDomainJobInfo qemuDomainJobInfo;
- typedef qemuDomainJobInfo *qemuDomainJobInfoPtr;
- struct _qemuDomainJobInfo {
-     virDomainJobType type;
-+    virDomainJobOperation operation;
-     unsigned long long started; /* When the async job started */
-     unsigned long long stopped; /* When the domain's CPUs were stopped */
-     unsigned long long sent; /* When the source sent status info to the
-@@ -433,7 +434,8 @@ int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
-     ATTRIBUTE_RETURN_CHECK;
- int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
-                                virDomainObjPtr obj,
--                               qemuDomainAsyncJob asyncJob)
-+                               qemuDomainAsyncJob asyncJob,
-+                               virDomainJobOperation operation)
-     ATTRIBUTE_RETURN_CHECK;
- int qemuDomainObjBeginNestedJob(virQEMUDriverPtr driver,
-                                 virDomainObjPtr obj,
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 2fcf4612e..8699fb2fe 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -268,7 +268,8 @@ qemuAutostartDomain(virDomainObjPtr vm,
-     virResetLastError();
-     if (vm->autostart &&
-         !virDomainObjIsActive(vm)) {
--        if (qemuProcessBeginJob(data->driver, vm) < 0) {
-+        if (qemuProcessBeginJob(data->driver, vm,
-+                                VIR_DOMAIN_JOB_OPERATION_START) < 0) {
-             virReportError(VIR_ERR_INTERNAL_ERROR,
-                            _("Failed to start job on VM '%s': %s"),
-                            vm->def->name, virGetLastErrorMessage());
-@@ -1764,7 +1765,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
-     virObjectRef(vm);
-     def = NULL;
- 
--    if (qemuProcessBeginJob(driver, vm) < 0) {
-+    if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_START) < 0) {
-         qemuDomainRemoveInactive(driver, vm);
-         goto cleanup;
-     }
-@@ -3152,7 +3153,8 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-     if (!qemuMigrationIsAllowed(driver, vm, false, 0))
-         goto cleanup;
- 
--    if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SAVE) < 0)
-+    if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SAVE,
-+                                   VIR_DOMAIN_JOB_OPERATION_SAVE) < 0)
-         goto cleanup;
- 
-     if (!virDomainObjIsActive(vm)) {
-@@ -3690,7 +3692,8 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom,
-         goto cleanup;
- 
-     if (qemuDomainObjBeginAsyncJob(driver, vm,
--                                   QEMU_ASYNC_JOB_DUMP) < 0)
-+                                   QEMU_ASYNC_JOB_DUMP,
-+                                   VIR_DOMAIN_JOB_OPERATION_DUMP) < 0)
-         goto cleanup;
- 
-     if (!virDomainObjIsActive(vm)) {
-@@ -3920,7 +3923,8 @@ processWatchdogEvent(virQEMUDriverPtr driver,
-     switch (action) {
-     case VIR_DOMAIN_WATCHDOG_ACTION_DUMP:
-         if (qemuDomainObjBeginAsyncJob(driver, vm,
--                                       QEMU_ASYNC_JOB_DUMP) < 0) {
-+                                       QEMU_ASYNC_JOB_DUMP,
-+                                       VIR_DOMAIN_JOB_OPERATION_DUMP) < 0) {
-             goto cleanup;
-         }
- 
-@@ -4007,7 +4011,8 @@ processGuestPanicEvent(virQEMUDriverPtr driver,
-     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-     bool removeInactive = false;
- 
--    if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_DUMP) < 0)
-+    if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_DUMP,
-+                                   VIR_DOMAIN_JOB_OPERATION_DUMP) < 0)
-         goto cleanup;
- 
-     if (!virDomainObjIsActive(vm)) {
-@@ -6492,7 +6497,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
-         priv->hookRun = true;
-     }
- 
--    if (qemuProcessBeginJob(driver, vm) < 0)
-+    if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_RESTORE) < 0)
-         goto cleanup;
- 
-     ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, &header, path,
-@@ -6912,6 +6917,7 @@ qemuDomainObjStart(virConnectPtr conn,
-     bool bypass_cache = (flags & VIR_DOMAIN_START_BYPASS_CACHE) != 0;
-     bool force_boot = (flags & VIR_DOMAIN_START_FORCE_BOOT) != 0;
-     unsigned int start_flags = VIR_QEMU_PROCESS_START_COLD;
-+    qemuDomainObjPrivatePtr priv = vm->privateData;
- 
-     start_flags |= start_paused ? VIR_QEMU_PROCESS_START_PAUSED : 0;
-     start_flags |= autodestroy ? VIR_QEMU_PROCESS_START_AUTODESTROY : 0;
-@@ -6935,6 +6941,9 @@ qemuDomainObjStart(virConnectPtr conn,
-             }
-             vm->hasManagedSave = false;
-         } else {
-+            virDomainJobOperation op = priv->job.current->operation;
-+            priv->job.current->operation = VIR_DOMAIN_JOB_OPERATION_RESTORE;
-+
-             ret = qemuDomainObjRestore(conn, driver, vm, managed_save,
-                                        start_paused, bypass_cache, asyncJob);
- 
-@@ -6951,6 +6960,7 @@ qemuDomainObjStart(virConnectPtr conn,
-                 goto cleanup;
-             } else {
-                 VIR_WARN("Ignoring incomplete managed state %s", managed_save);
-+                priv->job.current->operation = op;
-             }
-         }
-     }
-@@ -7000,7 +7010,7 @@ qemuDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
-     if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
-         goto cleanup;
- 
--    if (qemuProcessBeginJob(driver, vm) < 0)
-+    if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_START) < 0)
-         goto cleanup;
- 
-     if (virDomainObjIsActive(vm)) {
-@@ -14567,7 +14577,8 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
-      * a regular job, so we need to set the job mask to disallow query as
-      * 'savevm' blocks the monitor. External snapshot will then modify the
-      * job mask appropriately. */
--    if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SNAPSHOT) < 0)
-+    if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SNAPSHOT,
-+                                   VIR_DOMAIN_JOB_OPERATION_SNAPSHOT) < 0)
-         goto cleanup;
- 
-     qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
-@@ -15157,7 +15168,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-         goto cleanup;
-     }
- 
--    if (qemuProcessBeginJob(driver, vm) < 0)
-+    if (qemuProcessBeginJob(driver, vm,
-+                            VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_REVERT) < 0)
-         goto cleanup;
- 
-     if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 8cbad894c..cadbf9b97 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -5598,18 +5598,23 @@ qemuMigrationJobStart(virQEMUDriverPtr driver,
-                       qemuDomainAsyncJob job)
- {
-     qemuDomainObjPrivatePtr priv = vm->privateData;
--
--    if (qemuDomainObjBeginAsyncJob(driver, vm, job) < 0)
--        return -1;
-+    virDomainJobOperation op;
-+    unsigned long long mask;
- 
-     if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
--        qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
-+        op = VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN;
-+        mask = QEMU_JOB_NONE;
-     } else {
--        qemuDomainObjSetAsyncJobMask(vm, (QEMU_JOB_DEFAULT_MASK |
--                                          JOB_MASK(QEMU_JOB_SUSPEND) |
--                                          JOB_MASK(QEMU_JOB_MIGRATION_OP)));
-+        op = VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT;
-+        mask = QEMU_JOB_DEFAULT_MASK |
-+               JOB_MASK(QEMU_JOB_SUSPEND) |
-+               JOB_MASK(QEMU_JOB_MIGRATION_OP);
-     }
- 
-+    if (qemuDomainObjBeginAsyncJob(driver, vm, job, op) < 0)
-+        return -1;
-+
-+    qemuDomainObjSetAsyncJobMask(vm, mask);
-     priv->job.current->type = VIR_DOMAIN_JOB_UNBOUNDED;
- 
-     return 0;
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 2eee70203..afd9dfb71 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -4143,11 +4143,13 @@ qemuProcessIncomingDefNew(virQEMUCapsPtr qemuCaps,
-  */
- int
- qemuProcessBeginJob(virQEMUDriverPtr driver,
--                    virDomainObjPtr vm)
-+                    virDomainObjPtr vm,
-+                    virDomainJobOperation operation)
- {
-     qemuDomainObjPrivatePtr priv = vm->privateData;
- 
--    if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_START) < 0)
-+    if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_START,
-+                                   operation) < 0)
-         return -1;
- 
-     qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
-diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
-index 21f3b0cca..830d8cef8 100644
---- a/src/qemu/qemu_process.h
-+++ b/src/qemu/qemu_process.h
-@@ -59,7 +59,8 @@ qemuProcessIncomingDefPtr qemuProcessIncomingDefNew(virQEMUCapsPtr qemuCaps,
- void qemuProcessIncomingDefFree(qemuProcessIncomingDefPtr inc);
- 
- int qemuProcessBeginJob(virQEMUDriverPtr driver,
--                        virDomainObjPtr vm);
-+                        virDomainObjPtr vm,
-+                        virDomainJobOperation operation);
- void qemuProcessEndJob(virQEMUDriverPtr driver,
-                        virDomainObjPtr vm);
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Report-shutdown-event-details.patch b/SOURCES/libvirt-qemu-Report-shutdown-event-details.patch
deleted file mode 100644
index 56c04eb..0000000
--- a/SOURCES/libvirt-qemu-Report-shutdown-event-details.patch
+++ /dev/null
@@ -1,194 +0,0 @@
-From f0747aa9c94a5a79c9766959fcd479e04a56da3e Mon Sep 17 00:00:00 2001
-Message-Id: <f0747aa9c94a5a79c9766959fcd479e04a56da3e@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Wed, 31 May 2017 08:21:33 +0200
-Subject: [PATCH] qemu: Report shutdown event details
-
-QEMU will likely report the details of it shutting down, particularly
-whether the shutdown was initiated by the guest or host.  We should
-forward that information along, at least for shutdown events.  Reset
-has that as well, however that is not a lifecycle event and would add
-extra constants that might not be used.  It can be added later on.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1384007
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-(cherry picked from commit a8eba5036cb4b0e2ec827e9e6e019ce70e451377)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- examples/object-events/event-test.c |  6 ++++++
- include/libvirt/libvirt-domain.h    | 11 ++++++++++-
- src/qemu/qemu_monitor.c             |  6 +++---
- src/qemu/qemu_monitor.h             |  3 ++-
- src/qemu/qemu_monitor_json.c        | 10 ++++++++--
- src/qemu/qemu_process.c             | 21 +++++++++++++++++++--
- tools/virsh-domain.c                |  4 +++-
- 7 files changed, 51 insertions(+), 10 deletions(-)
-
-diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
-index 12690cac0..78d200806 100644
---- a/examples/object-events/event-test.c
-+++ b/examples/object-events/event-test.c
-@@ -240,6 +240,12 @@ eventDetailToString(int event,
-             case VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED:
-                 return "Finished";
- 
-+            case VIR_DOMAIN_EVENT_SHUTDOWN_GUEST:
-+                return "Guest request";
-+
-+            case VIR_DOMAIN_EVENT_SHUTDOWN_HOST:
-+                return "Host request";
-+
-             case VIR_DOMAIN_EVENT_SHUTDOWN_LAST:
-                 break;
-             }
-diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
-index c9e96a6c9..720db32f7 100644
---- a/include/libvirt/libvirt-domain.h
-+++ b/include/libvirt/libvirt-domain.h
-@@ -2983,7 +2983,16 @@ typedef enum {
-  * Details on the cause of a 'shutdown' lifecycle event
-  */
- typedef enum {
--    VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED = 0, /* Guest finished shutdown sequence */
-+    /* Guest finished shutdown sequence */
-+    VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED = 0,
-+
-+    /* Domain finished shutting down after request from the guest itself
-+     * (e.g. hardware-specific action) */
-+    VIR_DOMAIN_EVENT_SHUTDOWN_GUEST = 1,
-+
-+    /* Domain finished shutting down after request from the host (e.g. killed by
-+     * a signal) */
-+    VIR_DOMAIN_EVENT_SHUTDOWN_HOST = 2,
- 
- # ifdef VIR_ENUM_SENTINELS
-     VIR_DOMAIN_EVENT_SHUTDOWN_LAST
-diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
-index 488d761fb..b5e890607 100644
---- a/src/qemu/qemu_monitor.c
-+++ b/src/qemu/qemu_monitor.c
-@@ -1303,12 +1303,12 @@ qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
- 
- 
- int
--qemuMonitorEmitShutdown(qemuMonitorPtr mon)
-+qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest)
- {
-     int ret = -1;
--    VIR_DEBUG("mon=%p", mon);
-+    VIR_DEBUG("mon=%p guest=%u", mon, guest);
- 
--    QEMU_MONITOR_CALLBACK(mon, ret, domainShutdown, mon->vm);
-+    QEMU_MONITOR_CALLBACK(mon, ret, domainShutdown, mon->vm, guest);
-     return ret;
- }
- 
-diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
-index c1506b0fc..9901203b1 100644
---- a/src/qemu/qemu_monitor.h
-+++ b/src/qemu/qemu_monitor.h
-@@ -130,6 +130,7 @@ typedef int (*qemuMonitorDomainEventCallback)(qemuMonitorPtr mon,
-                                               void *opaque);
- typedef int (*qemuMonitorDomainShutdownCallback)(qemuMonitorPtr mon,
-                                                  virDomainObjPtr vm,
-+                                                 virTristateBool guest,
-                                                  void *opaque);
- typedef int (*qemuMonitorDomainResetCallback)(qemuMonitorPtr mon,
-                                               virDomainObjPtr vm,
-@@ -342,7 +343,7 @@ int qemuMonitorGetDiskSecret(qemuMonitorPtr mon,
- int qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
-                          long long seconds, unsigned int micros,
-                          const char *details);
--int qemuMonitorEmitShutdown(qemuMonitorPtr mon);
-+int qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest);
- int qemuMonitorEmitReset(qemuMonitorPtr mon);
- int qemuMonitorEmitPowerdown(qemuMonitorPtr mon);
- int qemuMonitorEmitStop(qemuMonitorPtr mon);
-diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
-index 601aa3e74..f22df3007 100644
---- a/src/qemu/qemu_monitor_json.c
-+++ b/src/qemu/qemu_monitor_json.c
-@@ -523,9 +523,15 @@ qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
- }
- 
- 
--static void qemuMonitorJSONHandleShutdown(qemuMonitorPtr mon, virJSONValuePtr data ATTRIBUTE_UNUSED)
-+static void qemuMonitorJSONHandleShutdown(qemuMonitorPtr mon, virJSONValuePtr data)
- {
--    qemuMonitorEmitShutdown(mon);
-+    bool guest = false;
-+    virTristateBool guest_initiated = VIR_TRISTATE_BOOL_ABSENT;
-+
-+    if (virJSONValueObjectGetBoolean(data, "guest", &guest) == 0)
-+        guest_initiated = guest ? VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO;
-+
-+    qemuMonitorEmitShutdown(mon, guest_initiated);
- }
- 
- static void qemuMonitorJSONHandleReset(qemuMonitorPtr mon, virJSONValuePtr data ATTRIBUTE_UNUSED)
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 6f0d07242..998dbeb6b 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -634,12 +634,14 @@ qemuProcessHandleEvent(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
- static int
- qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
-                           virDomainObjPtr vm,
-+                          virTristateBool guest_initiated,
-                           void *opaque)
- {
-     virQEMUDriverPtr driver = opaque;
-     qemuDomainObjPrivatePtr priv;
-     virObjectEventPtr event = NULL;
-     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-+    int detail = 0;
- 
-     VIR_DEBUG("vm=%p", vm);
- 
-@@ -662,9 +664,24 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
-     virDomainObjSetState(vm,
-                          VIR_DOMAIN_SHUTDOWN,
-                          VIR_DOMAIN_SHUTDOWN_UNKNOWN);
-+
-+    switch (guest_initiated) {
-+    case VIR_TRISTATE_BOOL_YES:
-+        detail = VIR_DOMAIN_EVENT_SHUTDOWN_GUEST;
-+        break;
-+
-+    case VIR_TRISTATE_BOOL_NO:
-+        detail = VIR_DOMAIN_EVENT_SHUTDOWN_HOST;
-+        break;
-+
-+    default:
-+        detail = VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED;
-+        break;
-+    }
-+
-     event = virDomainEventLifecycleNewFromObj(vm,
--                                     VIR_DOMAIN_EVENT_SHUTDOWN,
--                                     VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED);
-+                                              VIR_DOMAIN_EVENT_SHUTDOWN,
-+                                              detail);
- 
-     if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) {
-         VIR_WARN("Unable to save status on vm %s after state change",
-diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
-index bc0ded686..3374f2c8b 100644
---- a/tools/virsh-domain.c
-+++ b/tools/virsh-domain.c
-@@ -12385,7 +12385,9 @@ VIR_ENUM_IMPL(virshDomainEventStopped,
- VIR_ENUM_DECL(virshDomainEventShutdown)
- VIR_ENUM_IMPL(virshDomainEventShutdown,
-               VIR_DOMAIN_EVENT_SHUTDOWN_LAST,
--              N_("Finished"))
-+              N_("Finished"),
-+              N_("Finished after guest request"),
-+              N_("Finished after host request"))
- 
- VIR_ENUM_DECL(virshDomainEventPMSuspended)
- VIR_ENUM_IMPL(virshDomainEventPMSuspended,
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-Report-the-original-CPU-in-migratable-xml.patch b/SOURCES/libvirt-qemu-Report-the-original-CPU-in-migratable-xml.patch
deleted file mode 100644
index 430ea4e..0000000
--- a/SOURCES/libvirt-qemu-Report-the-original-CPU-in-migratable-xml.patch
+++ /dev/null
@@ -1,231 +0,0 @@
-From 9281d9a8d447e8b066cc600f1dcca7775920f01e Mon Sep 17 00:00:00 2001
-Message-Id: <9281d9a8d447e8b066cc600f1dcca7775920f01e@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 19 May 2017 15:20:31 +0200
-Subject: [PATCH] qemu: Report the original CPU in migratable xml
-
-The destination host may not be able to start a domain using the live
-updated CPU definition because either libvirt or QEMU may not be new
-enough. Thus we need to send the original guest CPU definition.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 356a2161e293eaab57448a8e68f489e0841efe19)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c    | 61 ++++++++++++++++++++++++++++++++++++++---------
- src/qemu/qemu_domain.h    |  1 +
- src/qemu/qemu_driver.c    | 13 ++++++----
- src/qemu/qemu_migration.c |  5 ++--
- 4 files changed, 63 insertions(+), 17 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 89fd9f9abc..514b56b33c 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -4175,11 +4175,13 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,
-     return ret;
- }
- 
--int
--qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
--                       virDomainDefPtr def,
--                       unsigned int flags,
--                       virBuffer *buf)
-+
-+static int
-+qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
-+                               virDomainDefPtr def,
-+                               virCPUDefPtr origCPU,
-+                               unsigned int flags,
-+                               virBuffer *buf)
- {
-     int ret = -1;
-     virDomainDefPtr copy = NULL;
-@@ -4300,6 +4302,16 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
-             if (qemuDomainChrDefDropDefaultPath(def->channels[i], driver) < 0)
-                 goto cleanup;
-         }
-+
-+        /* Replace the CPU definition updated according to QEMU with the one
-+         * used for starting the domain. The updated def will be sent
-+         * separately for backward compatibility.
-+         */
-+        if (origCPU) {
-+            virCPUDefFree(def->cpu);
-+            if (!(def->cpu = virCPUDefCopy(origCPU)))
-+                goto cleanup;
-+        }
-     }
- 
-  format:
-@@ -4313,13 +4325,26 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
-     return ret;
- }
- 
--char *qemuDomainDefFormatXML(virQEMUDriverPtr driver,
--                             virDomainDefPtr def,
--                             unsigned int flags)
-+
-+int
-+qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
-+                       virDomainDefPtr def,
-+                       unsigned int flags,
-+                       virBufferPtr buf)
-+{
-+    return qemuDomainDefFormatBufInternal(driver, def, NULL, flags, buf);
-+}
-+
-+
-+static char *
-+qemuDomainDefFormatXMLInternal(virQEMUDriverPtr driver,
-+                               virDomainDefPtr def,
-+                               virCPUDefPtr origCPU,
-+                               unsigned int flags)
- {
-     virBuffer buf = VIR_BUFFER_INITIALIZER;
- 
--    if (qemuDomainDefFormatBuf(driver, def, flags, &buf) < 0) {
-+    if (qemuDomainDefFormatBufInternal(driver, def, origCPU, flags, &buf) < 0) {
-         virBufferFreeAndReset(&buf);
-         return NULL;
-     }
-@@ -4333,26 +4358,40 @@ char *qemuDomainDefFormatXML(virQEMUDriverPtr driver,
-     return virBufferContentAndReset(&buf);
- }
- 
-+
-+char *
-+qemuDomainDefFormatXML(virQEMUDriverPtr driver,
-+                       virDomainDefPtr def,
-+                       unsigned int flags)
-+{
-+    return qemuDomainDefFormatXMLInternal(driver, def, NULL, flags);
-+}
-+
-+
- char *qemuDomainFormatXML(virQEMUDriverPtr driver,
-                           virDomainObjPtr vm,
-                           unsigned int flags)
- {
-     virDomainDefPtr def;
-+    qemuDomainObjPrivatePtr priv = vm->privateData;
-+    virCPUDefPtr origCPU = NULL;
- 
-     if ((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef) {
-         def = vm->newDef;
-     } else {
-         def = vm->def;
-+        origCPU = priv->origCPU;
-         if (virDomainObjIsActive(vm))
-             flags &= ~VIR_DOMAIN_XML_UPDATE_CPU;
-     }
- 
--    return qemuDomainDefFormatXML(driver, def, flags);
-+    return qemuDomainDefFormatXMLInternal(driver, def, origCPU, flags);
- }
- 
- char *
- qemuDomainDefFormatLive(virQEMUDriverPtr driver,
-                         virDomainDefPtr def,
-+                        virCPUDefPtr origCPU,
-                         bool inactive,
-                         bool compatible)
- {
-@@ -4363,7 +4402,7 @@ qemuDomainDefFormatLive(virQEMUDriverPtr driver,
-     if (compatible)
-         flags |= VIR_DOMAIN_XML_MIGRATABLE;
- 
--    return qemuDomainDefFormatXML(driver, def, flags);
-+    return qemuDomainDefFormatXMLInternal(driver, def, origCPU, flags);
- }
- 
- 
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 0c5dad60e1..9567458849 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -515,6 +515,7 @@ char *qemuDomainFormatXML(virQEMUDriverPtr driver,
- 
- char *qemuDomainDefFormatLive(virQEMUDriverPtr driver,
-                               virDomainDefPtr def,
-+                              virCPUDefPtr origCPU,
-                               bool inactive,
-                               bool compatible);
- 
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index dbb1ea9475..f5c5c302be 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -3330,9 +3330,9 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-             virDomainDefFree(def);
-             goto endjob;
-         }
--        xml = qemuDomainDefFormatLive(driver, def, true, true);
-+        xml = qemuDomainDefFormatLive(driver, def, NULL, true, true);
-     } else {
--        xml = qemuDomainDefFormatLive(driver, vm->def, true, true);
-+        xml = qemuDomainDefFormatLive(driver, vm->def, priv->origCPU, true, true);
-     }
-     if (!xml) {
-         virReportError(VIR_ERR_OPERATION_FAILED,
-@@ -14512,7 +14512,8 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
-                                                     "snapshot", false)) < 0)
-             goto cleanup;
- 
--        if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)) ||
-+        if (!(xml = qemuDomainDefFormatLive(driver, vm->def, priv->origCPU,
-+                                            true, true)) ||
-             !(snap->def->cookie = (virObjectPtr) qemuDomainSaveCookieNew(vm)))
-             goto cleanup;
- 
-@@ -14623,6 +14624,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
-     bool align_match = true;
-     virQEMUDriverConfigPtr cfg = NULL;
-     virCapsPtr caps = NULL;
-+    qemuDomainObjPrivatePtr priv;
- 
-     virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE |
-                   VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT |
-@@ -14740,6 +14742,8 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
- 
-     qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
- 
-+    priv = vm->privateData;
-+
-     if (redefine) {
-         if (virDomainSnapshotRedefinePrep(domain, vm, &def, &snap,
-                                           driver->xmlopt,
-@@ -14748,7 +14752,8 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
-     } else {
-         /* Easiest way to clone inactive portion of vm->def is via
-          * conversion in and back out of xml.  */
--        if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)) ||
-+        if (!(xml = qemuDomainDefFormatLive(driver, vm->def, priv->origCPU,
-+                                            true, true)) ||
-             !(def->dom = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
-                                                  VIR_DOMAIN_DEF_PARSE_INACTIVE |
-                                                  VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 5bf9bd10f7..ec5af7a612 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -2028,9 +2028,10 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
-         if (!qemuDomainDefCheckABIStability(driver, vm->def, def))
-             goto cleanup;
- 
--        rv = qemuDomainDefFormatLive(driver, def, false, true);
-+        rv = qemuDomainDefFormatLive(driver, def, NULL, false, true);
-     } else {
--        rv = qemuDomainDefFormatLive(driver, vm->def, false, true);
-+        rv = qemuDomainDefFormatLive(driver, vm->def, priv->origCPU,
-+                                     false, true);
-     }
- 
-  cleanup:
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Require-QEMU_CAPS_DEVICE_ISA_SERIAL-for-isa-serial.patch b/SOURCES/libvirt-qemu-Require-QEMU_CAPS_DEVICE_ISA_SERIAL-for-isa-serial.patch
new file mode 100644
index 0000000..bcf7fe2
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Require-QEMU_CAPS_DEVICE_ISA_SERIAL-for-isa-serial.patch
@@ -0,0 +1,200 @@
+From 4ab9c0ceda884c08553ebca52ab24a9de0971251 Mon Sep 17 00:00:00 2001
+Message-Id: <4ab9c0ceda884c08553ebca52ab24a9de0971251@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:18 +0100
+Subject: [PATCH] qemu: Require QEMU_CAPS_DEVICE_ISA_SERIAL for isa-serial
+
+We should make sure the isa-serial device is available before
+formatting it on the QEMU command line.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit b9be657b6807ddab3d4872723f4d5e53f8f49b01)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c  |  7 +++----
+ tests/qemuxml2argvtest.c | 29 +++++++++++++++++++++++++++--
+ 2 files changed, 30 insertions(+), 6 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index a2cfb3d4a3..5c246698c0 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9223,6 +9223,8 @@ static virQEMUCapsFlags
+ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel)
+ {
+     switch (targetModel) {
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
++        return QEMU_CAPS_DEVICE_ISA_SERIAL;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
+         return QEMU_CAPS_DEVICE_USB_SERIAL;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
+@@ -9233,7 +9235,6 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel)
+         return QEMU_CAPS_DEVICE_SCLPCONSOLE;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
+         return QEMU_CAPS_DEVICE_SCLPLMCONSOLE;
+-    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+@@ -10356,6 +10357,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+     virQEMUCapsFlags caps;
+ 
+     switch ((virDomainChrSerialTargetModel) serial->targetModel) {
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
+@@ -10372,9 +10374,6 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
+         }
+         break;
+ 
+-    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+-        break;
+-
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 852525e7b4..b61cee74c7 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -771,6 +771,7 @@ mymain(void)
+     DO_TEST_FAILURE("reboot-timeout-enabled", NONE);
+ 
+     DO_TEST("bios",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_SGA);
+     DO_TEST("bios-nvram", NONE);
+     DO_TEST("bios-nvram-secure",
+@@ -814,6 +815,7 @@ mymain(void)
+             QEMU_CAPS_SPICE,
+             QEMU_CAPS_HDA_DUPLEX,
+             QEMU_CAPS_USB_HUB,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_DEVICE_CIRRUS_VGA);
+     DO_TEST("eoi-disabled", NONE);
+     DO_TEST("eoi-enabled", NONE);
+@@ -1231,48 +1233,64 @@ mymain(void)
+ 
+     DO_TEST("serial-file-log",
+             QEMU_CAPS_CHARDEV_FILE_APPEND,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_CHARDEV_LOGFILE);
+     DO_TEST("serial-spiceport",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
+             QEMU_CAPS_DEVICE_QXL,
+             QEMU_CAPS_SPICE,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_CHARDEV_SPICEPORT);
+     DO_TEST("serial-spiceport-nospice", NONE);
+ 
+-    DO_TEST("console-compat", NONE);
+-    DO_TEST("console-compat-auto", NONE);
++    DO_TEST("console-compat",
++            QEMU_CAPS_DEVICE_ISA_SERIAL);
++    DO_TEST("console-compat-auto",
++            QEMU_CAPS_DEVICE_ISA_SERIAL);
+ 
+     DO_TEST("serial-vc-chardev",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("serial-pty-chardev",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("serial-dev-chardev",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("serial-dev-chardev-iobase",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("serial-file-chardev",
+             QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_CHARDEV_FILE_APPEND);
+     DO_TEST("serial-unix-chardev",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("serial-tcp-chardev",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("serial-udp-chardev",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("serial-tcp-telnet-chardev",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     driver.config->chardevTLS = 1;
+     DO_TEST("serial-tcp-tlsx509-chardev",
+             QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_OBJECT_TLS_CREDS_X509);
+     driver.config->chardevTLSx509verify = 1;
+     DO_TEST("serial-tcp-tlsx509-chardev-verify",
+             QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_OBJECT_TLS_CREDS_X509);
+     driver.config->chardevTLSx509verify = 0;
+     DO_TEST("serial-tcp-tlsx509-chardev-notls",
+             QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_OBJECT_TLS_CREDS_X509);
+     VIR_FREE(driver.config->chardevTLSx509certdir);
+     if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/libvirt-chardev") < 0)
+@@ -1284,22 +1302,26 @@ mymain(void)
+     DO_TEST("serial-tcp-tlsx509-secret-chardev",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_OBJECT_SECRET,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_OBJECT_TLS_CREDS_X509);
+ # else
+     DO_TEST_FAILURE("serial-tcp-tlsx509-secret-chardev",
+                     QEMU_CAPS_NODEFCONFIG,
+                     QEMU_CAPS_OBJECT_SECRET,
++                    QEMU_CAPS_DEVICE_ISA_SERIAL,
+                     QEMU_CAPS_OBJECT_TLS_CREDS_X509);
+ # endif
+     driver.config->chardevTLS = 0;
+     VIR_FREE(driver.config->chardevTLSx509certdir);
+     DO_TEST("serial-many-chardev",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("parallel-tcp-chardev",
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("parallel-parport-chardev",
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("console-compat-chardev",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("pci-serial-dev-chardev",
+             QEMU_CAPS_NODEFCONFIG,
+@@ -1320,6 +1342,7 @@ mymain(void)
+     DO_TEST("console-virtio",
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("console-virtio-many",
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("console-virtio-s390",
+             QEMU_CAPS_NODEFCONFIG,
+@@ -2310,6 +2333,7 @@ mymain(void)
+             QEMU_CAPS_CHARDEV_SPICEVMC,
+             QEMU_CAPS_DEVICE_QXL,
+             QEMU_CAPS_HDA_DUPLEX,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_USB_REDIR);
+ 
+     /* Test automatic and manual setting of pcie-root-port attributes */
+@@ -2907,6 +2931,7 @@ mymain(void)
+     DO_TEST("user-aliases", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_CIRRUS_VGA,
+             QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_PIIX_DISABLE_S3,
+             QEMU_CAPS_PIIX_DISABLE_S4, QEMU_CAPS_VNC,
++            QEMU_CAPS_DEVICE_ISA_SERIAL,
+             QEMU_CAPS_HDA_DUPLEX);
+     DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Require-QEMU_CAPS_DEVICE_PL011-for-pl011.patch b/SOURCES/libvirt-qemu-Require-QEMU_CAPS_DEVICE_PL011-for-pl011.patch
new file mode 100644
index 0000000..229de3a
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Require-QEMU_CAPS_DEVICE_PL011-for-pl011.patch
@@ -0,0 +1,118 @@
+From ae52a7777eae5936c68ffef6f84280adae80703b Mon Sep 17 00:00:00 2001
+Message-Id: <ae52a7777eae5936c68ffef6f84280adae80703b@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:20 +0100
+Subject: [PATCH] qemu: Require QEMU_CAPS_DEVICE_PL011 for pl011
+
+Even though we never format the device on the QEMU command line,
+as it's a platform serial device that's not user-instantiable,
+we should still make sure it's available before using it.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit b2fb483c34390b4c5eeff0304712cea0ace21d88)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c  | 12 ++++++++++++
+ tests/qemuxml2argvtest.c |  9 +++++++++
+ 2 files changed, 21 insertions(+)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 5c246698c0..18977480d9 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9236,6 +9236,7 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel)
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
+         return QEMU_CAPS_DEVICE_SCLPLMCONSOLE;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
++        return QEMU_CAPS_DEVICE_PL011;
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+         break;
+@@ -9328,6 +9329,17 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager,
+             if (qemuBuildChrDeviceCommandLine(cmd, def, serial, qemuCaps) < 0)
+                 return -1;
+         } else {
++            virQEMUCapsFlags caps;
++
++            caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
++
++            if (caps && !virQEMUCapsGet(qemuCaps, caps)) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                               _("'%s' is not supported in this QEMU binary"),
++                               virDomainChrSerialTargetModelTypeToString(serial->targetModel));
++                return -1;
++            }
++
+             virCommandAddArg(cmd, "-serial");
+             virCommandAddArgFormat(cmd, "chardev:char%s", serial->info.alias);
+         }
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index b61cee74c7..77c9783929 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -1922,10 +1922,13 @@ mymain(void)
+     DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);
+ 
+     DO_TEST("mach-virt-serial-native",
++            QEMU_CAPS_DEVICE_PL011,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("mach-virt-serial+console-native",
++            QEMU_CAPS_DEVICE_PL011,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("mach-virt-serial-compat",
++            QEMU_CAPS_DEVICE_PL011,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("mach-virt-serial-pci",
+             QEMU_CAPS_NODEFCONFIG,
+@@ -1943,6 +1946,7 @@ mymain(void)
+             QEMU_CAPS_DEVICE_QEMU_XHCI,
+             QEMU_CAPS_DEVICE_USB_SERIAL);
+     DO_TEST("mach-virt-console-native",
++            QEMU_CAPS_DEVICE_PL011,
+             QEMU_CAPS_NODEFCONFIG);
+     DO_TEST("mach-virt-console-virtio",
+             QEMU_CAPS_NODEFCONFIG);
+@@ -2492,11 +2496,13 @@ mymain(void)
+     DO_TEST("arm-virt-virtio",
+             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
+             QEMU_CAPS_DEVICE_VIRTIO_MMIO,
++            QEMU_CAPS_DEVICE_PL011,
+             QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
+ 
+     DO_TEST("aarch64-virt-virtio",
+             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
+             QEMU_CAPS_DEVICE_VIRTIO_MMIO,
++            QEMU_CAPS_DEVICE_PL011,
+             QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
+ 
+     /* Demonstrates the virtio-pci default... namely that there isn't any!
+@@ -2512,6 +2518,7 @@ mymain(void)
+             QEMU_CAPS_PCI_MULTIFUNCTION,
+             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+             QEMU_CAPS_DEVICE_IOH3420,
++            QEMU_CAPS_DEVICE_PL011,
+             QEMU_CAPS_VIRTIO_SCSI);
+     DO_TEST("aarch64-virt-2.6-virtio-pci-default",
+             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
+@@ -2520,6 +2527,7 @@ mymain(void)
+             QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
+             QEMU_CAPS_PCI_MULTIFUNCTION,
+             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
++            QEMU_CAPS_DEVICE_PL011,
+             QEMU_CAPS_DEVICE_IOH3420);
+     /* Example of using virtio-pci with no explicit PCI controller
+        but with manual PCI addresses */
+@@ -2638,6 +2646,7 @@ mymain(void)
+             QEMU_CAPS_MACH_VIRT_GIC_VERSION);
+     DO_TEST("aarch64-kvm-32-on-64",
+             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
++            QEMU_CAPS_DEVICE_PL011,
+             QEMU_CAPS_KVM, QEMU_CAPS_CPU_AARCH64_OFF);
+     DO_TEST_FAILURE("aarch64-kvm-32-on-64",
+             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Restore-machinename-even-without-cgroups.patch b/SOURCES/libvirt-qemu-Restore-machinename-even-without-cgroups.patch
new file mode 100644
index 0000000..b74bef2
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Restore-machinename-even-without-cgroups.patch
@@ -0,0 +1,53 @@
+From 50bfc7b26b1a45d34ff8f62febbd59d6be9fb02c Mon Sep 17 00:00:00 2001
+Message-Id: <50bfc7b26b1a45d34ff8f62febbd59d6be9fb02c@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:43 +0100
+Subject: [PATCH] qemu: Restore machinename even without cgroups
+
+The virresctrl will use this as well and we need to have that info after restart
+to properly clean up /sys/fs/resctrl.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 272649a1d7b4c6a9f5c355a3b3e2a49b748e0f4d)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/qemu/qemu_cgroup.c  | 4 ----
+ src/qemu/qemu_process.c | 4 ++++
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
+index 19252ea239..41e27c21e2 100644
+--- a/src/qemu/qemu_cgroup.c
++++ b/src/qemu/qemu_cgroup.c
+@@ -986,10 +986,6 @@ qemuConnectCgroup(virDomainObjPtr vm)
+     if (!virCgroupAvailable())
+         goto done;
+ 
+-    priv->machineName = qemuDomainGetMachineName(vm);
+-    if (!priv->machineName)
+-            goto cleanup;
+-
+     virCgroupFree(&priv->cgroup);
+ 
+     if (virCgroupNewDetectMachine(vm->def->name,
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index 29a8d8ba53..08081aa278 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -7194,6 +7194,10 @@ qemuProcessReconnect(void *opaque)
+     if (qemuHostdevUpdateActiveDomainDevices(driver, obj->def) < 0)
+         goto error;
+ 
++    priv->machineName = qemuDomainGetMachineName(obj);
++    if (!priv->machineName)
++        goto error;
++
+     if (qemuConnectCgroup(obj) < 0)
+         goto error;
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-Restore-resctrl-alloc-data-after-restart.patch b/SOURCES/libvirt-qemu-Restore-resctrl-alloc-data-after-restart.patch
new file mode 100644
index 0000000..eea1058
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Restore-resctrl-alloc-data-after-restart.patch
@@ -0,0 +1,47 @@
+From 120967192737301cd93c597ca06824e2f951b658 Mon Sep 17 00:00:00 2001
+Message-Id: <120967192737301cd93c597ca06824e2f951b658@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:45 +0100
+Subject: [PATCH] qemu: Restore resctrl alloc data after restart
+
+During reconnect we need to reconstruct the paths of all cachetunes so that they
+get cleaned up when the domain is stopped.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 6c44013b174d676c37e86fc884bd933cf8f982fa)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/qemu/qemu_process.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index 08081aa278..3bb4b14948 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -77,6 +77,7 @@
+ #include "configmake.h"
+ #include "nwfilter_conf.h"
+ #include "netdev_bandwidth_conf.h"
++#include "virresctrl.h"
+ 
+ #define VIR_FROM_THIS VIR_FROM_QEMU
+ 
+@@ -7328,6 +7329,12 @@ qemuProcessReconnect(void *opaque)
+     if (qemuConnectAgent(driver, obj) < 0)
+         goto error;
+ 
++    for (i = 0; i < obj->def->ncachetunes; i++) {
++        if (virResctrlAllocDeterminePath(obj->def->cachetunes[i]->alloc,
++                                         priv->machineName) < 0)
++            goto error;
++    }
++
+     /* update domain state XML with possibly updated state in virDomainObj */
+     if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, obj, driver->caps) < 0)
+         goto error;
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-Send-updated-CPU-in-migration-cookie.patch b/SOURCES/libvirt-qemu-Send-updated-CPU-in-migration-cookie.patch
deleted file mode 100644
index 9e25bdf..0000000
--- a/SOURCES/libvirt-qemu-Send-updated-CPU-in-migration-cookie.patch
+++ /dev/null
@@ -1,157 +0,0 @@
-From f33ea433e58c5fbd356d4085446a64f8a67496e5 Mon Sep 17 00:00:00 2001
-Message-Id: <f33ea433e58c5fbd356d4085446a64f8a67496e5@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 26 May 2017 17:06:56 +0200
-Subject: [PATCH] qemu: Send updated CPU in migration cookie
-
-Since the domain XML send during migration uses the original guest CPU
-definition but we still want the destination to enforce ABI if it is new
-enough, we send the live updated CPU definition in a migration cookie.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 48bc3053b8f2bfa3adc93d3c316d48d0f482cde4)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c        |  6 +++++-
- src/qemu/qemu_migration_cookie.c | 31 ++++++++++++++++++++++++++++++-
- src/qemu/qemu_migration_cookie.h |  5 +++++
- 3 files changed, 40 insertions(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index a7c90a09e8..c03f1be575 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -1989,6 +1989,9 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
-          vm->newDef && !qemuDomainVcpuHotplugIsInOrder(vm->newDef)))
-         cookieFlags |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG;
- 
-+    if (priv->origCPU)
-+        cookieFlags |= QEMU_MIGRATION_COOKIE_CPU;
-+
-     if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))
-         goto cleanup;
- 
-@@ -2613,7 +2616,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
-                                        QEMU_MIGRATION_COOKIE_LOCKSTATE |
-                                        QEMU_MIGRATION_COOKIE_NBD |
-                                        QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG |
--                                       QEMU_MIGRATION_COOKIE_CPU_HOTPLUG)))
-+                                       QEMU_MIGRATION_COOKIE_CPU_HOTPLUG |
-+                                       QEMU_MIGRATION_COOKIE_CPU)))
-         goto cleanup;
- 
-     if (STREQ_NULLABLE(protocol, "rdma") &&
-diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
-index 559b1f0c15..af0ac03418 100644
---- a/src/qemu/qemu_migration_cookie.c
-+++ b/src/qemu/qemu_migration_cookie.c
-@@ -48,7 +48,8 @@ VIR_ENUM_IMPL(qemuMigrationCookieFlag,
-               "nbd",
-               "statistics",
-               "memory-hotplug",
--              "cpu-hotplug");
-+              "cpu-hotplug",
-+              "cpu");
- 
- 
- static void
-@@ -109,6 +110,7 @@ qemuMigrationCookieFree(qemuMigrationCookiePtr mig)
-     VIR_FREE(mig->lockState);
-     VIR_FREE(mig->lockDriver);
-     VIR_FREE(mig->jobInfo);
-+    virCPUDefFree(mig->cpu);
-     VIR_FREE(mig);
- }
- 
-@@ -519,6 +521,22 @@ qemuMigrationCookieAddStatistics(qemuMigrationCookiePtr mig,
- }
- 
- 
-+static int
-+qemuMigrationCookieAddCPU(qemuMigrationCookiePtr mig,
-+                          virDomainObjPtr vm)
-+{
-+    if (mig->cpu)
-+        return 0;
-+
-+    if (!(mig->cpu = virCPUDefCopy(vm->def->cpu)))
-+        return -1;
-+
-+    mig->flags |= QEMU_MIGRATION_COOKIE_CPU;
-+
-+    return 0;
-+}
-+
-+
- static void
- qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf,
-                                      qemuMigrationCookieGraphicsPtr grap)
-@@ -755,6 +773,9 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver,
-     if (mig->flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo)
-         qemuMigrationCookieStatisticsXMLFormat(buf, mig->jobInfo);
- 
-+    if (mig->flags & QEMU_MIGRATION_COOKIE_CPU && mig->cpu)
-+        virCPUDefFormatBufFull(buf, mig->cpu, NULL, false);
-+
-     virBufferAdjustIndent(buf, -2);
-     virBufferAddLit(buf, "</qemu-migration>\n");
-     return 0;
-@@ -1198,6 +1219,10 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
-         (!(mig->jobInfo = qemuMigrationCookieStatisticsXMLParse(ctxt))))
-         goto error;
- 
-+    if (flags & QEMU_MIGRATION_COOKIE_CPU &&
-+        virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &mig->cpu) < 0)
-+        goto error;
-+
-     virObjectUnref(caps);
-     return 0;
- 
-@@ -1274,6 +1299,10 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
-     if (flags & QEMU_MIGRATION_COOKIE_CPU_HOTPLUG)
-         mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG;
- 
-+    if (flags & QEMU_MIGRATION_COOKIE_CPU &&
-+        qemuMigrationCookieAddCPU(mig, dom) < 0)
-+        return -1;
-+
-     if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
-         return -1;
- 
-diff --git a/src/qemu/qemu_migration_cookie.h b/src/qemu/qemu_migration_cookie.h
-index b009d5bf5d..e5f3d75a95 100644
---- a/src/qemu/qemu_migration_cookie.h
-+++ b/src/qemu/qemu_migration_cookie.h
-@@ -28,6 +28,7 @@ typedef enum {
-     QEMU_MIGRATION_COOKIE_FLAG_STATS,
-     QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG,
-     QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG,
-+    QEMU_MIGRATION_COOKIE_FLAG_CPU,
- 
-     QEMU_MIGRATION_COOKIE_FLAG_LAST
- } qemuMigrationCookieFlags;
-@@ -43,6 +44,7 @@ typedef enum {
-     QEMU_MIGRATION_COOKIE_STATS = (1 << QEMU_MIGRATION_COOKIE_FLAG_STATS),
-     QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG),
-     QEMU_MIGRATION_COOKIE_CPU_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG),
-+    QEMU_MIGRATION_COOKIE_CPU = (1 << QEMU_MIGRATION_COOKIE_FLAG_CPU),
- } qemuMigrationCookieFeatures;
- 
- typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
-@@ -122,6 +124,9 @@ struct _qemuMigrationCookie {
- 
-     /* If (flags & QEMU_MIGRATION_COOKIE_STATS) */
-     qemuDomainJobInfoPtr jobInfo;
-+
-+    /* If flags & QEMU_MIGRATION_COOKIE_CPU */
-+    virCPUDefPtr cpu;
- };
- 
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Separate-CPU-updating-code-from-qemuProcessReconnect.patch b/SOURCES/libvirt-qemu-Separate-CPU-updating-code-from-qemuProcessReconnect.patch
deleted file mode 100644
index 0d1fd37..0000000
--- a/SOURCES/libvirt-qemu-Separate-CPU-updating-code-from-qemuProcessReconnect.patch
+++ /dev/null
@@ -1,108 +0,0 @@
-From 24d641eb1f8cf8b90e1276426c5e7889b7324807 Mon Sep 17 00:00:00 2001
-Message-Id: <24d641eb1f8cf8b90e1276426c5e7889b7324807@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 6 Oct 2017 12:57:15 +0200
-Subject: [PATCH] qemu: Separate CPU updating code from qemuProcessReconnect
-
-The new function is called qemuProcessRefreshCPU.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 4b87b3675ffd7794542de70da4391f3787ed76a2)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1508549
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 68 ++++++++++++++++++++++++++++++++-----------------
- 1 file changed, 45 insertions(+), 23 deletions(-)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 8fe9ef36d7..4a8c4421a3 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -6662,6 +6662,49 @@ qemuProcessRefreshDisks(virQEMUDriverPtr driver,
- }
- 
- 
-+static int
-+qemuProcessRefreshCPU(virQEMUDriverPtr driver,
-+                      virDomainObjPtr vm)
-+{
-+    virCapsPtr caps = virQEMUDriverGetCapabilities(driver, false);
-+    virCPUDefPtr host = NULL;
-+    int ret = -1;
-+
-+    if (!caps)
-+        return -1;
-+
-+    if (!virQEMUCapsGuestIsNative(caps->host.arch, vm->def->os.arch) ||
-+        !caps->host.cpu ||
-+        !vm->def->cpu) {
-+        ret = 0;
-+        goto cleanup;
-+    }
-+
-+    /* If the domain with a host-model CPU was started by an old libvirt
-+     * (< 2.3) which didn't replace the CPU with a custom one, let's do it now
-+     * since the rest of our code does not really expect a host-model CPU in a
-+     * running domain.
-+     */
-+    if (vm->def->cpu->mode == VIR_CPU_MODE_HOST_MODEL) {
-+        if (!(host = virCPUCopyMigratable(caps->host.cpu->arch, caps->host.cpu)))
-+            goto cleanup;
-+
-+        if (virCPUUpdate(vm->def->os.arch, vm->def->cpu, host) < 0)
-+            goto cleanup;
-+
-+        if (qemuProcessUpdateCPU(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
-+            goto cleanup;
-+    }
-+
-+    ret = 0;
-+
-+ cleanup:
-+    virCPUDefFree(host);
-+    virObjectUnref(caps);
-+    return ret;
-+}
-+
-+
- struct qemuProcessReconnectData {
-     virConnectPtr conn;
-     virQEMUDriverPtr driver;
-@@ -6820,29 +6863,8 @@ qemuProcessReconnect(void *opaque)
-     ignore_value(qemuSecurityCheckAllLabel(driver->securityManager,
-                                            obj->def));
- 
--    /* If the domain with a host-model CPU was started by an old libvirt
--     * (< 2.3) which didn't replace the CPU with a custom one, let's do it now
--     * since the rest of our code does not really expect a host-model CPU in a
--     * running domain.
--     */
--    if (virQEMUCapsGuestIsNative(caps->host.arch, obj->def->os.arch) &&
--        caps->host.cpu &&
--        obj->def->cpu &&
--        obj->def->cpu->mode == VIR_CPU_MODE_HOST_MODEL) {
--        virCPUDefPtr host;
--
--        if (!(host = virCPUCopyMigratable(caps->host.cpu->arch, caps->host.cpu)))
--            goto error;
--
--        if (virCPUUpdate(obj->def->os.arch, obj->def->cpu, host) < 0) {
--            virCPUDefFree(host);
--            goto error;
--        }
--        virCPUDefFree(host);
--
--        if (qemuProcessUpdateCPU(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
--            goto error;
--    }
-+    if (qemuProcessRefreshCPU(driver, obj) < 0)
-+        goto error;
- 
-     if (qemuDomainRefreshVcpuInfo(driver, obj, QEMU_ASYNC_JOB_NONE, true) < 0)
-         goto error;
--- 
-2.15.0
-
diff --git a/SOURCES/libvirt-qemu-Separate-fetching-CPU-definitions-from-filling-qemuCaps.patch b/SOURCES/libvirt-qemu-Separate-fetching-CPU-definitions-from-filling-qemuCaps.patch
new file mode 100644
index 0000000..ba3f3e1
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Separate-fetching-CPU-definitions-from-filling-qemuCaps.patch
@@ -0,0 +1,126 @@
+From bc3c538ac7b184edea12e1377ec7cdce1d7bb9d2 Mon Sep 17 00:00:00 2001
+Message-Id: <bc3c538ac7b184edea12e1377ec7cdce1d7bb9d2@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Thu, 7 Dec 2017 11:21:48 +0100
+Subject: [PATCH] qemu: Separate fetching CPU definitions from filling qemuCaps
+
+virQEMUCapsProbeQMPCPUDefinitions is now a small wrapper which fills in
+qemuCaps with CPU models fetched by virQEMUCapsFetchCPUDefinitions.
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+(cherry picked from commit 4486dcdb4a386a906807d4eb7de586202e50cd18)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1521202
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c | 59 +++++++++++++++++++++++++++-----------------
+ src/qemu/qemu_capabilities.h |  1 +
+ 2 files changed, 38 insertions(+), 22 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 4301d2e799..4af1b6c662 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -2956,30 +2956,19 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
+ }
+ 
+ 
+-int
+-virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
+-                                  qemuMonitorPtr mon,
+-                                  bool tcg)
++virDomainCapsCPUModelsPtr
++virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon)
+ {
+-    virDomainCapsCPUModelsPtr models;
+-    qemuMonitorCPUDefInfoPtr *cpus;
+-    int ncpus;
+-    int ret = -1;
++    virDomainCapsCPUModelsPtr models = NULL;
++    qemuMonitorCPUDefInfoPtr *cpus = NULL;
++    int ncpus = 0;
+     size_t i;
+ 
+-    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS))
+-        return 0;
+-
+     if ((ncpus = qemuMonitorGetCPUDefinitions(mon, &cpus)) < 0)
+-        return -1;
++        goto error;
+ 
+     if (!(models = virDomainCapsCPUModelsNew(ncpus)))
+-        goto cleanup;
+-
+-    if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
+-        qemuCaps->tcgCPUModels = models;
+-    else
+-        qemuCaps->kvmCPUModels = models;
++        goto error;
+ 
+     for (i = 0; i < ncpus; i++) {
+         virDomainCapsCPUUsable usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
+@@ -2991,18 +2980,44 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
+ 
+         if (virDomainCapsCPUModelsAddSteal(models, &cpus[i]->name, usable,
+                                            &cpus[i]->blockers) < 0)
+-            goto cleanup;
++            goto error;
+     }
+ 
+-    ret = 0;
+-
+  cleanup:
+     for (i = 0; i < ncpus; i++)
+         qemuMonitorCPUDefInfoFree(cpus[i]);
+     VIR_FREE(cpus);
+-    return ret;
++    return models;
++
++ error:
++    virObjectUnref(models);
++    models = NULL;
++    goto cleanup;
+ }
+ 
++
++int
++virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
++                                  qemuMonitorPtr mon,
++                                  bool tcg)
++{
++    virDomainCapsCPUModelsPtr models = NULL;
++
++    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS))
++        return 0;
++
++    if (!(models = virQEMUCapsFetchCPUDefinitions(mon)))
++        return -1;
++
++    if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
++        qemuCaps->tcgCPUModels = models;
++    else
++        qemuCaps->kvmCPUModels = models;
++
++    return 0;
++}
++
++
+ static int
+ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
+                            qemuMonitorPtr mon,
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index c6eb9df146..0fb2a10a17 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -485,6 +485,7 @@ int virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps,
+                                  virDomainCapsCPUUsable usable);
+ virDomainCapsCPUModelsPtr virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
+                                                        virDomainVirtType type);
++virDomainCapsCPUModelsPtr virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon);
+ 
+ typedef enum {
+     /* Host CPU definition reported in domain capabilities. */
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Set-alias-for-memory-cell-in-qemuBuildMemoryCellBackendStr.patch b/SOURCES/libvirt-qemu-Set-alias-for-memory-cell-in-qemuBuildMemoryCellBackendStr.patch
new file mode 100644
index 0000000..37df1f5
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Set-alias-for-memory-cell-in-qemuBuildMemoryCellBackendStr.patch
@@ -0,0 +1,47 @@
+From 5d839559bfdaf17dd1c550eb451c64fcac7079b3 Mon Sep 17 00:00:00 2001
+Message-Id: <5d839559bfdaf17dd1c550eb451c64fcac7079b3@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Thu, 9 Nov 2017 16:06:44 +0100
+Subject: [PATCH] qemu: Set alias for memory cell in
+ qemuBuildMemoryCellBackendStr
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1461214
+
+Very soon qemuBuildMemoryBackendStr() is going to use memory cell
+aliases. Therefore set one. At the same time, move it a bit
+further - if virAsprintf() fails, there's no point in setting
+rest of the members.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit d52e6043bc5b19484ce5489345f9b9be61d95c1c)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 9f346c3649..57c855c047 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -3542,12 +3542,13 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
+     unsigned long long memsize = virDomainNumaGetNodeMemorySize(def->numa,
+                                                                 cell);
+ 
++    if (virAsprintf(&alias, "ram-node%zu", cell) < 0)
++        goto cleanup;
++
+     *backendStr = NULL;
+     mem.size = memsize;
+     mem.targetNode = cell;
+-
+-    if (virAsprintf(&alias, "ram-node%zu", cell) < 0)
+-        goto cleanup;
++    mem.info.alias = alias;
+ 
+     if ((rc = qemuBuildMemoryBackendStr(&props, &backendType, cfg, priv->qemuCaps,
+                                         def, &mem, priv->autoNodeset, false)) < 0)
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Set-iface-MTU-on-hotplug.patch b/SOURCES/libvirt-qemu-Set-iface-MTU-on-hotplug.patch
deleted file mode 100644
index 1a75bf1..0000000
--- a/SOURCES/libvirt-qemu-Set-iface-MTU-on-hotplug.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 0ae37bb09bc282c6bca9e425990685cef6a9b1b6 Mon Sep 17 00:00:00 2001
-Message-Id: <0ae37bb09bc282c6bca9e425990685cef6a9b1b6@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Thu, 8 Jun 2017 16:58:35 +0200
-Subject: [PATCH] qemu: Set iface MTU on hotplug
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1408701
-
-While implementing MTU (572eda12ad and friends), I've forgotten
-to actually set MTU on the host NIC in case of hotplug. We
-correctly tell qemu on the monitor what the MTU should be, but we
-are not actually setting it on the host NIC.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Reviewed-by: Laine Stump <laine@laine.org>
-(cherry picked from commit f00e6f8bc9081f158b7d6a1dcfa82218b1dbfb4d)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_hotplug.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index 094a5644e0..ab23a575d8 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -1134,6 +1134,10 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
-         }
-     }
- 
-+    if (net->mtu &&
-+        virNetDevSetMTU(net->ifname, net->mtu) < 0)
-+        goto cleanup;
-+
-     for (i = 0; i < tapfdSize; i++) {
-         if (qemuSecuritySetTapFDLabel(driver->securityManager,
-                                       vm->def, tapfd[i]) < 0)
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Set-operation-on-completed-migration-job.patch b/SOURCES/libvirt-qemu-Set-operation-on-completed-migration-job.patch
deleted file mode 100644
index 1a63330..0000000
--- a/SOURCES/libvirt-qemu-Set-operation-on-completed-migration-job.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From 3a9924b5ea76945b0df16cd21fd0acbb6fe152fc Mon Sep 17 00:00:00 2001
-Message-Id: <3a9924b5ea76945b0df16cd21fd0acbb6fe152fc@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 31 May 2017 10:08:28 +0200
-Subject: [PATCH] qemu: Set operation on completed migration job
-
-Without this patch libvirt would just report the operation of a
-completed job as "unknown" instead of "incoming migration".
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1457052
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 49d30bc2e292785bf2edc121c12bc5c10264d1d4)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration_cookie.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
-index 12887892db..559b1f0c15 100644
---- a/src/qemu/qemu_migration_cookie.c
-+++ b/src/qemu/qemu_migration_cookie.c
-@@ -1292,6 +1292,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
-                        int cookieinlen,
-                        unsigned int flags)
- {
-+    qemuDomainObjPrivatePtr priv = dom->privateData;
-     qemuMigrationCookiePtr mig = NULL;
- 
-     /* Parse & validate incoming cookie (if any) */
-@@ -1340,6 +1341,9 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
-         }
-     }
- 
-+    if (flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo)
-+        mig->jobInfo->operation = priv->job.current->operation;
-+
-     return mig;
- 
-  error:
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Set-targetModel-based-on-targetType-for-serial-devices.patch b/SOURCES/libvirt-qemu-Set-targetModel-based-on-targetType-for-serial-devices.patch
new file mode 100644
index 0000000..3bb64be
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Set-targetModel-based-on-targetType-for-serial-devices.patch
@@ -0,0 +1,820 @@
+From 09ae09618f6b4f7728b380ea1a9ee7f8ab681877 Mon Sep 17 00:00:00 2001
+Message-Id: <09ae09618f6b4f7728b380ea1a9ee7f8ab681877@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:08 +0100
+Subject: [PATCH] qemu: Set targetModel based on targetType for serial devices
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 72bf21f23357d2b3d37b4b1b5611d6a5f5dc663e)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c                               | 20 ++++++++++++++++++++
+ .../qemuargv2xmldata/qemuargv2xml-console-compat.xml |  4 +++-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml   |  4 +++-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml  |  4 +++-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml  |  8 ++++++--
+ tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml   |  4 +++-
+ .../qemuargv2xml-serial-tcp-telnet.xml               |  4 +++-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml   |  4 +++-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml   |  8 ++++++--
+ tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml  |  4 +++-
+ tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml    |  4 +++-
+ ...uhotplug-console-compat-2-live+console-virtio.xml | 12 +++++++++---
+ .../qemuhotplug-console-compat-2-live.xml            | 12 +++++++++---
+ ...qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml |  8 ++++++--
+ tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml |  8 ++++++--
+ .../qemuxml2xmlout-aarch64-pci-serial.xml            |  4 +++-
+ .../qemuxml2xmlout-bios-nvram-os-interleave.xml      |  4 +++-
+ .../qemuxml2xmlout-chardev-label.xml                 |  8 ++++++--
+ .../qemuxml2xmlout-console-compat-auto.xml           |  4 +++-
+ .../qemuxml2xmlout-console-compat.xml                |  4 +++-
+ .../qemuxml2xmlout-console-compat2.xml               |  4 +++-
+ .../qemuxml2xmlout-console-virtio-many.xml           |  4 +++-
+ .../qemuxml2xmlout-interface-driver.xml              |  4 +++-
+ .../qemuxml2xmlout-interface-server.xml              |  8 ++++++--
+ .../qemuxml2xmlout-net-bandwidth.xml                 |  4 +++-
+ .../qemuxml2xmlout-net-bandwidth2.xml                |  4 +++-
+ .../qemuxml2xmlout-net-coalesce.xml                  |  4 +++-
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml  |  4 +++-
+ .../qemuxml2xmlout-panic-pseries.xml                 |  4 +++-
+ .../qemuxml2xmlout-pci-serial-dev-chardev.xml        |  4 +++-
+ .../qemuxml2xmlout-pseries-cpu-compat-power9.xml     |  4 +++-
+ .../qemuxml2xmlout-pseries-cpu-compat.xml            |  4 +++-
+ .../qemuxml2xmlout-pseries-cpu-exact.xml             |  4 +++-
+ .../qemuxml2xmlout-pseries-panic-missing.xml         |  4 +++-
+ .../qemuxml2xmlout-pseries-panic-no-address.xml      |  4 +++-
+ .../qemuxml2xmlout-q35-virt-manager-basic.xml        |  4 +++-
+ .../qemuxml2xmlout-serial-spiceport-nospice.xml      |  4 +++-
+ .../qemuxml2xmlout-serial-spiceport.xml              |  4 +++-
+ .../qemuxml2xmlout-serial-target-port-auto.xml       | 12 +++++++++---
+ .../qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml    |  8 ++++++--
+ .../qemuxml2xmlout-tap-vhost-incorrect.xml           |  4 +++-
+ .../qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml  |  4 +++-
+ .../qemuxml2xmlout-vhost_queues.xml                  |  4 +++-
+ 43 files changed, 185 insertions(+), 55 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index bb25255b94..a8a91de2fe 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -4188,6 +4188,26 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
+         }
+     }
+ 
++    /* Set the default target model */
++    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
++        chr->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE) {
++        switch ((virDomainChrSerialTargetType) chr->targetType) {
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
++            chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL;
++            break;
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
++            chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL;
++            break;
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
++            chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL;
++            break;
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
++            /* Nothing to do */
++            break;
++        }
++    }
++
+     /* clear auto generated unix socket path for inactive definitions */
+     if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
+         if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0)
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml b/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml
+index 7c106f145c..cba43ca451 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml
+@@ -28,7 +28,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml
+index e76d0211dc..e9998d5542 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml
+@@ -29,7 +29,9 @@
+     </controller>
+     <serial type='dev'>
+       <source path='/dev/ttyS2'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='dev'>
+       <source path='/dev/ttyS2'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml
+index ed67ada0d8..0e9dfe5789 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml
+@@ -29,7 +29,9 @@
+     </controller>
+     <serial type='file'>
+       <source path='/tmp/serial.log'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='file'>
+       <source path='/tmp/serial.log'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml
+index 420771dc9c..05374b38da 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml
+@@ -28,11 +28,15 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <serial type='file'>
+       <source path='/tmp/serial.log'/>
+-      <target type='isa-serial' port='1'/>
++      <target type='isa-serial' port='1'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml
+index 7c106f145c..cba43ca451 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml
+@@ -28,7 +28,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml
+index 3fe61ffa05..1ac12440e2 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml
+@@ -30,7 +30,9 @@
+     <serial type='tcp'>
+       <source mode='bind' host='127.0.0.1' service='9999'/>
+       <protocol type='telnet'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='tcp'>
+       <source mode='bind' host='127.0.0.1' service='9999'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml
+index 3fc9fd39b0..c10cee903b 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml
+@@ -30,7 +30,9 @@
+     <serial type='tcp'>
+       <source mode='connect' host='127.0.0.1' service='9999'/>
+       <protocol type='raw'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='tcp'>
+       <source mode='connect' host='127.0.0.1' service='9999'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml
+index 5b4af3fe95..fd56dda84c 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml
+@@ -30,11 +30,15 @@
+     <serial type='udp'>
+       <source mode='bind' host='127.0.0.1' service='9999'/>
+       <source mode='connect' host='127.0.0.1' service='9998'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <serial type='udp'>
+       <source mode='connect' service='9999'/>
+-      <target type='isa-serial' port='1'/>
++      <target type='isa-serial' port='1'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='udp'>
+       <source mode='bind' host='127.0.0.1' service='9999'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml
+index 6bb291ff7f..70b192f671 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml
+@@ -29,7 +29,9 @@
+     </controller>
+     <serial type='unix'>
+       <source mode='connect' path='/tmp/serial.sock'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='unix'>
+       <source mode='connect' path='/tmp/serial.sock'/>
+diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml
+index 41954fc85d..630844ea0f 100644
+--- a/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml
++++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml
+@@ -28,7 +28,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+     </controller>
+     <serial type='vc'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='vc'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml
+index 427f431cce..abe68a0a07 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml
+@@ -68,17 +68,23 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+       <alias name='serial0'/>
+     </serial>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+       <alias name='serial1'/>
+     </serial>
+     <serial type='tcp'>
+       <source mode='bind' host='0.0.0.0' service='2445'/>
+       <protocol type='raw'/>
+-      <target type='isa-serial' port='1'/>
++      <target type='isa-serial' port='1'>
++        <model name='isa-serial'/>
++      </target>
+       <alias name='serial2'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml
+index 144f6eff7a..45161e1e2d 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml
+@@ -68,17 +68,23 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+       <alias name='serial0'/>
+     </serial>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+       <alias name='serial1'/>
+     </serial>
+     <serial type='tcp'>
+       <source mode='bind' host='0.0.0.0' service='2445'/>
+       <protocol type='raw'/>
+-      <target type='isa-serial' port='1'/>
++      <target type='isa-serial' port='1'>
++        <model name='isa-serial'/>
++      </target>
+       <alias name='serial2'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml
+index e6c4adb6f3..89dc9e6e1d 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml
++++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml
+@@ -29,12 +29,16 @@
+     <serial type='udp'>
+       <source mode='bind' host='127.0.0.1' service='1111'/>
+       <source mode='connect' host='127.0.0.1' service='2222'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <serial type='tcp'>
+       <source mode='connect' host='127.0.0.1' service='5555' tls='no'/>
+       <protocol type='raw'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='udp'>
+       <source mode='bind' host='127.0.0.1' service='1111'/>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
+index f9724d320e..52132a82d7 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
++++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
+@@ -110,10 +110,14 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <serial type='pty'>
+-      <target type='isa-serial' port='1'/>
++      <target type='isa-serial' port='1'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml
+index fddab31f07..b02a5a7db6 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml
+@@ -34,7 +34,9 @@
+     </controller>
+     <serial type='pty'>
+       <log file='/tmp/log' append='on'/>
+-      <target type='pci-serial' port='0'/>
++      <target type='pci-serial' port='0'>
++        <model name='pci-serial'/>
++      </target>
+       <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
+     </serial>
+   </devices>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml
+index 5ee73b527e..b6d7a66361 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml
+@@ -33,7 +33,9 @@
+     </controller>
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml
+index ad77f62d9e..7d5bbdd0ab 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml
+@@ -25,13 +25,17 @@
+       <source path='/tmp/serial.file'>
+         <seclabel model='dac' relabel='no'/>
+       </source>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <serial type='unix'>
+       <source mode='connect' path='/tmp/serial.sock'>
+         <seclabel model='dac' relabel='no'/>
+       </source>
+-      <target type='isa-serial' port='1'/>
++      <target type='isa-serial' port='1'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='file'>
+       <source path='/tmp/serial.file'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
+index cd9d75c4b7..267b253b15 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
+@@ -27,7 +27,9 @@
+     </controller>
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml
+index 0c0bd7b348..6a52800a33 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml
+@@ -28,7 +28,9 @@
+     </controller>
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml
+index 305c53eab7..8c7bbb768e 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml
+@@ -31,7 +31,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml
+index b38b3ce987..1a22b78b8c 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml
+@@ -30,7 +30,9 @@
+     </controller>
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml
+index 06192fbb4a..5be590e759 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml
+@@ -47,7 +47,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml
+index a6eaa38079..049b1472a8 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml
+@@ -104,10 +104,14 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <serial type='pty'>
+-      <target type='isa-serial' port='1'/>
++      <target type='isa-serial' port='1'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml
+index e6ad234240..4ec77d154f 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml
+@@ -55,7 +55,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml
+index 66448ec3dd..ee65c3a5b1 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml
+@@ -44,7 +44,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml
+index b1240b8ed1..56792b9999 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml
+@@ -57,7 +57,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml
+index 4f7ad323ed..fc7b2e39ae 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml
+@@ -54,7 +54,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
+index a563b6dddf..496df0696c 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
+@@ -22,7 +22,9 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml
+index 2f704cc0a1..8f77ef043a 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml
+@@ -28,7 +28,9 @@
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='dev'>
+       <source path='/dev/ttyS2'/>
+-      <target type='pci-serial' port='0'/>
++      <target type='pci-serial' port='0'>
++        <model name='pci-serial'/>
++      </target>
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+     </serial>
+     <console type='dev'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
+index 59587b3c32..9d4c5efe67 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
+@@ -25,7 +25,9 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
+index a39e1fd015..6059859abd 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
+@@ -25,7 +25,9 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
+index 666eede1a5..f3216523ed 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
+@@ -26,7 +26,9 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
+index a563b6dddf..496df0696c 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
+@@ -22,7 +22,9 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
+index a563b6dddf..496df0696c 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
+@@ -22,7 +22,9 @@
+       <target index='0'/>
+     </controller>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+       <address type='spapr-vio' reg='0x30000000'/>
+     </serial>
+     <console type='pty'>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
+index 27baaa3f14..2437fdec44 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
+@@ -79,7 +79,9 @@
+       <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml
+index 63462e6f94..e1d5cb9d72 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml
+@@ -28,7 +28,9 @@
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='spiceport'>
+       <source channel='org.qemu.console.serial.0'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='spiceport'>
+       <source channel='org.qemu.console.serial.0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml
+index c90bbeb7d5..ff92435afe 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml
+@@ -28,7 +28,9 @@
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='spiceport'>
+       <source channel='org.qemu.console.serial.0'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='spiceport'>
+       <source channel='org.qemu.console.serial.0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
+index a8790b5098..fded758eac 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
+@@ -27,13 +27,19 @@
+     </controller>
+     <controller type='pci' index='0' model='pci-root'/>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <serial type='null'>
+-      <target type='isa-serial' port='1'/>
++      <target type='isa-serial' port='1'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <serial type='stdio'>
+-      <target type='isa-serial' port='2'/>
++      <target type='isa-serial' port='2'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml
+index a8af87b53b..76d8948204 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml
+@@ -29,12 +29,16 @@
+     <serial type='udp'>
+       <source mode='bind' host='127.0.0.1' service='1111'/>
+       <source mode='connect' host='127.0.0.1' service='2222'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <serial type='tcp'>
+       <source mode='connect' host='127.0.0.1' service='5555'/>
+       <protocol type='raw'/>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='udp'>
+       <source mode='bind' host='127.0.0.1' service='1111'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml
+index 6d847de3a2..df4c67bb4d 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml
+@@ -40,7 +40,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml
+index 30989658f4..70c6a1a0fb 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml
+@@ -47,7 +47,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml
+index 72cbcc4cb5..49a7b550b3 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml
+@@ -46,7 +46,9 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+     </interface>
+     <serial type='pty'>
+-      <target type='isa-serial' port='0'/>
++      <target type='isa-serial' port='0'>
++        <model name='isa-serial'/>
++      </target>
+     </serial>
+     <console type='pty'>
+       <target type='serial' port='0'/>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Simplify-qemuMigrationResetTLS.patch b/SOURCES/libvirt-qemu-Simplify-qemuMigrationResetTLS.patch
deleted file mode 100644
index 8ba30d5..0000000
--- a/SOURCES/libvirt-qemu-Simplify-qemuMigrationResetTLS.patch
+++ /dev/null
@@ -1,122 +0,0 @@
-From baf6fbbba2c6cfbf4abe6e038900e9b5b3f8d7e1 Mon Sep 17 00:00:00 2001
-Message-Id: <baf6fbbba2c6cfbf4abe6e038900e9b5b3f8d7e1@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 5 Apr 2017 13:04:04 +0200
-Subject: [PATCH] qemu: Simplify qemuMigrationResetTLS
-
-It's only called from qemuMigrationReset now so it doesn't need to be
-exported and {tls,sec}Alias are always NULL.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 4097de405e5ea5fae3867028ee901c03f80eb15b)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1425003
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 37 +++++++++++++------------------------
- src/qemu/qemu_migration.h |  7 -------
- 2 files changed, 13 insertions(+), 31 deletions(-)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 27156cc78..3e9c35e4c 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -2406,45 +2406,36 @@ qemuMigrationSetParams(virQEMUDriverPtr driver,
-  * @driver: pointer to qemu driver
-  * @vm: domain object
-  * @asyncJob: migration job to join
-- * @tlsAlias: alias generated for TLS object (may be NULL)
-- * @secAlias: alias generated for a secinfo object (may be NULL)
-  *
-  * Deconstruct all the setup possibly done for TLS - delete the TLS and
-- * security objects, fre the secinfo, and reset the migration params to "".
-+ * security objects, free the secinfo, and reset the migration params to "".
-  *
-  * Returns 0 on success, -1 on failure
-  */
--int
-+static int
- qemuMigrationResetTLS(virQEMUDriverPtr driver,
-                       virDomainObjPtr vm,
--                      qemuDomainAsyncJob asyncJob,
--                      char *in_tlsAlias,
--                      char *in_secAlias)
-+                      qemuDomainAsyncJob asyncJob)
- {
-     qemuDomainObjPrivatePtr priv = vm->privateData;
--    char *tlsAlias = in_tlsAlias;
--    char *secAlias = in_secAlias;
-+    char *tlsAlias = NULL;
-+    char *secAlias = NULL;
-     qemuMonitorMigrationParams migParams = { 0 };
-     int ret = -1;
- 
--    /* If coming from a path that doesn't know whether it's been used or not,
--     * let's first check we need to do this. If the tls-creds doesn't exist
--     * or if they're set to "" then there's nothing to do since we never set
--     * anything up */
--    if (!in_tlsAlias && qemuMigrationCheckTLSCreds(driver, vm, asyncJob) < 0)
-+    if (qemuMigrationCheckTLSCreds(driver, vm, asyncJob) < 0)
-         return -1;
- 
-+    /* If the tls-creds doesn't exist or if they're set to "" then there's
-+     * nothing to do since we never set anything up */
-     if (!priv->migTLSAlias || !*priv->migTLSAlias)
-         return 0;
- 
-     /* NB: If either or both fail to allocate memory we can still proceed
-      *     since the next time we migrate another deletion attempt will be
-      *     made after successfully generating the aliases. */
--    if (!tlsAlias)
--        tlsAlias = qemuAliasTLSObjFromSrcAlias(QEMU_MIGRATION_TLS_ALIAS_BASE);
--    if (!secAlias)
--        secAlias = qemuDomainGetSecretAESAlias(QEMU_MIGRATION_TLS_ALIAS_BASE,
--                                               false);
-+    tlsAlias = qemuAliasTLSObjFromSrcAlias(QEMU_MIGRATION_TLS_ALIAS_BASE);
-+    secAlias = qemuDomainGetSecretAESAlias(QEMU_MIGRATION_TLS_ALIAS_BASE, false);
- 
-     qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, tlsAlias);
-     qemuDomainSecretInfoFree(&priv->migSecinfo);
-@@ -2457,10 +2448,8 @@ qemuMigrationResetTLS(virQEMUDriverPtr driver,
-     ret = 0;
- 
-  cleanup:
--    if (!in_tlsAlias)
--        VIR_FREE(tlsAlias);
--    if (!in_secAlias)
--        VIR_FREE(secAlias);
-+    VIR_FREE(tlsAlias);
-+    VIR_FREE(secAlias);
-     qemuMigrationParamsClear(&migParams);
- 
-     return ret;
-@@ -5887,6 +5876,6 @@ qemuMigrationReset(virQEMUDriverPtr driver,
-     if (!virDomainObjIsActive(vm))
-         return;
- 
--    if (qemuMigrationResetTLS(driver, vm, job, NULL, NULL) < 0)
-+    if (qemuMigrationResetTLS(driver, vm, job) < 0)
-         return;
- }
-diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
-index 28eb55056..b392b8fff 100644
---- a/src/qemu/qemu_migration.h
-+++ b/src/qemu/qemu_migration.h
-@@ -278,13 +278,6 @@ int qemuMigrationRunIncoming(virQEMUDriverPtr driver,
- void qemuMigrationPostcopyFailed(virQEMUDriverPtr driver,
-                                  virDomainObjPtr vm);
- 
--int
--qemuMigrationResetTLS(virQEMUDriverPtr driver,
--                      virDomainObjPtr vm,
--                      qemuDomainAsyncJob asyncJob,
--                      char *in_tlsAlias,
--                      char *in_secAlias);
--
- void
- qemuMigrationReset(virQEMUDriverPtr driver,
-                    virDomainObjPtr vm,
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Split-virQEMUCapsInitArchQMPBasic.patch b/SOURCES/libvirt-qemu-Split-virQEMUCapsInitArchQMPBasic.patch
deleted file mode 100644
index d196920..0000000
--- a/SOURCES/libvirt-qemu-Split-virQEMUCapsInitArchQMPBasic.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 56208ffe874c42274add74ba412059345e5c018d Mon Sep 17 00:00:00 2001
-Message-Id: <56208ffe874c42274add74ba412059345e5c018d@dist-git>
-From: Andrea Bolognani <abologna@redhat.com>
-Date: Tue, 4 Apr 2017 14:59:27 +0200
-Subject: [PATCH] qemu: Split virQEMUCapsInitArchQMPBasic()
-
-Instead of having a single function that probes the
-architecture from the monitor and then sets a bunch of
-basic capabilities based on it, have a separate function
-for each part: virQEMUCapsInitQMPArch() only sets the
-architecture, and virQEMUCapsInitQMPBasicArch() only sets
-the capabilities.
-
-This split will be useful later on, when we will want to
-set basic capabilities from the test suite without having
-to go through the pain of mocking the monitor.
-
-(cherry picked from commit a8fc7ef83439c235a3b1115cf6d7b80e096f4af2)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
-
-Signed-off-by: Andrea Bolognani <abologna@redhat.com>
----
- src/qemu/qemu_capabilities.c | 42 +++++++++++++++++++++++++++++++-----------
- 1 file changed, 31 insertions(+), 11 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 83ebcd020..b568a0f5e 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -4262,18 +4262,25 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps)
-     virQEMUCapsSet(qemuCaps, QEMU_CAPS_DISPLAY);
- }
- 
--/* Capabilities that are architecture depending
-- * initialized for QEMU.
-+
-+/**
-+ * virQEMUCapsInitQMPArch:
-+ * @qemuCaps: QEMU capabilities
-+ * @mon: QEMU monitor
-+ *
-+ * Initialize the architecture for @qemuCaps by asking @mon.
-+ *
-+ * Returns: 0 on success, <0 on failure
-  */
- static int
--virQEMUCapsInitArchQMPBasic(virQEMUCapsPtr qemuCaps,
-+virQEMUCapsInitQMPArch(virQEMUCapsPtr qemuCaps,
-                             qemuMonitorPtr mon)
- {
-     char *archstr = NULL;
-     int ret = -1;
- 
-     if (!(archstr = qemuMonitorGetTargetArch(mon)))
--        return -1;
-+        goto cleanup;
- 
-     if ((qemuCaps->arch = virQEMUCapsArchFromString(archstr)) == VIR_ARCH_NONE) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-@@ -4281,18 +4288,29 @@ virQEMUCapsInitArchQMPBasic(virQEMUCapsPtr qemuCaps,
-         goto cleanup;
-     }
- 
-+    ret = 0;
-+
-+ cleanup:
-+    VIR_FREE(archstr);
-+    return ret;
-+}
-+
-+
-+/**
-+ * virQEMUCapsInitQMPBasicArch:
-+ * @qemuCaps: QEMU capabilities
-+ *
-+ * Initialize @qemuCaps with basic architecture-dependent capabilities.
-+ */
-+static void
-+virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps)
-+{
-     /* ACPI/HPET/KVM PIT are x86 specific */
-     if (ARCH_IS_X86(qemuCaps->arch)) {
-         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI);
-         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_HPET);
-         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT);
-     }
--
--    ret = 0;
--
-- cleanup:
--    VIR_FREE(archstr);
--    return ret;
- }
- 
- 
-@@ -4517,9 +4535,11 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
- 
-     virQEMUCapsInitQMPBasic(qemuCaps);
- 
--    if (virQEMUCapsInitArchQMPBasic(qemuCaps, mon) < 0)
-+    if (virQEMUCapsInitQMPArch(qemuCaps, mon) < 0)
-         goto cleanup;
- 
-+    virQEMUCapsInitQMPBasicArch(qemuCaps);
-+
-     /* USB option is supported v1.3.0 onwards */
-     if (qemuCaps->version >= 1003000)
-         virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_USB_OPT);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Store-save-cookie-in-save-images-and-snapshots.patch b/SOURCES/libvirt-qemu-Store-save-cookie-in-save-images-and-snapshots.patch
deleted file mode 100644
index bef20ae..0000000
--- a/SOURCES/libvirt-qemu-Store-save-cookie-in-save-images-and-snapshots.patch
+++ /dev/null
@@ -1,313 +0,0 @@
-From b7638da5f8a4ad19fc45f530063044d0b5020422 Mon Sep 17 00:00:00 2001
-Message-Id: <b7638da5f8a4ad19fc45f530063044d0b5020422@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Thu, 25 May 2017 10:20:57 +0200
-Subject: [PATCH] qemu: Store save cookie in save images and snapshots
-
-The following patches will add an actual content in the cookie and use
-the data when restoring a domain.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 5c2f01abcb43810e7617f9a6544ce0d0b6caed34)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatsnapshot.html.in     |  6 +++
- docs/schemas/domainsnapshot.rng |  7 +++
- src/qemu/qemu_driver.c          | 96 ++++++++++++++++++++++++++++++++++++-----
- 3 files changed, 99 insertions(+), 10 deletions(-)
-
-diff --git a/docs/formatsnapshot.html.in b/docs/formatsnapshot.html.in
-index c3ab516fa4..5e8e21c8a7 100644
---- a/docs/formatsnapshot.html.in
-+++ b/docs/formatsnapshot.html.in
-@@ -235,6 +235,12 @@
-         at the time of the snapshot (<span class="since">since
-         0.9.5</span>).  Readonly.
-       </dd>
-+      <dt><code>cookie</code></dt>
-+      <dd>Save image cookie containing additional data libvirt may need to
-+        properly restore a domain from an active snapshot when such data
-+        cannot be stored directly in the <code>domain</code> to maintain
-+        compatibility with older libvirt or hypervisor. Readonly.
-+      </dd>
-     </dl>
- 
-     <h2><a name="example">Examples</a></h2>
-diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.rng
-index 4ab1b828f2..2680887095 100644
---- a/docs/schemas/domainsnapshot.rng
-+++ b/docs/schemas/domainsnapshot.rng
-@@ -90,6 +90,13 @@
-             </element>
-           </element>
-         </optional>
-+        <optional>
-+          <element name='cookie'>
-+            <zeroOrMore>
-+              <ref name='customElement'/>
-+            </zeroOrMore>
-+          </element>
-+        </optional>
-       </interleave>
-     </element>
-   </define>
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 7ce0f01f70..dbb1ea9475 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -2813,7 +2813,8 @@ struct _virQEMUSaveHeader {
-     uint32_t data_len;
-     uint32_t was_running;
-     uint32_t compressed;
--    uint32_t unused[15];
-+    uint32_t cookieOffset;
-+    uint32_t unused[14];
- };
- 
- typedef struct _virQEMUSaveData virQEMUSaveData;
-@@ -2821,6 +2822,7 @@ typedef virQEMUSaveData *virQEMUSaveDataPtr;
- struct _virQEMUSaveData {
-     virQEMUSaveHeader header;
-     char *xml;
-+    char *cookie;
- };
- 
- 
-@@ -2831,6 +2833,7 @@ bswap_header(virQEMUSaveHeaderPtr hdr)
-     hdr->data_len = bswap_32(hdr->data_len);
-     hdr->was_running = bswap_32(hdr->was_running);
-     hdr->compressed = bswap_32(hdr->compressed);
-+    hdr->cookieOffset = bswap_32(hdr->cookieOffset);
- }
- 
- 
-@@ -2841,6 +2844,7 @@ virQEMUSaveDataFree(virQEMUSaveDataPtr data)
-         return;
- 
-     VIR_FREE(data->xml);
-+    VIR_FREE(data->cookie);
-     VIR_FREE(data);
- }
- 
-@@ -2850,8 +2854,10 @@ virQEMUSaveDataFree(virQEMUSaveDataPtr data)
-  */
- static virQEMUSaveDataPtr
- virQEMUSaveDataNew(char *domXML,
-+                   qemuDomainSaveCookiePtr cookieObj,
-                    bool running,
--                   int compressed)
-+                   int compressed,
-+                   virDomainXMLOptionPtr xmlopt)
- {
-     virQEMUSaveDataPtr data = NULL;
-     virQEMUSaveHeaderPtr header;
-@@ -2861,6 +2867,11 @@ virQEMUSaveDataNew(char *domXML,
- 
-     VIR_STEAL_PTR(data->xml, domXML);
- 
-+    if (cookieObj &&
-+        !(data->cookie = virSaveCookieFormat((virObjectPtr) cookieObj,
-+                                             virDomainXMLOptionGetSaveCookie(xmlopt))))
-+        goto error;
-+
-     header = &data->header;
-     memcpy(header->magic, QEMU_SAVE_PARTIAL, sizeof(header->magic));
-     header->version = QEMU_SAVE_VERSION;
-@@ -2868,6 +2879,10 @@ virQEMUSaveDataNew(char *domXML,
-     header->compressed = compressed;
- 
-     return data;
-+
-+ error:
-+    virQEMUSaveDataFree(data);
-+    return NULL;
- }
- 
- 
-@@ -2887,11 +2902,17 @@ virQEMUSaveDataWrite(virQEMUSaveDataPtr data,
- {
-     virQEMUSaveHeaderPtr header = &data->header;
-     size_t len;
-+    size_t xml_len;
-+    size_t cookie_len = 0;
-     int ret = -1;
-     size_t zerosLen = 0;
-     char *zeros = NULL;
- 
--    len = strlen(data->xml) + 1;
-+    xml_len = strlen(data->xml) + 1;
-+    if (data->cookie)
-+        cookie_len = strlen(data->cookie) + 1;
-+
-+    len = xml_len + cookie_len;
- 
-     if (header->data_len > 0) {
-         if (len > header->data_len) {
-@@ -2907,6 +2928,9 @@ virQEMUSaveDataWrite(virQEMUSaveDataPtr data,
-         header->data_len = len;
-     }
- 
-+    if (data->cookie)
-+        header->cookieOffset = xml_len;
-+
-     if (safewrite(fd, header, sizeof(*header)) != sizeof(*header)) {
-         virReportSystemError(errno,
-                              _("failed to write header to domain save file '%s'"),
-@@ -2914,14 +2938,28 @@ virQEMUSaveDataWrite(virQEMUSaveDataPtr data,
-         goto cleanup;
-     }
- 
--    if (safewrite(fd, data->xml, header->data_len) != header->data_len ||
--        safewrite(fd, zeros, zerosLen) != zerosLen) {
-+    if (safewrite(fd, data->xml, xml_len) != xml_len) {
-         virReportSystemError(errno,
-                              _("failed to write domain xml to '%s'"),
-                              path);
-         goto cleanup;
-     }
- 
-+    if (data->cookie &&
-+        safewrite(fd, data->cookie, cookie_len) != cookie_len) {
-+        virReportSystemError(errno,
-+                             _("failed to write cookie to '%s'"),
-+                             path);
-+        goto cleanup;
-+    }
-+
-+    if (safewrite(fd, zeros, zerosLen) != zerosLen) {
-+        virReportSystemError(errno,
-+                             _("failed to write padding to '%s'"),
-+                             path);
-+        goto cleanup;
-+    }
-+
-     ret = 0;
- 
-  cleanup:
-@@ -3236,6 +3274,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-     qemuDomainObjPrivatePtr priv = vm->privateData;
-     virCapsPtr caps;
-     virQEMUSaveDataPtr data = NULL;
-+    qemuDomainSaveCookiePtr cookie = NULL;
- 
-     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-         goto cleanup;
-@@ -3301,7 +3340,11 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-         goto endjob;
-     }
- 
--    if (!(data = virQEMUSaveDataNew(xml, was_running, compressed)))
-+    if (!(cookie = qemuDomainSaveCookieNew(vm)))
-+        goto endjob;
-+
-+    if (!(data = virQEMUSaveDataNew(xml, cookie, was_running, compressed,
-+                                    driver->xmlopt)))
-         goto endjob;
-     xml = NULL;
- 
-@@ -3338,6 +3381,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-         qemuDomainRemoveInactive(driver, vm);
- 
-  cleanup:
-+    virObjectUnref(cookie);
-     VIR_FREE(xml);
-     virQEMUSaveDataFree(data);
-     qemuDomainEventQueue(driver, event);
-@@ -6282,6 +6326,8 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-     virDomainDefPtr def = NULL;
-     int oflags = open_write ? O_RDWR : O_RDONLY;
-     virCapsPtr caps = NULL;
-+    size_t xml_len;
-+    size_t cookie_len;
- 
-     if (bypass_cache) {
-         int directFlag = virFileDirectFdFlag();
-@@ -6362,15 +6408,33 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
-         goto error;
-     }
- 
--    if (VIR_ALLOC_N(data->xml, header->data_len) < 0)
-+    if (header->cookieOffset)
-+        xml_len = header->cookieOffset;
-+    else
-+        xml_len = header->data_len;
-+
-+    cookie_len = header->data_len - xml_len;
-+
-+    if (VIR_ALLOC_N(data->xml, xml_len) < 0)
-         goto error;
- 
--    if (saferead(fd, data->xml, header->data_len) != header->data_len) {
-+    if (saferead(fd, data->xml, xml_len) != xml_len) {
-         virReportError(VIR_ERR_OPERATION_FAILED,
-                        "%s", _("failed to read domain XML"));
-         goto error;
-     }
- 
-+    if (cookie_len > 0) {
-+        if (VIR_ALLOC_N(data->cookie, cookie_len) < 0)
-+            goto error;
-+
-+        if (saferead(fd, data->cookie, cookie_len) != cookie_len) {
-+            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
-+                           _("failed to read cookie"));
-+            goto error;
-+        }
-+    }
-+
-     /* Create a domain from this XML */
-     if (!(def = virDomainDefParseString(data->xml, caps, driver->xmlopt, NULL,
-                                         VIR_DOMAIN_DEF_PARSE_INACTIVE |
-@@ -6411,6 +6475,11 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
-     char *errbuf = NULL;
-     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-     virQEMUSaveHeaderPtr header = &data->header;
-+    qemuDomainSaveCookiePtr cookie = NULL;
-+
-+    if (virSaveCookieParseString(data->cookie, (virObjectPtr *) &cookie,
-+                                 virDomainXMLOptionGetSaveCookie(driver->xmlopt)) < 0)
-+        goto cleanup;
- 
-     if ((header->version == 2) &&
-         (header->compressed != QEMU_SAVE_FORMAT_RAW)) {
-@@ -6501,6 +6570,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
-     ret = 0;
- 
-  cleanup:
-+    virObjectUnref(cookie);
-     virCommandFree(cmd);
-     VIR_FREE(errbuf);
-     if (qemuSecurityRestoreSavedStateLabel(driver->securityManager,
-@@ -13561,6 +13631,9 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
-     if (ret < 0)
-         goto cleanup;
- 
-+    if (!(snap->def->cookie = (virObjectPtr) qemuDomainSaveCookieNew(vm)))
-+        goto cleanup;
-+
-     if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) {
-         event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
-                                          VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT);
-@@ -14439,10 +14512,13 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
-                                                     "snapshot", false)) < 0)
-             goto cleanup;
- 
--        if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)))
-+        if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)) ||
-+            !(snap->def->cookie = (virObjectPtr) qemuDomainSaveCookieNew(vm)))
-             goto cleanup;
- 
--        if (!(data = virQEMUSaveDataNew(xml, resume, compressed)))
-+        if (!(data = virQEMUSaveDataNew(xml,
-+                                        (qemuDomainSaveCookiePtr) snap->def->cookie,
-+                                        resume, compressed, driver->xmlopt)))
-             goto cleanup;
-         xml = NULL;
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Store-updated-CPU-in-save-cookie.patch b/SOURCES/libvirt-qemu-Store-updated-CPU-in-save-cookie.patch
deleted file mode 100644
index 6ba177a..0000000
--- a/SOURCES/libvirt-qemu-Store-updated-CPU-in-save-cookie.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-From 910db8ca0b1a92d8d7ed9763b2ced958142dcaa4 Mon Sep 17 00:00:00 2001
-Message-Id: <910db8ca0b1a92d8d7ed9763b2ced958142dcaa4@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Fri, 2 Jun 2017 22:52:03 +0200
-Subject: [PATCH] qemu: Store updated CPU in save cookie
-
-Since the domain XML saved in a snapshot or saved image uses the
-original guest CPU definition but we still want to enforce ABI when
-restoring the domain if libvirt and QEMU are new enough, we save the
-live updated CPU definition in a save cookie.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 8c19fbf452372c7c1becf987497525ee8b61abbf)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 22 +++++++++++++++++++---
- src/qemu/qemu_domain.h |  2 ++
- 2 files changed, 21 insertions(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 514b56b33c..7897a44634 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -9152,12 +9152,15 @@ qemuDomainSaveCookieDispose(void *obj)
-     qemuDomainSaveCookiePtr cookie = obj;
- 
-     VIR_DEBUG("cookie=%p", cookie);
-+
-+    virCPUDefFree(cookie->cpu);
- }
- 
- 
- qemuDomainSaveCookiePtr
- qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED)
- {
-+    qemuDomainObjPrivatePtr priv = vm->privateData;
-     qemuDomainSaveCookiePtr cookie = NULL;
- 
-     if (qemuDomainInitialize() < 0)
-@@ -9166,7 +9169,10 @@ qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED)
-     if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
-         goto error;
- 
--    VIR_DEBUG("Save cookie %p", cookie);
-+    if (priv->origCPU && !(cookie->cpu = virCPUDefCopy(vm->def->cpu)))
-+        goto error;
-+
-+    VIR_DEBUG("Save cookie %p, cpu=%p", cookie, cookie->cpu);
- 
-     return cookie;
- 
-@@ -9188,6 +9194,10 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED,
-     if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
-         goto error;
- 
-+    if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST,
-+                          &cookie->cpu) < 0)
-+        goto error;
-+
-     *obj = (virObjectPtr) cookie;
-     return 0;
- 
-@@ -9198,9 +9208,15 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED,
- 
- 
- static int
--qemuDomainSaveCookieFormat(virBufferPtr buf ATTRIBUTE_UNUSED,
--                           virObjectPtr obj ATTRIBUTE_UNUSED)
-+qemuDomainSaveCookieFormat(virBufferPtr buf,
-+                           virObjectPtr obj)
- {
-+    qemuDomainSaveCookiePtr cookie = (qemuDomainSaveCookiePtr) obj;
-+
-+    if (cookie->cpu &&
-+        virCPUDefFormatBufFull(buf, cookie->cpu, NULL, false) < 0)
-+        return -1;
-+
-     return 0;
- }
- 
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 9567458849..2eea7924fb 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -424,6 +424,8 @@ typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie;
- typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr;
- struct _qemuDomainSaveCookie {
-     virObject parent;
-+
-+    virCPUDefPtr cpu;
- };
- 
- qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Support-setting-NUMA-distances.patch b/SOURCES/libvirt-qemu-Support-setting-NUMA-distances.patch
new file mode 100644
index 0000000..bf556dc
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Support-setting-NUMA-distances.patch
@@ -0,0 +1,259 @@
+From da9b2f15ee80396d542057340a576cf65828191a Mon Sep 17 00:00:00 2001
+Message-Id: <da9b2f15ee80396d542057340a576cf65828191a@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Mon, 4 Dec 2017 13:38:52 +0100
+Subject: [PATCH] qemu: Support setting NUMA distances
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1454889
+
+Since we already have such support for libxl all we need is qemu
+driver adjustment. And a test case.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 97a051f0f80ec076f3ff48ef830236675f128ade)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/formatdomain.html.in                          |  2 +-
+ src/qemu/qemu_command.c                            | 39 ++++++++++++-
+ .../qemuxml2argv-numatune-distances.args           | 63 +++++++++++++++++++++
+ .../qemuxml2argv-numatune-distances.xml            | 65 ++++++++++++++++++++++
+ tests/qemuxml2argvtest.c                           |  2 +
+ 5 files changed, 169 insertions(+), 2 deletions(-)
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-distances.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-distances.xml
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index a5adf5d9aa..cc1c5577cd 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -1589,7 +1589,7 @@
+ 
+     <p>
+       Describing distances between NUMA cells is currently only supported
+-      by Xen. If no <code>distances</code> are given to describe
++      by Xen and QEMU. If no <code>distances</code> are given to describe
+       the SLIT data between different cells, it will default to a scheme
+       using 10 for local and 20 for remote distances.
+     </p>
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 18977480d9..624a50d0b3 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -7807,7 +7807,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
+                     virCommandPtr cmd,
+                     qemuDomainObjPrivatePtr priv)
+ {
+-    size_t i;
++    size_t i, j;
+     virQEMUCapsPtr qemuCaps = priv->qemuCaps;
+     virBuffer buf = VIR_BUFFER_INITIALIZER;
+     char *cpumask = NULL, *tmpmask = NULL, *next = NULL;
+@@ -7817,6 +7817,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
+     int ret = -1;
+     size_t ncells = virDomainNumaGetNodeCount(def->numa);
+     const long system_page_size = virGetSystemPageSizeKB();
++    bool numa_distances = false;
+ 
+     if (virDomainNumatuneHasPerNodeBinding(def->numa) &&
+         !(virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
+@@ -7925,6 +7926,42 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
+ 
+         virCommandAddArgBuffer(cmd, &buf);
+     }
++
++    /* If NUMA node distance is specified for at least one pair
++     * of nodes, we have to specify all the distances. Even
++     * though they might be the default ones. */
++    for (i = 0; i < ncells; i++) {
++        for (j = 0; j < ncells; j++) {
++            if (virDomainNumaNodeDistanceIsUsingDefaults(def->numa, i, j))
++                continue;
++
++            numa_distances = true;
++            break;
++        }
++        if (numa_distances)
++            break;
++    }
++
++    if (numa_distances) {
++        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_NUMA_DIST)) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                           _("setting NUMA distances is not "
++                             "supported with this qemu"));
++            goto cleanup;
++        }
++
++        for (i = 0; i < ncells; i++) {
++            for (j = 0; j < ncells; j++) {
++                size_t distance = virDomainNumaGetNodeDistance(def->numa, i, j);
++
++                virCommandAddArg(cmd, "-numa");
++                virBufferAsprintf(&buf, "dist,src=%zu,dst=%zu,val=%zu", i, j, distance);
++
++                virCommandAddArgBuffer(cmd, &buf);
++            }
++        }
++    }
++
+     ret = 0;
+ 
+  cleanup:
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numatune-distances.args b/tests/qemuxml2argvdata/qemuxml2argv-numatune-distances.args
+new file mode 100644
+index 0000000000..23b66246c7
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-numatune-distances.args
+@@ -0,0 +1,63 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-x86_64 \
++-name QEMUGuest \
++-S \
++-M xenfv \
++-m 12288 \
++-smp 12,sockets=12,cores=1,threads=1 \
++-numa node,nodeid=0,cpus=0,cpus=11,mem=2048 \
++-numa node,nodeid=1,cpus=1,cpus=10,mem=2048 \
++-numa node,nodeid=2,cpus=2,cpus=9,mem=2048 \
++-numa node,nodeid=3,cpus=3,cpus=8,mem=2048 \
++-numa node,nodeid=4,cpus=4,cpus=7,mem=2048 \
++-numa node,nodeid=5,cpus=5-6,mem=2048 \
++-numa dist,src=0,dst=0,val=10 \
++-numa dist,src=0,dst=1,val=21 \
++-numa dist,src=0,dst=2,val=31 \
++-numa dist,src=0,dst=3,val=41 \
++-numa dist,src=0,dst=4,val=51 \
++-numa dist,src=0,dst=5,val=61 \
++-numa dist,src=1,dst=0,val=21 \
++-numa dist,src=1,dst=1,val=10 \
++-numa dist,src=1,dst=2,val=21 \
++-numa dist,src=1,dst=3,val=31 \
++-numa dist,src=1,dst=4,val=41 \
++-numa dist,src=1,dst=5,val=51 \
++-numa dist,src=2,dst=0,val=31 \
++-numa dist,src=2,dst=1,val=21 \
++-numa dist,src=2,dst=2,val=10 \
++-numa dist,src=2,dst=3,val=21 \
++-numa dist,src=2,dst=4,val=31 \
++-numa dist,src=2,dst=5,val=41 \
++-numa dist,src=3,dst=0,val=41 \
++-numa dist,src=3,dst=1,val=31 \
++-numa dist,src=3,dst=2,val=21 \
++-numa dist,src=3,dst=3,val=10 \
++-numa dist,src=3,dst=4,val=21 \
++-numa dist,src=3,dst=5,val=31 \
++-numa dist,src=4,dst=0,val=51 \
++-numa dist,src=4,dst=1,val=41 \
++-numa dist,src=4,dst=2,val=31 \
++-numa dist,src=4,dst=3,val=21 \
++-numa dist,src=4,dst=4,val=10 \
++-numa dist,src=4,dst=5,val=21 \
++-numa dist,src=5,dst=0,val=61 \
++-numa dist,src=5,dst=1,val=51 \
++-numa dist,src=5,dst=2,val=41 \
++-numa dist,src=5,dst=3,val=31 \
++-numa dist,src=5,dst=4,val=21 \
++-numa dist,src=5,dst=5,val=10 \
++-uuid c7a5fdb2-cdaf-9455-926a-d65c16db1809 \
++-nographic \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-boot c \
++-usb \
++-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numatune-distances.xml b/tests/qemuxml2argvdata/qemuxml2argv-numatune-distances.xml
+new file mode 100644
+index 0000000000..0f33526b46
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-numatune-distances.xml
+@@ -0,0 +1,65 @@
++<domain type='qemu'>
++  <name>QEMUGuest</name>
++  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>8388608</memory>
++  <currentMemory unit='KiB'>8388608</currentMemory>
++  <vcpu placement='static'>12</vcpu>
++  <os>
++    <type arch='x86_64' machine='xenfv'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <features>
++    <acpi/>
++    <apic/>
++    <pae/>
++  </features>
++  <cpu>
++    <numa>
++      <cell id='0' cpus='0,11' memory='2097152' unit='KiB'>
++        <distances>
++          <sibling id='1' value='21'/>
++          <sibling id='2' value='31'/>
++          <sibling id='3' value='41'/>
++          <sibling id='4' value='51'/>
++          <sibling id='5' value='61'/>
++        </distances>
++      </cell>
++      <cell id='1' cpus='1,10' memory='2097152' unit='KiB'>
++        <distances>
++          <sibling id='2' value='21'/>
++          <sibling id='3' value='31'/>
++          <sibling id='4' value='41'/>
++          <sibling id='5' value='51'/>
++        </distances>
++      </cell>
++      <cell id='2' cpus='2,9' memory='2097152' unit='KiB'>
++        <distances>
++          <sibling id='3' value='21'/>
++          <sibling id='4' value='31'/>
++          <sibling id='5' value='41'/>
++        </distances>
++      </cell>
++      <cell id='3' cpus='3,8' memory='2097152' unit='KiB'>
++        <distances>
++          <sibling id='4' value='21'/>
++          <sibling id='5' value='31'/>
++        </distances>
++      </cell>
++      <cell id='4' cpus='4,7' memory='2097152' unit='KiB'>
++        <distances>
++          <sibling id='5' value='21'/>
++        </distances>
++      </cell>
++      <cell id='5' cpus='5-6' memory='2097152' unit='KiB'/>
++    </numa>
++  </cpu>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>restart</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-x86_64</emulator>
++    <controller type='usb' index='0'/>
++    <controller type='pci' index='0' model='pci-root'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 77c9783929..72cefe4906 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -1726,6 +1726,8 @@ mymain(void)
+                   QEMU_CAPS_OBJECT_MEMORY_RAM);
+     DO_TEST_FAILURE("numatune-memnode-no-memory", NONE);
+ 
++    DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST);
++
+     DO_TEST("numatune-auto-nodeset-invalid", NONE);
+     DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM,
+             QEMU_CAPS_OBJECT_MEMORY_FILE);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Support-usb-serial-and-pci-serial-on-pSeries.patch b/SOURCES/libvirt-qemu-Support-usb-serial-and-pci-serial-on-pSeries.patch
new file mode 100644
index 0000000..7905ad5
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Support-usb-serial-and-pci-serial-on-pSeries.patch
@@ -0,0 +1,293 @@
+From 6c6f469f08a2fd5d61d91bf0488ade5ef0033f2d Mon Sep 17 00:00:00 2001
+Message-Id: <6c6f469f08a2fd5d61d91bf0488ade5ef0033f2d@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:13 +0100
+Subject: [PATCH] qemu: Support usb-serial and pci-serial on pSeries
+
+The existing implementation set the address type for all serial
+devices to spapr-vio, which made it impossible to use other devices
+such as usb-serial and pci-serial; moreover, some decisions were
+made based on the address type rather than the device type.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit b342e94399eee7fd519234a12ca3ea04f6564154)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c                            |  9 ------
+ src/qemu/qemu_domain_address.c                     |  3 +-
+ .../qemuxml2argv-pseries-serial-pci.args           | 22 +++++++++++++++
+ .../qemuxml2argv-pseries-serial-pci.xml            | 18 ++++++++++++
+ .../qemuxml2argv-pseries-serial-usb.args           | 23 ++++++++++++++++
+ .../qemuxml2argv-pseries-serial-usb.xml            | 21 ++++++++++++++
+ tests/qemuxml2argvtest.c                           |  7 +++++
+ .../qemuxml2xmlout-pseries-serial-pci.xml          | 31 +++++++++++++++++++++
+ .../qemuxml2xmlout-pseries-serial-usb.xml          | 32 ++++++++++++++++++++++
+ tests/qemuxml2xmltest.c                            |  7 +++++
+ 10 files changed, 163 insertions(+), 10 deletions(-)
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 91083dc73d..056dafea39 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9260,15 +9260,6 @@ static bool
+ qemuChrIsPlatformDevice(const virDomainDef *def,
+                         virDomainChrDefPtr chr)
+ {
+-    if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) {
+-        if (!qemuDomainIsPSeries(def))
+-            return true;
+-        /* only pseries need -device spapr-vty with -chardev */
+-        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+-            chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO)
+-            return true;
+-    }
+-
+     if (def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) {
+         /* TARGET_TYPE_ISA here really means 'the default platform device' */
+         if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
+index 2319e503eb..f62bb2f97e 100644
+--- a/src/qemu/qemu_domain_address.c
++++ b/src/qemu/qemu_domain_address.c
+@@ -246,8 +246,9 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
+ 
+     for (i = 0; i < def->nserials; i++) {
+         if (def->serials[i]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+-            qemuDomainIsPSeries(def))
++            def->serials[i]->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO) {
+             def->serials[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
++        }
+         if (qemuDomainAssignSpaprVIOAddress(def, &def->serials[i]->info,
+                                             VIO_ADDR_SERIAL) < 0)
+             goto cleanup;
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args
+new file mode 100644
+index 0000000000..eb2a9bf0e0
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args
+@@ -0,0 +1,22 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-ppc64 \
++-name guest \
++-S \
++-M pseries \
++-m 512 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-boot c \
++-chardev pty,id=charserial0 \
++-device pci-serial,chardev=charserial0,id=serial0,bus=pci.0,addr=0x1
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml
+new file mode 100644
+index 0000000000..2c2534b4c2
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml
+@@ -0,0 +1,18 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' model='none'/>
++    <!-- This will be assigned a PCI address -->
++    <serial type='pty'>
++      <target type='pci-serial'/>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args
+new file mode 100644
+index 0000000000..0403985dc4
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args
+@@ -0,0 +1,23 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-ppc64 \
++-name guest \
++-S \
++-M pseries \
++-m 512 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-boot c \
++-device qemu-xhci,id=usb,bus=pci.0,addr=0x1 \
++-chardev pty,id=charserial0 \
++-device usb-serial,chardev=charserial0,id=serial0,bus=usb.0,port=1
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml
+new file mode 100644
+index 0000000000..734c90c66f
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml
+@@ -0,0 +1,21 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++  </os>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' model='qemu-xhci'/>
++    <!-- This should be assigned a USB address. You'll not be able to find it
++         in the file generated by qemuxml2xmltest due to limitations in the
++         test suite, but it will be there when actually running libvirt;
++         moreover, the USB address will be present in the .args file -->
++    <serial type='pty'>
++      <target type='usb-serial'/>
++    </serial>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 4b63dd141d..2b3bbd1b8b 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -1884,6 +1884,13 @@ mymain(void)
+     DO_TEST("pseries-serial-compat",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_DEVICE_SPAPR_VTY);
++    DO_TEST("pseries-serial-pci",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_PCI_SERIAL);
++    DO_TEST("pseries-serial-usb",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_QEMU_XHCI,
++            QEMU_CAPS_DEVICE_USB_SERIAL);
+     DO_TEST("pseries-console-native",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_DEVICE_SPAPR_VTY);
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml
+new file mode 100644
+index 0000000000..cba7ea96bb
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml
+@@ -0,0 +1,31 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <currentMemory unit='KiB'>524288</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' index='0' model='none'/>
++    <controller type='pci' index='0' model='pci-root'>
++      <model name='spapr-pci-host-bridge'/>
++      <target index='0'/>
++    </controller>
++    <serial type='pty'>
++      <target type='pci-serial' port='0'>
++        <model name='pci-serial'/>
++      </target>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
++    </serial>
++    <memballoon model='none'/>
++    <panic model='pseries'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml
+new file mode 100644
+index 0000000000..34f651308d
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml
+@@ -0,0 +1,32 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <currentMemory unit='KiB'>524288</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' index='0' model='qemu-xhci'>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
++    </controller>
++    <controller type='pci' index='0' model='pci-root'>
++      <model name='spapr-pci-host-bridge'/>
++      <target index='0'/>
++    </controller>
++    <serial type='pty'>
++      <target type='usb-serial' port='0'>
++        <model name='usb-serial'/>
++      </target>
++    </serial>
++    <memballoon model='none'/>
++    <panic model='pseries'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
+index ad429ead4d..f76bd5a68d 100644
+--- a/tests/qemuxml2xmltest.c
++++ b/tests/qemuxml2xmltest.c
+@@ -775,6 +775,13 @@ mymain(void)
+     DO_TEST("pseries-serial-compat",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_DEVICE_SPAPR_VTY);
++    DO_TEST("pseries-serial-pci",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_PCI_SERIAL);
++    DO_TEST("pseries-serial-usb",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_DEVICE_QEMU_XHCI,
++            QEMU_CAPS_DEVICE_USB_SERIAL);
+     DO_TEST("pseries-console-native",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_DEVICE_SPAPR_VTY);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-Tolerate-storage-source-private-data-being-NULL.patch b/SOURCES/libvirt-qemu-Tolerate-storage-source-private-data-being-NULL.patch
new file mode 100644
index 0000000..7723237
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Tolerate-storage-source-private-data-being-NULL.patch
@@ -0,0 +1,125 @@
+From aa56a230d346174047f4d21b127bdbea52a1ce3c Mon Sep 17 00:00:00 2001
+Message-Id: <aa56a230d346174047f4d21b127bdbea52a1ce3c@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Mon, 13 Nov 2017 13:43:21 +0100
+Subject: [PATCH] qemu: Tolerate storage source private data being NULL
+
+In some cases it does not make sense to pursue that the private data
+will be allocated (especially when we don't need to put anything in it).
+
+Ensure that the code works without it.
+
+This also fixes few crashes pointed out in
+https://bugzilla.redhat.com/show_bug.cgi?id=1510323
+
+(cherry picked from commit 8056721cbb75a717604a1f7971440726d9d85045)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c | 18 ++++++++++++++----
+ src/qemu/qemu_hotplug.c | 17 ++++++++++++-----
+ 2 files changed, 26 insertions(+), 9 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index f8eb59884c..e60f93083f 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -1362,12 +1362,17 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
+ {
+     int actualType = virStorageSourceGetActualType(disk->src);
+     qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
+-    qemuDomainSecretInfoPtr secinfo = srcpriv->secinfo;
+-    qemuDomainSecretInfoPtr encinfo = srcpriv->encinfo;
++    qemuDomainSecretInfoPtr secinfo = NULL;
++    qemuDomainSecretInfoPtr encinfo = NULL;
+     virJSONValuePtr srcprops = NULL;
+     char *source = NULL;
+     int ret = -1;
+ 
++    if (srcpriv) {
++        secinfo = srcpriv->secinfo;
++        encinfo = srcpriv->encinfo;
++    }
++
+     if (qemuDiskSourceNeedsProps(disk->src) &&
+         !(srcprops = qemuDiskSourceGetProps(disk->src)))
+         goto cleanup;
+@@ -2239,8 +2244,13 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
+         bool driveBoot = false;
+         virDomainDiskDefPtr disk = def->disks[i];
+         qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
+-        qemuDomainSecretInfoPtr secinfo = srcPriv->secinfo;
+-        qemuDomainSecretInfoPtr encinfo = srcPriv->encinfo;
++        qemuDomainSecretInfoPtr secinfo = NULL;
++        qemuDomainSecretInfoPtr encinfo = NULL;
++
++        if (srcPriv) {
++            secinfo = srcPriv->secinfo;
++            encinfo = srcPriv->encinfo;
++        }
+ 
+         if (disk->info.bootIndex) {
+             bootindex = disk->info.bootIndex;
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index 5701c033be..edf07d0b65 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -259,6 +259,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
+     qemuDomainObjPrivatePtr priv = vm->privateData;
+     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+     qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
++    qemuDomainSecretInfoPtr secinfo = NULL;
+     const char *format = NULL;
+     char *sourcestr = NULL;
+ 
+@@ -268,6 +269,9 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
+         goto cleanup;
+     }
+ 
++    if (srcPriv)
++        secinfo = srcPriv->secinfo;
++
+     if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
+         disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM) {
+         virReportError(VIR_ERR_INTERNAL_ERROR,
+@@ -300,7 +304,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
+     }
+ 
+     if (!virStorageSourceIsEmpty(newsrc)) {
+-        if (qemuGetDriveSourceString(newsrc, srcPriv->secinfo, &sourcestr) < 0)
++        if (qemuGetDriveSourceString(newsrc, secinfo, &sourcestr) < 0)
+             goto error;
+ 
+         if (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR) {
+@@ -371,8 +375,8 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
+     virJSONValuePtr secobjProps = NULL;
+     virJSONValuePtr encobjProps = NULL;
+     qemuDomainStorageSourcePrivatePtr srcPriv;
+-    qemuDomainSecretInfoPtr secinfo;
+-    qemuDomainSecretInfoPtr encinfo;
++    qemuDomainSecretInfoPtr secinfo = NULL;
++    qemuDomainSecretInfoPtr encinfo = NULL;
+ 
+     if (qemuDomainPrepareDisk(driver, vm, disk, NULL, false) < 0)
+         goto cleanup;
+@@ -384,13 +388,16 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
+         goto error;
+ 
+     srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
+-    secinfo = srcPriv->secinfo;
++    if (srcPriv) {
++        secinfo = srcPriv->secinfo;
++        encinfo = srcPriv->encinfo;
++    }
++
+     if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
+         if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0)
+             goto error;
+     }
+ 
+-    encinfo = srcPriv->encinfo;
+     if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0)
+         goto error;
+ 
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Update-host-model-CPUs-on-reconnect.patch b/SOURCES/libvirt-qemu-Update-host-model-CPUs-on-reconnect.patch
deleted file mode 100644
index 9e5a0e9..0000000
--- a/SOURCES/libvirt-qemu-Update-host-model-CPUs-on-reconnect.patch
+++ /dev/null
@@ -1,94 +0,0 @@
-From 9c2457dd94cf148dce04ee5fd3997003ca03a642 Mon Sep 17 00:00:00 2001
-Message-Id: <9c2457dd94cf148dce04ee5fd3997003ca03a642@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 11 Jul 2017 14:16:40 +0200
-Subject: [PATCH] qemu: Update host-model CPUs on reconnect
-
-When libvirt starts a new QEMU domain, it replaces host-model CPUs with
-the appropriate custom CPU definition. However, when reconnecting to a
-domain started by older libvirt (< 2.3), the domain would still have a
-host-model CPU in its active definition.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1463957
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 7cf22b4879e819dee42e0a058f7ed149dc9d639a)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1470582
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_process.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 48 insertions(+)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index e6f56dc484..8fe9ef36d7 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3718,6 +3718,30 @@ qemuProcessUpdateAndVerifyCPU(virQEMUDriverPtr driver,
- 
- 
- static int
-+qemuProcessUpdateCPU(virQEMUDriverPtr driver,
-+                     virDomainObjPtr vm,
-+                     qemuDomainAsyncJob asyncJob)
-+{
-+    virCPUDataPtr cpu = NULL;
-+    virCPUDataPtr disabled = NULL;
-+    int ret = -1;
-+
-+    if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < 0)
-+        goto cleanup;
-+
-+    if (qemuProcessUpdateLiveGuestCPU(vm, cpu, disabled) < 0)
-+        goto cleanup;
-+
-+    ret = 0;
-+
-+ cleanup:
-+    virCPUDataFree(cpu);
-+    virCPUDataFree(disabled);
-+    return ret;
-+}
-+
-+
-+static int
- qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
-                  virDomainObjPtr vm)
- {
-@@ -6796,6 +6820,30 @@ qemuProcessReconnect(void *opaque)
-     ignore_value(qemuSecurityCheckAllLabel(driver->securityManager,
-                                            obj->def));
- 
-+    /* If the domain with a host-model CPU was started by an old libvirt
-+     * (< 2.3) which didn't replace the CPU with a custom one, let's do it now
-+     * since the rest of our code does not really expect a host-model CPU in a
-+     * running domain.
-+     */
-+    if (virQEMUCapsGuestIsNative(caps->host.arch, obj->def->os.arch) &&
-+        caps->host.cpu &&
-+        obj->def->cpu &&
-+        obj->def->cpu->mode == VIR_CPU_MODE_HOST_MODEL) {
-+        virCPUDefPtr host;
-+
-+        if (!(host = virCPUCopyMigratable(caps->host.cpu->arch, caps->host.cpu)))
-+            goto error;
-+
-+        if (virCPUUpdate(obj->def->os.arch, obj->def->cpu, host) < 0) {
-+            virCPUDefFree(host);
-+            goto error;
-+        }
-+        virCPUDefFree(host);
-+
-+        if (qemuProcessUpdateCPU(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
-+            goto error;
-+    }
-+
-     if (qemuDomainRefreshVcpuInfo(driver, obj, QEMU_ASYNC_JOB_NONE, true) < 0)
-         goto error;
- 
--- 
-2.13.2
-
diff --git a/SOURCES/libvirt-qemu-Use-correct-variable-in-qemuDomainSetBlockIoTune.patch b/SOURCES/libvirt-qemu-Use-correct-variable-in-qemuDomainSetBlockIoTune.patch
deleted file mode 100644
index f9a2631..0000000
--- a/SOURCES/libvirt-qemu-Use-correct-variable-in-qemuDomainSetBlockIoTune.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From 71bdd999481b2feaecceb39dd3cfb7dfa61de3af Mon Sep 17 00:00:00 2001
-Message-Id: <71bdd999481b2feaecceb39dd3cfb7dfa61de3af@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Thu, 25 May 2017 14:33:25 +0200
-Subject: [PATCH] qemu: Use correct variable in qemuDomainSetBlockIoTune
-
-'param' contains the correct element from 'params'.
-
-If the group name would not be the first parameter libvirtd would crash.
-
-Introduced in c53bd25b13.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1455510
-(cherry picked from commit 0d3aff58e7ed190c97b40ee92f58cb0180cef6fe)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 3241de4cb..c31d07a65 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -17445,7 +17445,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
- 
-         /* NB: Cannot use macro since this is a value.s not a value.ul */
-         if (STREQ(param->field, VIR_DOMAIN_BLOCK_IOTUNE_GROUP_NAME)) {
--            if (VIR_STRDUP(info.group_name, params->value.s) < 0)
-+            if (VIR_STRDUP(info.group_name, param->value.s) < 0)
-                 goto endjob;
-             set_fields |= QEMU_BLOCK_IOTUNE_SET_GROUP_NAME;
-             if (virTypedParamsAddString(&eventParams, &eventNparams,
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-Use-more-data-for-comparing-CPUs.patch b/SOURCES/libvirt-qemu-Use-more-data-for-comparing-CPUs.patch
deleted file mode 100644
index 63c381f..0000000
--- a/SOURCES/libvirt-qemu-Use-more-data-for-comparing-CPUs.patch
+++ /dev/null
@@ -1,173 +0,0 @@
-From b2196db320485b642d6654279ebb6b75eeafd3e9 Mon Sep 17 00:00:00 2001
-Message-Id: <b2196db320485b642d6654279ebb6b75eeafd3e9@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Tue, 11 Apr 2017 20:46:05 +0200
-Subject: [PATCH] qemu: Use more data for comparing CPUs
-
-With QEMU older than 2.9.0 libvirt uses CPUID instruction to determine
-what CPU features are supported on the host. This was later used when
-checking compatibility of guest CPUs. Since QEMU 2.9.0 we ask QEMU for
-the host CPU data. But the two methods we use usually provide disjoint
-sets of CPU features because QEMU/KVM does not support all features
-provided by the host CPU and on the other hand it can enable some
-feature even if the host CPU does not support them.
-
-So if there is a domain which requires a CPU features disabled by
-QEMU/KVM, libvirt will refuse to start it with QEMU > 2.9.0 as its guest
-CPU is incompatible with the host CPU data we got from QEMU. But such
-domain would happily start on older QEMU (of course, the features would
-be missing the guest CPU). To fix this regression, we need to combine
-both CPU feature sets when checking guest CPU compatibility.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439933
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 5b4a6adb5ca24a6cb91cdc55c31506fb278d3a91)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 35 +++++++++++++++++++++++++++++++++--
- src/qemu/qemu_capabilities.h |  4 ++++
- src/qemu/qemu_process.c      |  2 +-
- 3 files changed, 38 insertions(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index ec773971e..49de506ed 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -387,6 +387,10 @@ struct _virQEMUCapsHostCPUData {
-     virCPUDefPtr reported;
-     /* Migratable host CPU definition used for updating guest CPU. */
-     virCPUDefPtr migratable;
-+    /* CPU definition with features detected by libvirt using virCPUGetHost
-+     * combined with features reported by QEMU. This is used for backward
-+     * compatible comparison between a guest CPU and a host CPU. */
-+    virCPUDefPtr full;
- };
- 
- /*
-@@ -2112,6 +2116,10 @@ virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUDataPtr dst,
-         !(dst->migratable = virCPUDefCopy(src->migratable)))
-         return -1;
- 
-+    if (src->full &&
-+        !(dst->full = virCPUDefCopy(src->full)))
-+        return -1;
-+
-     return 0;
- }
- 
-@@ -2122,6 +2130,7 @@ virQEMUCapsHostCPUDataClear(virQEMUCapsHostCPUDataPtr cpuData)
-     qemuMonitorCPUModelInfoFree(cpuData->info);
-     virCPUDefFree(cpuData->reported);
-     virCPUDefFree(cpuData->migratable);
-+    virCPUDefFree(cpuData->full);
- 
-     memset(cpuData, 0, sizeof(*cpuData));
- }
-@@ -2463,6 +2472,11 @@ virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
- 
-     case VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE:
-         return cpuData->migratable;
-+
-+    case VIR_QEMU_CAPS_HOST_CPU_FULL:
-+        /* 'full' is non-NULL only if we have data from both QEMU and
-+         * virCPUGetHost */
-+        return cpuData->full ? cpuData->full : cpuData->reported;
-     }
- 
-     return NULL;
-@@ -2473,12 +2487,14 @@ static void
- virQEMUCapsSetHostModel(virQEMUCapsPtr qemuCaps,
-                         virDomainVirtType type,
-                         virCPUDefPtr reported,
--                        virCPUDefPtr migratable)
-+                        virCPUDefPtr migratable,
-+                        virCPUDefPtr full)
- {
-     virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
- 
-     cpuData->reported = reported;
-     cpuData->migratable = migratable;
-+    cpuData->full = full;
- }
- 
- 
-@@ -3350,6 +3366,8 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-     virCPUDefPtr cpu = NULL;
-     virCPUDefPtr migCPU = NULL;
-     virCPUDefPtr hostCPU = NULL;
-+    virCPUDefPtr fullCPU = NULL;
-+    size_t i;
-     int rc;
- 
-     if (!caps || !virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch))
-@@ -3369,6 +3387,18 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-                                      virQEMUCapsCPUFilterFeatures,
-                                      qemuCaps) < 0)
-             goto error;
-+    } else if (type == VIR_DOMAIN_VIRT_KVM &&
-+               virCPUGetHostIsSupported(qemuCaps->arch)) {
-+        if (!(fullCPU = virCPUGetHost(qemuCaps->arch, VIR_CPU_TYPE_GUEST,
-+                                      NULL, NULL, 0)))
-+            goto error;
-+
-+        for (i = 0; i < cpu->nfeatures; i++) {
-+            if (cpu->features[i].policy == VIR_CPU_FEATURE_REQUIRE &&
-+                virCPUDefUpdateFeature(fullCPU, cpu->features[i].name,
-+                                       VIR_CPU_FEATURE_REQUIRE) < 0)
-+                goto error;
-+        }
-     }
- 
-     if (!(migCPU = virQEMUCapsNewHostCPUModel()))
-@@ -3384,7 +3414,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-             goto error;
-     }
- 
--    virQEMUCapsSetHostModel(qemuCaps, type, cpu, migCPU);
-+    virQEMUCapsSetHostModel(qemuCaps, type, cpu, migCPU, fullCPU);
- 
-  cleanup:
-     virCPUDefFree(hostCPU);
-@@ -3393,6 +3423,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-  error:
-     virCPUDefFree(cpu);
-     virCPUDefFree(migCPU);
-+    virCPUDefFree(fullCPU);
-     virResetLastError();
-     goto cleanup;
- }
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index 16fe044cc..644b8e27b 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -456,6 +456,10 @@ typedef enum {
-     VIR_QEMU_CAPS_HOST_CPU_REPORTED,
-     /* Migratable host CPU definition used for updating guest CPU. */
-     VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE,
-+    /* CPU definition with features detected by libvirt using virCPUGetHost
-+     * combined with features reported by QEMU. This is used for backward
-+     * compatible comparison between a guest CPU and a host CPU. */
-+    VIR_QEMU_CAPS_HOST_CPU_FULL,
- } virQEMUCapsHostCPUType;
- 
- virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index c81389ef2..a33ec87e6 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -5307,7 +5307,7 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def,
-     if (def->cpu->check == VIR_CPU_CHECK_PARTIAL &&
-         virCPUCompare(caps->host.arch,
-                       virQEMUCapsGetHostModel(qemuCaps, def->virtType,
--                                              VIR_QEMU_CAPS_HOST_CPU_REPORTED),
-+                                              VIR_QEMU_CAPS_HOST_CPU_FULL),
-                       def->cpu, true) < 0)
-         return -1;
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-Use-predictable-file-names-for-memory-backend-file.patch b/SOURCES/libvirt-qemu-Use-predictable-file-names-for-memory-backend-file.patch
new file mode 100644
index 0000000..afa7bba
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Use-predictable-file-names-for-memory-backend-file.patch
@@ -0,0 +1,391 @@
+From 12f6ee75efb15263f62fb12c693b74b116ac4a4f Mon Sep 17 00:00:00 2001
+Message-Id: <12f6ee75efb15263f62fb12c693b74b116ac4a4f@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Thu, 9 Nov 2017 16:06:47 +0100
+Subject: [PATCH] qemu: Use predictable file names for memory-backend-file
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1461214
+
+In some cases management application needs to allocate memory for
+qemu upfront and then just let qemu use that. Since we don't want
+to expose path for memory-backend-file anywhere in the domain
+XML, we can generate predictable paths. In this case:
+
+  $memoryBackingDir/libvirt/qemu/$shortName/$alias
+
+where $shortName is result of virDomainDefGetShortName().
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit fec8f9c49afb479f6c3c8c388426945f2c1f099b)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c                            |  2 +-
+ src/qemu/qemu_conf.c                               | 55 +++++++++++++++++-
+ src/qemu/qemu_conf.h                               |  9 ++-
+ src/qemu/qemu_driver.c                             | 17 ++++++
+ src/qemu/qemu_process.c                            | 65 ++++++++++++++++++----
+ .../qemuxml2argv-cpu-numa-memshared.args           |  6 +-
+ .../qemuxml2argv-fd-memory-numa-topology.args      |  3 +-
+ .../qemuxml2argv-fd-memory-numa-topology2.args     |  6 +-
+ .../qemuxml2argv-fd-memory-numa-topology3.args     |  9 ++-
+ .../qemuxml2argv-hugepages-memaccess2.args         |  9 ++-
+ 10 files changed, 155 insertions(+), 26 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 57c855c047..f8eb59884c 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -3439,7 +3439,7 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
+         } else {
+             /* We can have both pagesize and mem source. If that's the case,
+              * prefer hugepages as those are more specific. */
+-            if (qemuGetMemoryBackingPath(cfg, &memPath) < 0)
++            if (qemuGetMemoryBackingPath(def, cfg, mem->info.alias, &memPath) < 0)
+                 goto cleanup;
+         }
+ 
+diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
+index 3b670a68c5..e04523223d 100644
+--- a/src/qemu/qemu_conf.c
++++ b/src/qemu/qemu_conf.c
+@@ -1767,9 +1767,41 @@ qemuGetDomainHupageMemPath(const virDomainDef *def,
+ }
+ 
+ 
++int
++qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg,
++                             char **path)
++{
++    return virAsprintf(path, "%s/libvirt/qemu", cfg->memoryBackingDir);
++}
++
++
++int
++qemuGetMemoryBackingDomainPath(const virDomainDef *def,
++                               virQEMUDriverConfigPtr cfg,
++                               char **path)
++{
++    char *shortName = NULL;
++    char *base = NULL;
++    int ret = -1;
++
++    if (!(shortName = virDomainDefGetShortName(def)) ||
++        qemuGetMemoryBackingBasePath(cfg, &base) < 0 ||
++        virAsprintf(path, "%s/%s", base, shortName) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    VIR_FREE(base);
++    VIR_FREE(shortName);
++    return ret;
++}
++
++
+ /**
+  * qemuGetMemoryBackingPath:
++ * @def: domain definition
+  * @cfg: the driver config
++ * @alias: memory object alias
+  * @memPath: constructed path
+  *
+  * Constructs path to memory backing dir and stores it at @memPath.
+@@ -1778,8 +1810,27 @@ qemuGetDomainHupageMemPath(const virDomainDef *def,
+  *          -1 otherwise (with error reported).
+  */
+ int
+-qemuGetMemoryBackingPath(virQEMUDriverConfigPtr cfg,
++qemuGetMemoryBackingPath(const virDomainDef *def,
++                         virQEMUDriverConfigPtr cfg,
++                         const char *alias,
+                          char **memPath)
+ {
+-    return VIR_STRDUP(*memPath, cfg->memoryBackingDir);
++    char *domainPath = NULL;
++    int ret = -1;
++
++    if (!alias) {
++        /* This should never happen (TM) */
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("memory device alias is not assigned"));
++        goto cleanup;
++    }
++
++    if (qemuGetMemoryBackingDomainPath(def, cfg, &domainPath) < 0 ||
++        virAsprintf(memPath, "%s/%s", domainPath, alias) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    VIR_FREE(domainPath);
++    return ret;
+ }
+diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
+index 9d6866816f..a553e30e2e 100644
+--- a/src/qemu/qemu_conf.h
++++ b/src/qemu/qemu_conf.h
+@@ -364,6 +364,13 @@ int qemuGetDomainHupageMemPath(const virDomainDef *def,
+                                unsigned long long pagesize,
+                                char **memPath);
+ 
+-int qemuGetMemoryBackingPath(virQEMUDriverConfigPtr cfg,
++int qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg,
++                                 char **path);
++int qemuGetMemoryBackingDomainPath(const virDomainDef *def,
++                                   virQEMUDriverConfigPtr cfg,
++                                   char **path);
++int qemuGetMemoryBackingPath(const virDomainDef *def,
++                             virQEMUDriverConfigPtr cfg,
++                             const char *alias,
+                              char **memPath);
+ #endif /* __QEMUD_CONF_H */
+diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
+index 5617c78997..6096e00b2a 100644
+--- a/src/qemu/qemu_driver.c
++++ b/src/qemu/qemu_driver.c
+@@ -631,6 +631,7 @@ qemuStateInitialize(bool privileged,
+     uid_t run_uid = -1;
+     gid_t run_gid = -1;
+     char *hugepagePath = NULL;
++    char *memoryBackingPath = NULL;
+     size_t i;
+ 
+     if (VIR_ALLOC(qemu_driver) < 0)
+@@ -889,6 +890,21 @@ qemuStateInitialize(bool privileged,
+         VIR_FREE(hugepagePath);
+     }
+ 
++    if (qemuGetMemoryBackingBasePath(cfg, &memoryBackingPath) < 0)
++        goto error;
++
++    if (virFileMakePath(memoryBackingPath) < 0) {
++        virReportSystemError(errno,
++                             _("unable to create memory backing path %s"),
++                             memoryBackingPath);
++        goto error;
++    }
++
++    if (privileged &&
++        virFileUpdatePerm(memoryBackingPath,
++                          0, S_IXGRP | S_IXOTH) < 0)
++        goto error;
++
+     if (!(qemu_driver->closeCallbacks = virCloseCallbacksNew()))
+         goto error;
+ 
+@@ -946,6 +962,7 @@ qemuStateInitialize(bool privileged,
+     virObjectUnref(conn);
+     VIR_FREE(driverConf);
+     VIR_FREE(hugepagePath);
++    VIR_FREE(memoryBackingPath);
+     qemuStateCleanup();
+     return -1;
+ }
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index 3324cc61f1..86a4dee88e 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -3324,6 +3324,36 @@ qemuProcessNeedHugepagesPath(virDomainDefPtr def,
+ }
+ 
+ 
++static bool
++qemuProcessNeedMemoryBackingPath(virDomainDefPtr def,
++                                 virDomainMemoryDefPtr mem)
++{
++    size_t i;
++    size_t numaNodes;
++
++    if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE ||
++        def->mem.access != VIR_DOMAIN_MEMORY_ACCESS_DEFAULT)
++        return true;
++
++    numaNodes = virDomainNumaGetNodeCount(def->numa);
++    for (i = 0; i < numaNodes; i++) {
++        if (virDomainNumaGetNodeMemoryAccessMode(def->numa, i)
++            != VIR_DOMAIN_MEMORY_ACCESS_DEFAULT)
++            return true;
++    }
++
++    if (mem &&
++        mem->model == VIR_DOMAIN_MEMORY_MODEL_DIMM &&
++        (mem->access != VIR_DOMAIN_MEMORY_ACCESS_DEFAULT ||
++         (mem->targetNode >= 0 &&
++          virDomainNumaGetNodeMemoryAccessMode(def->numa, mem->targetNode)
++          != VIR_DOMAIN_MEMORY_ACCESS_DEFAULT)))
++        return true;
++
++    return false;
++}
++
++
+ static int
+ qemuProcessBuildDestroyMemoryPathsImpl(virQEMUDriverPtr driver,
+                                        virDomainDefPtr def,
+@@ -3363,33 +3393,46 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
+                                    bool build)
+ {
+     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+-    char *hugepagePath = NULL;
++    char *path = NULL;
+     size_t i;
+-    bool shouldBuild = false;
++    bool shouldBuildHP = false;
++    bool shouldBuildMB = false;
+     int ret = -1;
+ 
+-    if (build)
+-        shouldBuild = qemuProcessNeedHugepagesPath(vm->def, mem);
++    if (build) {
++        shouldBuildHP = qemuProcessNeedHugepagesPath(vm->def, mem);
++        shouldBuildMB = qemuProcessNeedMemoryBackingPath(vm->def, mem);
++    }
+ 
+-    if (!build || shouldBuild) {
++    if (!build || shouldBuildHP) {
+         for (i = 0; i < cfg->nhugetlbfs; i++) {
+-            VIR_FREE(hugepagePath);
+-            hugepagePath = qemuGetDomainHugepagePath(vm->def, &cfg->hugetlbfs[i]);
++            path = qemuGetDomainHugepagePath(vm->def, &cfg->hugetlbfs[i]);
+ 
+-            if (!hugepagePath)
++            if (!path)
+                 goto cleanup;
+ 
+             if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm->def,
+-                                                       hugepagePath, build) < 0)
++                                                       path, build) < 0)
+                 goto cleanup;
+ 
+-            VIR_FREE(hugepagePath);
++            VIR_FREE(path);
+         }
+     }
+ 
++    if (!build || shouldBuildMB) {
++        if (qemuGetMemoryBackingDomainPath(vm->def, cfg, &path) < 0)
++            goto cleanup;
++
++        if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm->def,
++                                                   path, build) < 0)
++            goto cleanup;
++
++        VIR_FREE(path);
++    }
++
+     ret = 0;
+  cleanup:
+-    VIR_FREE(hugepagePath);
++    VIR_FREE(path);
+     virObjectUnref(cfg);
+     return ret;
+ }
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
+index 5700c3413f..3528194293 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
+@@ -10,10 +10,12 @@ QEMU_AUDIO_DRV=none \
+ -M pc \
+ -m 214 \
+ -smp 16,sockets=2,cores=4,threads=2 \
+--object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node0,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node0,\
+ share=yes,size=112197632 \
+ -numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
+--object memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node1,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node1,\
+ share=no,size=112197632 \
+ -numa node,nodeid=1,cpus=8-15,memdev=ram-node1 \
+ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.args b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.args
+index 12f3d8ab8c..fa13532596 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.args
+@@ -11,7 +11,8 @@ QEMU_AUDIO_DRV=none \
+ -m 14336 \
+ -mem-prealloc \
+ -smp 8,sockets=1,cores=8,threads=1 \
+--object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node0,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node0,\
+ share=yes,size=15032385536 \
+ -numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
+ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args
+index 585e4d5061..6f73a1b99b 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args
+@@ -11,10 +11,12 @@ QEMU_AUDIO_DRV=none \
+ -m 28672 \
+ -mem-prealloc \
+ -smp 20,sockets=1,cores=8,threads=1 \
+--object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node0,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node0,\
+ share=no,size=15032385536 \
+ -numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
+--object memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node1,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node1,\
+ share=yes,size=15032385536 \
+ -numa node,nodeid=1,cpus=8-15,memdev=ram-node1 \
+ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.args b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.args
+index e9a57a69e5..3c352fe035 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.args
+@@ -11,13 +11,16 @@ QEMU_AUDIO_DRV=none \
+ -m 43008 \
+ -mem-prealloc \
+ -smp 32,sockets=1,cores=24,threads=1 \
+--object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node0,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node0,\
+ share=yes,size=15032385536 \
+ -numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \
+--object memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node1,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node1,\
+ share=yes,size=15032385536 \
+ -numa node,nodeid=1,cpus=2-3,memdev=ram-node1 \
+--object memory-backend-file,id=ram-node2,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node2,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node2,\
+ share=no,size=15032385536 \
+ -numa node,nodeid=2,cpus=4-5,memdev=ram-node2 \
+ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args
+index 55db491719..d8e506c19e 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args
+@@ -10,17 +10,20 @@ QEMU_AUDIO_DRV=none \
+ -M pc \
+ -m size=4194304k,slots=16,maxmem=8388608k \
+ -smp 4,sockets=4,cores=1,threads=1 \
+--object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node0,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node0,\
+ share=no,size=1073741824,host-nodes=0-3,policy=bind \
+ -numa node,nodeid=0,cpus=0,memdev=ram-node0 \
+ -object memory-backend-file,id=ram-node1,prealloc=yes,\
+ mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=1073741824,\
+ host-nodes=0-3,policy=bind \
+ -numa node,nodeid=1,cpus=1,memdev=ram-node1 \
+--object memory-backend-file,id=ram-node2,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node2,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node2,\
+ share=no,size=1073741824,host-nodes=0-3,policy=bind \
+ -numa node,nodeid=2,cpus=2,memdev=ram-node2 \
+--object memory-backend-file,id=ram-node3,mem-path=/var/lib/libvirt/qemu/ram,\
++-object memory-backend-file,id=ram-node3,\
++mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node3,\
+ share=no,size=1073741824,host-nodes=3,policy=bind \
+ -numa node,nodeid=3,cpus=3,memdev=ram-node3 \
+ -object memory-backend-file,id=memdimm0,prealloc=yes,\
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Use-qemuDomainCheckABIStability-where-needed.patch b/SOURCES/libvirt-qemu-Use-qemuDomainCheckABIStability-where-needed.patch
deleted file mode 100644
index e14cc76..0000000
--- a/SOURCES/libvirt-qemu-Use-qemuDomainCheckABIStability-where-needed.patch
+++ /dev/null
@@ -1,131 +0,0 @@
-From 5a76947526023484d27b6f43853602e6e0510063 Mon Sep 17 00:00:00 2001
-Message-Id: <5a76947526023484d27b6f43853602e6e0510063@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 14 Jun 2017 14:56:21 +0200
-Subject: [PATCH] qemu: Use qemuDomainCheckABIStability where needed
-
-Most places which want to check ABI stability for an active domain need
-to call this API rather than the original
-qemuDomainDefCheckABIStability. The only exception is in snapshots where
-we need to decide what to do depending on the saved image data.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1460952
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit f0a3fe1b0a2996272dd167501bb5de752d9d1956)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c    | 71 +++++++++++++++++++++++++++--------------------
- src/qemu/qemu_migration.c |  2 +-
- 2 files changed, 42 insertions(+), 31 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 5567103c37..c7c5e28ca3 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -3326,7 +3326,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-                                             VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) {
-             goto endjob;
-         }
--        if (!qemuDomainDefCheckABIStability(driver, vm->def, def)) {
-+        if (!qemuDomainCheckABIStability(driver, vm, def)) {
-             virDomainDefFree(def);
-             goto endjob;
-         }
-@@ -15415,39 +15415,50 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-          * to have finer control.  */
-         if (virDomainObjIsActive(vm)) {
-             /* Transitions 5, 6, 8, 9 */
--            /* Replace the CPU in config and put the original one in priv
--             * once we're done.
--             */
--            if (cookie && cookie->cpu && config->cpu) {
--                origCPU = config->cpu;
--                if (!(config->cpu = virCPUDefCopy(cookie->cpu)))
--                    goto endjob;
--            }
--
-             /* Check for ABI compatibility. We need to do this check against
-              * the migratable XML or it will always fail otherwise */
--            if (config &&
--                !qemuDomainDefCheckABIStability(driver, vm->def, config)) {
--                virErrorPtr err = virGetLastError();
-+            if (config) {
-+                bool compatible;
- 
--                if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) {
--                    /* Re-spawn error using correct category. */
--                    if (err->code == VIR_ERR_CONFIG_UNSUPPORTED)
--                        virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, "%s",
--                                       err->str2);
--                    goto endjob;
-+                /* Replace the CPU in config and put the original one in priv
-+                 * once we're done. When we have the updated CPU def in the
-+                 * cookie, we don't want to replace the CPU in migratable def
-+                 * when doing ABI checks to make sure the current CPU exactly
-+                 * matches the one used at the time the snapshot was taken.
-+                 */
-+                if (cookie && cookie->cpu && config->cpu) {
-+                    origCPU = config->cpu;
-+                    if (!(config->cpu = virCPUDefCopy(cookie->cpu)))
-+                        goto endjob;
-+
-+                    compatible = qemuDomainDefCheckABIStability(driver, vm->def,
-+                                                                config);
-+                } else {
-+                    compatible = qemuDomainCheckABIStability(driver, vm, config);
-+                }
-+
-+                if (!compatible) {
-+                    virErrorPtr err = virGetLastError();
-+
-+                    if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) {
-+                        /* Re-spawn error using correct category. */
-+                        if (err->code == VIR_ERR_CONFIG_UNSUPPORTED)
-+                            virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, "%s",
-+                                           err->str2);
-+                        goto endjob;
-+                    }
-+                    virResetError(err);
-+                    qemuProcessStop(driver, vm,
-+                                    VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT,
-+                                    QEMU_ASYNC_JOB_START, 0);
-+                    virDomainAuditStop(vm, "from-snapshot");
-+                    detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT;
-+                    event = virDomainEventLifecycleNewFromObj(vm,
-+                                                     VIR_DOMAIN_EVENT_STOPPED,
-+                                                     detail);
-+                    qemuDomainEventQueue(driver, event);
-+                    goto load;
-                 }
--                virResetError(err);
--                qemuProcessStop(driver, vm,
--                                VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT,
--                                QEMU_ASYNC_JOB_START, 0);
--                virDomainAuditStop(vm, "from-snapshot");
--                detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT;
--                event = virDomainEventLifecycleNewFromObj(vm,
--                                                 VIR_DOMAIN_EVENT_STOPPED,
--                                                 detail);
--                qemuDomainEventQueue(driver, event);
--                goto load;
-             }
- 
-             priv = vm->privateData;
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index a4540ce3c4..5eed933a3c 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -2028,7 +2028,7 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
-                                             VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
-             goto cleanup;
- 
--        if (!qemuDomainDefCheckABIStability(driver, vm->def, def))
-+        if (!qemuDomainCheckABIStability(driver, vm, def))
-             goto cleanup;
- 
-         rv = qemuDomainDefFormatLive(driver, def, NULL, false, true);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Use-the-end-of-QEMU-log-for-reporting-errors.patch b/SOURCES/libvirt-qemu-Use-the-end-of-QEMU-log-for-reporting-errors.patch
new file mode 100644
index 0000000..f3053bb
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Use-the-end-of-QEMU-log-for-reporting-errors.patch
@@ -0,0 +1,102 @@
+From 0b0135f00c4e17cb902ec6885648b5a4e667d56b Mon Sep 17 00:00:00 2001
+Message-Id: <0b0135f00c4e17cb902ec6885648b5a4e667d56b@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Wed, 22 Nov 2017 13:12:00 +0100
+Subject: [PATCH] qemu: Use the end of QEMU log for reporting errors
+
+When QEMU dies, we read its output stored in a log file and use it for
+reporting a hopefully useful error. However, virReportError will trim
+the message to (VIR_ERROR_MAX_LENGTH - 1) characters, which means the
+end of the log (which likely contains the error message we want to
+report) may get lost. We should trim the beginning of the log instead.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1335534
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 96f7a045e93ad08eb4130be97dd6d8a8c963a952)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+---
+ src/qemu/qemu_process.c | 34 ++++++++++++++++++++++++++++++----
+ 1 file changed, 30 insertions(+), 4 deletions(-)
+
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index c5fa8cb4b2..f7808227a8 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -1827,17 +1827,24 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob,
+  * qemuProcessReadLog: Read log file of a qemu VM
+  * @logCtxt: the domain log context
+  * @msg: pointer to buffer to store the read messages in
++ * @max: maximum length of the message returned in @msg
+  *
+  * Reads log of a qemu VM. Skips messages not produced by qemu or irrelevant
+- * messages. Returns returns 0 on success or -1 on error
++ * messages. If @max is not zero, @msg will contain at most @max characters
++ * from the end of the log and @msg will start after a new line if possible.
++ *
++ * Returns 0 on success or -1 on error
+  */
+ static int
+-qemuProcessReadLog(qemuDomainLogContextPtr logCtxt, char **msg)
++qemuProcessReadLog(qemuDomainLogContextPtr logCtxt,
++                   char **msg,
++                   size_t max)
+ {
+     char *buf;
+     ssize_t got;
+     char *eol;
+     char *filter_next;
++    size_t skip;
+ 
+     if ((got = qemuDomainLogContextRead(logCtxt, &buf)) < 0)
+         return -1;
+@@ -1848,7 +1855,7 @@ qemuProcessReadLog(qemuDomainLogContextPtr logCtxt, char **msg)
+         *eol = '\0';
+         if (virLogProbablyLogMessage(filter_next) ||
+             strstr(filter_next, "char device redirected to")) {
+-            size_t skip = (eol + 1) - filter_next;
++            skip = (eol + 1) - filter_next;
+             memmove(filter_next, eol + 1, buf + got - eol);
+             got -= skip;
+         } else {
+@@ -1863,6 +1870,19 @@ qemuProcessReadLog(qemuDomainLogContextPtr logCtxt, char **msg)
+         buf[got - 1] = '\0';
+         got--;
+     }
++
++    if (max > 0 && got > max) {
++        skip = got - max;
++
++        if (buf[skip - 1] != '\n' &&
++            (eol = strchr(buf + skip, '\n')) &&
++            !virStringIsEmpty(eol + 1))
++            skip = eol + 1 - buf;
++
++        memmove(buf, buf + skip, got - skip + 1);
++        got -= skip;
++    }
++
+     ignore_value(VIR_REALLOC_N_QUIET(buf, got + 1));
+     *msg = buf;
+     return 0;
+@@ -1874,8 +1894,14 @@ qemuProcessReportLogError(qemuDomainLogContextPtr logCtxt,
+                           const char *msgprefix)
+ {
+     char *logmsg = NULL;
++    size_t max;
+ 
+-    if (qemuProcessReadLog(logCtxt, &logmsg) < 0)
++    max = VIR_ERROR_MAX_LENGTH - 1;
++    max -= strlen(msgprefix);
++    /* The length of the formatting string minus two '%s' */
++    max -= strlen(_("%s: %s")) - 4;
++
++    if (qemuProcessReadLog(logCtxt, &logmsg, max) < 0)
+         return -1;
+ 
+     virResetLastError();
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-Use-updated-CPU-when-starting-QEMU-if-possible.patch b/SOURCES/libvirt-qemu-Use-updated-CPU-when-starting-QEMU-if-possible.patch
deleted file mode 100644
index 7367e2d..0000000
--- a/SOURCES/libvirt-qemu-Use-updated-CPU-when-starting-QEMU-if-possible.patch
+++ /dev/null
@@ -1,325 +0,0 @@
-From 3b5aa0e6272a4b507034bba3d093734ebd658b3b Mon Sep 17 00:00:00 2001
-Message-Id: <3b5aa0e6272a4b507034bba3d093734ebd658b3b@dist-git>
-From: Jiri Denemark <jdenemar@redhat.com>
-Date: Wed, 31 May 2017 12:34:10 +0200
-Subject: [PATCH] qemu: Use updated CPU when starting QEMU if possible
-
-If QEMU is new enough and we have the live updated CPU definition in
-either save or migration cookie, we can use it to enforce ABI. The
-original guest CPU from domain XML will be stored in private data.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 8e34f478137c2a6b5e57e382729bd2776b042301)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c    | 40 ++++++++++++++++++++++++++++++++++++++++
- src/qemu/qemu_domain.h    |  5 +++++
- src/qemu/qemu_driver.c    | 30 ++++++++++++++++++++++++------
- src/qemu/qemu_migration.c |  2 +-
- src/qemu/qemu_process.c   | 24 ++++++++++++++++++++++--
- src/qemu/qemu_process.h   |  2 ++
- 6 files changed, 94 insertions(+), 9 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 7897a44634..82dacb3c9c 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -9225,3 +9225,43 @@ virSaveCookieCallbacks virQEMUDriverDomainSaveCookie = {
-     .parse = qemuDomainSaveCookieParse,
-     .format = qemuDomainSaveCookieFormat,
- };
-+
-+
-+/**
-+ * qemuDomainUpdateCPU:
-+ * @vm: domain which is being started
-+ * @cpu: CPU updated when the domain was running previously (before migration,
-+ *       snapshot, or save)
-+ * @origCPU: where to store the original CPU from vm->def in case @cpu was
-+ *           used instead
-+ *
-+ * Replace the CPU definition with the updated one when QEMU is new enough to
-+ * allow us to check extra features it is about to enable or disable when
-+ * starting a domain. The original CPU is stored in @origCPU.
-+ *
-+ * Returns 0 on success, -1 on error.
-+ */
-+int
-+qemuDomainUpdateCPU(virDomainObjPtr vm,
-+                    virCPUDefPtr cpu,
-+                    virCPUDefPtr *origCPU)
-+{
-+    qemuDomainObjPrivatePtr priv = vm->privateData;
-+
-+    *origCPU = NULL;
-+
-+    if (!cpu || !vm->def->cpu ||
-+        !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION) ||
-+        virCPUDefIsEqual(vm->def->cpu, cpu, false))
-+        return 0;
-+
-+    if (!(cpu = virCPUDefCopy(cpu)))
-+        return -1;
-+
-+    VIR_DEBUG("Replacing CPU def with the updated one");
-+
-+    *origCPU = vm->def->cpu;
-+    vm->def->cpu = cpu;
-+
-+    return 0;
-+}
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 2eea7924fb..d635d2995f 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -921,4 +921,9 @@ char *qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk,
- virStorageSourcePtr qemuDomainGetStorageSourceByDevstr(const char *devstr,
-                                                        virDomainDefPtr def);
- 
-+int
-+qemuDomainUpdateCPU(virDomainObjPtr vm,
-+                    virCPUDefPtr cpu,
-+                    virCPUDefPtr *origCPU);
-+
- #endif /* __QEMU_DOMAIN_H__ */
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index f5c5c302be..5567103c37 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -1782,7 +1782,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
-         goto cleanup;
-     }
- 
--    if (qemuProcessStart(conn, driver, vm, QEMU_ASYNC_JOB_START,
-+    if (qemuProcessStart(conn, driver, vm, NULL, QEMU_ASYNC_JOB_START,
-                          NULL, -1, NULL, NULL,
-                          VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
-                          start_flags) < 0) {
-@@ -6500,8 +6500,8 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
-         }
-     }
- 
--    if (qemuProcessStart(conn, driver, vm, asyncJob,
--                         "stdio", *fd, path, NULL,
-+    if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL,
-+                         asyncJob, "stdio", *fd, path, NULL,
-                          VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
-                          VIR_QEMU_PROCESS_START_PAUSED) == 0)
-         restored = true;
-@@ -7118,7 +7118,7 @@ qemuDomainObjStart(virConnectPtr conn,
-         }
-     }
- 
--    ret = qemuProcessStart(conn, driver, vm, asyncJob,
-+    ret = qemuProcessStart(conn, driver, vm, NULL, asyncJob,
-                            NULL, -1, NULL, NULL,
-                            VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags);
-     virDomainAuditStart(vm, "booted", ret >= 0);
-@@ -15295,6 +15295,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-     virCapsPtr caps = NULL;
-     bool was_running = false;
-     bool was_stopped = false;
-+    qemuDomainSaveCookiePtr cookie;
-+    virCPUDefPtr origCPU = NULL;
- 
-     virCheckFlags(VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING |
-                   VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED |
-@@ -15400,6 +15402,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-             goto endjob;
-     }
- 
-+    cookie = (qemuDomainSaveCookiePtr) snap->def->cookie;
-+
-     switch ((virDomainState) snap->def->state) {
-     case VIR_DOMAIN_RUNNING:
-     case VIR_DOMAIN_PAUSED:
-@@ -15411,6 +15415,15 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-          * to have finer control.  */
-         if (virDomainObjIsActive(vm)) {
-             /* Transitions 5, 6, 8, 9 */
-+            /* Replace the CPU in config and put the original one in priv
-+             * once we're done.
-+             */
-+            if (cookie && cookie->cpu && config->cpu) {
-+                origCPU = config->cpu;
-+                if (!(config->cpu = virCPUDefCopy(cookie->cpu)))
-+                    goto endjob;
-+            }
-+
-             /* Check for ABI compatibility. We need to do this check against
-              * the migratable XML or it will always fail otherwise */
-             if (config &&
-@@ -15470,8 +15483,11 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-                  * failed loadvm attempt? */
-                 goto endjob;
-             }
--            if (config)
-+            if (config) {
-                 virDomainObjAssignDef(vm, config, false, NULL);
-+                virCPUDefFree(priv->origCPU);
-+                VIR_STEAL_PTR(priv->origCPU, origCPU);
-+            }
-         } else {
-             /* Transitions 2, 3 */
-         load:
-@@ -15480,6 +15496,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-                 virDomainObjAssignDef(vm, config, false, NULL);
- 
-             rc = qemuProcessStart(snapshot->domain->conn, driver, vm,
-+                                  cookie ? cookie->cpu : NULL,
-                                   QEMU_ASYNC_JOB_START, NULL, -1, NULL, snap,
-                                   VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
-                                   VIR_QEMU_PROCESS_START_PAUSED);
-@@ -15573,7 +15590,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-             start_flags |= paused ? VIR_QEMU_PROCESS_START_PAUSED : 0;
- 
-             qemuDomainEventQueue(driver, event);
--            rc = qemuProcessStart(snapshot->domain->conn, driver, vm,
-+            rc = qemuProcessStart(snapshot->domain->conn, driver, vm, NULL,
-                                   QEMU_ASYNC_JOB_START, NULL, -1, NULL, NULL,
-                                   VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
-                                   start_flags);
-@@ -15645,6 +15662,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-     virObjectUnref(caps);
-     virObjectUnref(cfg);
-     virNWFilterUnlockFilterUpdates();
-+    virCPUDefFree(origCPU);
- 
-     return ret;
- }
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index c03f1be575..a4540ce3c4 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -2650,7 +2650,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
-         goto stopjob;
-     }
- 
--    if (qemuProcessInit(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
-+    if (qemuProcessInit(driver, vm, mig->cpu, QEMU_ASYNC_JOB_MIGRATION_IN,
-                         true, VIR_QEMU_PROCESS_START_AUTODESTROY) < 0)
-         goto stopjob;
-     stopProcess = true;
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 79f780ed46..a7abfc720e 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3946,6 +3946,13 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
-         if (qemuProcessVerifyCPUFeatures(def, cpu) < 0)
-             goto cleanup;
- 
-+        /* Don't update the CPU if we already did so when starting a domain
-+         * during migration, restore or snapshot revert. */
-+        if (priv->origCPU) {
-+            ret = 0;
-+            goto cleanup;
-+        }
-+
-         if (!(orig = virCPUDefCopy(def->cpu)))
-             goto cleanup;
- 
-@@ -4864,6 +4871,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
- int
- qemuProcessInit(virQEMUDriverPtr driver,
-                 virDomainObjPtr vm,
-+                virCPUDefPtr updatedCPU,
-                 qemuDomainAsyncJob asyncJob,
-                 bool migration,
-                 unsigned int flags)
-@@ -4872,6 +4880,7 @@ qemuProcessInit(virQEMUDriverPtr driver,
-     virCapsPtr caps = NULL;
-     qemuDomainObjPrivatePtr priv = vm->privateData;
-     int stopFlags;
-+    virCPUDefPtr origCPU = NULL;
-     int ret = -1;
- 
-     VIR_DEBUG("vm=%p name=%s id=%d migration=%d",
-@@ -4896,6 +4905,9 @@ qemuProcessInit(virQEMUDriverPtr driver,
-                                                       vm->def->os.machine)))
-         goto cleanup;
- 
-+    if (qemuDomainUpdateCPU(vm, updatedCPU, &origCPU) < 0)
-+        goto cleanup;
-+
-     if (qemuProcessStartValidate(driver, vm, priv->qemuCaps, caps, flags) < 0)
-         goto cleanup;
- 
-@@ -4928,11 +4940,14 @@ qemuProcessInit(virQEMUDriverPtr driver,
- 
-         if (qemuDomainSetPrivatePaths(driver, vm) < 0)
-             goto stop;
-+
-+        VIR_STEAL_PTR(priv->origCPU, origCPU);
-     }
- 
-     ret = 0;
- 
-  cleanup:
-+    virCPUDefFree(origCPU);
-     virObjectUnref(cfg);
-     virObjectUnref(caps);
-     return ret;
-@@ -5963,6 +5978,7 @@ int
- qemuProcessStart(virConnectPtr conn,
-                  virQEMUDriverPtr driver,
-                  virDomainObjPtr vm,
-+                 virCPUDefPtr updatedCPU,
-                  qemuDomainAsyncJob asyncJob,
-                  const char *migrateFrom,
-                  int migrateFd,
-@@ -5993,7 +6009,8 @@ qemuProcessStart(virConnectPtr conn,
-     if (!migrateFrom && !snapshot)
-         flags |= VIR_QEMU_PROCESS_START_NEW;
- 
--    if (qemuProcessInit(driver, vm, asyncJob, !!migrateFrom, flags) < 0)
-+    if (qemuProcessInit(driver, vm, updatedCPU,
-+                        asyncJob, !!migrateFrom, flags) < 0)
-         goto cleanup;
- 
-     if (migrateFrom) {
-@@ -6072,7 +6089,8 @@ qemuProcessCreatePretendCmd(virConnectPtr conn,
-     flags |= VIR_QEMU_PROCESS_START_PRETEND;
-     flags |= VIR_QEMU_PROCESS_START_NEW;
- 
--    if (qemuProcessInit(driver, vm, QEMU_ASYNC_JOB_NONE, !!migrateURI, flags) < 0)
-+    if (qemuProcessInit(driver, vm, NULL, QEMU_ASYNC_JOB_NONE,
-+                        !!migrateURI, flags) < 0)
-         goto cleanup;
- 
-     if (qemuProcessPrepareDomain(conn, driver, vm, flags) < 0)
-@@ -6474,6 +6492,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
- 
-     /* clean up migration data */
-     VIR_FREE(priv->migTLSAlias);
-+    virCPUDefFree(priv->origCPU);
-+    priv->origCPU = NULL;
- 
-     /* clear previously used namespaces */
-     virBitmapFree(priv->namespaces);
-diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
-index 830d8cef84..c38310b47a 100644
---- a/src/qemu/qemu_process.h
-+++ b/src/qemu/qemu_process.h
-@@ -75,6 +75,7 @@ typedef enum {
- int qemuProcessStart(virConnectPtr conn,
-                      virQEMUDriverPtr driver,
-                      virDomainObjPtr vm,
-+                     virCPUDefPtr updatedCPU,
-                      qemuDomainAsyncJob asyncJob,
-                      const char *migrateFrom,
-                      int stdin_fd,
-@@ -93,6 +94,7 @@ virCommandPtr qemuProcessCreatePretendCmd(virConnectPtr conn,
- 
- int qemuProcessInit(virQEMUDriverPtr driver,
-                     virDomainObjPtr vm,
-+                    virCPUDefPtr updatedCPU,
-                     qemuDomainAsyncJob asyncJob,
-                     bool migration,
-                     unsigned int flags);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-Validate-target-model-for-serial-devices.patch b/SOURCES/libvirt-qemu-Validate-target-model-for-serial-devices.patch
new file mode 100644
index 0000000..6004ce1
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Validate-target-model-for-serial-devices.patch
@@ -0,0 +1,99 @@
+From 37bf217cd53b115427999d5421dca30eb472616c Mon Sep 17 00:00:00 2001
+Message-Id: <37bf217cd53b115427999d5421dca30eb472616c@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:09 +0100
+Subject: [PATCH] qemu: Validate target model for serial devices
+
+Target model and target type must agree for the configuration
+to make sense, so check that's actually the case and error out
+otherwise.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit a9254a2d6e9db1030350ff562b9ea91494143aa9)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/libvirt_private.syms |  2 ++
+ src/qemu/qemu_domain.c   | 41 +++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 43 insertions(+)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 65b1143c9b..ecf7036dff 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -209,6 +209,8 @@ virDomainChrGetDomainPtrs;
+ virDomainChrInsertPreAlloced;
+ virDomainChrPreAlloc;
+ virDomainChrRemove;
++virDomainChrSerialTargetModelTypeFromString;
++virDomainChrSerialTargetModelTypeToString;
+ virDomainChrSerialTargetTypeFromString;
+ virDomainChrSerialTargetTypeToString;
+ virDomainChrSourceDefClear;
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index a8a91de2fe..7b5bc97de6 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3475,6 +3475,25 @@ qemuDomainChrSerialTargetTypeToAddressType(int targetType)
+ }
+ 
+ 
++static int
++qemuDomainChrSerialTargetModelToTargetType(int targetModel)
++{
++    switch ((virDomainChrSerialTargetModel) targetModel) {
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
++        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
++        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
++        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI;
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
++    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
++        break;
++    }
++
++    return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
++}
++
++
+ static int
+ qemuDomainChrTargetDefValidate(const virDomainDef *def,
+                                const virDomainChrDef *chr)
+@@ -3511,6 +3530,28 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def,
+         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+             break;
+         }
++
++        /* Validate target model */
++        switch ((virDomainChrSerialTargetModel) chr->targetModel) {
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
++
++            expected = qemuDomainChrSerialTargetModelToTargetType(chr->targetModel);
++
++            if (chr->targetType != expected) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                               _("Target model '%s' requires target type '%s'"),
++                               virDomainChrSerialTargetModelTypeToString(chr->targetModel),
++                               virDomainChrSerialTargetTypeToString(expected));
++                return -1;
++            }
++            break;
++
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
++        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
++            break;
++        }
+         break;
+ 
+     case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-add-QEMU_CAPS_DEVICE_SCLPLMCONSOLE.patch b/SOURCES/libvirt-qemu-add-QEMU_CAPS_DEVICE_SCLPLMCONSOLE.patch
new file mode 100644
index 0000000..0e0d604
--- /dev/null
+++ b/SOURCES/libvirt-qemu-add-QEMU_CAPS_DEVICE_SCLPLMCONSOLE.patch
@@ -0,0 +1,162 @@
+From c77b3a25ee9f277359018a1b65ea73fefd9d4c4e Mon Sep 17 00:00:00 2001
+Message-Id: <c77b3a25ee9f277359018a1b65ea73fefd9d4c4e@dist-git>
+From: Pino Toscano <ptoscano@redhat.com>
+Date: Wed, 29 Nov 2017 16:22:53 +0100
+Subject: [PATCH] qemu: add QEMU_CAPS_DEVICE_SCLPLMCONSOLE
+
+Add a separate capability for the sclplmconsole device, and check it
+specifically instead of using QEMU_CAPS_DEVICE_SCLPCONSOLE for that too.
+
+Signed-off-by: Pino Toscano <ptoscano@redhat.com>
+Reviewed-by: Andrea Bolognani <abologna@redhat.com>
+(cherry picked from commit 593639ffffa43f52aae53038bc8bd75ec700b12f)
+
+ Conflicts:
+	src/qemu/qemu_capabilities.c
+	src/qemu/qemu_capabilities.h
+	tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+	tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
+
+	Insert the new capability in the right place, both in the
+	declaration and in caps.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c                     |  3 ++-
+ src/qemu/qemu_capabilities.h                     |  2 +-
+ src/qemu/qemu_command.c                          | 22 +++++++++++++++++++++-
+ tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml |  1 +
+ tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml  |  1 +
+ tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml  |  1 +
+ tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml  |  1 +
+ 7 files changed, 28 insertions(+), 3 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 374a2e79a7..322e0423d6 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -448,7 +448,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
+               "spapr-vty",
+ 
+               /* 275 */
+-
++              "sclplmconsole",
+ 
+               "disk-share-rw",
+     );
+@@ -1680,6 +1680,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
+     { "qemu-xhci", QEMU_CAPS_DEVICE_QEMU_XHCI },
+     { "spapr-pci-host-bridge", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE },
+     { "spapr-vty", QEMU_CAPS_DEVICE_SPAPR_VTY },
++    { "sclplmconsole", QEMU_CAPS_DEVICE_SCLPLMCONSOLE },
+ };
+ 
+ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = {
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index f115738b6b..c3a15948cf 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -434,7 +434,7 @@ typedef enum {
+     QEMU_CAPS_DEVICE_SPAPR_VTY, /* -device spapr-vty */
+ 
+     /* 275 */
+-
++    QEMU_CAPS_DEVICE_SCLPLMCONSOLE, /* -device sclplmconsole */
+ 
+     QEMU_CAPS_DISK_SHARE_RW, /* share-rw=on for concurrent disk access */
+ 
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 092d820b1d..19a819a3aa 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9419,7 +9419,6 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
+ 
+         switch (console->targetType) {
+         case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP:
+-        case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM:
+             if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCLPCONSOLE)) {
+                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                _("sclpconsole is not supported in this QEMU binary"));
+@@ -9440,6 +9439,27 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
+                 return -1;
+             break;
+ 
++        case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM:
++            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCLPLMCONSOLE)) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                               _("sclplmconsole is not supported in this QEMU binary"));
++                return -1;
++            }
++
++            if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
++                                                  console->source,
++                                                  console->info.alias,
++                                                  qemuCaps, true,
++                                                  chardevStdioLogd)))
++                return -1;
++            virCommandAddArg(cmd, "-chardev");
++            virCommandAddArg(cmd, devstr);
++            VIR_FREE(devstr);
++
++            if (qemuBuildChrDeviceCommandLine(cmd, def, console, qemuCaps) < 0)
++                return -1;
++            break;
++
+         case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO:
+             if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
+                                                   console->source,
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+index a6900bf1ef..463c30c77a 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+@@ -141,6 +141,7 @@
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='vxhs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='sclplmconsole'/>
+   <flag name='disk-share-rw'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
+diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml
+index c5dfa2a9d0..c2f310cd46 100644
+--- a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml
++++ b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml
+@@ -135,6 +135,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='sclplmconsole'/>
+   <version>2007000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml
+index 6d26896ef9..f6e024dc61 100644
+--- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml
++++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml
+@@ -137,6 +137,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='sclplmconsole'/>
+   <version>2007093</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
+index 4150b8eee7..5c4a02c8b1 100644
+--- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
++++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
+@@ -138,6 +138,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='sclplmconsole'/>
+   <flag name='disk-share-rw'/>
+   <version>2009000</version>
+   <kvmVersion>0</kvmVersion>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-add-support-for-qemu-xhci-USB-controller.patch b/SOURCES/libvirt-qemu-add-support-for-qemu-xhci-USB-controller.patch
deleted file mode 100644
index f5c1258..0000000
--- a/SOURCES/libvirt-qemu-add-support-for-qemu-xhci-USB-controller.patch
+++ /dev/null
@@ -1,263 +0,0 @@
-From 41750fbfbd634a090bbe399e18196d080e89b014 Mon Sep 17 00:00:00 2001
-Message-Id: <41750fbfbd634a090bbe399e18196d080e89b014@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Fri, 28 Apr 2017 11:59:50 +0200
-Subject: [PATCH] qemu: add support for qemu-xhci USB controller
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1438682
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Acked-by: Andrea Bolognani <abologna@redhat.com>
-(cherry picked from commit 278e70f8f8bac9e6482099d7f3f1a7a8f2109b5f)
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- docs/formatdomain.html.in                             |  4 ++--
- docs/schemas/domaincommon.rng                         |  1 +
- src/conf/domain_addr.c                                |  1 +
- src/conf/domain_conf.c                                |  1 +
- src/conf/domain_conf.h                                |  1 +
- src/qemu/qemu_command.c                               |  8 ++++++--
- src/qemu/qemu_domain.c                                | 12 +++++++-----
- src/qemu/qemu_domain_address.c                        |  1 +
- .../qemuxml2argv-usb-controller-qemu-xhci-limit.xml   | 14 ++++++++++++++
- ...uxml2argv-usb-controller-qemu-xhci-unavailable.xml |  1 +
- .../qemuxml2argv-usb-controller-qemu-xhci.args        | 19 +++++++++++++++++++
- .../qemuxml2argv-usb-controller-qemu-xhci.xml         | 14 ++++++++++++++
- tests/qemuxml2argvtest.c                              |  4 ++++
- 13 files changed, 72 insertions(+), 9 deletions(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci-limit.xml
- create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci-unavailable.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci.xml
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index c82cd69a2..2dc5e751a 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -3495,8 +3495,8 @@
-         <code>model</code>, which is one of "piix3-uhci", "piix4-uhci",
-         "ehci", "ich9-ehci1", "ich9-uhci1", "ich9-uhci2", "ich9-uhci3",
-         "vt82c686b-uhci", "pci-ohci", "nec-xhci", "qusb1" (xen pvusb
--        with qemu backend, version 1.1) or "qusb2" (xen pvusb with qemu
--        backend, version 2.0). Additionally,
-+        with qemu backend, version 1.1), "qusb2" (xen pvusb with qemu
-+        backend, version 2.0) or "qemu-xhci". Additionally,
-          <span class="since">since 0.10.0</span>, if the USB bus needs to
-          be explicitly disabled for the guest, <code>model='none'</code>
-          may be used.  <span class="since">Since 1.0.5</span>, no default
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index 7a9b4b702..7271f0113 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -1877,6 +1877,7 @@
-                   <value>none</value>
-                   <value>qusb1</value>
-                   <value>qusb2</value>
-+                  <value>qemu-xhci</value>
-                 </choice>
-               </attribute>
-             </optional>
-diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
-index 8b6109199..639168eff 100644
---- a/src/conf/domain_addr.c
-+++ b/src/conf/domain_addr.c
-@@ -1673,6 +1673,7 @@ virDomainUSBAddressControllerModelToPorts(virDomainControllerDefPtr cont)
-         return 3;
- 
-     case VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI:
-+    case VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI:
-         if (cont->opts.usbopts.ports != -1)
-             return cont->opts.usbopts.ports;
-         return 4;
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 2d5d00cf2..7ab5e5051 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -366,6 +366,7 @@ VIR_ENUM_IMPL(virDomainControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST,
-               "nec-xhci",
-               "qusb1",
-               "qusb2",
-+              "qemu-xhci",
-               "none")
- 
- VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 1dbbcdc51..c91791262 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -735,6 +735,7 @@ typedef enum {
-     VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
-     VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1,
-     VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2,
-+    VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI,
-     VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
- 
-     VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 9ce90c25b..30feef1de 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -152,6 +152,7 @@ VIR_ENUM_IMPL(qemuControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST,
-               "nec-usb-xhci",
-               "qusb1",
-               "qusb2",
-+              "qemu-xhci",
-               "none");
- 
- VIR_ENUM_DECL(qemuDomainFSDriver)
-@@ -2558,6 +2559,8 @@ qemuControllerModelUSBToCaps(int model)
-         return QEMU_CAPS_PCI_OHCI;
-     case VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI:
-         return QEMU_CAPS_NEC_USB_XHCI;
-+    case VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI:
-+        return QEMU_CAPS_DEVICE_QEMU_XHCI;
-     default:
-         return -1;
-     }
-@@ -2592,8 +2595,9 @@ qemuBuildUSBControllerDevStr(virDomainControllerDefPtr def,
-     virBufferAsprintf(buf, "%s", smodel);
- 
-     if (def->opts.usbopts.ports != -1) {
--        if (model != VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI ||
--            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI_PORTS)) {
-+        if ((model != VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI ||
-+             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI_PORTS)) &&
-+            model != VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                            _("usb controller type %s doesn't support 'ports' "
-                              "with this QEMU binary"), smodel);
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 25ab1f639..4d7de60cb 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -3194,7 +3194,7 @@ qemuDomainShmemDefPostParse(virDomainShmemDefPtr shm)
- }
- 
- 
--#define QEMU_USB_NEC_XHCI_MAXPORTS 15
-+#define QEMU_USB_XHCI_MAXPORTS 15
- 
- 
- static int
-@@ -3262,11 +3262,13 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
-                            virDomainVirtTypeToString(def->virtType));
-             return -1;
-         }
--        if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI &&
--            cont->opts.usbopts.ports > QEMU_USB_NEC_XHCI_MAXPORTS) {
-+        if ((cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI ||
-+             cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI) &&
-+            cont->opts.usbopts.ports > QEMU_USB_XHCI_MAXPORTS) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--                           _("nec-xhci controller only supports up to %u ports"),
--                           QEMU_USB_NEC_XHCI_MAXPORTS);
-+                           _("'%s' controller only supports up to '%u' ports"),
-+                           virDomainControllerModelUSBTypeToString(cont->model),
-+                           QEMU_USB_XHCI_MAXPORTS);
-             return -1;
-         }
-         break;
-diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
-index 064d05079..3da6b7369 100644
---- a/src/qemu/qemu_domain_address.c
-+++ b/src/qemu/qemu_domain_address.c
-@@ -502,6 +502,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
-         case VIR_DOMAIN_CONTROLLER_TYPE_USB:
-             switch ((virDomainControllerModelUSB) cont->model) {
-             case VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI:
-+            case VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI:
-                 return pcieFlags;
- 
-             case VIR_DOMAIN_CONTROLLER_MODEL_USB_EHCI:
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci-limit.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci-limit.xml
-new file mode 100644
-index 000000000..27cc99127
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci-limit.xml
-@@ -0,0 +1,14 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+  </os>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <controller type='usb' index='0' model='qemu-xhci' ports='16'/>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci-unavailable.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci-unavailable.xml
-new file mode 120000
-index 000000000..989306fa7
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci-unavailable.xml
-@@ -0,0 +1 @@
-+qemuxml2argv-usb-controller-qemu-xhci.xml
-\ No newline at end of file
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci.args
-new file mode 100644
-index 000000000..8adb3022f
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci.args
-@@ -0,0 +1,19 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-x86_64 \
-+-name QEMUGuest1 \
-+-S \
-+-M pc-0.11 \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-device qemu-xhci,p2=8,p3=8,id=usb,bus=pci.0,addr=0x3
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci.xml
-new file mode 100644
-index 000000000..b63f9e1c4
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-qemu-xhci.xml
-@@ -0,0 +1,14 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+  </os>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <controller type='usb' index='0' model='qemu-xhci' ports='8'/>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index ca1d23c10..317f17e74 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -1424,6 +1424,10 @@ mymain(void)
-     DO_TEST_PARSE_ERROR("usb-controller-xhci-limit",
-             QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
-             QEMU_CAPS_NEC_USB_XHCI, QEMU_CAPS_NEC_USB_XHCI_PORTS);
-+    DO_TEST("usb-controller-qemu-xhci", QEMU_CAPS_DEVICE_QEMU_XHCI);
-+    DO_TEST_FAILURE("usb-controller-qemu-xhci-unavailable", NONE);
-+    DO_TEST_PARSE_ERROR("usb-controller-qemu-xhci-limit",
-+                        QEMU_CAPS_DEVICE_QEMU_XHCI);
- 
-     DO_TEST("smbios", QEMU_CAPS_SMBIOS_TYPE);
-     DO_TEST_PARSE_ERROR("smbios-date", QEMU_CAPS_SMBIOS_TYPE);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-add-vmcoreinfo-support.patch b/SOURCES/libvirt-qemu-add-vmcoreinfo-support.patch
new file mode 100644
index 0000000..0cc7d72
--- /dev/null
+++ b/SOURCES/libvirt-qemu-add-vmcoreinfo-support.patch
@@ -0,0 +1,342 @@
+From b66931b0282f0209a262854b54b590d008070f85 Mon Sep 17 00:00:00 2001
+Message-Id: <b66931b0282f0209a262854b54b590d008070f85@dist-git>
+From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
+Date: Wed, 29 Nov 2017 17:00:04 +0100
+Subject: [PATCH] qemu: add vmcoreinfo support
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Starting from qemu 2.11, the `-device vmcoreinfo` will create a fw_cfg
+entry for a guest to store dump details, necessary to process kernel
+dump with KASLR enabled and providing additional kernel details.
+
+In essence, it is similar to -fw_cfg name=etc/vmcoreinfo,file=X but in
+this case it is not backed by a file, but collected by QEMU itself.
+
+Since the device is a singleton and shouldn't use additional hardware
+resources, it is presented as a <feature> element in the libvirt
+domain XML.
+
+The device is arm/x86 only for now (targets that support fw_cfg+dma).
+
+Related to:
+https://bugzilla.redhat.com/show_bug.cgi?id=1395248
+
+Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
+(cherry picked from commit 7e4177a35bae49a53b04940be04418daaa988734)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ docs/formatdomain.html.in                          |  4 +++
+ docs/schemas/domaincommon.rng                      |  9 +++++
+ src/conf/domain_conf.c                             |  3 ++
+ src/conf/domain_conf.h                             |  1 +
+ src/qemu/qemu_capabilities.c                       |  3 +-
+ src/qemu/qemu_capabilities.h                       |  2 +-
+ src/qemu/qemu_command.c                            | 25 ++++++++++++++
+ .../qemuxml2argvdata/qemuxml2argv-vmcoreinfo.args  | 25 ++++++++++++++
+ tests/qemuxml2argvdata/qemuxml2argv-vmcoreinfo.xml | 28 ++++++++++++++++
+ tests/qemuxml2argvtest.c                           |  1 +
+ .../qemuxml2xmlout-vmcoreinfo.xml                  | 38 ++++++++++++++++++++++
+ tests/qemuxml2xmltest.c                            |  1 +
+ 12 files changed, 138 insertions(+), 2 deletions(-)
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-vmcoreinfo.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-vmcoreinfo.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-vmcoreinfo.xml
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index cc1c5577cd..6807da5c6f 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -1940,6 +1940,10 @@
+           which is also known as a split I/O APIC mode.
+           <span class="since">Since 3.4.0</span> (QEMU/KVM only)
+       </dd>
++      <dt><code>vmcoreinfo</code></dt>
++      <dd>Enable QEMU vmcoreinfo device to let the guest kernel save debug
++          details. <span class="since">Since 3.10.0</span> (QEMU only)
++      </dd>
+     </dl>
+ 
+     <h3><a id="elementsTime">Time keeping</a></h3>
+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
+index 5576128db5..05709afc0c 100644
+--- a/docs/schemas/domaincommon.rng
++++ b/docs/schemas/domaincommon.rng
+@@ -4747,6 +4747,9 @@
+           <optional>
+             <ref name="hpt"/>
+           </optional>
++          <optional>
++            <ref name="vmcoreinfo"/>
++          </optional>
+         </interleave>
+       </element>
+     </optional>
+@@ -4947,6 +4950,12 @@
+     </element>
+   </define>
+ 
++  <define name="vmcoreinfo">
++    <element name="vmcoreinfo">
++      <empty/>
++    </element>
++  </define>
++
+   <define name="address">
+     <element name="address">
+       <choice>
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index bd6d851f21..2d54037b71 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -150,6 +150,7 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
+               "smm",
+               "ioapic",
+               "hpt",
++              "vmcoreinfo",
+ );
+ 
+ VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
+@@ -18824,6 +18825,7 @@ virDomainDefParseXML(xmlDocPtr xml,
+         case VIR_DOMAIN_FEATURE_VIRIDIAN:
+         case VIR_DOMAIN_FEATURE_PRIVNET:
+         case VIR_DOMAIN_FEATURE_HYPERV:
++        case VIR_DOMAIN_FEATURE_VMCOREINFO:
+         case VIR_DOMAIN_FEATURE_KVM:
+             def->features[val] = VIR_TRISTATE_SWITCH_ON;
+             break;
+@@ -26265,6 +26267,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
+             case VIR_DOMAIN_FEATURE_ACPI:
+             case VIR_DOMAIN_FEATURE_PAE:
+             case VIR_DOMAIN_FEATURE_VIRIDIAN:
++            case VIR_DOMAIN_FEATURE_VMCOREINFO:
+             case VIR_DOMAIN_FEATURE_PRIVNET:
+                 switch ((virTristateSwitch) def->features[i]) {
+                 case VIR_TRISTATE_SWITCH_ABSENT:
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 479a791f29..698d3280fe 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -1735,6 +1735,7 @@ typedef enum {
+     VIR_DOMAIN_FEATURE_SMM,
+     VIR_DOMAIN_FEATURE_IOAPIC,
+     VIR_DOMAIN_FEATURE_HPT,
++    VIR_DOMAIN_FEATURE_VMCOREINFO,
+ 
+     VIR_DOMAIN_FEATURE_LAST
+ } virDomainFeature;
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 13ff1286c4..4301d2e799 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -444,7 +444,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
+               "vxhs",
+               "virtio-blk.num-queues",
+               "machine.pseries.resize-hpt",
+-
++              "vmcoreinfo",
+               "spapr-vty",
+ 
+               /* 275 */
+@@ -1684,6 +1684,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
+     { "pcie-root-port", QEMU_CAPS_DEVICE_PCIE_ROOT_PORT },
+     { "qemu-xhci", QEMU_CAPS_DEVICE_QEMU_XHCI },
+     { "spapr-pci-host-bridge", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE },
++    { "vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO },
+     { "spapr-vty", QEMU_CAPS_DEVICE_SPAPR_VTY },
+     { "sclplmconsole", QEMU_CAPS_DEVICE_SCLPLMCONSOLE },
+     { "isa-serial", QEMU_CAPS_DEVICE_ISA_SERIAL },
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index 3e016b7c79..c6eb9df146 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -430,7 +430,7 @@ typedef enum {
+     QEMU_CAPS_VXHS, /* -drive file.driver=vxhs via query-qmp-schema */
+     QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES, /* virtio-blk-*.num-queues */
+     QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT, /* -machine pseries,resize-hpt */
+-
++    QEMU_CAPS_DEVICE_VMCOREINFO, /* -device vmcoreinfo */
+     QEMU_CAPS_DEVICE_SPAPR_VTY, /* -device spapr-vty */
+ 
+     /* 275 */
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index b462c7cf09..a1bf230fad 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9922,6 +9922,28 @@ qemuBuildTPMCommandLine(virCommandPtr cmd,
+ }
+ 
+ 
++static int
++qemuBuildVMCoreInfoCommandLine(virCommandPtr cmd,
++                               const virDomainDef *def,
++                               virQEMUCapsPtr qemuCaps)
++{
++    virTristateSwitch vmci = def->features[VIR_DOMAIN_FEATURE_VMCOREINFO];
++
++    if (vmci != VIR_TRISTATE_SWITCH_ON)
++        return 0;
++
++    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMCOREINFO)) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                       _("vmcoreinfo is not available "
++                         "with this QEMU binary"));
++        return -1;
++    }
++
++    virCommandAddArgList(cmd, "-device", "vmcoreinfo", NULL);
++    return 0;
++}
++
++
+ static int
+ qemuBuildPanicCommandLine(virCommandPtr cmd,
+                           const virDomainDef *def,
+@@ -10341,6 +10363,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
+     if (qemuBuildNVRAMCommandLine(cmd, def, qemuCaps) < 0)
+         goto error;
+ 
++    if (qemuBuildVMCoreInfoCommandLine(cmd, def, qemuCaps) < 0)
++        goto error;
++
+     if (snapshot)
+         virCommandAddArgList(cmd, "-loadvm", snapshot->def->name, NULL);
+ 
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-vmcoreinfo.args b/tests/qemuxml2argvdata/qemuxml2argv-vmcoreinfo.args
+new file mode 100644
+index 0000000000..772e5a071f
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-vmcoreinfo.args
+@@ -0,0 +1,25 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-i686 \
++-name QEMUGuest1 \
++-S \
++-M pc \
++-m 214 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
++-nographic \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-no-acpi \
++-boot c \
++-usb \
++-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
++-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
++-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
++-device vmcoreinfo
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-vmcoreinfo.xml b/tests/qemuxml2argvdata/qemuxml2argv-vmcoreinfo.xml
+new file mode 100644
+index 0000000000..f8e5865310
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-vmcoreinfo.xml
+@@ -0,0 +1,28 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219100</memory>
++  <currentMemory unit='KiB'>219100</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <features>
++    <vmcoreinfo/>
++  </features>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <disk type='block' device='disk'>
++      <source dev='/dev/HostVG/QEMUGuest1'/>
++      <target dev='hda' bus='ide'/>
++      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
++    </disk>
++    <controller type='ide' index='0'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 686a63855c..686d289b89 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -2933,6 +2933,7 @@ mymain(void)
+     DO_TEST_PARSE_ERROR("cpu-cache-emulate-l2", QEMU_CAPS_KVM);
+     DO_TEST_PARSE_ERROR("cpu-cache-passthrough3", QEMU_CAPS_KVM);
+     DO_TEST_PARSE_ERROR("cpu-cache-passthrough-l3", QEMU_CAPS_KVM);
++    DO_TEST("vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO);
+ 
+     DO_TEST("user-aliases", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_CIRRUS_VGA,
+             QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_PIIX_DISABLE_S3,
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-vmcoreinfo.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vmcoreinfo.xml
+new file mode 100644
+index 0000000000..a3922d6304
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vmcoreinfo.xml
+@@ -0,0 +1,38 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219100</memory>
++  <currentMemory unit='KiB'>219100</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <features>
++    <vmcoreinfo/>
++  </features>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <disk type='block' device='disk'>
++      <source dev='/dev/HostVG/QEMUGuest1'/>
++      <target dev='hda' bus='ide'/>
++      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
++    </disk>
++    <controller type='ide' index='0'>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
++    </controller>
++    <controller type='usb' index='0'>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
++    </controller>
++    <controller type='pci' index='0' model='pci-root'/>
++    <input type='mouse' bus='ps2'/>
++    <input type='keyboard' bus='ps2'/>
++    <memballoon model='virtio'>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
++    </memballoon>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
+index 8766646738..5ca0ea3a22 100644
+--- a/tests/qemuxml2xmltest.c
++++ b/tests/qemuxml2xmltest.c
+@@ -1319,6 +1319,7 @@ mymain(void)
+     DO_TEST("cpu-check-default-none2", NONE);
+     DO_TEST("cpu-check-default-partial", NONE);
+     DO_TEST("cpu-check-default-partial2", NONE);
++    DO_TEST("vmcoreinfo", NONE);
+ 
+     DO_TEST("smartcard-host", NONE);
+     DO_TEST("smartcard-host-certificates", NONE);
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-allow-conditional-device-property-probing.patch b/SOURCES/libvirt-qemu-allow-conditional-device-property-probing.patch
deleted file mode 100644
index f694282..0000000
--- a/SOURCES/libvirt-qemu-allow-conditional-device-property-probing.patch
+++ /dev/null
@@ -1,175 +0,0 @@
-From 363d20b7336faeb280bf583d9d148e441d4286be Mon Sep 17 00:00:00 2001
-Message-Id: <363d20b7336faeb280bf583d9d148e441d4286be@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:50 +0200
-Subject: [PATCH] qemu: allow conditional device property probing
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Do not probe for devices that QEMU does not know
-when probing for device options.
-
-(cherry picked from commit 4ae59411fa3f16e18e16cc4db7894fe5fd6404ce)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c | 99 ++++++++++++++++++++++++++++++--------------
- 1 file changed, 68 insertions(+), 31 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index b76b79342..49fb52e03 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -1728,71 +1728,103 @@ struct virQEMUCapsObjectTypeProps {
-     const char *type;
-     struct virQEMUCapsStringFlags *props;
-     size_t nprops;
-+    int capsCondition;
- };
- 
- static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
-     { "virtio-blk-pci", virQEMUCapsObjectPropsVirtioBlk,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk),
-+      -1 },
-     { "virtio-net-pci", virQEMUCapsObjectPropsVirtioNet,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet),
-+      -1 },
-     { "virtio-scsi-pci", virQEMUCapsObjectPropsVirtioSCSI,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI),
-+      -1 },
-     { "virtio-blk-ccw", virQEMUCapsObjectPropsVirtioBlk,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk),
-+      -1 },
-     { "virtio-net-ccw", virQEMUCapsObjectPropsVirtioNet,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet),
-+      -1 },
-     { "virtio-scsi-ccw", virQEMUCapsObjectPropsVirtioSCSI,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI),
-+      -1 },
-     { "virtio-blk-s390", virQEMUCapsObjectPropsVirtioBlk,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk),
-+      -1 },
-     { "virtio-net-s390", virQEMUCapsObjectPropsVirtioNet,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet),
-+      -1 },
-     { "pci-assign", virQEMUCapsObjectPropsPCIAssign,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign),
-+      -1 },
-     { "kvm-pci-assign", virQEMUCapsObjectPropsPCIAssign,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign),
-+      -1 },
-     { "vfio-pci", virQEMUCapsObjectPropsVfioPCI,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVfioPCI) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVfioPCI),
-+      -1 },
-     { "scsi-disk", virQEMUCapsObjectPropsSCSIDisk,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIDisk) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIDisk),
-+      -1 },
-     { "ide-drive", virQEMUCapsObjectPropsIDEDrive,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsIDEDrive) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsIDEDrive),
-+      -1 },
-     { "PIIX4_PM", virQEMUCapsObjectPropsPiix4PM,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPiix4PM) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPiix4PM),
-+      -1 },
-     { "usb-redir", virQEMUCapsObjectPropsUSBRedir,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBRedir) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBRedir),
-+      -1 },
-     { "usb-host", virQEMUCapsObjectPropsUSBHost,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBHost) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBHost),
-+      -1 },
-     { "scsi-generic", virQEMUCapsObjectPropsSCSIGeneric,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIGeneric) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIGeneric),
-+      -1 },
-     { "i440FX-pcihost", virQEMUCapsObjectPropsI440FXPCIHost,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsI440FXPCIHost) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsI440FXPCIHost),
-+      -1 },
-     { "q35-pcihost", virQEMUCapsObjectPropsQ35PCIHost,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQ35PCIHost) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQ35PCIHost),
-+      -1 },
-     { "usb-storage", virQEMUCapsObjectPropsUSBStorage,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBStorage) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBStorage),
-+      -1 },
-     { "kvm-pit", virQEMUCapsObjectPropsKVMPit,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsKVMPit) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsKVMPit),
-+      -1 },
-     { "VGA", virQEMUCapsObjectPropsVGA,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVGA) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVGA),
-+      -1 },
-     { "vmware-svga", virQEMUCapsObjectPropsVmwareSvga,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVmwareSvga) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVmwareSvga),
-+      -1 },
-     { "qxl", virQEMUCapsObjectPropsQxl,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQxl) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQxl),
-+      -1 },
-     { "virtio-gpu-pci", virQEMUCapsObjectPropsVirtioGpu,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu),
-+      -1 },
-     { "virtio-gpu-device", virQEMUCapsObjectPropsVirtioGpu,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu),
-+      -1 },
-     { "ICH9-LPC", virQEMUCapsObjectPropsICH9,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsICH9) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsICH9),
-+      -1 },
-     { "virtio-balloon-pci", virQEMUCapsObjectPropsVirtioBalloon,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon),
-+      -1 },
-     { "virtio-balloon-ccw", virQEMUCapsObjectPropsVirtioBalloon,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon),
-+      -1 },
-     { "virtio-balloon-device", virQEMUCapsObjectPropsVirtioBalloon,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon),
-+      -1 },
-     { "nec-usb-xhci", virQEMUCapsObjectPropsUSBNECXHCI,
--      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBNECXHCI) },
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBNECXHCI),
-+      -1 },
- };
- 
- struct virQEMUCapsPropTypeObjects {
-@@ -2767,6 +2799,11 @@ virQEMUCapsProbeQMPObjects(virQEMUCapsPtr qemuCaps,
- 
-     for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsObjectProps); i++) {
-         const char *type = virQEMUCapsObjectProps[i].type;
-+        int cap = virQEMUCapsObjectProps[i].capsCondition;
-+
-+        if (cap >= 0 && !virQEMUCapsGet(qemuCaps, cap))
-+            continue;
-+
-         if ((nvalues = qemuMonitorGetObjectProps(mon,
-                                                  type,
-                                                  &values)) < 0)
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-block-Add-function-to-check-if-storage-source-allows-concurrent-access.patch b/SOURCES/libvirt-qemu-block-Add-function-to-check-if-storage-source-allows-concurrent-access.patch
new file mode 100644
index 0000000..f077d25
--- /dev/null
+++ b/SOURCES/libvirt-qemu-block-Add-function-to-check-if-storage-source-allows-concurrent-access.patch
@@ -0,0 +1,67 @@
+From a77029a7a8885902edbc0034c15c2a609a1093ba Mon Sep 17 00:00:00 2001
+Message-Id: <a77029a7a8885902edbc0034c15c2a609a1093ba@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:18 +0100
+Subject: [PATCH] qemu: block: Add function to check if storage source allows
+ concurrent access
+
+Storage source format backing a shared device (e.g. running a cluster
+filesystem) needs to support the sharing so that metadata are not
+corrupted. Add a central function for checking this.
+
+(cherry picked from commit 1fc3cd8731640aefc48bbd9fc489f21cb99c6f67)
+
+ Conflicts:
+	src/qemu/qemu_block.c: context of one of the blockdev-add saga
+                               refactors not being backported
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1511480
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_block.c | 15 +++++++++++++++
+ src/qemu/qemu_block.h |  3 +++
+ 2 files changed, 18 insertions(+)
+
+diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
+index 0761f89913..86fa565f39 100644
+--- a/src/qemu/qemu_block.c
++++ b/src/qemu/qemu_block.c
+@@ -390,6 +390,21 @@ qemuBlockGetNodeData(virJSONValuePtr data)
+ }
+ 
+ 
++/**
++ * qemuBlockStorageSourceSupportsConcurrentAccess:
++ * @src: disk storage source
++ *
++ * Returns true if the given storage format supports concurrent access from two
++ * separate processes.
++ */
++bool
++qemuBlockStorageSourceSupportsConcurrentAccess(virStorageSourcePtr src)
++{
++    /* no need to check in backing chain since only RAW storage supports this */
++    return src->format == VIR_STORAGE_FILE_RAW;
++}
++
++
+ /**
+  * qemuBlockStorageSourceBuildJSONSocketAddress
+  * @host: the virStorageNetHostDefPtr definition to build
+diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
+index f0a2c9aa7d..ebf3149ce8 100644
+--- a/src/qemu/qemu_block.h
++++ b/src/qemu/qemu_block.h
+@@ -53,6 +53,9 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
+ virHashTablePtr
+ qemuBlockGetNodeData(virJSONValuePtr data);
+ 
++bool
++qemuBlockStorageSourceSupportsConcurrentAccess(virStorageSourcePtr src);
++
+ virJSONValuePtr
+ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src);
+ 
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-block-commit-Determine-relative-path-of-images-before-initializing.patch b/SOURCES/libvirt-qemu-block-commit-Determine-relative-path-of-images-before-initializing.patch
deleted file mode 100644
index a6d2bf2..0000000
--- a/SOURCES/libvirt-qemu-block-commit-Determine-relative-path-of-images-before-initializing.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-From 615457ad6a27f84b9c1898626dc691fe445ec852 Mon Sep 17 00:00:00 2001
-Message-Id: <615457ad6a27f84b9c1898626dc691fe445ec852@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Wed, 22 Nov 2017 18:20:49 +0100
-Subject: [PATCH] qemu: block commit: Determine relative path of images before
- initializing
-
-Changing labelling of the images does not need to happen after setting
-the labeling and lock manager access. This saves the cleanup of the
-labeling if the relative path can't be determined.
-
-(cherry picked from commit 3488f449a63994c1a20e08cd6a7fe35de303e77a)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1516717
-
-This commit simplifies backport of the actual patch, is simple and useful.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 26 +++++++++++++-------------
- 1 file changed, 13 insertions(+), 13 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 46016fb36e..f8df2d452d 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -17225,19 +17225,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
-             goto endjob;
-     }
- 
--    /* For the commit to succeed, we must allow qemu to open both the
--     * 'base' image and the parent of 'top' as read/write; 'top' might
--     * not have a parent, or might already be read-write.  XXX It
--     * would also be nice to revert 'base' to read-only, as well as
--     * revoke access to files removed from the chain, when the commit
--     * operation succeeds, but doing that requires tracking the
--     * operation in XML across libvirtd restarts.  */
--    clean_access = true;
--    if (qemuDomainDiskChainElementPrepare(driver, vm, baseSource, false) < 0 ||
--        (top_parent && top_parent != disk->src &&
--         qemuDomainDiskChainElementPrepare(driver, vm, top_parent, false) < 0))
--        goto endjob;
--
-     if (flags & VIR_DOMAIN_BLOCK_COMMIT_RELATIVE &&
-         topSource != disk->src) {
-         if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHANGE_BACKING_FILE)) {
-@@ -17257,6 +17244,19 @@ qemuDomainBlockCommit(virDomainPtr dom,
-         }
-     }
- 
-+    /* For the commit to succeed, we must allow qemu to open both the
-+     * 'base' image and the parent of 'top' as read/write; 'top' might
-+     * not have a parent, or might already be read-write.  XXX It
-+     * would also be nice to revert 'base' to read-only, as well as
-+     * revoke access to files removed from the chain, when the commit
-+     * operation succeeds, but doing that requires tracking the
-+     * operation in XML across libvirtd restarts.  */
-+    clean_access = true;
-+    if (qemuDomainDiskChainElementPrepare(driver, vm, baseSource, false) < 0 ||
-+        (top_parent && top_parent != disk->src &&
-+         qemuDomainDiskChainElementPrepare(driver, vm, top_parent, false) < 0))
-+        goto endjob;
-+
-     /* Start the commit operation.  Pass the user's original spelling,
-      * if any, through to qemu, since qemu may behave differently
-      * depending on whether the input was specified as relative or
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-block-commit-Don-t-overwrite-error-when-rolling-back-disk-labels.patch b/SOURCES/libvirt-qemu-block-commit-Don-t-overwrite-error-when-rolling-back-disk-labels.patch
deleted file mode 100644
index af45104..0000000
--- a/SOURCES/libvirt-qemu-block-commit-Don-t-overwrite-error-when-rolling-back-disk-labels.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 8fc980241464db978fad2e86bc3d6916a173cbe9 Mon Sep 17 00:00:00 2001
-Message-Id: <8fc980241464db978fad2e86bc3d6916a173cbe9@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Wed, 22 Nov 2017 18:20:48 +0100
-Subject: [PATCH] qemu: block commit: Don't overwrite error when rolling back
- disk labels
-
-Calls to qemuDomainDiskChainElementPrepare resets the original error,
-thus we need to save it in the cleanup path of qemuDomainBlockCommit.
-
-(cherry picked from commit c885b7fe1de1961391a117c033b4012a02cc8fca)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1516717
-
-Helps resolve merge conflicts with the actual patch and is useful by
-itself.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index bfd7ff6c09..46016fb36e 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -17302,10 +17302,16 @@ qemuDomainBlockCommit(virDomainPtr dom,
- 
-  endjob:
-     if (ret < 0 && clean_access) {
-+        virErrorPtr orig_err = virSaveLastError();
-         /* Revert access to read-only, if possible.  */
-         qemuDomainDiskChainElementPrepare(driver, vm, baseSource, true);
-         if (top_parent && top_parent != disk->src)
-             qemuDomainDiskChainElementPrepare(driver, vm, top_parent, true);
-+
-+        if (orig_err) {
-+            virSetError(orig_err);
-+            virFreeError(orig_err);
-+        }
-     }
-     virStorageSourceFree(mirror);
-     qemuDomainObjEndJob(driver, vm);
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-blockjob-Reset-disk-source-index-after-pivot.patch b/SOURCES/libvirt-qemu-blockjob-Reset-disk-source-index-after-pivot.patch
new file mode 100644
index 0000000..b7d2681
--- /dev/null
+++ b/SOURCES/libvirt-qemu-blockjob-Reset-disk-source-index-after-pivot.patch
@@ -0,0 +1,40 @@
+From cf8fcc97c173618534874046d2f29d4135cf2441 Mon Sep 17 00:00:00 2001
+Message-Id: <cf8fcc97c173618534874046d2f29d4135cf2441@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Fri, 8 Dec 2017 10:27:03 +0100
+Subject: [PATCH] qemu: blockjob: Reset disk source index after pivot
+
+Since we are re-detecting the backing chain after pivoting to the active
+block commit target (or block copy target) the disk index needs to be
+reset to 0. This is necessary since we move a member of the backing
+chain to disk->src but clear indexes only starting from
+disk->src->backingStore. The freshly detected images have indexes
+starting from 1, but since we've pivoted into an image which was
+previously a backing store it would have a non-0 index.
+The lookup function would then return the top of the chain for queries
+like 'vda[1]' instead of the first backing store.
+
+This problem will not be present once we keep the disk indexes stable.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1519745
+(cherry picked from commit fac8724ceb371f962d5d185c639456a34d71659e)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_blockjob.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
+index c1b46f7d0a..afc05f161c 100644
+--- a/src/qemu/qemu_blockjob.c
++++ b/src/qemu/qemu_blockjob.c
+@@ -165,6 +165,7 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
+         disk->mirror = NULL;
+         disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
+         disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
++        disk->src->id = 0;
+         ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk,
+                                                   true, true));
+         ignore_value(qemuBlockNodeNamesDetect(driver, vm, asyncJob));
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-capabilities-force-update-if-the-microcode-version-does-not-match.patch b/SOURCES/libvirt-qemu-capabilities-force-update-if-the-microcode-version-does-not-match.patch
index d993f7d..f7ce68c 100644
--- a/SOURCES/libvirt-qemu-capabilities-force-update-if-the-microcode-version-does-not-match.patch
+++ b/SOURCES/libvirt-qemu-capabilities-force-update-if-the-microcode-version-does-not-match.patch
@@ -1,5 +1,5 @@
-From ac08fdc6dcbdc6e9fdb976fd2143c663d3748752 Mon Sep 17 00:00:00 2001
-Message-Id: <ac08fdc6dcbdc6e9fdb976fd2143c663d3748752@dist-git>
+From 94ea163b2853d51a3037e8f8ee664058ae7c541d Mon Sep 17 00:00:00 2001
+Message-Id: <94ea163b2853d51a3037e8f8ee664058ae7c541d@dist-git>
 From: Paolo Bonzini <pbonzini@redhat.com>
 Date: Tue, 12 Dec 2017 16:23:41 +0100
 Subject: [PATCH] qemu: capabilities: force update if the microcode version
@@ -18,33 +18,14 @@ Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
 
 Conflicts:
-	src/qemu/qemu_capabilities.c
-	src/qemu/qemu_capabilities.h
-            - virQEMUCapsCache is based on virFileCache in 7.5
-
-	src/qemu/qemu_capspriv.h
-            - context; more functions were added in 7.5
-
 	tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml
 	tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml
-	tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
-	tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
-	tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
-	tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
-	tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
-            - missing in 7.4
-
-	tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-            - context; different package version in 7.4
-
-	tests/qemucapsprobe.c
-            - virQEMUCapsNewForBinaryInternal has fewer parameters
-              in 7.5
+            - missing in 7.5
 ---
- src/qemu/qemu_capabilities.c                       | 56 +++++++++++++++++++---
- src/qemu/qemu_capabilities.h                       |  7 ++-
- src/qemu/qemu_capspriv.h                           |  6 +++
- src/qemu/qemu_driver.c                             |  9 +++-
+ src/qemu/qemu_capabilities.c                       | 40 +++++++++++++++++++++-
+ src/qemu/qemu_capabilities.h                       |  6 ++--
+ src/qemu/qemu_capspriv.h                           |  5 +++
+ src/qemu/qemu_driver.c                             |  9 ++++-
  tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml   |  1 +
  tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml   |  1 +
  tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml   |  1 +
@@ -52,35 +33,40 @@ Conflicts:
  tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml   |  1 +
  tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml   |  1 +
  tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml   |  1 +
+ tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml   |  1 +
+ tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml   |  1 +
+ tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml  |  1 +
  tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml   |  1 +
  tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml   |  1 +
  .../caps_2.6.0-gicv2.aarch64.xml                   |  1 +
  .../caps_2.6.0-gicv3.aarch64.xml                   |  1 +
- tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml  |  1 +
+ tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml    |  1 +
  tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml   |  1 +
  tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml    |  1 +
  tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |  1 +
  tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml    |  1 +
  tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |  1 +
+ tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml    |  1 +
+ tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml    |  1 +
  tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  1 +
- tests/qemucapabilitiestest.c                       | 14 ++++--
+ tests/qemucapabilitiestest.c                       | 14 +++++---
  tests/qemucapsprobe.c                              |  2 +-
  tests/testutilsqemu.c                              |  2 +-
- 25 files changed, 98 insertions(+), 16 deletions(-)
+ 30 files changed, 91 insertions(+), 10 deletions(-)
 
 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index a42f8d9988..504e2c9587 100644
+index 165fdbc5ea..09323d2580 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
-@@ -426,6 +426,7 @@ struct _virQEMUCaps {
- 
+@@ -507,6 +507,7 @@ struct _virQEMUCaps {
      unsigned int version;
      unsigned int kvmVersion;
+     unsigned int libvirtVersion;
 +    unsigned int microcodeVersion;
      char *package;
  
      virArch arch;
-@@ -2217,6 +2218,7 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
+@@ -2296,6 +2297,7 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
  
      ret->version = qemuCaps->version;
      ret->kvmVersion = qemuCaps->kvmVersion;
@@ -88,7 +74,15 @@ index a42f8d9988..504e2c9587 100644
  
      if (VIR_STRDUP(ret->package, qemuCaps->package) < 0)
          goto error;
-@@ -3817,6 +3819,13 @@ virQEMUCapsLoadCache(virCapsPtr caps,
+@@ -3819,6 +3821,7 @@ struct _virQEMUCapsCachePriv {
+     uid_t runUid;
+     gid_t runGid;
+     virArch hostArch;
++    unsigned int microcodeVersion;
+ };
+ typedef struct _virQEMUCapsCachePriv virQEMUCapsCachePriv;
+ typedef virQEMUCapsCachePriv *virQEMUCapsCachePrivPtr;
+@@ -3941,6 +3944,13 @@ virQEMUCapsLoadCache(virArch hostArch,
          goto cleanup;
      }
  
@@ -102,7 +96,7 @@ index a42f8d9988..504e2c9587 100644
      if (virXPathBoolean("boolean(./package)", ctxt) > 0) {
          qemuCaps->package = virXPathString("string(./package)", ctxt);
          if (!qemuCaps->package &&
-@@ -4083,6 +4092,9 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps,
+@@ -4219,6 +4229,9 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
      virBufferAsprintf(&buf, "<kvmVersion>%d</kvmVersion>\n",
                        qemuCaps->kvmVersion);
  
@@ -112,27 +106,34 @@ index a42f8d9988..504e2c9587 100644
      if (qemuCaps->package)
          virBufferAsprintf(&buf, "<package>%s</package>\n",
                            qemuCaps->package);
-@@ -4286,7 +4298,8 @@ virQEMUCapsInitCached(virCapsPtr caps,
-         goto discard;
+@@ -4360,6 +4373,16 @@ virQEMUCapsIsValid(void *data,
+         return false;
      }
  
--    if (!virQEMUCapsIsValid(qemuCaps, qemuctime, runUid, runGid))
-+    if (!virQEMUCapsIsValid(qemuCaps, qemuctime, runUid, runGid,
-+                            virCapabilitiesGetMicrocodeVersion(caps)))
-         goto discard;
++    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
++        priv->microcodeVersion != qemuCaps->microcodeVersion) {
++        VIR_DEBUG("Outdated capabilities for '%s': microcode version changed "
++                  "(%u vs %u)",
++                  qemuCaps->binary,
++                  priv->microcodeVersion,
++                  qemuCaps->microcodeVersion);
++        return false;
++    }
++
+     return true;
+ }
  
-     /* Discard cache if QEMU binary or libvirtd changed */
-@@ -5138,6 +5151,7 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
-                                 const char *cacheDir,
+@@ -5189,6 +5212,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
+                                 const char *libDir,
                                  uid_t runUid,
                                  gid_t runGid,
 +                                unsigned int microcodeVersion,
                                  bool qmpOnly)
  {
      virQEMUCapsPtr qemuCaps;
-@@ -5204,6 +5218,9 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
-         virQEMUCapsInitHostCPUModel(qemuCaps, caps, VIR_DOMAIN_VIRT_QEMU);
-     }
+@@ -5245,6 +5269,9 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
+     virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM);
+     virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU);
  
 +    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
 +        qemuCaps->microcodeVersion = microcodeVersion;
@@ -140,49 +141,15 @@ index a42f8d9988..504e2c9587 100644
   cleanup:
      VIR_FREE(qmperr);
      return qemuCaps;
-@@ -5220,10 +5237,12 @@ virQEMUCapsNewForBinary(virCapsPtr caps,
-                         const char *libDir,
-                         const char *cacheDir,
-                         uid_t runUid,
--                        gid_t runGid)
-+                        gid_t runGid,
-+                        unsigned int microcodeVersion)
- {
-     return virQEMUCapsNewForBinaryInternal(caps, binary, libDir, cacheDir,
--                                           runUid, runGid, false);
-+                                           runUid, runGid, microcodeVersion,
-+                                           false);
+@@ -5266,6 +5293,7 @@ virQEMUCapsNewData(const char *binary,
+                                            priv->libDir,
+                                            priv->runUid,
+                                            priv->runGid,
++                                           priv->microcodeVersion,
+                                            false);
  }
  
- 
-@@ -5231,7 +5250,8 @@ bool
- virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps,
-                    time_t qemuctime,
-                    uid_t runUid,
--                   gid_t runGid)
-+                   gid_t runGid,
-+                   unsigned int microcodeVersion)
- {
-     bool kvmUsable;
- 
-@@ -5279,6 +5299,16 @@ virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps,
-         return false;
-     }
- 
-+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
-+        microcodeVersion != qemuCaps->microcodeVersion) {
-+        VIR_DEBUG("Outdated capabilities for '%s': microcode version changed "
-+                  "(%u vs %u)",
-+                  qemuCaps->binary,
-+                  microcodeVersion,
-+                  qemuCaps->microcodeVersion);
-+        return false;
-+    }
-+
-     return true;
- }
- 
-@@ -5325,7 +5355,8 @@ virQEMUCapsCachePtr
+@@ -5348,7 +5376,8 @@ virFileCachePtr
  virQEMUCapsCacheNew(const char *libDir,
                      const char *cacheDir,
                      uid_t runUid,
@@ -190,37 +157,17 @@ index a42f8d9988..504e2c9587 100644
 +                    gid_t runGid,
 +                    unsigned int microcodeVersion)
  {
-     virQEMUCapsCachePtr cache;
+     char *capsCacheDir = NULL;
+     virFileCachePtr cache = NULL;
+@@ -5371,6 +5400,7 @@ virQEMUCapsCacheNew(const char *libDir,
  
-@@ -5348,6 +5379,7 @@ virQEMUCapsCacheNew(const char *libDir,
+     priv->runUid = runUid;
+     priv->runGid = runGid;
++    priv->microcodeVersion = microcodeVersion;
  
-     cache->runUid = runUid;
-     cache->runGid = runGid;
-+    cache->microcodeVersion = microcodeVersion;
- 
-     return cache;
- 
-@@ -5364,7 +5396,8 @@ virQEMUCapsCacheValidate(virQEMUCapsCachePtr cache,
-                          virQEMUCapsPtr *qemuCaps)
- {
-     if (*qemuCaps &&
--        !virQEMUCapsIsValid(*qemuCaps, 0, cache->runUid, cache->runGid)) {
-+        !virQEMUCapsIsValid(*qemuCaps, 0, cache->runUid, cache->runGid,
-+                            virCapabilitiesGetMicrocodeVersion(caps))) {
-         VIR_DEBUG("Cached capabilities %p no longer valid for %s",
-                   *qemuCaps, binary);
-         virHashRemoveEntry(cache->binaries, binary);
-@@ -5375,7 +5408,8 @@ virQEMUCapsCacheValidate(virQEMUCapsCachePtr cache,
-         VIR_DEBUG("Creating capabilities for %s", binary);
-         *qemuCaps = virQEMUCapsNewForBinary(caps, binary,
-                                             cache->libDir, cache->cacheDir,
--                                            cache->runUid, cache->runGid);
-+                                            cache->runUid, cache->runGid,
-+                                            virCapabilitiesGetMicrocodeVersion(caps));
-         if (*qemuCaps) {
-             VIR_DEBUG("Caching capabilities %p for %s", *qemuCaps, binary);
-             if (virHashAddEntry(cache->binaries, binary, *qemuCaps) < 0) {
-@@ -5926,3 +5960,11 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps,
+  cleanup:
+     VIR_FREE(capsCacheDir);
+@@ -5848,3 +5878,11 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps,
          return -1;
      return 0;
  }
@@ -233,73 +180,57 @@ index a42f8d9988..504e2c9587 100644
 +    qemuCaps->microcodeVersion = microcodeVersion;
 +}
 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index bc4ad44496..d1a1d46b5a 100644
+index 0fb2a10a17..4b5d70fbb0 100644
 --- a/src/qemu/qemu_capabilities.h
 +++ b/src/qemu/qemu_capabilities.h
-@@ -497,7 +497,8 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
- bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps,
-                         time_t ctime,
-                         uid_t runUid,
--                        gid_t runGid);
-+                        gid_t runGid,
-+                        unsigned int microcodeVersion);
- 
- void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
+@@ -520,8 +520,10 @@ void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
                                      const char *machineType);
-@@ -509,7 +510,9 @@ void virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps,
  
- virQEMUCapsCachePtr virQEMUCapsCacheNew(const char *libDir,
-                                         const char *cacheDir,
+ virFileCachePtr virQEMUCapsCacheNew(const char *libDir,
+-                                        const char *cacheDir,
 -                                        uid_t uid, gid_t gid);
-+                                        uid_t uid,
-+                                        gid_t gid,
-+                                        unsigned int microcodeVersion);
- virQEMUCapsPtr virQEMUCapsCacheLookup(virCapsPtr caps,
-                                       virQEMUCapsCachePtr cache,
++                                    const char *cacheDir,
++                                    uid_t uid,
++                                    gid_t gid,
++                                    unsigned int microcodeVersion);
+ virQEMUCapsPtr virQEMUCapsCacheLookup(virFileCachePtr cache,
                                        const char *binary);
+ virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
 diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
-index 1baaaf3340..d39a71a2f8 100644
+index 219daa3629..98d163b920 100644
 --- a/src/qemu/qemu_capspriv.h
 +++ b/src/qemu/qemu_capspriv.h
-@@ -35,6 +35,7 @@ struct _virQEMUCapsCache {
-     char *cacheDir;
-     uid_t runUid;
-     gid_t runGid;
-+    unsigned int microcodeVersion;
- };
- 
- virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps);
-@@ -46,6 +47,7 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
-                                 const char *cacheDir,
+@@ -36,6 +36,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
+                                 const char *libDir,
                                  uid_t runUid,
                                  gid_t runGid,
 +                                unsigned int microcodeVersion,
                                  bool qmpOnly);
  
- int virQEMUCapsLoadCache(virCapsPtr caps,
-@@ -93,4 +95,8 @@ virCPUDefPtr
- virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps,
-                                    virQEMUCapsPtr qemuCaps,
-                                    virDomainVirtType type);
+ int virQEMUCapsLoadCache(virArch hostArch,
+@@ -102,4 +103,8 @@ int
+ virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
+                                   qemuMonitorPtr mon,
+                                   bool tcg);
 +
 +void
 +virQEMUCapsSetMicrocodeVersion(virQEMUCapsPtr qemuCaps,
 +                               unsigned int microcodeVersion);
  #endif
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 498f787ad3..0943d222b4 100644
+index fa73fc30d6..0bc6eaa431 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
-@@ -628,6 +628,8 @@ qemuStateInitialize(bool privileged,
-     gid_t run_gid = -1;
+@@ -633,6 +633,8 @@ qemuStateInitialize(bool privileged,
      char *hugepagePath = NULL;
+     char *memoryBackingPath = NULL;
      size_t i;
 +    virCPUDefPtr hostCPU = NULL;
 +    unsigned int microcodeVersion = 0;
  
      if (VIR_ALLOC(qemu_driver) < 0)
          return -1;
-@@ -847,10 +849,15 @@ qemuStateInitialize(bool privileged,
+@@ -855,10 +857,15 @@ qemuStateInitialize(bool privileged,
          run_gid = cfg->group;
      }
  
@@ -317,11 +248,11 @@ index 498f787ad3..0943d222b4 100644
          goto error;
  
 diff --git a/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml
-index 5ad406ce1b..12d5873251 100644
+index d560811ab7..3001d487c6 100644
 --- a/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml
 @@ -112,6 +112,7 @@
-   <flag name='query-cpu-definitions'/>
+   <flag name='isa-serial'/>
    <version>1002002</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>26900</microcodeVersion>
@@ -329,11 +260,11 @@ index 5ad406ce1b..12d5873251 100644
    <arch>x86_64</arch>
    <cpu type='kvm' name='qemu64'/>
 diff --git a/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml
-index 4ec731d655..8bfbf79a74 100644
+index 576475f7fa..283f30ef07 100644
 --- a/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml
 @@ -130,6 +130,7 @@
-   <flag name='query-cpu-definitions'/>
+   <flag name='isa-serial'/>
    <version>1003001</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>30198</microcodeVersion>
@@ -341,11 +272,11 @@ index 4ec731d655..8bfbf79a74 100644
    <arch>x86_64</arch>
    <cpu type='kvm' name='qemu64'/>
 diff --git a/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml
-index 601c62e65a..19925d0f29 100644
+index 0c271d3e41..200069ae86 100644
 --- a/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml
 @@ -131,6 +131,7 @@
-   <flag name='query-cpu-definitions'/>
+   <flag name='isa-serial'/>
    <version>1004002</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>30915</microcodeVersion>
@@ -353,11 +284,11 @@ index 601c62e65a..19925d0f29 100644
    <arch>x86_64</arch>
    <cpu type='kvm' name='Opteron_G5'/>
 diff --git a/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
-index 14f34b2771..df3c2d87b6 100644
+index 5c667975bf..e02c0961cd 100644
 --- a/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
 @@ -143,6 +143,7 @@
-   <flag name='kernel-irqchip'/>
+   <flag name='isa-serial'/>
    <version>1005003</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>47019</microcodeVersion>
@@ -365,11 +296,11 @@ index 14f34b2771..df3c2d87b6 100644
    <arch>x86_64</arch>
    <cpu type='kvm' name='Opteron_G5'/>
 diff --git a/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
-index 8fc23d6aad..889cd96dde 100644
+index 8ae07a91db..e3896685e9 100644
 --- a/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
 @@ -148,6 +148,7 @@
-   <flag name='kernel-irqchip'/>
+   <flag name='isa-serial'/>
    <version>1006000</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>45248</microcodeVersion>
@@ -377,11 +308,11 @@ index 8fc23d6aad..889cd96dde 100644
    <arch>x86_64</arch>
    <cpu type='kvm' name='Opteron_G5'/>
 diff --git a/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
-index 47c8956b44..426fcfc139 100644
+index 34bd6be1cd..5b4d1ea661 100644
 --- a/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
 @@ -150,6 +150,7 @@
-   <flag name='kernel-irqchip'/>
+   <flag name='isa-serial'/>
    <version>1007000</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>50692</microcodeVersion>
@@ -389,23 +320,59 @@ index 47c8956b44..426fcfc139 100644
    <arch>x86_64</arch>
    <cpu type='kvm' name='Opteron_G5'/>
 diff --git a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
-index afe7d53ff4..82737b2a7f 100644
+index 0d7c144ff7..200e57adac 100644
 --- a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
 @@ -166,6 +166,7 @@
-   <flag name='kernel-irqchip'/>
+   <flag name='isa-serial'/>
    <version>2001001</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>59488</microcodeVersion>
    <package></package>
    <arch>x86_64</arch>
    <cpu type='kvm' name='Opteron_G5'/>
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+index 09cce92067..d9ba077123 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+@@ -184,6 +184,7 @@
+   <flag name='isa-serial'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
++  <microcodeVersion>383421</microcodeVersion>
+   <package> (v2.10.0)</package>
+   <arch>ppc64</arch>
+   <cpu type='kvm' name='default'/>
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+index 00fe1cffa7..d9cbbd8ccb 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+@@ -146,6 +146,7 @@
+   <flag name='disk-share-rw'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
++  <microcodeVersion>304153</microcodeVersion>
+   <package></package>
+   <arch>s390x</arch>
+   <hostCPU type='kvm' model='z14-base' migratability='no'>
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+index 2417251678..c7b9787142 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+@@ -229,6 +229,7 @@
+   <flag name='isa-serial'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
++  <microcodeVersion>345185</microcodeVersion>
+   <package> (v2.10.0)</package>
+   <arch>x86_64</arch>
+   <hostCPU type='kvm' model='base' migratability='yes'>
 diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
-index 5bdc1a2bdd..dca3452861 100644
+index 5007523c1f..9b315aecf4 100644
 --- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
-@@ -188,6 +188,7 @@
-   <flag name='kernel-irqchip'/>
+@@ -191,6 +191,7 @@
+   <flag name='isa-serial'/>
    <version>2004000</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>75653</microcodeVersion>
@@ -413,11 +380,11 @@ index 5bdc1a2bdd..dca3452861 100644
    <arch>x86_64</arch>
    <cpu type='kvm' name='Opteron_G5'/>
 diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
-index 36bc1342bb..03bc558c18 100644
+index a9ad292d01..3096eadf72 100644
 --- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
-@@ -194,6 +194,7 @@
-   <flag name='kernel-irqchip'/>
+@@ -197,6 +197,7 @@
+   <flag name='isa-serial'/>
    <version>2005000</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>216775</microcodeVersion>
@@ -425,11 +392,11 @@ index 36bc1342bb..03bc558c18 100644
    <arch>x86_64</arch>
    <cpu type='kvm' name='Opteron_G5'/>
 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
-index 33bc462084..c78719c778 100644
+index d3e2e18faa..4cdd894a97 100644
 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
-@@ -172,6 +172,7 @@
-   <flag name='kernel-irqchip.split'/>
+@@ -176,6 +176,7 @@
+   <flag name='pl011'/>
    <version>2006000</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>228838</microcodeVersion>
@@ -437,35 +404,35 @@ index 33bc462084..c78719c778 100644
    <arch>aarch64</arch>
    <cpu type='kvm' name='pxa262'/>
 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
-index a8ce6b03b1..314b9407c0 100644
+index bc86d03537..5655af7d3d 100644
 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
-@@ -172,6 +172,7 @@
-   <flag name='kernel-irqchip.split'/>
+@@ -176,6 +176,7 @@
+   <flag name='pl011'/>
    <version>2006000</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>228838</microcodeVersion>
    <package></package>
    <arch>aarch64</arch>
    <cpu type='kvm' name='pxa262'/>
-diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
-index 425992f0d5..f09d0f74d1 100644
---- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
-@@ -166,6 +166,7 @@
-   <flag name='kernel-irqchip.split'/>
+diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
+index 27d99bd937..31701bb40b 100644
+--- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
+@@ -171,6 +171,7 @@
+   <flag name='isa-serial'/>
    <version>2006000</version>
    <kvmVersion>0</kvmVersion>
-+  <microcodeVersion>262913</microcodeVersion>
++  <microcodeVersion>263602</microcodeVersion>
    <package></package>
    <arch>ppc64</arch>
    <cpu type='kvm' name='default'/>
 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
-index 97e71ec4f4..4dadf178bd 100644
+index 97621612ab..6ae19ffd36 100644
 --- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
-@@ -204,6 +204,7 @@
-   <flag name='kernel-irqchip.split'/>
+@@ -207,6 +207,7 @@
+   <flag name='isa-serial'/>
    <version>2006000</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>227579</microcodeVersion>
@@ -473,11 +440,11 @@ index 97e71ec4f4..4dadf178bd 100644
    <arch>x86_64</arch>
    <cpu type='kvm' name='Opteron_G5'/>
 diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml
-index 70cce64179..75d77ccd13 100644
+index c2f310cd46..b6ec680d5c 100644
 --- a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml
-@@ -134,6 +134,7 @@
-   <flag name='kernel-irqchip.split'/>
+@@ -138,6 +138,7 @@
+   <flag name='sclplmconsole'/>
    <version>2007000</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>217559</microcodeVersion>
@@ -485,11 +452,11 @@ index 70cce64179..75d77ccd13 100644
    <arch>s390x</arch>
    <cpu type='kvm' name='host'/>
 diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
-index 49c046212b..b9531ad2d2 100644
+index e4ea9452c5..294ac126e5 100644
 --- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
-@@ -207,6 +207,7 @@
-   <flag name='intel-iommu.intremap'/>
+@@ -211,6 +211,7 @@
+   <flag name='isa-serial'/>
    <version>2007000</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>239276</microcodeVersion>
@@ -497,11 +464,11 @@ index 49c046212b..b9531ad2d2 100644
    <arch>x86_64</arch>
    <cpu type='kvm' name='Opteron_G5'/>
 diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml
-index 51be9bce4d..a707d76bc3 100644
+index f6e024dc61..d788ad206e 100644
 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml
-@@ -136,6 +136,7 @@
-   <flag name='kernel-irqchip.split'/>
+@@ -140,6 +140,7 @@
+   <flag name='sclplmconsole'/>
    <version>2007093</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>242460</microcodeVersion>
@@ -509,31 +476,55 @@ index 51be9bce4d..a707d76bc3 100644
    <arch>s390x</arch>
    <hostCPU type='kvm' model='zEC12.2-base' migratability='no'>
 diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-index 01edbc88da..d3bce6b15c 100644
+index c6d3e21d5c..156563d99a 100644
 --- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-@@ -209,6 +209,7 @@
-   <flag name='intel-iommu.eim'/>
+@@ -213,6 +213,7 @@
+   <flag name='isa-serial'/>
    <version>2008000</version>
    <kvmVersion>0</kvmVersion>
 +  <microcodeVersion>255931</microcodeVersion>
    <package> (v2.8.0)</package>
    <arch>x86_64</arch>
    <cpu type='kvm' name='host' usable='yes'/>
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+index f5cf0ba932..aa0c833a0c 100644
+--- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+@@ -178,6 +178,7 @@
+   <flag name='isa-serial'/>
+   <version>2009000</version>
+   <kvmVersion>0</kvmVersion>
++  <microcodeVersion>347135</microcodeVersion>
+   <package> (v2.9.0)</package>
+   <arch>ppc64</arch>
+   <cpu type='kvm' name='default'/>
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
+index 5c4a02c8b1..ba809b6ae3 100644
+--- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
++++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
+@@ -142,6 +142,7 @@
+   <flag name='disk-share-rw'/>
+   <version>2009000</version>
+   <kvmVersion>0</kvmVersion>
++  <microcodeVersion>265878</microcodeVersion>
+   <package></package>
+   <arch>s390x</arch>
+   <hostCPU type='kvm' model='z13.2-base' migratability='no'>
 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-index 2140eab398..34dd9353d8 100644
+index 82cc4e79f4..11f2508a04 100644
 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
 +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-@@ -219,6 +219,7 @@
-   <flag name='virtio.ats'/>
-   <version>2008090</version>
+@@ -225,6 +225,7 @@
+   <flag name='isa-serial'/>
+   <version>2009000</version>
    <kvmVersion>0</kvmVersion>
-+  <microcodeVersion>317985</microcodeVersion>
-   <package> (v2.9.0-rc0-142-g940a8ce)</package>
++  <microcodeVersion>321194</microcodeVersion>
+   <package> (v2.9.0)</package>
    <arch>x86_64</arch>
    <hostCPU type='kvm' model='base' migratability='yes'>
 diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
-index 2918ff4695..c817478e49 100644
+index 6e39866ebe..44b3b1fda5 100644
 --- a/tests/qemucapabilitiestest.c
 +++ b/tests/qemucapabilitiestest.c
 @@ -61,10 +61,16 @@ testQemuCaps(const void *opaque)
@@ -555,26 +546,26 @@ index 2918ff4695..c817478e49 100644
 +        virQEMUCapsSetMicrocodeVersion(capsActual, virFileLength(repliesFile, -1));
 +    }
  
-     if (!(actual = virQEMUCapsFormatCache(capsActual, 0, 0)))
+     if (!(actual = virQEMUCapsFormatCache(capsActual)))
          goto cleanup;
 diff --git a/tests/qemucapsprobe.c b/tests/qemucapsprobe.c
-index 561c5d7c14..03bf81d3bd 100644
+index 4b8d6229b4..a5f5a38b16 100644
 --- a/tests/qemucapsprobe.c
 +++ b/tests/qemucapsprobe.c
-@@ -71,7 +71,7 @@ main(int argc, char **argv)
+@@ -72,7 +72,7 @@ main(int argc, char **argv)
          return EXIT_FAILURE;
  
-     if (!(caps = virQEMUCapsNewForBinaryInternal(NULL, argv[1], "/tmp", NULL,
+     if (!(caps = virQEMUCapsNewForBinaryInternal(VIR_ARCH_NONE, argv[1], "/tmp",
 -                                                 -1, -1, true)))
 +                                                 -1, -1, 0, true)))
          return EXIT_FAILURE;
  
      virObjectUnref(caps);
 diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
-index 4cc482dfb0..e0fb97fba1 100644
+index 2c7124bf26..f8182033fc 100644
 --- a/tests/testutilsqemu.c
 +++ b/tests/testutilsqemu.c
-@@ -600,7 +600,7 @@ int qemuTestDriverInit(virQEMUDriver *driver)
+@@ -603,7 +603,7 @@ int qemuTestDriverInit(virQEMUDriver *driver)
  
      /* Using /dev/null for libDir and cacheDir automatically produces errors
       * upon attempt to use any of them */
diff --git a/SOURCES/libvirt-qemu-caps-Add-capability-for-share-rw-disk-option.patch b/SOURCES/libvirt-qemu-caps-Add-capability-for-share-rw-disk-option.patch
new file mode 100644
index 0000000..72eff63
--- /dev/null
+++ b/SOURCES/libvirt-qemu-caps-Add-capability-for-share-rw-disk-option.patch
@@ -0,0 +1,185 @@
+From dbb91baa8d629753ac7a686ca38a621553875005 Mon Sep 17 00:00:00 2001
+Message-Id: <dbb91baa8d629753ac7a686ca38a621553875005@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:22 +0100
+Subject: [PATCH] qemu: caps: Add capability for 'share-rw' disk option
+
+'share-rw' for the disk device configures qemu to allow concurrent
+access to the backing storage.
+
+The capability is checked in various supported disk frontend buses since
+it does not make sense to partially backport it.
+
+(cherry picked from commit 860a3c4bea1d24773d8a495f213d5de3ac48a462)
+
+ Conflicts:
+	src/qemu/qemu_capabilities.c
+	src/qemu/qemu_capabilities.h
+
+        Few capabilities were not backported, so I left empty space
+        instead.
+
+	tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml
+	tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml
+	tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+	tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+	tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+	tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+	tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
+
+        Some of the test files were missing and the rest had conflict
+        due to the above capabilities not being backported.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1378242
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c                      | 11 +++++++++++
+ src/qemu/qemu_capabilities.h                      |  7 +++++++
+ tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml  |  1 +
+ tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml  |  1 +
+ tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml |  1 +
+ tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml   |  1 +
+ tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml   |  1 +
+ tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml  |  1 +
+ 8 files changed, 24 insertions(+)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index f30d2fa09e..2f41e076cb 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -444,6 +444,13 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
+               "vxhs",
+               "virtio-blk.num-queues",
+               "machine.pseries.resize-hpt",
++
++
++
++              /* 275 */
++
++
++              "disk-share-rw",
+     );
+ 
+ 
+@@ -1686,6 +1693,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
+     { "scsi", QEMU_CAPS_VIRTIO_BLK_SCSI },
+     { "logical_block_size", QEMU_CAPS_BLOCKIO },
+     { "num-queues", QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES },
++    { "share-rw", QEMU_CAPS_DISK_SHARE_RW },
+ };
+ 
+ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioNet[] = {
+@@ -1716,10 +1724,12 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVfioPCI[] = {
+ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsSCSIDisk[] = {
+     { "channel", QEMU_CAPS_SCSI_DISK_CHANNEL },
+     { "wwn", QEMU_CAPS_SCSI_DISK_WWN },
++    { "share-rw", QEMU_CAPS_DISK_SHARE_RW },
+ };
+ 
+ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIDEDrive[] = {
+     { "wwn", QEMU_CAPS_IDE_DRIVE_WWN },
++    { "share-rw", QEMU_CAPS_DISK_SHARE_RW },
+ };
+ 
+ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsPiix4PM[] = {
+@@ -1750,6 +1760,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQ35PCIHost[] = {
+ 
+ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsUSBStorage[] = {
+     { "removable", QEMU_CAPS_USB_STORAGE_REMOVABLE },
++    { "share-rw", QEMU_CAPS_DISK_SHARE_RW },
+ };
+ 
+ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsKVMPit[] = {
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index e7d766f801..60818daa1c 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -431,6 +431,13 @@ typedef enum {
+     QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES, /* virtio-blk-*.num-queues */
+     QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT, /* -machine pseries,resize-hpt */
+ 
++
++
++    /* 275 */
++
++
++    QEMU_CAPS_DISK_SHARE_RW, /* share-rw=on for concurrent disk access */
++
+     QEMU_CAPS_LAST /* this must always be the last item */
+ } virQEMUCapsFlags;
+ 
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+index b0ee3f1523..c01777a5a3 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+@@ -178,6 +178,7 @@
+   <flag name='vxhs'/>
+   <flag name='virtio-blk.num-queues'/>
+   <flag name='machine.pseries.resize-hpt'/>
++  <flag name='disk-share-rw'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.10.0)</package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+index 7e44652feb..a6900bf1ef 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+@@ -141,6 +141,7 @@
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='vxhs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='disk-share-rw'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+index ddbd8c32fa..33db3e6674 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+@@ -224,6 +224,7 @@
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='vxhs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='disk-share-rw'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.10.0)</package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+index 786cea8eab..e912211f40 100644
+--- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+@@ -173,6 +173,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='disk-share-rw'/>
+   <version>2009000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.9.0)</package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
+index 896ed503c3..4150b8eee7 100644
+--- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
++++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml
+@@ -138,6 +138,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='disk-share-rw'/>
+   <version>2009000</version>
+   <kvmVersion>0</kvmVersion>
+   <package></package>
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
+index 05f9dc0308..0ea9a2fce3 100644
+--- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
+@@ -221,6 +221,7 @@
+   <flag name='chardev-reconnect'/>
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='disk-share-rw'/>
+   <version>2009000</version>
+   <kvmVersion>0</kvmVersion>
+   <package> (v2.9.0)</package>
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-change-the-logic-of-setting-default-USB-controller.patch b/SOURCES/libvirt-qemu-change-the-logic-of-setting-default-USB-controller.patch
deleted file mode 100644
index 0cb71a1..0000000
--- a/SOURCES/libvirt-qemu-change-the-logic-of-setting-default-USB-controller.patch
+++ /dev/null
@@ -1,67 +0,0 @@
-From 09e42278625a78997f11ffe898e82684a6524131 Mon Sep 17 00:00:00 2001
-Message-Id: <09e42278625a78997f11ffe898e82684a6524131@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Fri, 28 Apr 2017 11:59:47 +0200
-Subject: [PATCH] qemu: change the logic of setting default USB controller
-
-The new logic will set the piix3-uhci if available regardless of
-any architecture and it will be updated to better model based on
-architecture and device existence.
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Acked-by: Andrea Bolognani <abologna@redhat.com>
-(cherry picked from commit e69001b46448ae7e0f9f727965d4bea169ca2d9e)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1438682
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 23 ++++++++++++++---------
- 1 file changed, 14 insertions(+), 9 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 53586878b..a1a4003af 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -3223,11 +3223,17 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
-              * when the relevant device is not available.
-              *
-              * See qemuBuildControllerDevCommandLine() */
--            if (ARCH_IS_S390(def->os.arch) &&
--                cont->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
--                /* set the default USB model to none for s390 unless an
--                 * address is found */
--                cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
-+
-+            /* Default USB controller is piix3-uhci if available. */
-+            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
-+                cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
-+
-+            if (ARCH_IS_S390(def->os.arch)) {
-+                if (cont->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
-+                    /* set the default USB model to none for s390 unless an
-+                     * address is found */
-+                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
-+                }
-             } else if (ARCH_IS_PPC64(def->os.arch)) {
-                 /* To not break migration we need to set default USB controller
-                  * for ppc64 to pci-ohci if we cannot change ABI of the VM.
-@@ -3238,11 +3244,10 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
-                     cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
-                 } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI)) {
-                     cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
-+                } else {
-+                    /* Explicitly fallback to legacy USB controller for PPC64. */
-+                    cont->model = -1;
-                 }
--            } else {
--                /* Default USB controller for anything else is piix3-uhci */
--                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
--                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
-             }
-         }
-         /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-command-Mark-shared-disks-as-such-in-qemu.patch b/SOURCES/libvirt-qemu-command-Mark-shared-disks-as-such-in-qemu.patch
new file mode 100644
index 0000000..969c0db
--- /dev/null
+++ b/SOURCES/libvirt-qemu-command-Mark-shared-disks-as-such-in-qemu.patch
@@ -0,0 +1,139 @@
+From 378887595f3cbb937f6c3e88ed3828e5f6698e33 Mon Sep 17 00:00:00 2001
+Message-Id: <378887595f3cbb937f6c3e88ed3828e5f6698e33@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:23 +0100
+Subject: [PATCH] qemu: command: Mark <shared/> disks as such in qemu
+
+Qemu has now an internal mechanism for locking images to fix specific
+cases of disk corruption. This requires libvirt to mark the image as
+shared so that qemu lifts certain restrictions.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1378242
+(cherry picked from commit 28907b0043fbf71085a798372ab9c816ba043b93)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c                            |  4 +++
+ .../qemuxml2argv-disk-drive-shared-locking.args    | 32 +++++++++++++++++
+ .../qemuxml2argv-disk-drive-shared-locking.xml     | 42 ++++++++++++++++++++++
+ tests/qemuxml2argvtest.c                           |  2 ++
+ 4 files changed, 80 insertions(+)
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.xml
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index dfacff4b12..fc7f54e81e 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -2182,6 +2182,10 @@ qemuBuildDriveDevStr(const virDomainDef *def,
+         goto error;
+     }
+ 
++    if (disk->src->shared &&
++        virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_SHARE_RW))
++        virBufferAddLit(&opt, ",share-rw=on");
++
+     if (!(drivealias = qemuAliasFromDisk(disk)))
+         goto error;
+     virBufferAsprintf(&opt, ",drive=%s,id=%s", drivealias, disk->info.alias);
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.args
+new file mode 100644
+index 0000000000..cdf17f26d1
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.args
+@@ -0,0 +1,32 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-i686 \
++-name QEMUGuest1 \
++-S \
++-M pc \
++-m 214 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
++-nographic \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-no-acpi \
++-boot c \
++-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \
++-usb \
++-drive file=/dev/ide,format=raw,if=none,id=drive-ide0-0-0,cache=none \
++-device ide-drive,bus=ide.0,unit=0,share-rw=on,drive=drive-ide0-0-0,\
++id=ide0-0-0 \
++-drive file=/dev/scsi,format=raw,if=none,id=drive-scsi0-0-0-0,cache=none \
++-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,share-rw=on,\
++drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
++-drive file=/dev/virtio,format=raw,if=none,id=drive-virtio-disk0,cache=none \
++-device virtio-blk-pci,bus=pci.0,addr=0x4,share-rw=on,drive=drive-virtio-disk0,\
++id=virtio-disk0 \
++-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.xml
+new file mode 100644
+index 0000000000..dd48857a30
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-locking.xml
+@@ -0,0 +1,42 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219136</memory>
++  <currentMemory unit='KiB'>219136</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <disk type='block' device='disk'>
++      <driver name='qemu' type='raw'/>
++      <source dev='/dev/ide'/>
++      <target dev='hda' bus='ide'/>
++      <shareable/>
++      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
++    </disk>
++    <disk type='block' device='disk'>
++      <driver name='qemu' type='raw'/>
++      <source dev='/dev/scsi'/>
++      <target dev='sda' bus='scsi'/>
++      <shareable/>
++      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
++    </disk>
++    <disk type='block' device='disk'>
++      <driver name='qemu' type='raw'/>
++      <source dev='/dev/virtio'/>
++      <target dev='vda' bus='virtio'/>
++      <shareable/>
++    </disk>
++    <controller type='usb' index='0'/>
++    <controller type='ide' index='0'/>
++    <controller type='scsi' index='0' model='virtio-scsi'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 00110cae19..4e981c9fab 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -909,6 +909,8 @@ mymain(void)
+     DO_TEST("disk-drive-shared",
+             QEMU_CAPS_DRIVE_SERIAL);
+     DO_TEST_PARSE_ERROR("disk-drive-shared-qcow", NONE);
++    DO_TEST("disk-drive-shared-locking",
++            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DISK_SHARE_RW);
+     DO_TEST("disk-drive-error-policy-stop",
+             QEMU_CAPS_MONITOR_JSON);
+     DO_TEST("disk-drive-error-policy-enospace",
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-do-not-crash-on-USB-address-with-no-port-and-invalid-bus.patch b/SOURCES/libvirt-qemu-do-not-crash-on-USB-address-with-no-port-and-invalid-bus.patch
deleted file mode 100644
index dffa58f..0000000
--- a/SOURCES/libvirt-qemu-do-not-crash-on-USB-address-with-no-port-and-invalid-bus.patch
+++ /dev/null
@@ -1,82 +0,0 @@
-From 74f7abdf0e567914abc12319f1e3d723e18d0d6d Mon Sep 17 00:00:00 2001
-Message-Id: <74f7abdf0e567914abc12319f1e3d723e18d0d6d@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Thu, 13 Apr 2017 12:05:48 +0200
-Subject: [PATCH] qemu: do not crash on USB address with no port and invalid
- bus
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Properly error out when the user requests a port from a bus
-that does not have a controller present in the domain XML.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441589
-(cherry picked from commit b003b9781b6ae633cfe4fdf6b9620ca246fa2432)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
----
- src/conf/domain_addr.c                             |  3 ++-
- .../qemuxml2argv-usb-bus-missing.xml               | 22 ++++++++++++++++++++++
- tests/qemuxml2argvtest.c                           |  3 +++
- 3 files changed, 27 insertions(+), 1 deletion(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-bus-missing.xml
-
-diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
-index 35bdc3453..8b6109199 100644
---- a/src/conf/domain_addr.c
-+++ b/src/conf/domain_addr.c
-@@ -2009,7 +2009,8 @@ virDomainUSBAddressAssign(virDomainUSBAddressSetPtr addrs,
- 
-     if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
-         VIR_DEBUG("A USB port on bus %u was requested", info->addr.usb.bus);
--        if (!addrs->buses[info->addr.usb.bus]) {
-+        if (info->addr.usb.bus >= addrs->nbuses ||
-+            !addrs->buses[info->addr.usb.bus]) {
-             virReportError(VIR_ERR_XML_ERROR,
-                            _("USB bus %u requested but no controller "
-                              "with that index is present"), info->addr.usb.bus);
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-bus-missing.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-bus-missing.xml
-new file mode 100644
-index 000000000..831a4c0af
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-bus-missing.xml
-@@ -0,0 +1,22 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='i686' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-i686</emulator>
-+    <controller type='usb' index='0'/>
-+    <memballoon model='virtio'/>
-+    <input type='mouse' bus='usb'>
-+      <address type='usb' bus='0'/>
-+    </input>
-+    <hub type='usb'>
-+      <address type='usb' bus='1'/>
-+    </hub>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index cfd6dcd55..94be771d3 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -1349,6 +1349,9 @@ mymain(void)
-     DO_TEST("usb-port-missing",
-             QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
-             QEMU_CAPS_NODEFCONFIG);
-+    DO_TEST_PARSE_ERROR("usb-bus-missing",
-+                        QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
-+                        QEMU_CAPS_NODEFCONFIG);
-     DO_TEST("usb-ports",
-             QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
-             QEMU_CAPS_NODEFCONFIG);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-domain-Despaghettify-qemuDomainDeviceDefValidate.patch b/SOURCES/libvirt-qemu-domain-Despaghettify-qemuDomainDeviceDefValidate.patch
new file mode 100644
index 0000000..df9427a
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Despaghettify-qemuDomainDeviceDefValidate.patch
@@ -0,0 +1,223 @@
+From 1747bfd95ad80d2453de11e99a7bf9fa53c9aa55 Mon Sep 17 00:00:00 2001
+Message-Id: <1747bfd95ad80d2453de11e99a7bf9fa53c9aa55@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:14 +0100
+Subject: [PATCH] qemu: domain: Despaghettify qemuDomainDeviceDefValidate
+
+Move network device validation into a separate function.
+
+(cherry picked from commit 577ccd07c35a8e9b9d682778cc7d6c1d34d891f9)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1511480
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 184 ++++++++++++++++++++++++++-----------------------
+ 1 file changed, 97 insertions(+), 87 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 72d67adfe3..30a602a1e9 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3553,102 +3553,112 @@ qemuDomainWatchdogDefValidate(const virDomainWatchdogDef *dev,
+ }
+ 
+ 
++static int
++qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
++{
++    bool hasIPv4 = false;
++    bool hasIPv6 = false;
++    size_t i;
++
++    if (net->type == VIR_DOMAIN_NET_TYPE_USER) {
++        if (net->guestIP.nroutes) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                           _("Invalid attempt to set network interface "
++                             "guest-side IP route, not supported by QEMU"));
++            return -1;
++        }
++
++        for (i = 0; i < net->guestIP.nips; i++) {
++            const virNetDevIPAddr *ip = net->guestIP.ips[i];
++
++            if (VIR_SOCKET_ADDR_VALID(&net->guestIP.ips[i]->peer)) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                               _("Invalid attempt to set peer IP for guest"));
++                return -1;
++            }
++
++            if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET)) {
++                if (hasIPv4) {
++                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                                   _("Only one IPv4 address per "
++                                     "interface is allowed"));
++                    return -1;
++                }
++                hasIPv4 = true;
++
++                if (ip->prefix > 27) {
++                    virReportError(VIR_ERR_XML_ERROR, "%s",
++                                   _("prefix too long"));
++                    return -1;
++                }
++            }
++
++            if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET6)) {
++                if (hasIPv6) {
++                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                                   _("Only one IPv6 address per "
++                                     "interface is allowed"));
++                    return -1;
++                }
++                hasIPv6 = true;
++
++                if (ip->prefix > 120) {
++                    virReportError(VIR_ERR_XML_ERROR, "%s",
++                                   _("prefix too long"));
++                    return -1;
++                }
++            }
++        }
++    } else if (net->guestIP.nroutes || net->guestIP.nips) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                       _("Invalid attempt to set network interface "
++                         "guest-side IP route and/or address info, "
++                         "not supported by QEMU"));
++        return -1;
++    }
++
++    if (STREQ_NULLABLE(net->model, "virtio")) {
++        if (net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queue_size - 1)) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                           _("rx_queue_size has to be a power of two"));
++            return -1;
++        }
++        if (net->driver.virtio.tx_queue_size & (net->driver.virtio.tx_queue_size - 1)) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                           _("tx_queue_size has to be a power of two"));
++            return -1;
++        }
++    }
++
++    if (net->mtu &&
++        !qemuDomainNetSupportsMTU(net->type)) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("setting MTU on interface type %s is not supported yet"),
++                       virDomainNetTypeToString(net->type));
++        return -1;
++    }
++
++    if (net->coalesce && !qemuDomainNetSupportsCoalesce(net->type)) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("coalesce settings on interface type %s are not supported"),
++                       virDomainNetTypeToString(net->type));
++        return -1;
++    }
++
++    return 0;
++}
++
++
+ static int
+ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+                             const virDomainDef *def,
+                             void *opaque ATTRIBUTE_UNUSED)
+ {
+     int ret = -1;
+-    size_t i;
+ 
+     if (dev->type == VIR_DOMAIN_DEVICE_NET) {
+-        const virDomainNetDef *net = dev->data.net;
+-        bool hasIPv4 = false, hasIPv6 = false;
+-
+-        if (net->type == VIR_DOMAIN_NET_TYPE_USER) {
+-            if (net->guestIP.nroutes) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("Invalid attempt to set network interface "
+-                                 "guest-side IP route, not supported by QEMU"));
+-                goto cleanup;
+-            }
+-
+-            for (i = 0; i < net->guestIP.nips; i++) {
+-                const virNetDevIPAddr *ip = net->guestIP.ips[i];
+-
+-                if (VIR_SOCKET_ADDR_VALID(&net->guestIP.ips[i]->peer)) {
+-                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                                   _("Invalid attempt to set peer IP for guest"));
+-                    goto cleanup;
+-                }
+-
+-                if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET)) {
+-                    if (hasIPv4) {
+-                        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                                       _("Only one IPv4 address per "
+-                                         "interface is allowed"));
+-                        goto cleanup;
+-                    }
+-                    hasIPv4 = true;
+-
+-                    if (ip->prefix > 27) {
+-                        virReportError(VIR_ERR_XML_ERROR, "%s",
+-                                       _("prefix too long"));
+-                        goto cleanup;
+-                    }
+-                }
+-
+-                if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET6)) {
+-                    if (hasIPv6) {
+-                        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                                       _("Only one IPv6 address per "
+-                                         "interface is allowed"));
+-                        goto cleanup;
+-                    }
+-                    hasIPv6 = true;
+-
+-                    if (ip->prefix > 120) {
+-                        virReportError(VIR_ERR_XML_ERROR, "%s",
+-                                       _("prefix too long"));
+-                        goto cleanup;
+-                    }
+-                }
+-            }
+-        } else if (net->guestIP.nroutes || net->guestIP.nips) {
+-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                           _("Invalid attempt to set network interface "
+-                             "guest-side IP route and/or address info, "
+-                             "not supported by QEMU"));
++        if (qemuDomainDeviceDefValidateNetwork(dev->data.net) < 0)
+             goto cleanup;
+-        }
+-
+-        if (STREQ_NULLABLE(net->model, "virtio")) {
+-            if (net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queue_size - 1)) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("rx_queue_size has to be a power of two"));
+-                goto cleanup;
+-            }
+-            if (net->driver.virtio.tx_queue_size & (net->driver.virtio.tx_queue_size - 1)) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("tx_queue_size has to be a power of two"));
+-                goto cleanup;
+-            }
+-        }
+-
+-        if (net->mtu &&
+-            !qemuDomainNetSupportsMTU(net->type)) {
+-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+-                           _("setting MTU on interface type %s is not supported yet"),
+-                           virDomainNetTypeToString(net->type));
+-            goto cleanup;
+-        }
+-
+-        if (net->coalesce && !qemuDomainNetSupportsCoalesce(net->type)) {
+-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+-                           _("coalesce settings on interface type %s are not supported"),
+-                           virDomainNetTypeToString(net->type));
+-            goto cleanup;
+-        }
+     } else if (dev->type == VIR_DOMAIN_DEVICE_CHR) {
+         if (qemuDomainChrDefValidate(dev->data.chr, def) < 0)
+             goto cleanup;
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-domain-Don-t-allocate-storage-source-private-data-if-not-needed.patch b/SOURCES/libvirt-qemu-domain-Don-t-allocate-storage-source-private-data-if-not-needed.patch
new file mode 100644
index 0000000..bc349d7
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Don-t-allocate-storage-source-private-data-if-not-needed.patch
@@ -0,0 +1,50 @@
+From f0ec77f06f7f72d29748c2a04877ac97632ef63b Mon Sep 17 00:00:00 2001
+Message-Id: <f0ec77f06f7f72d29748c2a04877ac97632ef63b@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Mon, 13 Nov 2017 13:43:22 +0100
+Subject: [PATCH] qemu: domain: Don't allocate storage source private data if
+ not needed
+
+(cherry picked from commit 2c82fddca93ea83736260a5a90040fb5fa391e9a)
+https://bugzilla.redhat.com/show_bug.cgi?id=1510323
+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 27117d83ef..81f45516af 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -1385,13 +1385,18 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
+ {
+     virStorageSourcePtr src = disk->src;
+     qemuDomainStorageSourcePrivatePtr srcPriv;
++    bool hasAuth = qemuDomainSecretDiskCapable(src);
++    bool hasEnc = qemuDomainDiskHasEncryptionSecret(src);
++
++    if (!hasAuth && !hasEnc)
++        return 0;
+ 
+     if (!(disk->src->privateData = qemuDomainStorageSourcePrivateNew()))
+         return -1;
+ 
+     srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
+ 
+-    if (qemuDomainSecretDiskCapable(src)) {
++    if (hasAuth) {
+         virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI;
+ 
+         if (src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)
+@@ -1404,7 +1409,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
+               return -1;
+     }
+ 
+-    if (qemuDomainDiskHasEncryptionSecret(src)) {
++    if (hasEnc) {
+         if (!(srcPriv->encinfo =
+               qemuDomainSecretInfoNew(conn, priv, disk->info.alias,
+                                       VIR_SECRET_USAGE_TYPE_VOLUME, NULL,
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-domain-Don-t-call-namespace-setup-for-storage-already-accessed-by-vm.patch b/SOURCES/libvirt-qemu-domain-Don-t-call-namespace-setup-for-storage-already-accessed-by-vm.patch
index 9f47835..5dd8f09 100644
--- a/SOURCES/libvirt-qemu-domain-Don-t-call-namespace-setup-for-storage-already-accessed-by-vm.patch
+++ b/SOURCES/libvirt-qemu-domain-Don-t-call-namespace-setup-for-storage-already-accessed-by-vm.patch
@@ -1,7 +1,7 @@
-From cccfeedda80612c8ce2c48e4eed26fe6c51382f3 Mon Sep 17 00:00:00 2001
-Message-Id: <cccfeedda80612c8ce2c48e4eed26fe6c51382f3@dist-git>
+From 2570986655a119553082702dad8f256fb72ead75 Mon Sep 17 00:00:00 2001
+Message-Id: <2570986655a119553082702dad8f256fb72ead75@dist-git>
 From: Peter Krempa <pkrempa@redhat.com>
-Date: Wed, 22 Nov 2017 18:20:50 +0100
+Date: Wed, 22 Nov 2017 18:21:35 +0100
 Subject: [PATCH] qemu: domain: Don't call namespace setup for storage already
  accessed by vm
 
@@ -24,9 +24,6 @@ qemuDomainBlockCommit do not, so the calls are anotated accordingly.
 
 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1506072
 (cherry picked from commit 3746a38e7b9ae5342675547624122d55e73d6c81)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1516717
-
 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
 ---
  src/qemu/qemu_domain.c | 17 ++++++++++++++---
@@ -35,10 +32,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  3 files changed, 22 insertions(+), 10 deletions(-)
 
 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 68c1f3b7c5..dd70bd6367 100644
+index 485e085cea..72d67adfe3 100644
 --- a/src/qemu/qemu_domain.c
 +++ b/src/qemu/qemu_domain.c
-@@ -5510,15 +5510,25 @@ qemuDomainDiskChainElementRevoke(virQEMUDriverPtr driver,
+@@ -6074,15 +6074,25 @@ qemuDomainDiskChainElementRevoke(virQEMUDriverPtr driver,
  
  /**
   * qemuDomainDiskChainElementPrepare:
@@ -66,7 +63,7 @@ index 68c1f3b7c5..dd70bd6367 100644
  {
      bool was_readonly = elem->readonly;
      virQEMUDriverConfigPtr cfg = NULL;
-@@ -5531,7 +5541,8 @@ qemuDomainDiskChainElementPrepare(virQEMUDriverPtr driver,
+@@ -6095,7 +6105,8 @@ qemuDomainDiskChainElementPrepare(virQEMUDriverPtr driver,
      if (virDomainLockImageAttach(driver->lockManager, cfg->uri, vm, elem) < 0)
          goto cleanup;
  
@@ -77,10 +74,10 @@ index 68c1f3b7c5..dd70bd6367 100644
  
      if (qemuSetupImageCgroup(vm, elem) < 0)
 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 1a658bcf7e..68458ad9ae 100644
+index ff5328277c..caf583373f 100644
 --- a/src/qemu/qemu_domain.h
 +++ b/src/qemu/qemu_domain.h
-@@ -642,7 +642,8 @@ void qemuDomainDiskChainElementRevoke(virQEMUDriverPtr driver,
+@@ -688,7 +688,8 @@ void qemuDomainDiskChainElementRevoke(virQEMUDriverPtr driver,
  int qemuDomainDiskChainElementPrepare(virQEMUDriverPtr driver,
                                        virDomainObjPtr vm,
                                        virStorageSourcePtr elem,
@@ -91,10 +88,10 @@ index 1a658bcf7e..68458ad9ae 100644
  int qemuDomainCleanupAdd(virDomainObjPtr vm,
                           qemuDomainCleanupCallback cb);
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index f8df2d452d..498f787ad3 100644
+index 6096e00b2a..b35ab6d30e 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
-@@ -14277,7 +14277,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
+@@ -14578,7 +14578,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
      }
  
      /* set correct security, cgroup and locking options on the new image */
@@ -103,7 +100,7 @@ index f8df2d452d..498f787ad3 100644
          qemuDomainDiskChainElementRevoke(driver, vm, dd->src);
          goto cleanup;
      }
-@@ -16865,7 +16865,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
+@@ -17173,7 +17173,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
                                           keepParentLabel) < 0)
          goto endjob;
  
@@ -112,7 +109,7 @@ index f8df2d452d..498f787ad3 100644
          qemuDomainDiskChainElementRevoke(driver, vm, mirror);
          goto endjob;
      }
-@@ -17252,9 +17252,9 @@ qemuDomainBlockCommit(virDomainPtr dom,
+@@ -17566,9 +17566,9 @@ qemuDomainBlockCommit(virDomainPtr dom,
       * operation succeeds, but doing that requires tracking the
       * operation in XML across libvirtd restarts.  */
      clean_access = true;
@@ -124,7 +121,7 @@ index f8df2d452d..498f787ad3 100644
          goto endjob;
  
      /* Start the commit operation.  Pass the user's original spelling,
-@@ -17304,9 +17304,9 @@ qemuDomainBlockCommit(virDomainPtr dom,
+@@ -17612,9 +17612,9 @@ qemuDomainBlockCommit(virDomainPtr dom,
      if (ret < 0 && clean_access) {
          virErrorPtr orig_err = virSaveLastError();
          /* Revert access to read-only, if possible.  */
@@ -137,5 +134,5 @@ index f8df2d452d..498f787ad3 100644
          if (orig_err) {
              virSetError(orig_err);
 -- 
-2.15.1
+2.15.0
 
diff --git a/SOURCES/libvirt-qemu-domain-Fix-backing-store-terminator-for-non-backing-local-files.patch b/SOURCES/libvirt-qemu-domain-Fix-backing-store-terminator-for-non-backing-local-files.patch
new file mode 100644
index 0000000..6d27d1b
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Fix-backing-store-terminator-for-non-backing-local-files.patch
@@ -0,0 +1,186 @@
+From d3cf944874059fd81b68f8cc0beef6b8b69490bb Mon Sep 17 00:00:00 2001
+Message-Id: <d3cf944874059fd81b68f8cc0beef6b8b69490bb@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Fri, 1 Dec 2017 15:57:03 +0100
+Subject: [PATCH] qemu: domain: Fix backing store terminator for non-backing
+ local files
+
+Raw local files do not pass through the backing store detector and thus
+the code did not allocate the required backing store terminator for
+them. Previously the terminating element would be formatted into the XML
+since the default values used for the metadata allowed that. This is a
+regression since a693fdba0111ff which was not detected in the review.
+
+This patch also reverts all the changes in the test files.
+
+(cherry picked from commit adcc31bb89e47ef642cbcfcff372131db7cd8d8b)
+
+ Conflicts:
+	src/qemu/qemu_domain.c - as with previous patch the return code
+        logic hat do be negated
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1509110
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c                                             | 7 +++++++
+ .../qemuhotplug-base-ccw-live+ccw-virtio.xml                       | 1 +
+ ...otplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml | 2 ++
+ .../qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml                | 1 +
+ ...hotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml | 1 +
+ .../qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml     | 1 +
+ ...qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml | 1 +
+ tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml   | 1 +
+ tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml    | 1 +
+ tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml | 1 +
+ .../qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml  | 1 +
+ 11 files changed, 18 insertions(+)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 33cb3df949..9dd9db049b 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -6372,6 +6372,13 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
+             goto cleanup;
+         }
+ 
++        /* terminate the chain for such images as the code below would do */
++        if (!disk->src->backingStore &&
++            VIR_ALLOC(disk->src->backingStore) < 0) {
++            ret = -1;
++            goto cleanup;
++        }
++
+         goto cleanup;
+     }
+ 
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml
+index 0fa8d036b9..cd03d0e09b 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml
+@@ -22,6 +22,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='vde' bus='virtio'/>
+       <readonly/>
+       <shareable/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml
+index 135427fff5..7be75f977b 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml
+@@ -22,6 +22,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='hda' bus='virtio'/>
+       <readonly/>
+       <shareable/>
+@@ -31,6 +32,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='hdb' bus='virtio'/>
+       <readonly/>
+       <shareable/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml
+index e17c4e43b2..a83f1b5d73 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml
+@@ -22,6 +22,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='hda' bus='virtio'/>
+       <readonly/>
+       <shareable/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml
+index 326d312fa9..3e90207519 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml
+@@ -22,6 +22,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='hda' bus='virtio'/>
+       <readonly/>
+       <shareable/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml
+index 326d312fa9..3e90207519 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml
+@@ -22,6 +22,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='hda' bus='virtio'/>
+       <readonly/>
+       <shareable/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
+index 16caeb3542..4c3ea3202b 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
+@@ -33,6 +33,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='sdg' bus='scsi'/>
+       <readonly/>
+       <shareable/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml
+index a6dbf0b1bd..493a615fd3 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml
+@@ -22,6 +22,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='sdf' bus='scsi'/>
+       <readonly/>
+       <shareable/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml
+index 6ccb88f140..3609819ea3 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml
+@@ -22,6 +22,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='sdq' bus='usb'/>
+       <readonly/>
+       <shareable/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml
+index b97c0b41e2..b88b220e33 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml
+@@ -22,6 +22,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='vde' bus='virtio'/>
+       <readonly/>
+       <shareable/>
+diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml
+index 6422e1640d..c12d18f716 100644
+--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml
++++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml
+@@ -22,6 +22,7 @@
+     <disk type='file' device='disk'>
+       <driver name='qemu' type='raw' cache='none'/>
+       <source file='/dev/null'/>
++      <backingStore/>
+       <target dev='sdf' bus='scsi'/>
+       <readonly/>
+       <shareable/>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-domain-Move-hostdev-validation-into-separate-function.patch b/SOURCES/libvirt-qemu-domain-Move-hostdev-validation-into-separate-function.patch
new file mode 100644
index 0000000..5588ea5
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Move-hostdev-validation-into-separate-function.patch
@@ -0,0 +1,65 @@
+From 413eb4cbdddfd7ecc3fd12320a59033c76f878cc Mon Sep 17 00:00:00 2001
+Message-Id: <413eb4cbdddfd7ecc3fd12320a59033c76f878cc@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:15 +0100
+Subject: [PATCH] qemu: domain: Move hostdev validation into separate function
+
+(cherry picked from commit a6936ec0987f6b014516e4d51b44c9c9de57a6cb)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1511480
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 30 ++++++++++++++++++++----------
+ 1 file changed, 20 insertions(+), 10 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 30a602a1e9..13b96368c1 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3649,6 +3649,23 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
+ }
+ 
+ 
++static int
++qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
++                                   const virDomainDef *def)
++{
++    /* forbid capabilities mode hostdev in this kind of hypervisor */
++    if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("hostdev mode 'capabilities' is not "
++                         "supported in %s"),
++                       virDomainVirtTypeToString(def->virtType));
++        return -1;
++    }
++
++    return 0;
++}
++
++
+ static int
+ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+                             const virDomainDef *def,
+@@ -3674,16 +3691,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+     } else if (dev->type == VIR_DOMAIN_DEVICE_WATCHDOG) {
+         if (qemuDomainWatchdogDefValidate(dev->data.watchdog, def) < 0)
+             goto cleanup;
+-    }
+-
+-    /* forbid capabilities mode hostdev in this kind of hypervisor */
+-    if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
+-        dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
+-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+-                       _("hostdev mode 'capabilities' is not "
+-                         "supported in %s"),
+-                       virDomainVirtTypeToString(def->virtType));
+-        goto cleanup;
++    } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
++        if (qemuDomainDeviceDefValidateHostdev(dev->data.hostdev, def) < 0)
++            goto cleanup;
+     }
+ 
+     if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-domain-Move-video-device-validation-into-separate-function.patch b/SOURCES/libvirt-qemu-domain-Move-video-device-validation-into-separate-function.patch
new file mode 100644
index 0000000..e804d01
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Move-video-device-validation-into-separate-function.patch
@@ -0,0 +1,79 @@
+From 2cfaf0011f6462310f658a650fbdf998ed575ff0 Mon Sep 17 00:00:00 2001
+Message-Id: <2cfaf0011f6462310f658a650fbdf998ed575ff0@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:16 +0100
+Subject: [PATCH] qemu: domain: Move video device validation into separate
+ function
+
+(cherry picked from commit ab948b6299aa311c07bb46b79c6ccbe7d46fb94e)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1511480
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 43 ++++++++++++++++++++++++++-----------------
+ 1 file changed, 26 insertions(+), 17 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 13b96368c1..1b72d95d7e 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3666,6 +3666,29 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
+ }
+ 
+ 
++static int
++qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video)
++{
++    if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
++        video->vgamem) {
++        if (video->vgamem < 1024) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                           _("value for 'vgamem' must be at least 1 MiB "
++                             "(1024 KiB)"));
++            return -1;
++        }
++
++        if (video->vgamem != VIR_ROUND_UP_POWER_OF_TWO(video->vgamem)) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                           _("value for 'vgamem' must be power of two"));
++            return -1;
++        }
++    }
++
++    return 0;
++}
++
++
+ static int
+ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+                             const virDomainDef *def,
+@@ -3694,23 +3717,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
+         if (qemuDomainDeviceDefValidateHostdev(dev->data.hostdev, def) < 0)
+             goto cleanup;
+-    }
+-
+-    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
+-        if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
+-            dev->data.video->vgamem) {
+-            if (dev->data.video->vgamem < 1024) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("value for 'vgamem' must be at least 1 MiB "
+-                                 "(1024 KiB)"));
+-                goto cleanup;
+-            }
+-            if (dev->data.video->vgamem != VIR_ROUND_UP_POWER_OF_TWO(dev->data.video->vgamem)) {
+-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("value for 'vgamem' must be power of two"));
+-                goto cleanup;
+-            }
+-        }
++    } else if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
++        if (qemuDomainDeviceDefValidateVideo(dev->data.video) < 0)
++            goto cleanup;
+     }
+ 
+     ret = 0;
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-domain-Parse-and-format-relPath-into-disk-source-private-data.patch b/SOURCES/libvirt-qemu-domain-Parse-and-format-relPath-into-disk-source-private-data.patch
new file mode 100644
index 0000000..5f899ce
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Parse-and-format-relPath-into-disk-source-private-data.patch
@@ -0,0 +1,32 @@
+From c6ff8d075d0fd4b2819d1c4858ad2c8e8c45c051 Mon Sep 17 00:00:00 2001
+Message-Id: <c6ff8d075d0fd4b2819d1c4858ad2c8e8c45c051@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 14 Dec 2017 14:31:53 +0100
+Subject: [PATCH] qemu: domain: Parse and format relPath into disk source
+ private data
+
+Register the helpers directly to format and parse the data.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1523261
+(cherry picked from commit b3d0270c44b85944f91906225b27bca6700a6333)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 625bcb20d5..8967f2774d 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -2439,6 +2439,8 @@ virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks = {
+     .chrSourceNew = qemuDomainChrSourcePrivateNew,
+     .parse = qemuDomainObjPrivateXMLParse,
+     .format = qemuDomainObjPrivateXMLFormat,
++    .storageParse = virStorageSourcePrivateDataParseRelPath,
++    .storageFormat = virStorageSourcePrivateDataFormatRelPath,
+ };
+ 
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-domain-Refactor-control-flow-in-qemuDomainDetermineDiskChain.patch b/SOURCES/libvirt-qemu-domain-Refactor-control-flow-in-qemuDomainDetermineDiskChain.patch
new file mode 100644
index 0000000..397b0e9
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Refactor-control-flow-in-qemuDomainDetermineDiskChain.patch
@@ -0,0 +1,52 @@
+From 3dcba116fd4e0a6df50b905b021151b30ef55714 Mon Sep 17 00:00:00 2001
+Message-Id: <3dcba116fd4e0a6df50b905b021151b30ef55714@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Fri, 1 Dec 2017 15:57:01 +0100
+Subject: [PATCH] qemu: domain: Refactor control flow in
+ qemuDomainDetermineDiskChain
+
+Split out clearing of the backing chain prior to other code since it
+will be required later and optimize few layers of nested conditions and
+loops.
+
+(cherry picked from commit b19710b9b6039728620a8d557a322ef139529226)
+
+ Conflicts:
+	src/qemu/qemu_domain.c:
+        a92c4f7537577f1443ddd6fef4e0dfcb054e5f08 was not backported thus
+        the code skipping to the end of the backing chain is missing
+
+        This patch only moves the block that clears the backing store
+        earlier so that the rest of the patches will apply
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1509110
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 11 +++++------
+ 1 file changed, 5 insertions(+), 6 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 1b5f439621..13d120040b 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -6355,12 +6355,11 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
+     if (virStorageSourceIsEmpty(disk->src))
+         goto cleanup;
+ 
+-    if (virStorageSourceHasBacking(disk->src)) {
+-        if (force_probe)
+-            virStorageSourceBackingStoreClear(disk->src);
+-        else
+-            goto cleanup;
+-    }
++    if (force_probe)
++        virStorageSourceBackingStoreClear(disk->src);
++
++    if (virStorageSourceHasBacking(disk->src))
++        goto cleanup;
+ 
+     qemuDomainGetImageIds(cfg, vm, disk->src, &uid, &gid);
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-domain-Refactor-domain-device-validation-function.patch b/SOURCES/libvirt-qemu-domain-Refactor-domain-device-validation-function.patch
new file mode 100644
index 0000000..e962ee9
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Refactor-domain-device-validation-function.patch
@@ -0,0 +1,112 @@
+From 2d801f20547584950c0b312e5d6fbc975d65868e Mon Sep 17 00:00:00 2001
+Message-Id: <2d801f20547584950c0b312e5d6fbc975d65868e@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:17 +0100
+Subject: [PATCH] qemu: domain: Refactor domain device validation function
+
+Use a style that will discourage from adding inline checks.
+
+(cherry picked from commit 85b0e2f1260bb169298db5b44859be48426821f0)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1511480
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 79 +++++++++++++++++++++++++++++++++-----------------
+ 1 file changed, 52 insertions(+), 27 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 1b72d95d7e..1159be9980 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3694,36 +3694,61 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+                             const virDomainDef *def,
+                             void *opaque ATTRIBUTE_UNUSED)
+ {
+-    int ret = -1;
++    int ret = 0;
+ 
+-    if (dev->type == VIR_DOMAIN_DEVICE_NET) {
+-        if (qemuDomainDeviceDefValidateNetwork(dev->data.net) < 0)
+-            goto cleanup;
+-    } else if (dev->type == VIR_DOMAIN_DEVICE_CHR) {
+-        if (qemuDomainChrDefValidate(dev->data.chr, def) < 0)
+-            goto cleanup;
+-    } else if (dev->type == VIR_DOMAIN_DEVICE_SMARTCARD) {
+-        if (qemuDomainSmartcardDefValidate(dev->data.smartcard) < 0)
+-            goto cleanup;
+-    } else if (dev->type == VIR_DOMAIN_DEVICE_RNG) {
+-        if (qemuDomainRNGDefValidate(dev->data.rng) < 0)
+-            goto cleanup;
+-    } else if (dev->type == VIR_DOMAIN_DEVICE_REDIRDEV) {
+-        if (qemuDomainRedirdevDefValidate(dev->data.redirdev) < 0)
+-            goto cleanup;
+-    } else if (dev->type == VIR_DOMAIN_DEVICE_WATCHDOG) {
+-        if (qemuDomainWatchdogDefValidate(dev->data.watchdog, def) < 0)
+-            goto cleanup;
+-    } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
+-        if (qemuDomainDeviceDefValidateHostdev(dev->data.hostdev, def) < 0)
+-            goto cleanup;
+-    } else if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
+-        if (qemuDomainDeviceDefValidateVideo(dev->data.video) < 0)
+-            goto cleanup;
++    switch ((virDomainDeviceType) dev->type) {
++    case VIR_DOMAIN_DEVICE_NET:
++        ret = qemuDomainDeviceDefValidateNetwork(dev->data.net);
++        break;
++
++    case VIR_DOMAIN_DEVICE_CHR:
++        ret = qemuDomainChrDefValidate(dev->data.chr, def);
++        break;
++
++    case VIR_DOMAIN_DEVICE_SMARTCARD:
++        ret = qemuDomainSmartcardDefValidate(dev->data.smartcard);
++        break;
++
++    case VIR_DOMAIN_DEVICE_RNG:
++        ret = qemuDomainRNGDefValidate(dev->data.rng);
++        break;
++
++    case VIR_DOMAIN_DEVICE_REDIRDEV:
++        ret = qemuDomainRedirdevDefValidate(dev->data.redirdev);
++        break;
++
++    case VIR_DOMAIN_DEVICE_WATCHDOG:
++        ret = qemuDomainWatchdogDefValidate(dev->data.watchdog, def);
++        break;
++
++    case VIR_DOMAIN_DEVICE_HOSTDEV:
++        ret = qemuDomainDeviceDefValidateHostdev(dev->data.hostdev, def);
++        break;
++
++    case VIR_DOMAIN_DEVICE_VIDEO:
++        ret = qemuDomainDeviceDefValidateVideo(dev->data.video);
++        break;
++
++    case VIR_DOMAIN_DEVICE_DISK:
++    case VIR_DOMAIN_DEVICE_LEASE:
++    case VIR_DOMAIN_DEVICE_FS:
++    case VIR_DOMAIN_DEVICE_INPUT:
++    case VIR_DOMAIN_DEVICE_SOUND:
++    case VIR_DOMAIN_DEVICE_CONTROLLER:
++    case VIR_DOMAIN_DEVICE_GRAPHICS:
++    case VIR_DOMAIN_DEVICE_HUB:
++    case VIR_DOMAIN_DEVICE_MEMBALLOON:
++    case VIR_DOMAIN_DEVICE_NVRAM:
++    case VIR_DOMAIN_DEVICE_SHMEM:
++    case VIR_DOMAIN_DEVICE_TPM:
++    case VIR_DOMAIN_DEVICE_PANIC:
++    case VIR_DOMAIN_DEVICE_MEMORY:
++    case VIR_DOMAIN_DEVICE_IOMMU:
++    case VIR_DOMAIN_DEVICE_NONE:
++    case VIR_DOMAIN_DEVICE_LAST:
++        break;
+     }
+ 
+-    ret = 0;
+- cleanup:
+     return ret;
+ }
+ 
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-domain-Reject-shared-disk-access-if-backing-format-does-not-support-it.patch b/SOURCES/libvirt-qemu-domain-Reject-shared-disk-access-if-backing-format-does-not-support-it.patch
new file mode 100644
index 0000000..2f3ab52
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Reject-shared-disk-access-if-backing-format-does-not-support-it.patch
@@ -0,0 +1,150 @@
+From e335715f4f93b62641b8a3a780c8617b1db1434b Mon Sep 17 00:00:00 2001
+Message-Id: <e335715f4f93b62641b8a3a780c8617b1db1434b@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:19 +0100
+Subject: [PATCH] qemu: domain: Reject shared disk access if backing format
+ does not support it
+
+Disk sharing between two VMs may corrupt the images if the format driver
+does not support it. Check that the user declared use of a supported
+storage format when they want to share the disk.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511480
+(cherry picked from commit 3b03a27cd00c2f032661d2bf8905795425752fc7)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c                             | 27 +++++++++++++++++++++
+ .../qemuxml2argv-disk-drive-shared-qcow.xml        | 28 ++++++++++++++++++++++
+ .../qemuxml2argv-disk-drive-shared.args            |  2 +-
+ .../qemuxml2argv-disk-drive-shared.xml             |  2 +-
+ tests/qemuxml2argvtest.c                           |  1 +
+ 5 files changed, 58 insertions(+), 2 deletions(-)
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-qcow.xml
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 1159be9980..2f987787cd 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -25,6 +25,7 @@
+ 
+ #include "qemu_domain.h"
+ #include "qemu_alias.h"
++#include "qemu_block.h"
+ #include "qemu_cgroup.h"
+ #include "qemu_command.h"
+ #include "qemu_process.h"
+@@ -3689,6 +3690,29 @@ qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video)
+ }
+ 
+ 
++static int
++qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk)
++{
++    if (disk->src->shared && !disk->src->readonly) {
++        if (disk->src->format <= VIR_STORAGE_FILE_AUTO) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                           _("shared access for disk '%s' requires use of "
++                             "explicitly specified disk format"), disk->dst);
++            return -1;
++        }
++
++        if (!qemuBlockStorageSourceSupportsConcurrentAccess(disk->src)) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                           _("shared access for disk '%s' requires use of "
++                             "supported storage format"), disk->dst);
++            return -1;
++        }
++    }
++
++    return 0;
++}
++
++
+ static int
+ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+                             const virDomainDef *def,
+@@ -3730,6 +3754,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+         break;
+ 
+     case VIR_DOMAIN_DEVICE_DISK:
++        ret = qemuDomainDeviceDefValidateDisk(dev->data.disk);
++        break;
++
+     case VIR_DOMAIN_DEVICE_LEASE:
+     case VIR_DOMAIN_DEVICE_FS:
+     case VIR_DOMAIN_DEVICE_INPUT:
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-qcow.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-qcow.xml
+new file mode 100644
+index 0000000000..ca88a944b3
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared-qcow.xml
+@@ -0,0 +1,28 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219136</memory>
++  <currentMemory unit='KiB'>219136</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <disk type='block' device='disk'>
++      <driver name='qemu' type='qcow2'/>
++      <source dev='/dev/HostVG/QEMUGuest1'/>
++      <target dev='hda' bus='ide'/>
++      <shareable/>
++      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
++    </disk>
++    <controller type='usb' index='0'/>
++    <controller type='ide' index='0'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args
+index 502157bf8c..326fde1b36 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args
+@@ -19,7 +19,7 @@ server,nowait \
+ -no-acpi \
+ -boot c \
+ -usb \
+--drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
++-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0,\
+ serial=XYZXYZXYZYXXYZYZYXYZY,cache=none \
+ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+ -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.xml
+index 9f74723783..677c2b0b7d 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.xml
++++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.xml
+@@ -15,7 +15,7 @@
+   <devices>
+     <emulator>/usr/bin/qemu-system-i686</emulator>
+     <disk type='block' device='disk'>
+-      <driver name='qemu' type='qcow2'/>
++      <driver name='qemu' type='raw'/>
+       <source dev='/dev/HostVG/QEMUGuest1'/>
+       <target dev='hda' bus='ide'/>
+       <shareable/>
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index ff9c8608aa..00110cae19 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -908,6 +908,7 @@ mymain(void)
+             QEMU_CAPS_DRIVE_BOOT);
+     DO_TEST("disk-drive-shared",
+             QEMU_CAPS_DRIVE_SERIAL);
++    DO_TEST_PARSE_ERROR("disk-drive-shared-qcow", NONE);
+     DO_TEST("disk-drive-error-policy-stop",
+             QEMU_CAPS_MONITOR_JSON);
+     DO_TEST("disk-drive-error-policy-enospace",
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-domain-Store-vcpu-halted-state-as-a-tristate.patch b/SOURCES/libvirt-qemu-domain-Store-vcpu-halted-state-as-a-tristate.patch
new file mode 100644
index 0000000..2731a00
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Store-vcpu-halted-state-as-a-tristate.patch
@@ -0,0 +1,96 @@
+From d75ea91fe4c95b17f928931637f65fcf317e986c Mon Sep 17 00:00:00 2001
+Message-Id: <d75ea91fe4c95b17f928931637f65fcf317e986c@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Wed, 7 Feb 2018 14:16:01 +0100
+Subject: [PATCH] qemu: domain: Store vcpu halted state as a tristate
+
+Since it may be possible that the state is unknown in some cases we
+should store it as a tristate so that other code using it can determine
+whether the state was updated.
+
+(cherry picked from commit ca588a34b23a1f30dc7eeb7d5134706e31b403ef)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1534585
+---
+ src/qemu/qemu_domain.c |  3 ++-
+ src/qemu/qemu_domain.h |  2 +-
+ src/qemu/qemu_driver.c | 13 ++++---------
+ 3 files changed, 7 insertions(+), 11 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index b0c78cc7c4..e87c7d030c 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -8000,7 +8000,8 @@ qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
+     for (i = 0; i < maxvcpus; i++) {
+         vcpu = virDomainDefGetVcpu(vm->def, i);
+         vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
+-        vcpupriv->halted = virBitmapIsBitSet(haltedmap, vcpupriv->qemu_id);
++        vcpupriv->halted = virTristateBoolFromBool(virBitmapIsBitSet(haltedmap,
++                                                                     vcpupriv->qemu_id));
+     }
+ 
+     ret = 0;
+diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
+index 1a82922415..19e58ef3be 100644
+--- a/src/qemu/qemu_domain.h
++++ b/src/qemu/qemu_domain.h
+@@ -389,7 +389,7 @@ struct _qemuDomainVcpuPrivate {
+     int enable_id; /* order in which the vcpus were enabled in qemu */
+     int qemu_id; /* ID reported by qemu as 'CPU' in query-cpus */
+     char *alias;
+-    bool halted;
++    virTristateBool halted;
+ 
+     /* information for hotpluggable cpus */
+     char *type;
+diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
+index b5bef7442e..b8022a06ba 100644
+--- a/src/qemu/qemu_driver.c
++++ b/src/qemu/qemu_driver.c
+@@ -19526,7 +19526,6 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
+     char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
+     virVcpuInfoPtr cpuinfo = NULL;
+     unsigned long long *cpuwait = NULL;
+-    bool vcpuhalted = false;
+ 
+     if (virTypedParamsAddUInt(&record->params,
+                               &record->nparams,
+@@ -19546,15 +19545,11 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
+         VIR_ALLOC_N(cpuwait, virDomainDefGetVcpus(dom->def)) < 0)
+         goto cleanup;
+ 
+-    if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) {
+-        if (qemuDomainRefreshVcpuHalted(driver, dom,
+-                                        QEMU_ASYNC_JOB_NONE) < 0) {
++    if (HAVE_JOB(privflags) && virDomainObjIsActive(dom) &&
++        qemuDomainRefreshVcpuHalted(driver, dom, QEMU_ASYNC_JOB_NONE) < 0) {
+             /* it's ok to be silent and go ahead, because halted vcpu info
+              * wasn't here from the beginning */
+             virResetLastError();
+-        } else {
+-            vcpuhalted = true;
+-        }
+     }
+ 
+     if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait,
+@@ -19602,14 +19597,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
+ 
+         vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
+ 
+-        if (vcpuhalted) {
++        if (vcpupriv->halted != VIR_TRISTATE_BOOL_ABSENT) {
+             snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+                      "vcpu.%u.halted", cpuinfo[i].number);
+             if (virTypedParamsAddBoolean(&record->params,
+                                          &record->nparams,
+                                          maxparams,
+                                          param_name,
+-                                         vcpupriv->halted) < 0)
++                                         vcpupriv->halted == VIR_TRISTATE_BOOL_YES) < 0)
+                 goto cleanup;
+         }
+     }
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-don-t-kill-qemu-process-on-restart-if-networkNotify-fails.patch b/SOURCES/libvirt-qemu-don-t-kill-qemu-process-on-restart-if-networkNotify-fails.patch
deleted file mode 100644
index 638dae4..0000000
--- a/SOURCES/libvirt-qemu-don-t-kill-qemu-process-on-restart-if-networkNotify-fails.patch
+++ /dev/null
@@ -1,142 +0,0 @@
-From 01c309a7d81daa85e7212e37c8b4b9dd2c08f898 Mon Sep 17 00:00:00 2001
-Message-Id: <01c309a7d81daa85e7212e37c8b4b9dd2c08f898@dist-git>
-From: Laine Stump <laine@laine.org>
-Date: Tue, 2 May 2017 12:31:51 -0400
-Subject: [PATCH] qemu: don't kill qemu process on restart if networkNotify
- fails
-
-Nothing that could happen during networkNotifyActualDevice() could
-justify unceremoniously killing the qemu process, but that's what we
-were doing.
-
-In particular, new code added in commit 85bcc022 (first appearred in
-libvirt-3.2.0) attempts to reattach tap devices to their assigned
-bridge devices when libvirtd restarts (to make it easier to recover
-from a restart of a libvirt network). But if the network has been
-stopped and *not* restarted, the bridge device won't exist and
-networkNotifyActualDevice() will fail.
-
-This patch changes networkNotifyActualDevice() and
-qemuProcessNotifyNets() to return void, so that qemuProcessReconnect()
-will soldier on regardless of what happens (any errors will still be
-logged though).
-
-Partially resolves: https://bugzilla.redhat.com/1442700
-
-(cherry picked from commit cb182eb11d3a99adb06e188989899dcd488c43fc)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/network/bridge_driver.c | 10 ++++------
- src/network/bridge_driver.h |  7 +++----
- src/qemu/qemu_process.c     |  9 +++------
- 3 files changed, 10 insertions(+), 16 deletions(-)
-
-diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
-index ef982363b..cb91a2c90 100644
---- a/src/network/bridge_driver.c
-+++ b/src/network/bridge_driver.c
-@@ -4656,9 +4656,9 @@ networkAllocateActualDevice(virDomainDefPtr dom,
-  * order, or re-attach the interface's tap device to the network's
-  * bridge.
-  *
-- * Returns 0 on success, -1 on failure.
-+ * No return value (but does log any failures)
-  */
--int
-+void
- networkNotifyActualDevice(virDomainDefPtr dom,
-                           virDomainNetDefPtr iface)
- {
-@@ -4668,11 +4668,10 @@ networkNotifyActualDevice(virDomainDefPtr dom,
-     virNetworkDefPtr netdef;
-     virNetworkForwardIfDefPtr dev = NULL;
-     size_t i;
--    int ret = -1;
-     char *master = NULL;
- 
-     if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK)
--        return 0;
-+        return;
- 
-     network = virNetworkObjFindByName(driver->networks, iface->data.network.name);
-     if (!network) {
-@@ -4848,11 +4847,10 @@ networkNotifyActualDevice(virDomainDefPtr dom,
-     }
-     networkLogAllocation(netdef, actualType, dev, iface, true);
- 
--    ret = 0;
-  cleanup:
-     virNetworkObjEndAPI(&network);
-     VIR_FREE(master);
--    return ret;
-+    return;
- 
-  error:
-     goto cleanup;
-diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h
-index c696f0301..aaedd67a1 100644
---- a/src/network/bridge_driver.h
-+++ b/src/network/bridge_driver.h
-@@ -37,8 +37,8 @@ int networkRegister(void);
- int networkAllocateActualDevice(virDomainDefPtr dom,
-                                 virDomainNetDefPtr iface)
-     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
--int networkNotifyActualDevice(virDomainDefPtr dom,
--                              virDomainNetDefPtr iface)
-+void networkNotifyActualDevice(virDomainDefPtr dom,
-+                               virDomainNetDefPtr iface)
-     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
- int networkReleaseActualDevice(virDomainDefPtr dom,
-                                virDomainNetDefPtr iface)
-@@ -72,11 +72,10 @@ int networkBandwidthUpdate(virDomainNetDefPtr iface,
- #  define networkDnsmasqConfContents(network, pidfile, configstr, \
-                     dctx, caps) 0
- 
--static inline int
-+static inline void
- networkNotifyActualDevice(virDomainDefPtr dom ATTRIBUTE_UNUSED,
-                           virDomainNetDefPtr iface ATTRIBUTE_UNUSED)
- {
--    return 0;
- }
- 
- static inline int
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index a33ec87e6..df5ba575a 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -2825,7 +2825,7 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver,
- 
- 
- 
--static int
-+static void
- qemuProcessNotifyNets(virDomainDefPtr def)
- {
-     size_t i;
-@@ -2840,10 +2840,8 @@ qemuProcessNotifyNets(virDomainDefPtr def)
-         if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT)
-            ignore_value(virNetDevMacVLanReserveName(net->ifname, false));
- 
--        if (networkNotifyActualDevice(def, net) < 0)
--            return -1;
-+        networkNotifyActualDevice(def, net);
-     }
--    return 0;
- }
- 
- static int
-@@ -3480,8 +3478,7 @@ qemuProcessReconnect(void *opaque)
-     if (qemuSecurityReserveLabel(driver->securityManager, obj->def, obj->pid) < 0)
-         goto error;
- 
--    if (qemuProcessNotifyNets(obj->def) < 0)
--        goto error;
-+    qemuProcessNotifyNets(obj->def);
- 
-     if (qemuProcessFiltersInstantiate(obj->def))
-         goto error;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-driver-Allow-passing-disk-target-as-top-image-with-block-commit.patch b/SOURCES/libvirt-qemu-driver-Allow-passing-disk-target-as-top-image-with-block-commit.patch
deleted file mode 100644
index fc292ce..0000000
--- a/SOURCES/libvirt-qemu-driver-Allow-passing-disk-target-as-top-image-with-block-commit.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From 6126edc9e0fcf658c95f8ede0c05b72dad6d221b Mon Sep 17 00:00:00 2001
-Message-Id: <6126edc9e0fcf658c95f8ede0c05b72dad6d221b@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Wed, 17 May 2017 17:44:54 +0200
-Subject: [PATCH] qemu: driver: Allow passing disk target as top image with
- block commit
-
-Since we allow active layer block commit the users are allowed to commit
-the top of the chain (e.g. vda) into the backing image. The API would
-not accept that parameter, as it tried to look up the image in the
-backing chain.
-
-Add the ability to use the top level image target name explicitly as the
-top image of the block commit operation.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1451394
-(cherry picked from commit ed61e0b368859b25beb5259f84edd4910cd5218f)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 8699fb2fe..a0f641fd4 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -16933,7 +16933,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
-     if (qemuDomainDiskBlockJobIsActive(disk))
-         goto endjob;
- 
--    if (!top)
-+    if (!top || STREQ(top, disk->dst))
-         topSource = disk->src;
-     else if (virStorageFileParseChainIndex(disk->dst, top, &topIndex) < 0 ||
-              !(topSource = virStorageFileChainLookup(disk->src, NULL,
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-driver-Extract-vcpu-halted-state-directly.patch b/SOURCES/libvirt-qemu-driver-Extract-vcpu-halted-state-directly.patch
new file mode 100644
index 0000000..674fc61
--- /dev/null
+++ b/SOURCES/libvirt-qemu-driver-Extract-vcpu-halted-state-directly.patch
@@ -0,0 +1,89 @@
+From 82aa1d86ca26a7693b3817cc6331c9f094549098 Mon Sep 17 00:00:00 2001
+Message-Id: <82aa1d86ca26a7693b3817cc6331c9f094549098@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Wed, 7 Feb 2018 14:15:59 +0100
+Subject: [PATCH] qemu: driver: Extract vcpu halted state directly
+
+Don't extract the halted state into a separate array, but rater access
+the vcpu structures directly. We still need to call the vcpu helper to
+retrieve the performance statistics though.
+
+(cherry picked from commit 38d26864f7b0bf780ff07bf95c81a68699ddebaf)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1534585
+---
+ src/qemu/qemu_driver.c | 21 ++++++++++++++-------
+ 1 file changed, 14 insertions(+), 7 deletions(-)
+
+diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
+index 0bc6eaa431..bfb3c3c4c5 100644
+--- a/src/qemu/qemu_driver.c
++++ b/src/qemu/qemu_driver.c
+@@ -19527,12 +19527,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
+                        int *maxparams,
+                        unsigned int privflags)
+ {
++    virDomainVcpuDefPtr vcpu;
++    qemuDomainVcpuPrivatePtr vcpupriv;
+     size_t i;
+     int ret = -1;
+     char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
+     virVcpuInfoPtr cpuinfo = NULL;
+     unsigned long long *cpuwait = NULL;
+-    bool *cpuhalted = NULL;
++    bool vcpuhalted = false;
+ 
+     if (virTypedParamsAddUInt(&record->params,
+                               &record->nparams,
+@@ -19558,14 +19560,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
+             /* it's ok to be silent and go ahead, because halted vcpu info
+              * wasn't here from the beginning */
+             virResetLastError();
+-        } else if (VIR_ALLOC_N(cpuhalted, virDomainDefGetVcpus(dom->def)) < 0) {
+-            goto cleanup;
++        } else {
++            vcpuhalted = true;
+         }
+     }
+ 
+     if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait,
+                                  virDomainDefGetVcpus(dom->def),
+-                                 NULL, 0, cpuhalted) < 0) {
++                                 NULL, 0, NULL) < 0) {
+         virResetLastError();
+         ret = 0; /* it's ok to be silent and go ahead */
+         goto cleanup;
+@@ -19602,14 +19604,20 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
+                                     cpuwait[i]) < 0)
+             goto cleanup;
+ 
+-        if (cpuhalted) {
++        /* state below is extracted from the individual vcpu structs */
++        if (!(vcpu = virDomainDefGetVcpu(dom->def, cpuinfo[i].number)))
++            continue;
++
++        vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
++
++        if (vcpuhalted) {
+             snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+                      "vcpu.%u.halted", cpuinfo[i].number);
+             if (virTypedParamsAddBoolean(&record->params,
+                                          &record->nparams,
+                                          maxparams,
+                                          param_name,
+-                                         cpuhalted[i]) < 0)
++                                         vcpupriv->halted) < 0)
+                 goto cleanup;
+         }
+     }
+@@ -19619,7 +19627,6 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
+  cleanup:
+     VIR_FREE(cpuinfo);
+     VIR_FREE(cpuwait);
+-    VIR_FREE(cpuhalted);
+     return ret;
+ }
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-drop-code-for-VIR_DOMAIN_JOB_BOUNDED-and-timeRemaining.patch b/SOURCES/libvirt-qemu-drop-code-for-VIR_DOMAIN_JOB_BOUNDED-and-timeRemaining.patch
deleted file mode 100644
index 8eb685c..0000000
--- a/SOURCES/libvirt-qemu-drop-code-for-VIR_DOMAIN_JOB_BOUNDED-and-timeRemaining.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 5e9305c83e7acf31e849af2db6b82c7651114425 Mon Sep 17 00:00:00 2001
-Message-Id: <5e9305c83e7acf31e849af2db6b82c7651114425@dist-git>
-From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
-Date: Fri, 1 Sep 2017 09:49:19 +0300
-Subject: [PATCH] qemu: drop code for VIR_DOMAIN_JOB_BOUNDED and timeRemaining
-
-qemu driver does not have VIR_DOMAIN_JOB_BOUNDED jobs and
-timeRemaining is always 0.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 16bf7619b8377b21e8cb2af33b53949ff77755c6)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530130
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c           | 7 -------
- src/qemu/qemu_domain.h           | 1 -
- src/qemu/qemu_driver.c           | 3 +--
- src/qemu/qemu_migration_cookie.c | 5 -----
- 4 files changed, 1 insertion(+), 15 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index ade06f07db..3c2368368f 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -395,7 +395,6 @@ qemuDomainJobInfoToInfo(qemuDomainJobInfoPtr jobInfo,
- {
-     info->type = jobInfo->type;
-     info->timeElapsed = jobInfo->timeElapsed;
--    info->timeRemaining = jobInfo->timeRemaining;
- 
-     info->memTotal = jobInfo->stats.ram_total;
-     info->memRemaining = jobInfo->stats.ram_remaining;
-@@ -440,12 +439,6 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
-                                 jobInfo->timeElapsed - jobInfo->timeDelta) < 0)
-         goto error;
- 
--    if (jobInfo->type == VIR_DOMAIN_JOB_BOUNDED &&
--        virTypedParamsAddULLong(&par, &npar, &maxpar,
--                                VIR_DOMAIN_JOB_TIME_REMAINING,
--                                jobInfo->timeRemaining) < 0)
--        goto error;
--
-     if (stats->downtime_set &&
-         virTypedParamsAddULLong(&par, &npar, &maxpar,
-                                 VIR_DOMAIN_JOB_DOWNTIME,
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 68458ad9ae..7002407218 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -112,7 +112,6 @@ struct _qemuDomainJobInfo {
-                                     info from the source (migrations only). */
-     /* Computed values */
-     unsigned long long timeElapsed;
--    unsigned long long timeRemaining;
-     long long timeDelta; /* delta = received - sent, i.e., the difference
-                             between the source and the destination time plus
-                             the time between the end of Perform phase on the
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 501f19fbcc..1c60d533e8 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -12971,8 +12971,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
-     }
-     *jobInfo = *info;
- 
--    if (jobInfo->type == VIR_DOMAIN_JOB_BOUNDED ||
--        jobInfo->type == VIR_DOMAIN_JOB_UNBOUNDED) {
-+    if (jobInfo->type == VIR_DOMAIN_JOB_UNBOUNDED) {
-         if (fetch)
-             ret = qemuMigrationFetchJobStatus(driver, vm, QEMU_ASYNC_JOB_NONE,
-                                               jobInfo);
-diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
-index af0ac03418..5f8595fdba 100644
---- a/src/qemu/qemu_migration_cookie.c
-+++ b/src/qemu/qemu_migration_cookie.c
-@@ -612,9 +612,6 @@ qemuMigrationCookieStatisticsXMLFormat(virBufferPtr buf,
-     virBufferAsprintf(buf, "<%1$s>%2$llu</%1$s>\n",
-                       VIR_DOMAIN_JOB_TIME_ELAPSED,
-                       jobInfo->timeElapsed);
--    virBufferAsprintf(buf, "<%1$s>%2$llu</%1$s>\n",
--                      VIR_DOMAIN_JOB_TIME_REMAINING,
--                      jobInfo->timeRemaining);
-     if (stats->downtime_set)
-         virBufferAsprintf(buf, "<%1$s>%2$llu</%1$s>\n",
-                           VIR_DOMAIN_JOB_DOWNTIME,
-@@ -987,8 +984,6 @@ qemuMigrationCookieStatisticsXMLParse(xmlXPathContextPtr ctxt)
- 
-     virXPathULongLong("string(./" VIR_DOMAIN_JOB_TIME_ELAPSED "[1])",
-                       ctxt, &jobInfo->timeElapsed);
--    virXPathULongLong("string(./" VIR_DOMAIN_JOB_TIME_REMAINING "[1])",
--                      ctxt, &jobInfo->timeRemaining);
- 
-     if (virXPathULongLong("string(./" VIR_DOMAIN_JOB_DOWNTIME "[1])",
-                           ctxt, &stats->downtime) == 0)
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-fix-security-labeling-for-attach-detach-of-char-devices.patch b/SOURCES/libvirt-qemu-fix-security-labeling-for-attach-detach-of-char-devices.patch
new file mode 100644
index 0000000..c4d6daa
--- /dev/null
+++ b/SOURCES/libvirt-qemu-fix-security-labeling-for-attach-detach-of-char-devices.patch
@@ -0,0 +1,154 @@
+From f0e402ae3edf7717f1f2c1317f8b445ad20fdda4 Mon Sep 17 00:00:00 2001
+Message-Id: <f0e402ae3edf7717f1f2c1317f8b445ad20fdda4@dist-git>
+From: Pavel Hrdina <phrdina@redhat.com>
+Date: Tue, 5 Dec 2017 14:02:34 +0100
+Subject: [PATCH] qemu: fix security labeling for attach/detach of char devices
+
+Commit e93d844b90 was not enough to fix the permission denied
+issue.  We need to apply security labels as well.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1465833
+
+Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 1c57eea3625f59a80bea08d8779837a40acc4660)
+Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
+Reviewed-by: Erik Skultety <eskultet@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_hotplug.c  | 10 ++++++++
+ src/qemu/qemu_security.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
+ src/qemu/qemu_security.h |  8 +++++++
+ 3 files changed, 78 insertions(+)
+
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index 56e8a93885..eab9ad794a 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -1818,6 +1818,7 @@ int qemuDomainAttachChrDevice(virConnectPtr conn,
+     bool chardevAttached = false;
+     bool teardowncgroup = false;
+     bool teardowndevice = false;
++    bool teardownlabel = false;
+     char *tlsAlias = NULL;
+     char *secAlias = NULL;
+     bool need_release = false;
+@@ -1838,6 +1839,10 @@ int qemuDomainAttachChrDevice(virConnectPtr conn,
+         goto cleanup;
+     teardowndevice = true;
+ 
++    if (qemuSecuritySetChardevLabel(driver, vm, chr) < 0)
++        goto cleanup;
++    teardownlabel = true;
++
+     if (qemuSetupChardevCgroup(vm, chr) < 0)
+         goto cleanup;
+     teardowncgroup = true;
+@@ -1880,6 +1885,8 @@ int qemuDomainAttachChrDevice(virConnectPtr conn,
+             qemuDomainReleaseDeviceAddress(vm, &chr->info, NULL);
+         if (teardowncgroup && qemuTeardownChardevCgroup(vm, chr) < 0)
+             VIR_WARN("Unable to remove chr device cgroup ACL on hotplug fail");
++        if (teardownlabel && qemuSecurityRestoreChardevLabel(driver, vm, chr) < 0)
++            VIR_WARN("Unable to restore security label on char device");
+         if (teardowndevice && qemuDomainNamespaceTeardownChardev(driver, vm, chr) < 0)
+             VIR_WARN("Unable to remove chr device from /dev");
+     }
+@@ -4111,6 +4118,9 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
+     if (qemuTeardownChardevCgroup(vm, chr) < 0)
+         VIR_WARN("Failed to remove chr device cgroup ACL");
+ 
++    if (qemuSecurityRestoreChardevLabel(driver, vm, chr) < 0)
++        VIR_WARN("Unable to restore security label on char device");
++
+     if (qemuDomainNamespaceTeardownChardev(driver, vm, chr) < 0)
+         VIR_WARN("Unable to remove chr device from /dev");
+ 
+diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c
+index e7d2bbd5a3..2aced22d2d 100644
+--- a/src/qemu/qemu_security.c
++++ b/src/qemu/qemu_security.c
+@@ -364,3 +364,63 @@ qemuSecurityRestoreInputLabel(virDomainObjPtr vm,
+     virSecurityManagerTransactionAbort(driver->securityManager);
+     return ret;
+ }
++
++
++int
++qemuSecuritySetChardevLabel(virQEMUDriverPtr driver,
++                            virDomainObjPtr vm,
++                            virDomainChrDefPtr chr)
++{
++    int ret = -1;
++    qemuDomainObjPrivatePtr priv = vm->privateData;
++
++    if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
++        virSecurityManagerTransactionStart(driver->securityManager) < 0)
++        goto cleanup;
++
++    if (virSecurityManagerSetChardevLabel(driver->securityManager,
++                                          vm->def,
++                                          chr->source,
++                                          priv->chardevStdioLogd) < 0)
++        goto cleanup;
++
++    if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
++        virSecurityManagerTransactionCommit(driver->securityManager,
++                                            vm->pid) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    virSecurityManagerTransactionAbort(driver->securityManager);
++    return ret;
++}
++
++
++int
++qemuSecurityRestoreChardevLabel(virQEMUDriverPtr driver,
++                                virDomainObjPtr vm,
++                                virDomainChrDefPtr chr)
++{
++    int ret = -1;
++    qemuDomainObjPrivatePtr priv = vm->privateData;
++
++    if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
++        virSecurityManagerTransactionStart(driver->securityManager) < 0)
++        goto cleanup;
++
++    if (virSecurityManagerRestoreChardevLabel(driver->securityManager,
++                                              vm->def,
++                                              chr->source,
++                                              priv->chardevStdioLogd) < 0)
++        goto cleanup;
++
++    if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
++        virSecurityManagerTransactionCommit(driver->securityManager,
++                                            vm->pid) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    virSecurityManagerTransactionAbort(driver->securityManager);
++    return ret;
++}
+diff --git a/src/qemu/qemu_security.h b/src/qemu/qemu_security.h
+index 76d63f06ec..d54ce6fead 100644
+--- a/src/qemu/qemu_security.h
++++ b/src/qemu/qemu_security.h
+@@ -76,6 +76,14 @@ int qemuSecuritySetInputLabel(virDomainObjPtr vm,
+ int qemuSecurityRestoreInputLabel(virDomainObjPtr vm,
+                                   virDomainInputDefPtr input);
+ 
++int qemuSecuritySetChardevLabel(virQEMUDriverPtr driver,
++                                virDomainObjPtr vm,
++                                virDomainChrDefPtr chr);
++
++int qemuSecurityRestoreChardevLabel(virQEMUDriverPtr driver,
++                                    virDomainObjPtr vm,
++                                    virDomainChrDefPtr chr);
++
+ /* Please note that for these APIs there is no wrapper yet. Do NOT blindly add
+  * new APIs here. If an API can touch a /dev file add a proper wrapper instead.
+  */
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-format-caching-mode-on-iommu-command-line.patch b/SOURCES/libvirt-qemu-format-caching-mode-on-iommu-command-line.patch
deleted file mode 100644
index 2e36e87..0000000
--- a/SOURCES/libvirt-qemu-format-caching-mode-on-iommu-command-line.patch
+++ /dev/null
@@ -1,159 +0,0 @@
-From d5e2a0cc600ea90645df6161b662cf32a16a7a1b Mon Sep 17 00:00:00 2001
-Message-Id: <d5e2a0cc600ea90645df6161b662cf32a16a7a1b@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:57 +0200
-Subject: [PATCH] qemu: format caching-mode on iommu command line
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Format the caching-mode option for the intel-iommu device,
-based on its <driver caching> attribute value.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-(cherry picked from commit a56914486ca67f921ee6e3ce26b5787fccb47155)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-Conflicts:
-	tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-        - downstream did not update qemu version to 2.9.0
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c                       |  2 ++
- src/qemu/qemu_capabilities.h                       |  1 +
- src/qemu/qemu_command.c                            | 11 ++++++++++
- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  1 +
- .../qemuxml2argv-intel-iommu-caching-mode.args     | 25 ++++++++++++++++++++++
- tests/qemuxml2argvtest.c                           | 11 ++++++++++
- 6 files changed, 51 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 4fd0df260..c970d70e3 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -370,6 +370,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
-               "kernel-irqchip", /* 255 */
-               "kernel-irqchip.split",
-               "intel-iommu.intremap",
-+              "intel-iommu.caching-mode",
-     );
- 
- 
-@@ -1724,6 +1725,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsUSBNECXHCI[] = {
- 
- static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIntelIOMMU[] = {
-     { "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
-+    { "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING_MODE },
- };
- 
- /* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format */
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index d1730a725..4e322b5c2 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -408,6 +408,7 @@ typedef enum {
-     QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */
-     QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT, /* -machine kernel_irqchip=split */
-     QEMU_CAPS_INTEL_IOMMU_INTREMAP, /* intel-iommu.intremap */
-+    QEMU_CAPS_INTEL_IOMMU_CACHING_MODE, /* intel-iommu.caching-mode */
- 
-     QEMU_CAPS_LAST /* this must always be the last item */
- } virQEMUCapsFlags;
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index a8dac1489..d4d0c00d5 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -6680,6 +6680,13 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
-                              "with this QEMU binary"));
-             return -1;
-         }
-+        if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT &&
-+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_CACHING_MODE))  {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                           _("iommu: caching mode is not supported "
-+                             "with this QEMU binary"));
-+            return -1;
-+        }
-         break;
-     case VIR_DOMAIN_IOMMU_MODEL_LAST:
-         break;
-@@ -6709,6 +6716,10 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
-             virBufferAsprintf(&opts, ",intremap=%s",
-                               virTristateSwitchTypeToString(iommu->intremap));
-         }
-+        if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) {
-+            virBufferAsprintf(&opts, ",caching-mode=%s",
-+                              virTristateSwitchTypeToString(iommu->caching_mode));
-+        }
-     case VIR_DOMAIN_IOMMU_MODEL_LAST:
-         break;
-     }
-diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-index 5a88cf505..b5649d8d7 100644
---- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-@@ -212,6 +212,7 @@
-   <flag name='kernel-irqchip'/>
-   <flag name='kernel-irqchip.split'/>
-   <flag name='intel-iommu.intremap'/>
-+  <flag name='intel-iommu.caching-mode'/>
-   <version>2008090</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.9.0-rc0-142-g940a8ce)</package>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args
-new file mode 100644
-index 000000000..1bec6d00b
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args
-@@ -0,0 +1,25 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-x86_64 \
-+-name QEMUGuest1 \
-+-S \
-+-machine q35,accel=tcg \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-device intel-iommu,intremap=on,caching-mode=on \
-+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
-+-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
-+-device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \
-+-device ich9-usb-ehci1,id=usb,bus=pci.2,addr=0x2.0x7 \
-+-device rtl8139,vlan=0,id=net0,mac=52:54:00:ab:0c:5c,bus=pci.2,addr=0x1 \
-+-net user,vlan=0,name=hostnet0
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 8061292b3..e3d6d757b 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -2523,6 +2523,17 @@ mymain(void)
-             QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
-             QEMU_CAPS_INTEL_IOMMU_INTREMAP,
-             QEMU_CAPS_DEVICE_INTEL_IOMMU);
-+    DO_TEST("intel-iommu-caching-mode",
-+            QEMU_CAPS_MACHINE_OPT,
-+            QEMU_CAPS_DEVICE_PCI_BRIDGE,
-+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
-+            QEMU_CAPS_DEVICE_IOH3420,
-+            QEMU_CAPS_ICH9_AHCI,
-+            QEMU_CAPS_PCI_MULTIFUNCTION,
-+            QEMU_CAPS_ICH9_USB_EHCI1,
-+            QEMU_CAPS_DEVICE_INTEL_IOMMU,
-+            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
-+            QEMU_CAPS_INTEL_IOMMU_CACHING_MODE);
- 
-     DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-format-device-iotlb-on-intel-iommu-command-line.patch b/SOURCES/libvirt-qemu-format-device-iotlb-on-intel-iommu-command-line.patch
deleted file mode 100644
index e8e5a49..0000000
--- a/SOURCES/libvirt-qemu-format-device-iotlb-on-intel-iommu-command-line.patch
+++ /dev/null
@@ -1,153 +0,0 @@
-From 6fa4cae7c760c804c601735a4eba91e72e2e756b Mon Sep 17 00:00:00 2001
-Message-Id: <6fa4cae7c760c804c601735a4eba91e72e2e756b@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:48:57 +0200
-Subject: [PATCH] qemu: format device-iotlb on intel-iommu command line
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Format the device-iotlb attribute.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 240e443afdac0df342bb462ac2754a46e6efbc23)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-Conflicts:
-	tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-          that QEMU version again
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c                          |  3 +++
- src/qemu/qemu_capabilities.h                          |  3 +++
- src/qemu/qemu_command.c                               | 11 +++++++++++
- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml      |  1 +
- .../qemuxml2argv-intel-iommu-device-iotlb.args        | 19 +++++++++++++++++++
- tests/qemuxml2argvtest.c                              |  7 +++++++
- 6 files changed, 44 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.args
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 29bb9949af..d8f3079083 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -372,6 +372,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
-               "intel-iommu.intremap",
-               "intel-iommu.caching-mode",
-               "intel-iommu.eim",
-+
-+              "intel-iommu.device-iotlb", /* 260 */
-     );
- 
- 
-@@ -1728,6 +1730,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIntelIOMMU[] = {
-     { "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
-     { "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING_MODE },
-     { "eim", QEMU_CAPS_INTEL_IOMMU_EIM },
-+    { "device-iotlb", QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB },
- };
- 
- /* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format */
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index 1c64364af4..e0f81711fe 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -411,6 +411,9 @@ typedef enum {
-     QEMU_CAPS_INTEL_IOMMU_CACHING_MODE, /* intel-iommu.caching-mode */
-     QEMU_CAPS_INTEL_IOMMU_EIM, /* intel-iommu.eim */
- 
-+    /* 260 */
-+    QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB, /* intel-iommu.device-iotlb */
-+
-     QEMU_CAPS_LAST /* this must always be the last item */
- } virQEMUCapsFlags;
- 
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 9c0d151da1..9c5639b036 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -6694,6 +6694,13 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
-                              "with this QEMU binary"));
-             return -1;
-         }
-+        if (iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT &&
-+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB)) {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                           _("iommu: device IOTLB is not supported "
-+                             "with this QEMU binary"));
-+            return -1;
-+        }
-         break;
-     case VIR_DOMAIN_IOMMU_MODEL_LAST:
-         break;
-@@ -6731,6 +6738,10 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
-             virBufferAsprintf(&opts, ",eim=%s",
-                               virTristateSwitchTypeToString(iommu->eim));
-         }
-+        if (iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT) {
-+            virBufferAsprintf(&opts, ",device-iotlb=%s",
-+                              virTristateSwitchTypeToString(iommu->iotlb));
-+        }
-     case VIR_DOMAIN_IOMMU_MODEL_LAST:
-         break;
-     }
-diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-index 2002dc7c0d..29a483d123 100644
---- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-@@ -214,6 +214,7 @@
-   <flag name='intel-iommu.intremap'/>
-   <flag name='intel-iommu.caching-mode'/>
-   <flag name='intel-iommu.eim'/>
-+  <flag name='intel-iommu.device-iotlb'/>
-   <version>2008090</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.9.0-rc0-142-g940a8ce)</package>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.args
-new file mode 100644
-index 0000000000..6d8f8e2188
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.args
-@@ -0,0 +1,19 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-x86_64 \
-+-name QEMUGuest1 \
-+-S \
-+-machine q35,accel=kvm,kernel_irqchip=split \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-device intel-iommu,intremap=on,device-iotlb=on
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 9e0d4d7141..bff32200d7 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -2541,6 +2541,13 @@ mymain(void)
-             QEMU_CAPS_INTEL_IOMMU_INTREMAP,
-             QEMU_CAPS_INTEL_IOMMU_EIM,
-             QEMU_CAPS_DEVICE_INTEL_IOMMU);
-+    DO_TEST("intel-iommu-device-iotlb",
-+            QEMU_CAPS_MACHINE_OPT,
-+            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
-+            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
-+            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
-+            QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB,
-+            QEMU_CAPS_DEVICE_INTEL_IOMMU);
- 
-     DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-format-eim-on-intel-iommu-command-line.patch b/SOURCES/libvirt-qemu-format-eim-on-intel-iommu-command-line.patch
deleted file mode 100644
index 3ef2d8a..0000000
--- a/SOURCES/libvirt-qemu-format-eim-on-intel-iommu-command-line.patch
+++ /dev/null
@@ -1,207 +0,0 @@
-From 2c6067b5f21f5965912c115d0b5e3afd2d1f6ddd Mon Sep 17 00:00:00 2001
-Message-Id: <2c6067b5f21f5965912c115d0b5e3afd2d1f6ddd@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 26 May 2017 08:52:57 +0200
-Subject: [PATCH] qemu: format eim on intel-iommu command line
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This option turns on extended interrupt mode,
-which allows more than 255 vCPUs.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1451282
-
-Reviewed-by: Andrea Bolognani <abologna@redhat.com>
-(cherry picked from commit 381e638d81fd13475112ec9ae2cc4fdbe546ed4d)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-Also:
-https://bugzilla.redhat.com/show_bug.cgi?id=1289153
-
-Conflicts:
-    tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-      that QEMU version again
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c                        |  2 ++
- src/qemu/qemu_capabilities.h                        |  1 +
- src/qemu/qemu_command.c                             | 11 +++++++++++
- src/qemu/qemu_domain.c                              | 21 +++++++++++++++++++++
- tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml    |  1 +
- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml    |  1 +
- .../qemuxml2argv-intel-iommu-eim.args               | 19 +++++++++++++++++++
- tests/qemuxml2argvtest.c                            |  7 +++++++
- 8 files changed, 63 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.args
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index c970d70e3..80db60bc4 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -371,6 +371,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
-               "kernel-irqchip.split",
-               "intel-iommu.intremap",
-               "intel-iommu.caching-mode",
-+              "intel-iommu.eim",
-     );
- 
- 
-@@ -1726,6 +1727,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsUSBNECXHCI[] = {
- static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIntelIOMMU[] = {
-     { "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
-     { "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING_MODE },
-+    { "eim", QEMU_CAPS_INTEL_IOMMU_EIM },
- };
- 
- /* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format */
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index 4e322b5c2..1c64364af 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -409,6 +409,7 @@ typedef enum {
-     QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT, /* -machine kernel_irqchip=split */
-     QEMU_CAPS_INTEL_IOMMU_INTREMAP, /* intel-iommu.intremap */
-     QEMU_CAPS_INTEL_IOMMU_CACHING_MODE, /* intel-iommu.caching-mode */
-+    QEMU_CAPS_INTEL_IOMMU_EIM, /* intel-iommu.eim */
- 
-     QEMU_CAPS_LAST /* this must always be the last item */
- } virQEMUCapsFlags;
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index d4d0c00d5..9c0d151da 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -6687,6 +6687,13 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
-                              "with this QEMU binary"));
-             return -1;
-         }
-+        if (iommu->eim != VIR_TRISTATE_SWITCH_ABSENT &&
-+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_EIM))  {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                           _("iommu: eim is not supported "
-+                             "with this QEMU binary"));
-+            return -1;
-+        }
-         break;
-     case VIR_DOMAIN_IOMMU_MODEL_LAST:
-         break;
-@@ -6720,6 +6727,10 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
-             virBufferAsprintf(&opts, ",caching-mode=%s",
-                               virTristateSwitchTypeToString(iommu->caching_mode));
-         }
-+        if (iommu->eim != VIR_TRISTATE_SWITCH_ABSENT) {
-+            virBufferAsprintf(&opts, ",eim=%s",
-+                              virTristateSwitchTypeToString(iommu->eim));
-+        }
-     case VIR_DOMAIN_IOMMU_MODEL_LAST:
-         break;
-     }
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index a8a68aedd..89698d4fc 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -2941,6 +2941,9 @@ qemuDomainDefValidateVideo(const virDomainDef *def)
- }
- 
- 
-+#define QEMU_MAX_VCPUS_WITHOUT_EIM 255
-+
-+
- static int
- qemuDomainDefValidate(const virDomainDef *def,
-                       virCapsPtr caps,
-@@ -3020,6 +3023,24 @@ qemuDomainDefValidate(const virDomainDef *def,
-         }
-     }
- 
-+    if (ARCH_IS_X86(def->os.arch) &&
-+        virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM) {
-+        if (!qemuDomainIsQ35(def)) {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                           _("more than %d vCPUs are only supported on "
-+                             "q35-based machine types"),
-+                           QEMU_MAX_VCPUS_WITHOUT_EIM);
-+            goto cleanup;
-+        }
-+        if (!def->iommu || def->iommu->eim != VIR_TRISTATE_SWITCH_ON) {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                           _("more than %d vCPUs require extended interrupt "
-+                             "mode enabled on the iommu device"),
-+                           QEMU_MAX_VCPUS_WITHOUT_EIM);
-+            goto cleanup;
-+        }
-+    }
-+
-     if (qemuDomainDefValidateVideo(def) < 0)
-         goto cleanup;
- 
-diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-index e51567817..01edbc88d 100644
---- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-@@ -206,6 +206,7 @@
-   <flag name='kernel-irqchip'/>
-   <flag name='kernel-irqchip.split'/>
-   <flag name='intel-iommu.intremap'/>
-+  <flag name='intel-iommu.eim'/>
-   <version>2008000</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.8.0)</package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-index b5649d8d7..2002dc7c0 100644
---- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-@@ -213,6 +213,7 @@
-   <flag name='kernel-irqchip.split'/>
-   <flag name='intel-iommu.intremap'/>
-   <flag name='intel-iommu.caching-mode'/>
-+  <flag name='intel-iommu.eim'/>
-   <version>2008090</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.9.0-rc0-142-g940a8ce)</package>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.args
-new file mode 100644
-index 000000000..ebf7c49bf
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.args
-@@ -0,0 +1,19 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-x86_64 \
-+-name QEMUGuest1 \
-+-S \
-+-machine q35,accel=kvm,kernel_irqchip=split \
-+-m 214 \
-+-smp 288,sockets=288,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-device intel-iommu,intremap=on,eim=on
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index e3d6d757b..ecdda2db9 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -2534,6 +2534,13 @@ mymain(void)
-             QEMU_CAPS_DEVICE_INTEL_IOMMU,
-             QEMU_CAPS_INTEL_IOMMU_INTREMAP,
-             QEMU_CAPS_INTEL_IOMMU_CACHING_MODE);
-+    DO_TEST("intel-iommu-eim",
-+            QEMU_CAPS_MACHINE_OPT,
-+            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
-+            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
-+            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
-+            QEMU_CAPS_INTEL_IOMMU_EIM,
-+            QEMU_CAPS_DEVICE_INTEL_IOMMU);
- 
-     DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-format-intel-iommu-intremap-on-the-command-line.patch b/SOURCES/libvirt-qemu-format-intel-iommu-intremap-on-the-command-line.patch
deleted file mode 100644
index 8006311..0000000
--- a/SOURCES/libvirt-qemu-format-intel-iommu-intremap-on-the-command-line.patch
+++ /dev/null
@@ -1,715 +0,0 @@
-From f341f4c03ec726b6004e477259ba2da0932528e3 Mon Sep 17 00:00:00 2001
-Message-Id: <f341f4c03ec726b6004e477259ba2da0932528e3@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:55 +0200
-Subject: [PATCH] qemu: format intel-iommu, intremap on the command line
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-(cherry picked from commit 04028a9db9f2657e8d57d1e4705073c908aa248c)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-Conflicts:
-        tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-          - downstream did not update qemu version to 2.9.0
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c                       |  8 ++++
- src/qemu/qemu_capabilities.h                       |  1 +
- src/qemu/qemu_command.c                            | 18 ++++++++
- .../qemucapabilitiesdata/caps_2.4.0.x86_64.replies | 22 +++++++---
- .../qemucapabilitiesdata/caps_2.5.0.x86_64.replies | 24 +++++++----
- .../qemucapabilitiesdata/caps_2.6.0.x86_64.replies | 24 +++++++----
- .../qemucapabilitiesdata/caps_2.7.0.x86_64.replies | 28 +++++++++----
- tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |  1 +
- .../qemucapabilitiesdata/caps_2.8.0.x86_64.replies | 37 ++++++++++++----
- tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |  1 +
- .../qemucapabilitiesdata/caps_2.9.0.x86_64.replies | 49 ++++++++++++++++++----
- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  1 +
- .../qemuxml2argv-intel-iommu-ioapic.args           |  2 +-
- tests/qemuxml2argvtest.c                           |  1 +
- 14 files changed, 173 insertions(+), 44 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index f27fe0a24..4fd0df260 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -369,6 +369,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
- 
-               "kernel-irqchip", /* 255 */
-               "kernel-irqchip.split",
-+              "intel-iommu.intremap",
-     );
- 
- 
-@@ -1721,6 +1722,10 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsUSBNECXHCI[] = {
-     { "p3", QEMU_CAPS_NEC_USB_XHCI_PORTS },
- };
- 
-+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIntelIOMMU[] = {
-+    { "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
-+};
-+
- /* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format */
- static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = {
-     { "blockdev-add/arg-type/options/+gluster/debug-level", QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
-@@ -1828,6 +1833,9 @@ static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
-     { "nec-usb-xhci", virQEMUCapsObjectPropsUSBNECXHCI,
-       ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBNECXHCI),
-       -1 },
-+    { "intel-iommu", virQEMUCapsObjectPropsIntelIOMMU,
-+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsIntelIOMMU),
-+      QEMU_CAPS_DEVICE_INTEL_IOMMU},
- };
- 
- struct virQEMUCapsPropTypeObjects {
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index a6cdf2c3d..d1730a725 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -407,6 +407,7 @@ typedef enum {
-     /* 255 */
-     QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */
-     QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT, /* -machine kernel_irqchip=split */
-+    QEMU_CAPS_INTEL_IOMMU_INTREMAP, /* intel-iommu.intremap */
- 
-     QEMU_CAPS_LAST /* this must always be the last item */
- } virQEMUCapsFlags;
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 7151b1843..a8dac1489 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -6671,6 +6671,20 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
-     if (!iommu)
-         return 0;
- 
-+    switch (iommu->model) {
-+    case VIR_DOMAIN_IOMMU_MODEL_INTEL:
-+        if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT &&
-+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_INTREMAP)) {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                           _("iommu: interrupt remapping is not supported "
-+                             "with this QEMU binary"));
-+            return -1;
-+        }
-+        break;
-+    case VIR_DOMAIN_IOMMU_MODEL_LAST:
-+        break;
-+    }
-+
-     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU))
-         return 0; /* Already handled via -machine */
- 
-@@ -6691,6 +6705,10 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
-             return -1;
-         }
-         virBufferAddLit(&opts, "intel-iommu");
-+        if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
-+            virBufferAsprintf(&opts, ",intremap=%s",
-+                              virTristateSwitchTypeToString(iommu->intremap));
-+        }
-     case VIR_DOMAIN_IOMMU_MODEL_LAST:
-         break;
-     }
-diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies
-index 68221816b..9f256c48a 100644
---- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies
-+++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies
-@@ -3123,6 +3123,16 @@
- {
-   "return": [
-     {
-+      "name": "version",
-+      "type": "uint32"
-+    }
-+  ],
-+  "id": "libvirt-41"
-+}
-+
-+{
-+  "return": [
-+    {
-       "name": "pc-i440fx-2.4",
-       "is-default": true,
-       "cpu-max": 255,
-@@ -3246,7 +3256,7 @@
-       "cpu-max": 255
-     }
-   ],
--  "id": "libvirt-41"
-+  "id": "libvirt-42"
- }
- 
- {
-@@ -3336,21 +3346,21 @@
-       "name": "qemu64"
-     }
-   ],
--  "id": "libvirt-42"
-+  "id": "libvirt-43"
- }
- 
- {
-   "return": [
-     "tpm-tis"
-   ],
--  "id": "libvirt-43"
-+  "id": "libvirt-44"
- }
- 
- {
-   "return": [
-     "passthrough"
-   ],
--  "id": "libvirt-44"
-+  "id": "libvirt-45"
- }
- 
- {
-@@ -4358,7 +4368,7 @@
-       "option": "drive"
-     }
-   ],
--  "id": "libvirt-45"
-+  "id": "libvirt-46"
- }
- 
- {
-@@ -4388,7 +4398,7 @@
-       "capability": "events"
-     }
-   ],
--  "id": "libvirt-46"
-+  "id": "libvirt-47"
- }
- 
- {
-diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies
-index 2eeed7d6c..876bc2f0a 100644
---- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies
-+++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies
-@@ -3286,6 +3286,16 @@
- {
-   "return": [
-     {
-+      "name": "version",
-+      "type": "uint32"
-+    }
-+  ],
-+  "id": "libvirt-41"
-+}
-+
-+{
-+  "return": [
-+    {
-       "name": "pc-i440fx-2.4",
-       "cpu-max": 255
-     },
-@@ -3417,7 +3427,7 @@
-       "cpu-max": 255
-     }
-   ],
--  "id": "libvirt-41"
-+  "id": "libvirt-42"
- }
- 
- {
-@@ -3507,21 +3517,21 @@
-       "name": "qemu64"
-     }
-   ],
--  "id": "libvirt-42"
-+  "id": "libvirt-43"
- }
- 
- {
-   "return": [
-     "tpm-tis"
-   ],
--  "id": "libvirt-43"
-+  "id": "libvirt-44"
- }
- 
- {
-   "return": [
-     "passthrough"
-   ],
--  "id": "libvirt-44"
-+  "id": "libvirt-45"
- }
- 
- {
-@@ -4566,7 +4576,7 @@
-       "option": "drive"
-     }
-   ],
--  "id": "libvirt-45"
-+  "id": "libvirt-46"
- }
- 
- {
-@@ -4600,7 +4610,7 @@
-       "capability": "x-postcopy-ram"
-     }
-   ],
--  "id": "libvirt-46"
-+  "id": "libvirt-47"
- }
- 
- {
-@@ -12145,7 +12155,7 @@
-       "meta-type": "array"
-     }
-   ],
--  "id": "libvirt-47"
-+  "id": "libvirt-48"
- }
- 
- {
-diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies
-index 0c285cd95..d6d0b5786 100644
---- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies
-+++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies
-@@ -3368,6 +3368,16 @@
- {
-   "return": [
-     {
-+      "name": "version",
-+      "type": "uint32"
-+    }
-+  ],
-+  "id": "libvirt-41"
-+}
-+
-+{
-+  "return": [
-+    {
-       "name": "pc-0.12",
-       "cpu-max": 255
-     },
-@@ -3475,7 +3485,7 @@
-       "cpu-max": 255
-     }
-   ],
--  "id": "libvirt-41"
-+  "id": "libvirt-42"
- }
- 
- {
-@@ -3565,21 +3575,21 @@
-       "name": "qemu64"
-     }
-   ],
--  "id": "libvirt-42"
-+  "id": "libvirt-43"
- }
- 
- {
-   "return": [
-     "tpm-tis"
-   ],
--  "id": "libvirt-43"
-+  "id": "libvirt-44"
- }
- 
- {
-   "return": [
-     "passthrough"
-   ],
--  "id": "libvirt-44"
-+  "id": "libvirt-45"
- }
- 
- {
-@@ -4673,7 +4683,7 @@
-       "option": "drive"
-     }
-   ],
--  "id": "libvirt-45"
-+  "id": "libvirt-46"
- }
- 
- {
-@@ -4707,7 +4717,7 @@
-       "capability": "postcopy-ram"
-     }
-   ],
--  "id": "libvirt-46"
-+  "id": "libvirt-47"
- }
- 
- {
-@@ -12712,7 +12722,7 @@
-       "meta-type": "array"
-     }
-   ],
--  "id": "libvirt-47"
-+  "id": "libvirt-48"
- }
- 
- {
-diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies
-index 4a872370b..671a958be 100644
---- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies
-+++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies
-@@ -3559,6 +3559,20 @@
- {
-   "return": [
-     {
-+      "name": "version",
-+      "type": "uint32"
-+    },
-+    {
-+      "name": "intremap",
-+      "type": "bool"
-+    }
-+  ],
-+  "id": "libvirt-41"
-+}
-+
-+{
-+  "return": [
-+    {
-       "hotpluggable-cpus": true,
-       "name": "pc-0.12",
-       "cpu-max": 255
-@@ -3702,7 +3716,7 @@
-       "cpu-max": 255
-     }
-   ],
--  "id": "libvirt-41"
-+  "id": "libvirt-42"
- }
- 
- {
-@@ -3795,21 +3809,21 @@
-       "name": "qemu64"
-     }
-   ],
--  "id": "libvirt-42"
-+  "id": "libvirt-43"
- }
- 
- {
-   "return": [
-     "tpm-tis"
-   ],
--  "id": "libvirt-43"
-+  "id": "libvirt-44"
- }
- 
- {
-   "return": [
-     "passthrough"
-   ],
--  "id": "libvirt-44"
-+  "id": "libvirt-45"
- }
- 
- {
-@@ -4907,7 +4921,7 @@
-       "option": "drive"
-     }
-   ],
--  "id": "libvirt-45"
-+  "id": "libvirt-46"
- }
- 
- {
-@@ -4941,7 +4955,7 @@
-       "capability": "postcopy-ram"
-     }
-   ],
--  "id": "libvirt-46"
-+  "id": "libvirt-47"
- }
- 
- {
-@@ -13297,7 +13311,7 @@
-       "meta-type": "object"
-     }
-   ],
--  "id": "libvirt-47"
-+  "id": "libvirt-48"
- }
- 
- {
-diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
-index 6c2ea59c6..49c046212 100644
---- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
-@@ -204,6 +204,7 @@
-   <flag name='query-named-block-nodes'/>
-   <flag name='kernel-irqchip'/>
-   <flag name='kernel-irqchip.split'/>
-+  <flag name='intel-iommu.intremap'/>
-   <version>2007000</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.7.0)</package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies
-index b3ad9121e..3087d7680 100644
---- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies
-+++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies
-@@ -3692,6 +3692,29 @@
- {
-   "return": [
-     {
-+      "name": "eim",
-+      "description": "on/off/auto",
-+      "type": "OnOffAuto"
-+    },
-+    {
-+      "name": "x-buggy-eim",
-+      "type": "bool"
-+    },
-+    {
-+      "name": "intremap",
-+      "type": "bool"
-+    },
-+    {
-+      "name": "version",
-+      "type": "uint32"
-+    }
-+  ],
-+  "id": "libvirt-41"
-+}
-+
-+{
-+  "return": [
-+    {
-       "hotpluggable-cpus": true,
-       "name": "pc-0.12",
-       "cpu-max": 255
-@@ -3855,7 +3878,7 @@
-       "cpu-max": 255
-     }
-   ],
--  "id": "libvirt-41"
-+  "id": "libvirt-42"
- }
- 
- {
-@@ -4061,21 +4084,21 @@
-       "static": false
-     }
-   ],
--  "id": "libvirt-42"
-+  "id": "libvirt-43"
- }
- 
- {
-   "return": [
-     "tpm-tis"
-   ],
--  "id": "libvirt-43"
-+  "id": "libvirt-44"
- }
- 
- {
-   "return": [
-     "passthrough"
-   ],
--  "id": "libvirt-44"
-+  "id": "libvirt-45"
- }
- 
- {
-@@ -5198,7 +5221,7 @@
-       "option": "drive"
-     }
-   ],
--  "id": "libvirt-45"
-+  "id": "libvirt-46"
- }
- 
- {
-@@ -5236,7 +5259,7 @@
-       "capability": "x-colo"
-     }
-   ],
--  "id": "libvirt-46"
-+  "id": "libvirt-47"
- }
- 
- {
-@@ -14006,7 +14029,7 @@
-       "meta-type": "object"
-     }
-   ],
--  "id": "libvirt-47"
-+  "id": "libvirt-48"
- }
- 
- {
-diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-index 9c8c79ab0..e51567817 100644
---- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-@@ -205,6 +205,7 @@
-   <flag name='query-named-block-nodes'/>
-   <flag name='kernel-irqchip'/>
-   <flag name='kernel-irqchip.split'/>
-+  <flag name='intel-iommu.intremap'/>
-   <version>2008000</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.8.0)</package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies
-index bae24750c..3cfefb709 100644
---- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies
-+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies
-@@ -4003,6 +4003,37 @@
- {
-   "return": [
-     {
-+      "name": "eim",
-+      "description": "on/off/auto",
-+      "type": "OnOffAuto"
-+    },
-+    {
-+      "name": "caching-mode",
-+      "type": "bool"
-+    },
-+    {
-+      "name": "x-buggy-eim",
-+      "type": "bool"
-+    },
-+    {
-+      "name": "intremap",
-+      "type": "bool"
-+    },
-+    {
-+      "name": "version",
-+      "type": "uint32"
-+    },
-+    {
-+      "name": "device-iotlb",
-+      "type": "bool"
-+    }
-+  ],
-+  "id": "libvirt-41"
-+}
-+
-+{
-+  "return": [
-+    {
-       "hotpluggable-cpus": true,
-       "name": "pc-0.12",
-       "cpu-max": 255
-@@ -4176,7 +4207,7 @@
-       "cpu-max": 255
-     }
-   ],
--  "id": "libvirt-41"
-+  "id": "libvirt-42"
- }
- 
- {
-@@ -4458,21 +4489,21 @@
-       "migration-safe": true
-     }
-   ],
--  "id": "libvirt-42"
-+  "id": "libvirt-43"
- }
- 
- {
-   "return": [
-     "tpm-tis"
-   ],
--  "id": "libvirt-43"
-+  "id": "libvirt-44"
- }
- 
- {
-   "return": [
-     "passthrough"
-   ],
--  "id": "libvirt-44"
-+  "id": "libvirt-45"
- }
- 
- {
-@@ -5721,7 +5752,7 @@
-       "option": "drive"
-     }
-   ],
--  "id": "libvirt-45"
-+  "id": "libvirt-46"
- }
- 
- {
-@@ -5763,7 +5794,7 @@
-       "capability": "release-ram"
-     }
-   ],
--  "id": "libvirt-46"
-+  "id": "libvirt-47"
- }
- 
- {
-@@ -14888,7 +14919,7 @@
-       "meta-type": "object"
-     }
-   ],
--  "id": "libvirt-47"
-+  "id": "libvirt-48"
- }
- 
- {
-@@ -15067,7 +15098,7 @@
-       }
-     }
-   },
--  "id": "libvirt-48"
-+  "id": "libvirt-49"
- }
- 
- {
-@@ -15308,7 +15339,7 @@
-       }
-     }
-   },
--  "id": "libvirt-49"
-+  "id": "libvirt-50"
- }
- 
- {
-diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-index e4cdca89a..5a88cf505 100644
---- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-@@ -211,6 +211,7 @@
-   <flag name='qemu-xhci'/>
-   <flag name='kernel-irqchip'/>
-   <flag name='kernel-irqchip.split'/>
-+  <flag name='intel-iommu.intremap'/>
-   <version>2008090</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.9.0-rc0-142-g940a8ce)</package>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args
-index 43d71adfc..c6539878a 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args
-@@ -16,4 +16,4 @@ QEMU_AUDIO_DRV=none \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
- -no-acpi \
- -boot c \
---device intel-iommu
-+-device intel-iommu,intremap=on
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index c7aad297c..8061292b3 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -2521,6 +2521,7 @@ mymain(void)
-             QEMU_CAPS_MACHINE_OPT,
-             QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
-             QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
-+            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
-             QEMU_CAPS_DEVICE_INTEL_IOMMU);
- 
-     DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-format-kernel_irqchip-on-the-command-line.patch b/SOURCES/libvirt-qemu-format-kernel_irqchip-on-the-command-line.patch
deleted file mode 100644
index 30631b6..0000000
--- a/SOURCES/libvirt-qemu-format-kernel_irqchip-on-the-command-line.patch
+++ /dev/null
@@ -1,401 +0,0 @@
-From be9562bdb0bef5b3e8db7dd22104631f13188f3a Mon Sep 17 00:00:00 2001
-Message-Id: <be9562bdb0bef5b3e8db7dd22104631f13188f3a@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:53 +0200
-Subject: [PATCH] qemu: format kernel_irqchip on the command line
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Add kernel_irqchip=split/on to the QEMU command line
-and a capability that looks for it in query-command-line-options
-output. For the 'split' option, use a version check
-since it cannot be reasonably probed.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-(cherry picked from commit 6b5c6314b2f7a3b54c94a591e6b0dcd13ef1c6ce)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-Conflicts:
-        tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-          - downstream did not update the qemu version to 2.9.0
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c                       |  8 +++++++
- src/qemu/qemu_capabilities.h                       |  4 ++++
- src/qemu/qemu_command.c                            | 25 ++++++++++++++++++++++
- src/qemu/qemu_domain.c                             | 19 ++++++++++++++++
- tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml   |  1 +
- tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml   |  1 +
- tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml   |  1 +
- tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml   |  1 +
- tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml   |  1 +
- tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml   |  1 +
- .../caps_2.6.0-gicv2.aarch64.xml                   |  2 ++
- .../caps_2.6.0-gicv3.aarch64.xml                   |  2 ++
- tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml  |  2 ++
- tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml   |  2 ++
- tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml    |  2 ++
- tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |  2 ++
- tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml    |  2 ++
- tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |  2 ++
- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  2 ++
- .../qemuxml2argv-intel-iommu-ioapic.args           | 19 ++++++++++++++++
- tests/qemuxml2argvtest.c                           |  5 +++++
- 21 files changed, 104 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 49fb52e03..f27fe0a24 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -366,6 +366,9 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
-               "query-named-block-nodes",
-               "cpu-cache",
-               "qemu-xhci",
-+
-+              "kernel-irqchip", /* 255 */
-+              "kernel-irqchip.split",
-     );
- 
- 
-@@ -3128,6 +3131,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
-     { "drive", "throttling.bps-total-max-length", QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH },
-     { "drive", "throttling.group", QEMU_CAPS_DRIVE_IOTUNE_GROUP },
-     { "spice", "rendernode", QEMU_CAPS_SPICE_RENDERNODE },
-+    { "machine", "kernel_irqchip", QEMU_CAPS_MACHINE_KERNEL_IRQCHIP },
- };
- 
- static int
-@@ -4743,6 +4747,10 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
-     if (qemuCaps->version >= 2004050)
-         virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACH_VIRT_GIC_VERSION);
- 
-+    /* no way to query if -machine kernel_irqchip supports split */
-+    if (qemuCaps->version >= 2006000)
-+        virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT);
-+
-     if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0)
-         goto cleanup;
- 
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index 1cd3ec37d..a6cdf2c3d 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -404,6 +404,10 @@ typedef enum {
-     QEMU_CAPS_CPU_CACHE, /* -cpu supports host-cache-info and l3-cache properties */
-     QEMU_CAPS_DEVICE_QEMU_XHCI, /* -device qemu-xhci */
- 
-+    /* 255 */
-+    QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */
-+    QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT, /* -machine kernel_irqchip=split */
-+
-     QEMU_CAPS_LAST /* this must always be the last item */
- } virQEMUCapsFlags;
- 
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index b27b9f8ad..7151b1843 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -7429,6 +7429,31 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
-             }
-         }
- 
-+        if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_TRISTATE_SWITCH_ON) {
-+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP)) {
-+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                               _("I/O APIC tuning is not supported by this "
-+                                 "QEMU binary"));
-+                goto cleanup;
-+            }
-+            switch (def->ioapic) {
-+            case VIR_DOMAIN_IOAPIC_QEMU:
-+                if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT)) {
-+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                                   _("split I/O APIC is not supported by this "
-+                                     "QEMU binary"));
-+                    goto cleanup;
-+                }
-+                virBufferAddLit(&buf, ",kernel_irqchip=split");
-+                break;
-+            case VIR_DOMAIN_IOAPIC_KVM:
-+                virBufferAddLit(&buf, ",kernel_irqchip=on");
-+                break;
-+            case VIR_DOMAIN_IOAPIC_LAST:
-+                break;
-+            }
-+        }
-+
-         virCommandAddArgBuffer(cmd, &buf);
-     }
- 
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 04d1b39db..a8a68aedd 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -2776,6 +2776,22 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def)
- 
- 
- static int
-+qemuDomainDefVerifyFeatures(const virDomainDef *def)
-+{
-+    if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_TRISTATE_SWITCH_ON &&
-+        !ARCH_IS_X86(def->os.arch)) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("I/O APIC tuning is not supported "
-+                         "for '%s' architecture"),
-+                       virArchToString(def->os.arch));
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+
-+static int
- qemuDomainDefPostParse(virDomainDefPtr def,
-                        virCapsPtr caps,
-                        unsigned int parseFlags,
-@@ -2830,6 +2846,9 @@ qemuDomainDefPostParse(virDomainDefPtr def,
- 
-     qemuDomainDefEnableDefaultFeatures(def, qemuCaps);
- 
-+    if (qemuDomainDefVerifyFeatures(def) < 0)
-+        goto cleanup;
-+
-     if (qemuDomainRecheckInternalPaths(def, cfg, parseFlags) < 0)
-         goto cleanup;
- 
-diff --git a/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
-index a68c13bbd..14f34b277 100644
---- a/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml
-@@ -140,6 +140,7 @@
-   <flag name='display'/>
-   <flag name='vhost-scsi'/>
-   <flag name='query-cpu-definitions'/>
-+  <flag name='kernel-irqchip'/>
-   <version>1005003</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
-index 365b3a650..8fc23d6aa 100644
---- a/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
-@@ -145,6 +145,7 @@
-   <flag name='display'/>
-   <flag name='vhost-scsi'/>
-   <flag name='query-cpu-definitions'/>
-+  <flag name='kernel-irqchip'/>
-   <version>1006000</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
-index 689fbf82c..47c8956b4 100644
---- a/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
-@@ -147,6 +147,7 @@
-   <flag name='display'/>
-   <flag name='vhost-scsi'/>
-   <flag name='query-cpu-definitions'/>
-+  <flag name='kernel-irqchip'/>
-   <version>1007000</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
-index e092dd254..afe7d53ff 100644
---- a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
-@@ -163,6 +163,7 @@
-   <flag name='vhost-scsi'/>
-   <flag name='query-cpu-definitions'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-   <version>2001001</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
-index ea03f2e66..5bdc1a2bd 100644
---- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
-@@ -185,6 +185,7 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-   <version>2004000</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
-index 164605f20..36bc1342b 100644
---- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
-@@ -191,6 +191,7 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-   <version>2005000</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
-index af3a8e7cb..33bc46208 100644
---- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
-@@ -168,6 +168,8 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-+  <flag name='kernel-irqchip.split'/>
-   <version>2006000</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
-index 4402ffa6f..a8ce6b03b 100644
---- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
-@@ -168,6 +168,8 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-+  <flag name='kernel-irqchip.split'/>
-   <version>2006000</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
-index 3f05169c8..425992f0d 100644
---- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
-@@ -162,6 +162,8 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-+  <flag name='kernel-irqchip.split'/>
-   <version>2006000</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
-index 1d823eac2..97e71ec4f 100644
---- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
-@@ -200,6 +200,8 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-+  <flag name='kernel-irqchip.split'/>
-   <version>2006000</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml
-index 38d36b3e6..70cce6417 100644
---- a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml
-@@ -130,6 +130,8 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-+  <flag name='kernel-irqchip.split'/>
-   <version>2007000</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
-index 24d7cb438..6c2ea59c6 100644
---- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
-@@ -202,6 +202,8 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-+  <flag name='kernel-irqchip.split'/>
-   <version>2007000</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.7.0)</package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml
-index 42c92c567..51be9bce4 100644
---- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml
-@@ -132,6 +132,8 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-+  <flag name='kernel-irqchip.split'/>
-   <version>2007093</version>
-   <kvmVersion>0</kvmVersion>
-   <package></package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-index 0bc13683e..9c8c79ab0 100644
---- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
-@@ -203,6 +203,8 @@
-   <flag name='query-cpu-definitions'/>
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-+  <flag name='kernel-irqchip'/>
-+  <flag name='kernel-irqchip.split'/>
-   <version>2008000</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.8.0)</package>
-diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-index 83ed0f1c6..e4cdca89a 100644
---- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-@@ -209,6 +209,8 @@
-   <flag name='query-named-block-nodes'/>
-   <flag name='cpu-cache'/>
-   <flag name='qemu-xhci'/>
-+  <flag name='kernel-irqchip'/>
-+  <flag name='kernel-irqchip.split'/>
-   <version>2008090</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.9.0-rc0-142-g940a8ce)</package>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args
-new file mode 100644
-index 000000000..43d71adfc
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args
-@@ -0,0 +1,19 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-x86_64 \
-+-name QEMUGuest1 \
-+-S \
-+-machine q35,accel=kvm,kernel_irqchip=split \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-device intel-iommu
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 406fbfea4..c7aad297c 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -2517,6 +2517,11 @@ mymain(void)
-     DO_TEST("intel-iommu-machine",
-             QEMU_CAPS_MACHINE_OPT,
-             QEMU_CAPS_MACHINE_IOMMU);
-+    DO_TEST("intel-iommu-ioapic",
-+            QEMU_CAPS_MACHINE_OPT,
-+            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
-+            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
-+            QEMU_CAPS_DEVICE_INTEL_IOMMU);
- 
-     DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-format-virtio-related-options-on-the-command-line.patch b/SOURCES/libvirt-qemu-format-virtio-related-options-on-the-command-line.patch
deleted file mode 100644
index 27afdd1..0000000
--- a/SOURCES/libvirt-qemu-format-virtio-related-options-on-the-command-line.patch
+++ /dev/null
@@ -1,303 +0,0 @@
-From 27eff2a6edc81f85757d7d03134dc65d737c316f Mon Sep 17 00:00:00 2001
-Message-Id: <27eff2a6edc81f85757d7d03134dc65d737c316f@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:49:09 +0200
-Subject: [PATCH] qemu: format virtio-related options on the command line
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Format iommu_platform= and ats= for virtio devices.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit b2cbc3a0607bf26a82911f7db6dcbc09c9bbf5e8)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-Conflicts:
-	tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-          the version again
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c                       | 12 ++++-
- src/qemu/qemu_capabilities.h                       |  2 +
- src/qemu/qemu_command.c                            | 58 ++++++++++++++++++++++
- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  2 +
- .../qemuxml2argv-virtio-options.args               | 37 ++++++++------
- tests/qemuxml2argvtest.c                           |  4 +-
- 6 files changed, 98 insertions(+), 17 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index d8f3079083..eea57e4c9c 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -374,6 +374,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
-               "intel-iommu.eim",
- 
-               "intel-iommu.device-iotlb", /* 260 */
-+              "virtio.iommu_platform",
-+              "virtio.ats",
-     );
- 
- 
-@@ -1851,7 +1853,7 @@ struct virQEMUCapsPropTypeObjects {
-     const char **objects;
- };
- 
--static const char *virQEMUCapsVirtioPCIDisableLegacyObjects[] = {
-+static const char *virQEMUCapsVirtioPCIObjects[] = {
-      "virtio-balloon-pci",
-      "virtio-blk-pci",
-      "virtio-scsi-pci",
-@@ -1870,7 +1872,13 @@ static const char *virQEMUCapsVirtioPCIDisableLegacyObjects[] = {
- static struct virQEMUCapsPropTypeObjects virQEMUCapsPropObjects[] = {
-     { "disable-legacy",
-       QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
--      virQEMUCapsVirtioPCIDisableLegacyObjects }
-+      virQEMUCapsVirtioPCIObjects },
-+    { "iommu_platform",
-+      QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM,
-+      virQEMUCapsVirtioPCIObjects },
-+    { "ats",
-+      QEMU_CAPS_VIRTIO_PCI_ATS,
-+      virQEMUCapsVirtioPCIObjects },
- };
- 
- 
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index e0f81711fe..bbc6f6812f 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -413,6 +413,8 @@ typedef enum {
- 
-     /* 260 */
-     QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB, /* intel-iommu.device-iotlb */
-+    QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, /* virtio-*-pci.iommu_platform */
-+    QEMU_CAPS_VIRTIO_PCI_ATS, /* virtio-*-pci.ats */
- 
-     QEMU_CAPS_LAST /* this must always be the last item */
- } virQEMUCapsFlags;
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 9c5639b036..e220bf5ba0 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -389,6 +389,38 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
- }
- 
- static int
-+qemuBuildVirtioOptionsStr(virBufferPtr buf,
-+                          virDomainVirtioOptionsPtr virtio,
-+                          virQEMUCapsPtr qemuCaps)
-+{
-+    if (!virtio)
-+        return 0;
-+
-+    if (virtio->iommu != VIR_TRISTATE_SWITCH_ABSENT) {
-+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM)) {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                           _("the iommu setting is not supported "
-+                             "with this QEMU binary"));
-+            return -1;
-+        }
-+        virBufferAsprintf(buf, ",iommu_platform=%s",
-+                          virTristateSwitchTypeToString(virtio->iommu));
-+    }
-+    if (virtio->ats != VIR_TRISTATE_SWITCH_ABSENT) {
-+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_ATS)) {
-+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-+                           _("the ats setting is not supported with this "
-+                             "QEMU binary"));
-+            return -1;
-+        }
-+        virBufferAsprintf(buf, ",ats=%s",
-+                          virTristateSwitchTypeToString(virtio->ats));
-+    }
-+
-+    return 0;
-+}
-+
-+static int
- qemuBuildRomStr(virBufferPtr buf,
-                 virDomainDeviceInfoPtr info)
- {
-@@ -2167,6 +2199,10 @@ qemuBuildDriveDevStr(const virDomainDef *def,
-                               (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN)
-                               ? "on" : "off");
-         }
-+
-+        if (qemuBuildVirtioOptionsStr(&opt, disk->virtio, qemuCaps) < 0)
-+            goto error;
-+
-         if (qemuBuildDeviceAddressStr(&opt, def, &disk->info, qemuCaps) < 0)
-             goto error;
-         break;
-@@ -2490,6 +2526,8 @@ qemuBuildFSDevStr(const virDomainDef *def,
-                       QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
-     virBufferAsprintf(&opt, ",mount_tag=%s", fs->dst);
- 
-+    qemuBuildVirtioOptionsStr(&opt, fs->virtio, qemuCaps);
-+
-     if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, qemuCaps) < 0)
-         goto error;
- 
-@@ -2734,6 +2772,8 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
-                                       def->iothread);
-                 }
-             }
-+            if (qemuBuildVirtioOptionsStr(&buf, def->virtio, qemuCaps) < 0)
-+                goto error;
-             break;
-         case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC:
-             virBufferAddLit(&buf, "lsi");
-@@ -2779,6 +2819,8 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
-             virBufferAsprintf(&buf, ",vectors=%d",
-                               def->opts.vioserial.vectors);
-         }
-+        if (qemuBuildVirtioOptionsStr(&buf, def->virtio, qemuCaps) < 0)
-+            goto error;
-         break;
- 
-     case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
-@@ -3773,12 +3815,16 @@ qemuBuildNicDevStr(virDomainDefPtr def,
-     virBufferAsprintf(&buf, ",id=%s", net->info.alias);
-     virBufferAsprintf(&buf, ",mac=%s",
-                       virMacAddrFormat(&net->mac, macaddr));
-+
-     if (qemuBuildDeviceAddressStr(&buf, def, &net->info, qemuCaps) < 0)
-         goto error;
-     if (qemuBuildRomStr(&buf, &net->info) < 0)
-         goto error;
-     if (bootindex && virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX))
-         virBufferAsprintf(&buf, ",bootindex=%u", bootindex);
-+    if (usingVirtio &&
-+        qemuBuildVirtioOptionsStr(&buf, net->virtio, qemuCaps) < 0)
-+        goto error;
- 
-     if (virBufferCheckError(&buf) < 0)
-         goto error;
-@@ -4053,6 +4099,9 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd,
-                           virTristateSwitchTypeToString(def->memballoon->autodeflate));
-     }
- 
-+    if (qemuBuildVirtioOptionsStr(&buf, def->memballoon->virtio, qemuCaps) < 0)
-+        goto error;
-+
-     virCommandAddArg(cmd, "-device");
-     virCommandAddArgBuffer(cmd, &buf);
-     return 0;
-@@ -4183,6 +4232,9 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
-     if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
-         goto error;
- 
-+    if (qemuBuildVirtioOptionsStr(&buf, dev->virtio, qemuCaps) < 0)
-+        goto error;
-+
-     if (virBufferCheckError(&buf) < 0)
-         goto error;
- 
-@@ -4495,6 +4547,9 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
-     if (qemuBuildDeviceAddressStr(&buf, def, &video->info, qemuCaps) < 0)
-         goto error;
- 
-+    if (qemuBuildVirtioOptionsStr(&buf, video->virtio, qemuCaps) < 0)
-+        goto error;
-+
-     if (virBufferCheckError(&buf) < 0)
-         goto error;
- 
-@@ -5860,6 +5915,9 @@ qemuBuildRNGDevStr(const virDomainDef *def,
-             virBufferAddLit(&buf, ",period=1000");
-     }
- 
-+    if (qemuBuildVirtioOptionsStr(&buf, dev->virtio, qemuCaps) < 0)
-+        goto error;
-+
-     if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
-         goto error;
-     if (virBufferCheckError(&buf) < 0)
-diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-index 29a483d123..2140eab398 100644
---- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-@@ -215,6 +215,8 @@
-   <flag name='intel-iommu.caching-mode'/>
-   <flag name='intel-iommu.eim'/>
-   <flag name='intel-iommu.device-iotlb'/>
-+  <flag name='virtio.iommu_platform'/>
-+  <flag name='virtio.ats'/>
-   <version>2008090</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.9.0-rc0-142-g940a8ce)</package>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.args
-index f9f3c2cbad..ce0388dfc2 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.args
-@@ -16,26 +16,35 @@ QEMU_AUDIO_DRV=none \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
- -no-acpi \
- -boot c \
---device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x8 \
---device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x9 \
-+-device virtio-scsi-pci,iommu_platform=on,ats=on,id=scsi0,bus=pci.0,addr=0x8 \
-+-device virtio-serial-pci,id=virtio-serial0,iommu_platform=on,ats=on,bus=pci.0,\
-+addr=0x9 \
- -usb \
- -drive file=/var/lib/libvirt/images/img1,format=raw,if=none,\
- id=drive-virtio-disk0 \
---device virtio-blk-pci,bus=pci.0,addr=0xa,drive=drive-virtio-disk0,\
--id=virtio-disk0 \
-+-device virtio-blk-pci,iommu_platform=on,ats=on,bus=pci.0,addr=0xa,\
-+drive=drive-virtio-disk0,id=virtio-disk0 \
- -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \
---device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.0,addr=0x3 \
-+-device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,iommu_platform=on,\
-+ats=on,bus=pci.0,addr=0x3 \
- -fsdev local,security_model=mapped,writeout=immediate,id=fsdev-fs1,\
- path=/export/fs2 \
---device virtio-9p-pci,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,bus=pci.0,addr=0x4 \
---device virtio-net-pci,vlan=0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x6 \
-+-device virtio-9p-pci,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,iommu_platform=on,\
-+ats=on,bus=pci.0,addr=0x4 \
-+-device virtio-net-pci,vlan=0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x6,\
-+iommu_platform=on,ats=on \
- -net user,vlan=0,name=hostnet0 \
---device virtio-mouse-pci,id=input0,bus=pci.0,addr=0xe \
---device virtio-keyboard-pci,id=input1,bus=pci.0,addr=0x10 \
---device virtio-tablet-pci,id=input2,bus=pci.0,addr=0x11 \
-+-device virtio-mouse-pci,id=input0,bus=pci.0,addr=0xe,iommu_platform=on,ats=on \
-+-device virtio-keyboard-pci,id=input1,bus=pci.0,addr=0x10,iommu_platform=on,\
-+ats=on \
-+-device virtio-tablet-pci,id=input2,bus=pci.0,addr=0x11,iommu_platform=on,\
-+ats=on \
- -device virtio-input-host-pci,id=input3,evdev=/dev/input/event1234,bus=pci.0,\
--addr=0x12 \
---device virtio-gpu-pci,id=video0,virgl=on,bus=pci.0,addr=0x2 \
---device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0xc \
-+addr=0x12,iommu_platform=on,ats=on \
-+-device virtio-gpu-pci,id=video0,virgl=on,bus=pci.0,addr=0x2,iommu_platform=on,\
-+ats=on \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0xc,iommu_platform=on,\
-+ats=on \
- -object rng-random,id=objrng0,filename=/dev/random \
---device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0xd
-+-device virtio-rng-pci,rng=objrng0,id=rng0,iommu_platform=on,ats=on,bus=pci.0,\
-+addr=0xd
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index c186780ef1..175037bf96 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -2558,7 +2558,9 @@ mymain(void)
-             QEMU_CAPS_VIRTIO_GPU_VIRGL,
-             QEMU_CAPS_DEVICE_VIRTIO_RNG,
-             QEMU_CAPS_OBJECT_RNG_RANDOM,
--            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
-+            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
-+            QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM,
-+            QEMU_CAPS_VIRTIO_PCI_ATS);
- 
-     DO_TEST("fd-memory-numa-topology", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE,
-             QEMU_CAPS_KVM);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-functions-for-dealing-with-input-device-namespaces-and-labels.patch b/SOURCES/libvirt-qemu-functions-for-dealing-with-input-device-namespaces-and-labels.patch
new file mode 100644
index 0000000..25439cd
--- /dev/null
+++ b/SOURCES/libvirt-qemu-functions-for-dealing-with-input-device-namespaces-and-labels.patch
@@ -0,0 +1,212 @@
+From 2661dd59c5885adddb522be5e5542461f4e8bf3c Mon Sep 17 00:00:00 2001
+Message-Id: <2661dd59c5885adddb522be5e5542461f4e8bf3c@dist-git>
+From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
+Date: Mon, 27 Nov 2017 14:21:01 +0100
+Subject: [PATCH] qemu: functions for dealing with input device namespaces and
+ labels
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Introudce functions that will let us create the evdevs in namespaces
+and label the devices on input device hotplug/hotunplug.
+
+(cherry picked from commit c4c7a18c4b8107b3521880eb20a94c928bdeacb0)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1509866
+
+Signed-off-by: Ján Tomko <jtomko@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c   | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
+ src/qemu/qemu_domain.h   |  6 ++++
+ src/qemu/qemu_security.c | 58 ++++++++++++++++++++++++++++++++++++++
+ src/qemu/qemu_security.h |  6 ++++
+ 4 files changed, 142 insertions(+)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index dbe9ed5e98..138f773c22 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -9997,6 +9997,78 @@ qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr driver,
+ }
+ 
+ 
++int
++qemuDomainNamespaceSetupInput(virDomainObjPtr vm,
++                              virDomainInputDefPtr input)
++{
++    qemuDomainObjPrivatePtr priv = vm->privateData;
++    virQEMUDriverPtr driver = priv->driver;
++    virQEMUDriverConfigPtr cfg = NULL;
++    char **devMountsPath = NULL;
++    size_t ndevMountsPath = 0;
++    const char *path = NULL;
++    int ret = -1;
++
++    if (!(path = virDomainInputDefGetPath(input)))
++        return 0;
++
++    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
++        return 0;
++
++    cfg = virQEMUDriverGetConfig(driver);
++    if (qemuDomainGetPreservedMounts(cfg, vm,
++                                     &devMountsPath, NULL,
++                                     &ndevMountsPath) < 0)
++        goto cleanup;
++
++    if (qemuDomainAttachDeviceMknod(driver, vm, path,
++                                    devMountsPath, ndevMountsPath) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    virStringListFreeCount(devMountsPath, ndevMountsPath);
++    virObjectUnref(cfg);
++    return ret;
++}
++
++
++int
++qemuDomainNamespaceTeardownInput(virDomainObjPtr vm,
++                                 virDomainInputDefPtr input)
++{
++    qemuDomainObjPrivatePtr priv = vm->privateData;
++    virQEMUDriverPtr driver = priv->driver;
++    virQEMUDriverConfigPtr cfg = NULL;
++    char **devMountsPath = NULL;
++    size_t ndevMountsPath = 0;
++    const char *path = NULL;
++    int ret = -1;
++
++    if (!(path = virDomainInputDefGetPath(input)))
++        return 0;
++
++    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
++        return 0;
++
++    cfg = virQEMUDriverGetConfig(driver);
++    if (qemuDomainGetPreservedMounts(cfg, vm,
++                                     &devMountsPath, NULL,
++                                     &ndevMountsPath) < 0)
++        goto cleanup;
++
++    if (qemuDomainDetachDeviceUnlink(driver, vm, path,
++                                     devMountsPath, ndevMountsPath) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    virStringListFreeCount(devMountsPath, ndevMountsPath);
++    virObjectUnref(cfg);
++    return ret;
++}
++
++
+ /**
+  * qemuDomainDiskLookupByNodename:
+  * @def: domain definition to look for the disk
+diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
+index caf583373f..1a82922415 100644
+--- a/src/qemu/qemu_domain.h
++++ b/src/qemu/qemu_domain.h
+@@ -969,6 +969,12 @@ int qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr driver,
+                                    virDomainObjPtr vm,
+                                    virDomainRNGDefPtr rng);
+ 
++int qemuDomainNamespaceSetupInput(virDomainObjPtr vm,
++                                  virDomainInputDefPtr input);
++
++int qemuDomainNamespaceTeardownInput(virDomainObjPtr vm,
++                                     virDomainInputDefPtr input);
++
+ virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virDomainDefPtr def,
+                                                    const char *nodename,
+                                                    virStorageSourcePtr *src,
+diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c
+index 6fc3b0bb6e..e7d2bbd5a3 100644
+--- a/src/qemu/qemu_security.c
++++ b/src/qemu/qemu_security.c
+@@ -306,3 +306,61 @@ qemuSecurityRestoreMemoryLabel(virQEMUDriverPtr driver,
+     virSecurityManagerTransactionAbort(driver->securityManager);
+     return ret;
+ }
++
++
++int
++qemuSecuritySetInputLabel(virDomainObjPtr vm,
++                          virDomainInputDefPtr input)
++{
++    qemuDomainObjPrivatePtr priv = vm->privateData;
++    virQEMUDriverPtr driver = priv->driver;
++    int ret = -1;
++
++    if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
++        virSecurityManagerTransactionStart(driver->securityManager) < 0)
++        goto cleanup;
++
++    if (virSecurityManagerSetInputLabel(driver->securityManager,
++                                        vm->def,
++                                        input) < 0)
++        goto cleanup;
++
++    if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
++        virSecurityManagerTransactionCommit(driver->securityManager,
++                                            vm->pid) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    virSecurityManagerTransactionAbort(driver->securityManager);
++    return ret;
++}
++
++
++int
++qemuSecurityRestoreInputLabel(virDomainObjPtr vm,
++                              virDomainInputDefPtr input)
++{
++    qemuDomainObjPrivatePtr priv = vm->privateData;
++    virQEMUDriverPtr driver = priv->driver;
++    int ret = -1;
++
++    if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
++        virSecurityManagerTransactionStart(driver->securityManager) < 0)
++        goto cleanup;
++
++    if (virSecurityManagerRestoreInputLabel(driver->securityManager,
++                                            vm->def,
++                                            input) < 0)
++        goto cleanup;
++
++    if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
++        virSecurityManagerTransactionCommit(driver->securityManager,
++                                            vm->pid) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    virSecurityManagerTransactionAbort(driver->securityManager);
++    return ret;
++}
+diff --git a/src/qemu/qemu_security.h b/src/qemu/qemu_security.h
+index 7b25855bf9..76d63f06ec 100644
+--- a/src/qemu/qemu_security.h
++++ b/src/qemu/qemu_security.h
+@@ -70,6 +70,12 @@ int qemuSecurityRestoreMemoryLabel(virQEMUDriverPtr driver,
+                                    virDomainObjPtr vm,
+                                    virDomainMemoryDefPtr mem);
+ 
++int qemuSecuritySetInputLabel(virDomainObjPtr vm,
++                              virDomainInputDefPtr input);
++
++int qemuSecurityRestoreInputLabel(virDomainObjPtr vm,
++                                  virDomainInputDefPtr input);
++
+ /* Please note that for these APIs there is no wrapper yet. Do NOT blindly add
+  * new APIs here. If an API can touch a /dev file add a proper wrapper instead.
+  */
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-hotplug-Add-validation-for-coldplug-of-individual-vcpus.patch b/SOURCES/libvirt-qemu-hotplug-Add-validation-for-coldplug-of-individual-vcpus.patch
deleted file mode 100644
index 52d8305..0000000
--- a/SOURCES/libvirt-qemu-hotplug-Add-validation-for-coldplug-of-individual-vcpus.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From 2d773381c7dd2d015a0890db36df64c76a6bfe46 Mon Sep 17 00:00:00 2001
-Message-Id: <2d773381c7dd2d015a0890db36df64c76a6bfe46@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 4 Apr 2017 09:31:23 +0200
-Subject: [PATCH] qemu: hotplug: Add validation for coldplug of individual
- vcpus
-
-Validate that users don't try to disable vcpu 0.
-
-(cherry picked from commit ee86d45de35bff5f75d1583701cc9514b59e747c)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1437010
----
- src/qemu/qemu_hotplug.c | 20 ++++++++++++++++++++
- 1 file changed, 20 insertions(+)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index 5488b1dd4..999c8b804 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -5875,6 +5875,21 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
- }
- 
- 
-+static int
-+qemuDomainVcpuValidateConfig(virBitmapPtr map,
-+                             bool state)
-+{
-+    /* vcpu 0 can't be disabled */
-+    if (!state && virBitmapIsBitSet(map, 0)) {
-+        virReportError(VIR_ERR_INVALID_ARG, "%s",
-+                       _("vCPU '0' must be enabled"));
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+
- int
- qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
-                           virDomainObjPtr vm,
-@@ -5909,6 +5924,11 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
-         }
-     }
- 
-+    if (persistentDef) {
-+        if (qemuDomainVcpuValidateConfig(map, state) < 0)
-+            goto cleanup;
-+    }
-+
-     if (livevcpus &&
-         qemuDomainSetVcpusLive(driver, cfg, vm, livevcpus, state) < 0)
-         goto cleanup;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-hotplug-Clear-vcpu-ordering-for-coldplug-of-vcpus.patch b/SOURCES/libvirt-qemu-hotplug-Clear-vcpu-ordering-for-coldplug-of-vcpus.patch
deleted file mode 100644
index a44491d..0000000
--- a/SOURCES/libvirt-qemu-hotplug-Clear-vcpu-ordering-for-coldplug-of-vcpus.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 3c2e5075ef3be22f203177cc9a1a912546d37ffe Mon Sep 17 00:00:00 2001
-Message-Id: <3c2e5075ef3be22f203177cc9a1a912546d37ffe@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 4 Apr 2017 09:31:22 +0200
-Subject: [PATCH] qemu: hotplug: Clear vcpu ordering for coldplug of vcpus
-
-Vcpu order is required to stay sequential. Clear the order on cpu
-coldplug to avoid issues with removing vcpus out of sequence.
-
-(cherry picked from commit b416a33a6f49b7755a65d0de4ee09c770b79cc8d)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1437010
----
- src/qemu/qemu_hotplug.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index 48de6b815..5488b1dd4 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -5784,13 +5784,15 @@ qemuDomainSetVcpuConfig(virDomainDefPtr def,
- 
-     def->individualvcpus = true;
- 
-+    /* ordering information may become invalid, thus clear it */
-+    virDomainDefVcpuOrderClear(def);
-+
-     while ((next = virBitmapNextSetBit(map, next)) >= 0) {
-         if (!(vcpu = virDomainDefGetVcpu(def, next)))
-             continue;
- 
-         vcpu->online = state;
-         vcpu->hotpluggable = VIR_TRISTATE_BOOL_YES;
--        vcpu->order = 0;
-     }
- }
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-hotplug-Don-t-save-status-XML-when-monitor-is-closed.patch b/SOURCES/libvirt-qemu-hotplug-Don-t-save-status-XML-when-monitor-is-closed.patch
deleted file mode 100644
index 1683c56..0000000
--- a/SOURCES/libvirt-qemu-hotplug-Don-t-save-status-XML-when-monitor-is-closed.patch
+++ /dev/null
@@ -1,107 +0,0 @@
-From 1cf501e2f4cb1e6840ddb8a8f7b051936f0f8b18 Mon Sep 17 00:00:00 2001
-Message-Id: <1cf501e2f4cb1e6840ddb8a8f7b051936f0f8b18@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Thu, 20 Apr 2017 11:33:10 +0200
-Subject: [PATCH] qemu: hotplug: Don't save status XML when monitor is closed
-
-In the vcpu hotplug code if exit from the monitor failed we would still
-attempt to save the status XML. When the daemon is terminated the
-monitor socket is closed. In such case, the written status XML would not
-contain the monitor path and thus be invalid.
-
-Avoid this issue by only saving status XML on success of the monitor
-command.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1439452
-(cherry picked from commit 355f5ab998994d40e011cec491483506bbefe04f)
----
- src/qemu/qemu_hotplug.c | 29 ++++++++++++++++-------------
- 1 file changed, 16 insertions(+), 13 deletions(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index 79d0dc94e..120bcdc62 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -5386,6 +5386,7 @@ qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver,
- 
- static int
- qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
-+                         virQEMUDriverConfigPtr cfg,
-                          virDomainObjPtr vm,
-                          unsigned int vcpu)
- {
-@@ -5427,6 +5428,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
-     if (qemuDomainRemoveVcpu(driver, vm, vcpu) < 0)
-         goto cleanup;
- 
-+    qemuDomainVcpuPersistOrder(vm->def);
-+
-+    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
-+        goto cleanup;
-+
-     ret = 0;
- 
-  cleanup:
-@@ -5437,6 +5443,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
- 
- static int
- qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
-+                         virQEMUDriverConfigPtr cfg,
-                          virDomainObjPtr vm,
-                          unsigned int vcpu)
- {
-@@ -5497,6 +5504,11 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
-     if (qemuDomainValidateVcpuInfo(vm) < 0)
-         goto cleanup;
- 
-+    qemuDomainVcpuPersistOrder(vm->def);
-+
-+    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
-+        goto cleanup;
-+
-     ret = 0;
- 
-  cleanup:
-@@ -5611,7 +5623,6 @@ qemuDomainSetVcpusLive(virQEMUDriverPtr driver,
-     qemuDomainObjPrivatePtr priv = vm->privateData;
-     qemuCgroupEmulatorAllNodesDataPtr emulatorCgroup = NULL;
-     ssize_t nextvcpu = -1;
--    int rc = 0;
-     int ret = -1;
- 
-     if (qemuCgroupEmulatorAllNodesAllow(priv->cgroup, &emulatorCgroup) < 0)
-@@ -5619,27 +5630,19 @@ qemuDomainSetVcpusLive(virQEMUDriverPtr driver,
- 
-     if (enable) {
-         while ((nextvcpu = virBitmapNextSetBit(vcpumap, nextvcpu)) != -1) {
--            if ((rc = qemuDomainHotplugAddVcpu(driver, vm, nextvcpu)) < 0)
--                break;
-+            if (qemuDomainHotplugAddVcpu(driver, cfg, vm, nextvcpu) < 0)
-+                goto cleanup;
-         }
-     } else {
-         for (nextvcpu = virDomainDefGetVcpusMax(vm->def) - 1; nextvcpu >= 0; nextvcpu--) {
-             if (!virBitmapIsBitSet(vcpumap, nextvcpu))
-                 continue;
- 
--            if ((rc = qemuDomainHotplugDelVcpu(driver, vm, nextvcpu)) < 0)
--                break;
-+            if (qemuDomainHotplugDelVcpu(driver, cfg, vm, nextvcpu) < 0)
-+                goto cleanup;
-         }
-     }
- 
--    qemuDomainVcpuPersistOrder(vm->def);
--
--    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
--        goto cleanup;
--
--    if (rc < 0)
--        goto cleanup;
--
-     ret = 0;
- 
-  cleanup:
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-hotplug-Fix-formatting-strings-in-qemuDomainFilterHotplugVcpuEntities.patch b/SOURCES/libvirt-qemu-hotplug-Fix-formatting-strings-in-qemuDomainFilterHotplugVcpuEntities.patch
deleted file mode 100644
index e814390..0000000
--- a/SOURCES/libvirt-qemu-hotplug-Fix-formatting-strings-in-qemuDomainFilterHotplugVcpuEntities.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From 498fbdbe081260f7e42a1659e11912f9f2c0e5ad Mon Sep 17 00:00:00 2001
-Message-Id: <498fbdbe081260f7e42a1659e11912f9f2c0e5ad@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 4 Apr 2017 09:31:21 +0200
-Subject: [PATCH] qemu: hotplug: Fix formatting strings in
- qemuDomainFilterHotplugVcpuEntities
-
-'next' is declared as 'ssize_t' so use '%zd'
-
-(cherry picked from commit 86d69c309181ed7782427261abd85a4b3fdc704f)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1437010
----
- src/qemu/qemu_hotplug.c | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index b5b520d8c..48de6b815 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -5823,13 +5823,13 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
- 
-         if (vcpu->online == state) {
-             virReportError(VIR_ERR_INVALID_ARG,
--                           _("vcpu '%zu' is already in requested state"), next);
-+                           _("vcpu '%zd' is already in requested state"), next);
-             goto cleanup;
-         }
- 
-         if (vcpu->online && !vcpu->hotpluggable) {
-             virReportError(VIR_ERR_INVALID_ARG,
--                           _("vcpu '%zu' can't be hotunplugged"), next);
-+                           _("vcpu '%zd' can't be hotunplugged"), next);
-             goto cleanup;
-         }
-     }
-@@ -5845,7 +5845,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
- 
-         if (vcpupriv->vcpus == 0) {
-             virReportError(VIR_ERR_INVALID_ARG,
--                           _("vcpu '%zu' belongs to a larger hotpluggable entity, "
-+                           _("vcpu '%zd' belongs to a larger hotpluggable entity, "
-                              "but siblings were not selected"), next);
-             goto cleanup;
-         }
-@@ -5854,7 +5854,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
-             if (!virBitmapIsBitSet(map, i)) {
-                 virReportError(VIR_ERR_INVALID_ARG,
-                                _("vcpu '%zu' was not selected but it belongs to "
--                                 "hotpluggable entity '%zu-%zu' which was "
-+                                 "hotpluggable entity '%zd-%zd' which was "
-                                  "partially selected"),
-                                i, next, next + vcpupriv->vcpus - 1);
-                 goto cleanup;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-hotplug-Iterate-over-vcpu-0-in-individual-vcpu-hotplug-code.patch b/SOURCES/libvirt-qemu-hotplug-Iterate-over-vcpu-0-in-individual-vcpu-hotplug-code.patch
deleted file mode 100644
index 40d40ca..0000000
--- a/SOURCES/libvirt-qemu-hotplug-Iterate-over-vcpu-0-in-individual-vcpu-hotplug-code.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From 9dcf5d0029fe9b1e1e17b20070702bc1ce6382ad Mon Sep 17 00:00:00 2001
-Message-Id: <9dcf5d0029fe9b1e1e17b20070702bc1ce6382ad@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 4 Apr 2017 09:31:20 +0200
-Subject: [PATCH] qemu: hotplug: Iterate over vcpu 0 in individual vcpu hotplug
- code
-
-Buggy condition meant that vcpu0 would not be iterated in the checks.
-Since it's not hotpluggable anyways we would not be able to break the
-configuration of a live VM.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1437013
-(cherry picked from commit 315f443dbb9f821fb207c30585e01dfbaac01878)
----
- src/qemu/qemu_hotplug.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index de561da58..b5b520d8c 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -5784,7 +5784,7 @@ qemuDomainSetVcpuConfig(virDomainDefPtr def,
- 
-     def->individualvcpus = true;
- 
--    while ((next = virBitmapNextSetBit(map, next)) > 0) {
-+    while ((next = virBitmapNextSetBit(map, next)) >= 0) {
-         if (!(vcpu = virDomainDefGetVcpu(def, next)))
-             continue;
- 
-@@ -5817,7 +5817,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
-         return NULL;
- 
-     /* make sure that all selected vcpus are in the correct state */
--    while ((next = virBitmapNextSetBit(map, next)) > 0) {
-+    while ((next = virBitmapNextSetBit(map, next)) >= 0) {
-         if (!(vcpu = virDomainDefGetVcpu(def, next)))
-             continue;
- 
-@@ -5837,7 +5837,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
-     /* Make sure that all vCPUs belonging to a single hotpluggable entity were
-      * selected and then de-select any sub-threads of it. */
-     next = -1;
--    while ((next = virBitmapNextSetBit(map, next)) > 0) {
-+    while ((next = virBitmapNextSetBit(map, next)) >= 0) {
-         if (!(vcpu = virDomainDefGetVcpu(def, next)))
-             continue;
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-hotplug-Unexport-qemuDomainHotplugDelVcpu.patch b/SOURCES/libvirt-qemu-hotplug-Unexport-qemuDomainHotplugDelVcpu.patch
deleted file mode 100644
index f560a5b..0000000
--- a/SOURCES/libvirt-qemu-hotplug-Unexport-qemuDomainHotplugDelVcpu.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From abb3d4b218479bb4609a208491448bc70b0d356d Mon Sep 17 00:00:00 2001
-Message-Id: <abb3d4b218479bb4609a208491448bc70b0d356d@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Thu, 20 Apr 2017 11:33:09 +0200
-Subject: [PATCH] qemu: hotplug: Unexport qemuDomainHotplugDelVcpu
-
-The function is used only in the hotplug module.
-
-(cherry picked from commit f24dc5e2c2ad184e64d8e80f196cee5006fc7e10)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439452
----
- src/qemu/qemu_hotplug.c | 2 +-
- src/qemu/qemu_hotplug.h | 3 ---
- 2 files changed, 1 insertion(+), 4 deletions(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index 37b8d455c..79d0dc94e 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -5384,7 +5384,7 @@ qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver,
- }
- 
- 
--int
-+static int
- qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
-                          virDomainObjPtr vm,
-                          unsigned int vcpu)
-diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h
-index f06f232bb..985c6733f 100644
---- a/src/qemu/qemu_hotplug.h
-+++ b/src/qemu/qemu_hotplug.h
-@@ -140,9 +140,6 @@ int qemuDomainDetachRNGDevice(virQEMUDriverPtr driver,
-                               virDomainObjPtr vm,
-                               virDomainRNGDefPtr rng);
- 
--int qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
--                             virDomainObjPtr vm,
--                             unsigned int vcpu);
- void qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver,
-                                virDomainObjPtr vm,
-                                const char *alias);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-hotplug-Validate-that-vcpu-hotplug-does-not-break-config.patch b/SOURCES/libvirt-qemu-hotplug-Validate-that-vcpu-hotplug-does-not-break-config.patch
deleted file mode 100644
index 4245ade..0000000
--- a/SOURCES/libvirt-qemu-hotplug-Validate-that-vcpu-hotplug-does-not-break-config.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From b6f6759fcada504563b4c439975bee66fd611162 Mon Sep 17 00:00:00 2001
-Message-Id: <b6f6759fcada504563b4c439975bee66fd611162@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 4 Apr 2017 09:31:24 +0200
-Subject: [PATCH] qemu: hotplug: Validate that vcpu-hotplug does not break
- config
-
-Make sure that non-hotpluggable vcpus stay clustered at the beginning
-after modifying persistent definition.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1437010
-(cherry picked from commit 079832103c3b7883e36db90705631cc55cac9dcc)
----
- src/qemu/qemu_hotplug.c | 26 ++++++++++++++++++++++++--
- 1 file changed, 24 insertions(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index 999c8b804..a6dac6f09 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -5876,9 +5876,14 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
- 
- 
- static int
--qemuDomainVcpuValidateConfig(virBitmapPtr map,
-+qemuDomainVcpuValidateConfig(virDomainDefPtr def,
-+                             virBitmapPtr map,
-                              bool state)
- {
-+    virDomainVcpuDefPtr vcpu;
-+    size_t maxvcpus = virDomainDefGetVcpusMax(def);
-+    ssize_t next;
-+
-     /* vcpu 0 can't be disabled */
-     if (!state && virBitmapIsBitSet(map, 0)) {
-         virReportError(VIR_ERR_INVALID_ARG, "%s",
-@@ -5886,6 +5891,23 @@ qemuDomainVcpuValidateConfig(virBitmapPtr map,
-         return -1;
-     }
- 
-+    /* non-hotpluggable vcpus need to stay clustered starting from vcpu 0 */
-+    for (next = virBitmapNextSetBit(map, -1) + 1; next < maxvcpus; next++) {
-+        if (!(vcpu = virDomainDefGetVcpu(def, next)))
-+            continue;
-+
-+        /* skip vcpus being modified */
-+        if (virBitmapIsBitSet(map, next))
-+            continue;
-+
-+        if (vcpu->online && vcpu->hotpluggable == VIR_TRISTATE_BOOL_NO) {
-+            virReportError(VIR_ERR_INVALID_ARG,
-+                           _("vcpu '%zd' can't be modified as it is followed "
-+                             "by non-hotpluggable online vcpus"), next);
-+            return -1;
-+        }
-+    }
-+
-     return 0;
- }
- 
-@@ -5925,7 +5947,7 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
-     }
- 
-     if (persistentDef) {
--        if (qemuDomainVcpuValidateConfig(map, state) < 0)
-+        if (qemuDomainVcpuValidateConfig(persistentDef, map, state) < 0)
-             goto cleanup;
-     }
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-improve-detection-of-UNIX-path-generated-by-libvirt.patch b/SOURCES/libvirt-qemu-improve-detection-of-UNIX-path-generated-by-libvirt.patch
deleted file mode 100644
index 009c002..0000000
--- a/SOURCES/libvirt-qemu-improve-detection-of-UNIX-path-generated-by-libvirt.patch
+++ /dev/null
@@ -1,229 +0,0 @@
-From b5c438b6dba5efe46a8489bde49201d953367c07 Mon Sep 17 00:00:00 2001
-Message-Id: <b5c438b6dba5efe46a8489bde49201d953367c07@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Tue, 16 May 2017 11:46:13 +0200
-Subject: [PATCH] qemu: improve detection of UNIX path generated by libvirt
-
-Currently we consider all UNIX paths with specific prefix as generated
-by libvirt, but that's a wrong assumption.  Let's make the detection
-better by actually checking whether the whole path matches one of the
-paths that we generate or generated in the past.
-
-The UNIX path isn't stored in config XML since libvirt-1.3.1.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1446980
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit ed996604464ab1652ad8d2de3ac446f460dd2ab1)
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c                             | 66 +++++++++++++++++-----
- .../qemuxml2argv-channel-unix-source-path.xml      | 29 ++++++++++
- .../qemuxml2xmlout-channel-unix-source-path.xml    | 45 +++++++++++++++
- tests/qemuxml2xmltest.c                            |  2 +
- 4 files changed, 128 insertions(+), 14 deletions(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-unix-source-path.xml
- create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-unix-source-path.xml
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 5ef3d0577..117c6142b 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -3123,24 +3123,58 @@ qemuDomainDefaultNetModel(const virDomainDef *def,
- 
- 
- /*
-- * Clear auto generated unix socket path, i.e., the one which starts with our
-- * channel directory.
-+ * Clear auto generated unix socket paths:
-+ *
-+ * libvirt 1.2.18 and older:
-+ *     {cfg->channelTargetDir}/{dom-name}.{target-name}
-+ *
-+ * libvirt 1.2.19 - 1.3.2:
-+ *     {cfg->channelTargetDir}/domain-{dom-name}/{target-name}
-+ *
-+ * libvirt 1.3.3 and newer:
-+ *     {cfg->channelTargetDir}/domain-{dom-id}-{short-dom-name}/{target-name}
-+ *
-+ * The unix socket path was stored in config XML until libvirt 1.3.0.
-+ * If someone specifies the same path as we generate, they shouldn't do it.
-+ *
-+ * This function clears the path for migration as well, so we need to clear
-+ * the path even if we are not storing it in the XML.
-  */
--static void
-+static int
- qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr,
-                                 virQEMUDriverPtr driver)
- {
--    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-+    virQEMUDriverConfigPtr cfg;
-+    virBuffer buf = VIR_BUFFER_INITIALIZER;
-+    char *regexp = NULL;
-+    int ret = -1;
- 
--    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
--        chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
--        chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX &&
--        chr->source->data.nix.path &&
--        STRPREFIX(chr->source->data.nix.path, cfg->channelTargetDir)) {
--        VIR_FREE(chr->source->data.nix.path);
-+    if (chr->deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL ||
-+        chr->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO ||
-+        chr->source->type != VIR_DOMAIN_CHR_TYPE_UNIX ||
-+        !chr->source->data.nix.path) {
-+        return 0;
-     }
- 
-+    cfg = virQEMUDriverGetConfig(driver);
-+
-+    virBufferEscapeRegex(&buf, "^%s", cfg->channelTargetDir);
-+    virBufferAddLit(&buf, "/([^/]+\\.)|(domain-[^/]+/)");
-+    virBufferEscapeRegex(&buf, "%s$", chr->target.name);
-+
-+    if (virBufferCheckError(&buf) < 0)
-+        goto cleanup;
-+
-+    regexp = virBufferContentAndReset(&buf);
-+
-+    if (virStringMatch(chr->source->data.nix.path, regexp))
-+        VIR_FREE(chr->source->data.nix.path);
-+
-+    ret = 0;
-+ cleanup:
-+    VIR_FREE(regexp);
-     virObjectUnref(cfg);
-+    return ret;
- }
- 
- 
-@@ -3408,8 +3442,10 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
- 
-     /* clear auto generated unix socket path for inactive definitions */
-     if ((parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
--        dev->type == VIR_DOMAIN_DEVICE_CHR)
--        qemuDomainChrDefDropDefaultPath(dev->data.chr, driver);
-+        dev->type == VIR_DOMAIN_DEVICE_CHR) {
-+        if (qemuDomainChrDefDropDefaultPath(dev->data.chr, driver) < 0)
-+            goto cleanup;
-+    }
- 
-     /* forbid capabilities mode hostdev in this kind of hypervisor */
-     if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
-@@ -4195,8 +4231,10 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
-             }
-         }
- 
--        for (i = 0; i < def->nchannels; i++)
--            qemuDomainChrDefDropDefaultPath(def->channels[i], driver);
-+        for (i = 0; i < def->nchannels; i++) {
-+            if (qemuDomainChrDefDropDefaultPath(def->channels[i], driver) < 0)
-+                goto cleanup;
-+        }
-     }
- 
-  format:
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-unix-source-path.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-unix-source-path.xml
-new file mode 100644
-index 000000000..42cb3c387
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-unix-source-path.xml
-@@ -0,0 +1,29 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219100</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+  </os>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <channel type='unix'>
-+      <source mode='bind' path='/tmp/channel/QEMUGuest1.org.qemu.guest_agent.0'/>
-+      <target type='virtio' name='org.qemu.guest_agent.0'/>
-+    </channel>
-+    <channel type='unix'>
-+      <source mode='bind' path='/tmp/channel/domain-QEMUGuest1/org.qemu.guest_agent.1'/>
-+      <target type='virtio' name='org.qemu.guest_agent.1'/>
-+    </channel>
-+    <channel type='unix'>
-+      <source mode='bind' path='/tmp/channel/domain-1-QEMUGuest1/org.qemu.guest_agent.2'/>
-+      <target type='virtio' name='org.qemu.guest_agent.2'/>
-+    </channel>
-+    <channel type='unix'>
-+      <source mode='bind' path='/tmp/channel/QEMUGuest1/org.qemu.guest_agent.3'/>
-+      <target type='virtio' name='org.qemu.guest_agent.3'/>
-+    </channel>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-unix-source-path.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-unix-source-path.xml
-new file mode 100644
-index 000000000..2d8fa1e3a
---- /dev/null
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-unix-source-path.xml
-@@ -0,0 +1,45 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219100</memory>
-+  <currentMemory unit='KiB'>219100</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <controller type='usb' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
-+    </controller>
-+    <controller type='pci' index='0' model='pci-root'/>
-+    <controller type='virtio-serial' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
-+    </controller>
-+    <channel type='unix'>
-+      <target type='virtio' name='org.qemu.guest_agent.0'/>
-+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
-+    </channel>
-+    <channel type='unix'>
-+      <target type='virtio' name='org.qemu.guest_agent.1'/>
-+      <address type='virtio-serial' controller='0' bus='0' port='2'/>
-+    </channel>
-+    <channel type='unix'>
-+      <target type='virtio' name='org.qemu.guest_agent.2'/>
-+      <address type='virtio-serial' controller='0' bus='0' port='3'/>
-+    </channel>
-+    <channel type='unix'>
-+      <source mode='bind' path='/tmp/channel/QEMUGuest1/org.qemu.guest_agent.3'/>
-+      <target type='virtio' name='org.qemu.guest_agent.3'/>
-+      <address type='virtio-serial' controller='0' bus='0' port='4'/>
-+    </channel>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
-index 26a2259fd..ff533ab19 100644
---- a/tests/qemuxml2xmltest.c
-+++ b/tests/qemuxml2xmltest.c
-@@ -555,6 +555,8 @@ mymain(void)
-     DO_TEST("channel-virtio", NONE);
-     DO_TEST("channel-virtio-state", NONE);
- 
-+    DO_TEST_FULL("channel-unix-source-path", WHEN_INACTIVE, GIC_NONE, NONE);
-+
-     DO_TEST("hostdev-usb-address", NONE);
-     DO_TEST("hostdev-pci-address", NONE);
-     DO_TEST("hostdev-vfio", NONE);
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-introduce-QEMU_CAPS_DEVICE_QEMU_XHCI.patch b/SOURCES/libvirt-qemu-introduce-QEMU_CAPS_DEVICE_QEMU_XHCI.patch
deleted file mode 100644
index ef575a4..0000000
--- a/SOURCES/libvirt-qemu-introduce-QEMU_CAPS_DEVICE_QEMU_XHCI.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From 0ca6807c400aa86fb9316f4fa481c253f0de1311 Mon Sep 17 00:00:00 2001
-Message-Id: <0ca6807c400aa86fb9316f4fa481c253f0de1311@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Fri, 28 Apr 2017 11:59:49 +0200
-Subject: [PATCH] qemu: introduce QEMU_CAPS_DEVICE_QEMU_XHCI
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Acked-by: Andrea Bolognani <abologna@redhat.com>
-(cherry picked from commit 5237a74d4aeb073255a2a7165144a56b9e2e3b53)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1438682
-
-Conflicts:
-    - resolved capabilities flag conflicts due to missing capability
-      in downstream code
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_capabilities.c                     | 2 ++
- src/qemu/qemu_capabilities.h                     | 1 +
- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 +
- 3 files changed, 4 insertions(+)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 49de506ed..b76b79342 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -365,6 +365,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
-               "block-write-threshold",
-               "query-named-block-nodes",
-               "cpu-cache",
-+              "qemu-xhci",
-     );
- 
- 
-@@ -1611,6 +1612,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
-     { "vhost-scsi", QEMU_CAPS_DEVICE_VHOST_SCSI },
-     { "nvdimm", QEMU_CAPS_DEVICE_NVDIMM },
-     { "pcie-root-port", QEMU_CAPS_DEVICE_PCIE_ROOT_PORT },
-+    { "qemu-xhci", QEMU_CAPS_DEVICE_QEMU_XHCI },
- };
- 
- static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = {
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index 644b8e27b..1cd3ec37d 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -402,6 +402,7 @@ typedef enum {
-     QEMU_CAPS_BLOCK_WRITE_THRESHOLD, /* BLOCK_WRITE_THRESHOLD event */
-     QEMU_CAPS_QUERY_NAMED_BLOCK_NODES, /* qmp query-named-block-nodes */
-     QEMU_CAPS_CPU_CACHE, /* -cpu supports host-cache-info and l3-cache properties */
-+    QEMU_CAPS_DEVICE_QEMU_XHCI, /* -device qemu-xhci */
- 
-     QEMU_CAPS_LAST /* this must always be the last item */
- } virQEMUCapsFlags;
-diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-index 496c9ceb8..83ed0f1c6 100644
---- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
-@@ -208,6 +208,7 @@
-   <flag name='block-write-threshold'/>
-   <flag name='query-named-block-nodes'/>
-   <flag name='cpu-cache'/>
-+  <flag name='qemu-xhci'/>
-   <version>2008090</version>
-   <kvmVersion>0</kvmVersion>
-   <package> (v2.9.0-rc0-142-g940a8ce)</package>
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-introduce-QEMU_DOMAIN_JOB_STATUS_POSTCOPY.patch b/SOURCES/libvirt-qemu-introduce-QEMU_DOMAIN_JOB_STATUS_POSTCOPY.patch
deleted file mode 100644
index 2db5463..0000000
--- a/SOURCES/libvirt-qemu-introduce-QEMU_DOMAIN_JOB_STATUS_POSTCOPY.patch
+++ /dev/null
@@ -1,171 +0,0 @@
-From 626d23419335db221e7b52a5bc07ad4f74391199 Mon Sep 17 00:00:00 2001
-Message-Id: <626d23419335db221e7b52a5bc07ad4f74391199@dist-git>
-From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
-Date: Fri, 1 Sep 2017 09:49:21 +0300
-Subject: [PATCH] qemu: introduce QEMU_DOMAIN_JOB_STATUS_POSTCOPY
-
-Let's introduce QEMU_DOMAIN_JOB_STATUS_POSTCOPY state for job.current->status
-instead of checking job.current->stats.status. The latter can be changed
-when fetching migration statistics. Moving state function from the variable
-and leave only store function seems more managable.
-
-This patch removes all state checking usage of stats except for
-qemuDomainGetJobStatsInternal. This place will be handled separately.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 09f57f9aaca6d2703567d5cda45d47fc06131ae0)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530130
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c    |  1 +
- src/qemu/qemu_domain.h    |  1 +
- src/qemu/qemu_driver.c    |  5 +++--
- src/qemu/qemu_migration.c | 18 +++++++++++-------
- src/qemu/qemu_process.c   |  4 ++--
- 5 files changed, 18 insertions(+), 11 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index c9b3e13892..329ec6e2ce 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -397,6 +397,7 @@ qemuDomainJobStatusToType(qemuDomainJobStatus status)
-         break;
- 
-     case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
-+    case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
-         return VIR_DOMAIN_JOB_UNBOUNDED;
- 
-     case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index e4e672f872..c8b3873b9f 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -102,6 +102,7 @@ VIR_ENUM_DECL(qemuDomainAsyncJob)
- typedef enum {
-     QEMU_DOMAIN_JOB_STATUS_NONE = 0,
-     QEMU_DOMAIN_JOB_STATUS_ACTIVE,
-+    QEMU_DOMAIN_JOB_STATUS_POSTCOPY,
-     QEMU_DOMAIN_JOB_STATUS_COMPLETED,
-     QEMU_DOMAIN_JOB_STATUS_FAILED,
-     QEMU_DOMAIN_JOB_STATUS_CANCELED,
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index a271f60abf..ecba87a121 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -12971,7 +12971,8 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
-     }
-     *jobInfo = *info;
- 
--    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE) {
-+    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
-+        jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-         if (fetch)
-             ret = qemuMigrationFetchJobStatus(driver, vm, QEMU_ASYNC_JOB_NONE,
-                                               jobInfo);
-@@ -13105,7 +13106,7 @@ static int qemuDomainAbortJob(virDomainPtr dom)
-     }
- 
-     if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT &&
--        (priv->job.current->stats.status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY ||
-+        (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY ||
-          (virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED &&
-           reason == VIR_DOMAIN_PAUSED_POSTCOPY))) {
-         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 500f467f25..1726349f94 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -1333,6 +1333,10 @@ static void
- qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
- {
-     switch ((qemuMonitorMigrationStatus) jobInfo->stats.status) {
-+    case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY:
-+        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_POSTCOPY;
-+        break;
-+
-     case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
-         jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
-         break;
-@@ -1351,7 +1355,6 @@ qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
- 
-     case QEMU_MONITOR_MIGRATION_STATUS_SETUP:
-     case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE:
--    case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY:
-     case QEMU_MONITOR_MIGRATION_STATUS_CANCELLING:
-     case QEMU_MONITOR_MIGRATION_STATUS_LAST:
-         break;
-@@ -1457,6 +1460,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
-         break;
- 
-     case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
-+    case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
-         break;
-     }
-     return 0;
-@@ -1514,8 +1518,7 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
-      * will continue waiting until the migrate state changes to completed.
-      */
-     if (flags & QEMU_MIGRATION_COMPLETED_POSTCOPY &&
--        jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
--        jobInfo->stats.status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY) {
-+        jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-         VIR_DEBUG("Migration switched to post-copy");
-         if (updateStats &&
-             qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0)
-@@ -1529,7 +1532,8 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
-         return 0;
- 
-  error:
--    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE) {
-+    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
-+        jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-         /* The migration was aborted by us rather than QEMU itself. */
-         jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
-         return -2;
-@@ -3824,7 +3828,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
-     else if (rc == -1)
-         goto cleanup;
- 
--    if (priv->job.current->stats.status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY)
-+    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY)
-         inPostCopy = true;
- 
-     /* When migration completed, QEMU will have paused the CPUs for us.
-@@ -3876,7 +3880,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
-         ignore_value(virTimeMillisNow(&priv->job.completed->sent));
-     }
- 
--    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE && !inPostCopy)
-+    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE)
-         priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
- 
-     cookieFlags |= QEMU_MIGRATION_COOKIE_NETWORK |
-@@ -5249,7 +5253,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
-             goto endjob;
-     }
- 
--    if (priv->job.current->stats.status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY)
-+    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY)
-         inPostCopy = true;
- 
-     if (!(flags & VIR_MIGRATE_PAUSED)) {
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 3235cebad0..25de367afc 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -723,8 +723,8 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
-         }
- 
-         if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT) {
--            if (priv->job.current->stats.status ==
--                        QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY) {
-+            if (priv->job.current->status ==
-+                        QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-                 reason = VIR_DOMAIN_PAUSED_POSTCOPY;
-                 detail = VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY;
-             } else {
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-introduce-migrating-job-status.patch b/SOURCES/libvirt-qemu-introduce-migrating-job-status.patch
deleted file mode 100644
index eeb09f8..0000000
--- a/SOURCES/libvirt-qemu-introduce-migrating-job-status.patch
+++ /dev/null
@@ -1,117 +0,0 @@
-From 59dfc370693ee7631f7b538660cfd30f213b0a86 Mon Sep 17 00:00:00 2001
-Message-Id: <59dfc370693ee7631f7b538660cfd30f213b0a86@dist-git>
-From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
-Date: Fri, 1 Sep 2017 09:49:28 +0300
-Subject: [PATCH] qemu: introduce migrating job status
-
-Instead of checking stat.status let's set status to migrating
-as soon as migrate command is send (waiting for completion
-is a good place too).
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 5a274d4fdc0015909fa95e6667922bb249a95bd5)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530130
-
-Conflicts:
-	src/qemu/qemu_migration.c
-            - commit e87d4b9e2f is not backported
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c    | 1 +
- src/qemu/qemu_domain.h    | 1 +
- src/qemu/qemu_driver.c    | 4 +++-
- src/qemu/qemu_migration.c | 9 +++++++--
- 4 files changed, 12 insertions(+), 3 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 4b1ead7d0a..e81d682c00 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -397,6 +397,7 @@ qemuDomainJobStatusToType(qemuDomainJobStatus status)
-         break;
- 
-     case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
-+    case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
-     case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
-         return VIR_DOMAIN_JOB_UNBOUNDED;
- 
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index c8b3873b9f..0cf54d99ae 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -102,6 +102,7 @@ VIR_ENUM_DECL(qemuDomainAsyncJob)
- typedef enum {
-     QEMU_DOMAIN_JOB_STATUS_NONE = 0,
-     QEMU_DOMAIN_JOB_STATUS_ACTIVE,
-+    QEMU_DOMAIN_JOB_STATUS_MIGRATING,
-     QEMU_DOMAIN_JOB_STATUS_POSTCOPY,
-     QEMU_DOMAIN_JOB_STATUS_COMPLETED,
-     QEMU_DOMAIN_JOB_STATUS_FAILED,
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 8972897a28..931f3d344d 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -12934,7 +12934,8 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
-         fetch = false;
- 
-     /* Do not ask QEMU if migration is not even running yet  */
--    if (!priv->job.current || !priv->job.current->stats.status)
-+    if (!priv->job.current ||
-+        priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE)
-         fetch = false;
- 
-     if (fetch) {
-@@ -12970,6 +12971,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
-     *jobInfo = *info;
- 
-     if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
-+        jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
-         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-         if (fetch)
-             ret = qemuMigrationFetchJobStatus(driver, vm, QEMU_ASYNC_JOB_NONE,
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 9f7aad6680..c8cd7ebfa3 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -1460,6 +1460,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
-         break;
- 
-     case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
-+    case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
-     case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
-         break;
-     }
-@@ -1532,7 +1533,8 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
-         return 0;
- 
-  error:
--    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
-+    /* state can not be active at this point */
-+    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
-         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-         /* The migration was aborted by us rather than QEMU itself. */
-         jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
-@@ -1563,6 +1565,8 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
- 
-     flags |= QEMU_MIGRATION_COMPLETED_UPDATE_STATS;
- 
-+    jobInfo->status = QEMU_DOMAIN_JOB_STATUS_MIGRATING;
-+
-     while ((rv = qemuMigrationCompleted(driver, vm, asyncJob,
-                                         dconn, flags)) != 1) {
-         if (rv < 0)
-@@ -3879,7 +3883,8 @@ qemuMigrationRun(virQEMUDriverPtr driver,
-         ignore_value(virTimeMillisNow(&priv->job.completed->sent));
-     }
- 
--    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE)
-+    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
-+        priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING)
-         priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
- 
-     cookieFlags |= QEMU_MIGRATION_COOKIE_NETWORK |
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-introduce-qemu-domain-job-status.patch b/SOURCES/libvirt-qemu-introduce-qemu-domain-job-status.patch
deleted file mode 100644
index 1a31ee5..0000000
--- a/SOURCES/libvirt-qemu-introduce-qemu-domain-job-status.patch
+++ /dev/null
@@ -1,339 +0,0 @@
-From c95e8e44a4b4c07b79cafafe20018c5d2d37bfbd Mon Sep 17 00:00:00 2001
-Message-Id: <c95e8e44a4b4c07b79cafafe20018c5d2d37bfbd@dist-git>
-From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
-Date: Fri, 1 Sep 2017 09:49:20 +0300
-Subject: [PATCH] qemu: introduce qemu domain job status
-
-This patch simply switches code from using VIR_DOMAIN_JOB_* to
-introduced QEMU_DOMAIN_JOB_STATUS_*. Later this gives us freedom
-to introduce states for postcopy and mirroring phases.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 751a1c7f0ade5c9e5ea858bbaf97e39950f821e6)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530130
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c           | 27 ++++++++++++++++++++--
- src/qemu/qemu_domain.h           | 10 +++++++-
- src/qemu/qemu_driver.c           | 10 ++++----
- src/qemu/qemu_migration.c        | 50 +++++++++++++++++++---------------------
- src/qemu/qemu_migration_cookie.c |  2 +-
- src/qemu/qemu_process.c          |  2 +-
- 6 files changed, 65 insertions(+), 36 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 3c2368368f..c9b3e13892 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -389,11 +389,34 @@ qemuDomainJobInfoUpdateDowntime(qemuDomainJobInfoPtr jobInfo)
-     return 0;
- }
- 
-+static virDomainJobType
-+qemuDomainJobStatusToType(qemuDomainJobStatus status)
-+{
-+    switch (status) {
-+    case QEMU_DOMAIN_JOB_STATUS_NONE:
-+        break;
-+
-+    case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
-+        return VIR_DOMAIN_JOB_UNBOUNDED;
-+
-+    case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
-+        return VIR_DOMAIN_JOB_COMPLETED;
-+
-+    case QEMU_DOMAIN_JOB_STATUS_FAILED:
-+        return VIR_DOMAIN_JOB_FAILED;
-+
-+    case QEMU_DOMAIN_JOB_STATUS_CANCELED:
-+        return VIR_DOMAIN_JOB_CANCELLED;
-+    }
-+
-+    return VIR_DOMAIN_JOB_NONE;
-+}
-+
- int
- qemuDomainJobInfoToInfo(qemuDomainJobInfoPtr jobInfo,
-                         virDomainJobInfoPtr info)
- {
--    info->type = jobInfo->type;
-+    info->type = qemuDomainJobStatusToType(jobInfo->status);
-     info->timeElapsed = jobInfo->timeElapsed;
- 
-     info->memTotal = jobInfo->stats.ram_total;
-@@ -553,7 +576,7 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
-                              stats->cpu_throttle_percentage) < 0)
-         goto error;
- 
--    *type = jobInfo->type;
-+    *type = qemuDomainJobStatusToType(jobInfo->status);
-     *params = par;
-     *nparams = npar;
-     return 0;
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 7002407218..e4e672f872 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -99,10 +99,18 @@ typedef enum {
- } qemuDomainAsyncJob;
- VIR_ENUM_DECL(qemuDomainAsyncJob)
- 
-+typedef enum {
-+    QEMU_DOMAIN_JOB_STATUS_NONE = 0,
-+    QEMU_DOMAIN_JOB_STATUS_ACTIVE,
-+    QEMU_DOMAIN_JOB_STATUS_COMPLETED,
-+    QEMU_DOMAIN_JOB_STATUS_FAILED,
-+    QEMU_DOMAIN_JOB_STATUS_CANCELED,
-+} qemuDomainJobStatus;
-+
- typedef struct _qemuDomainJobInfo qemuDomainJobInfo;
- typedef qemuDomainJobInfo *qemuDomainJobInfoPtr;
- struct _qemuDomainJobInfo {
--    virDomainJobType type;
-+    qemuDomainJobStatus status;
-     virDomainJobOperation operation;
-     unsigned long long started; /* When the async job started */
-     unsigned long long stopped; /* When the domain's CPUs were stopped */
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 1c60d533e8..a271f60abf 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -3299,7 +3299,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-         goto endjob;
-     }
- 
--    priv->job.current->type = VIR_DOMAIN_JOB_UNBOUNDED;
-+    priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
- 
-     /* Pause */
-     if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
-@@ -12965,13 +12965,13 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
-         info = priv->job.current;
- 
-     if (!info) {
--        jobInfo->type = VIR_DOMAIN_JOB_NONE;
-+        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_NONE;
-         ret = 0;
-         goto cleanup;
-     }
-     *jobInfo = *info;
- 
--    if (jobInfo->type == VIR_DOMAIN_JOB_UNBOUNDED) {
-+    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE) {
-         if (fetch)
-             ret = qemuMigrationFetchJobStatus(driver, vm, QEMU_ASYNC_JOB_NONE,
-                                               jobInfo);
-@@ -13006,7 +13006,7 @@ qemuDomainGetJobInfo(virDomainPtr dom,
-     if (qemuDomainGetJobStatsInternal(driver, vm, false, &jobInfo) < 0)
-         goto cleanup;
- 
--    if (jobInfo.type == VIR_DOMAIN_JOB_NONE) {
-+    if (jobInfo.status == QEMU_DOMAIN_JOB_STATUS_NONE) {
-         memset(info, 0, sizeof(*info));
-         info->type = VIR_DOMAIN_JOB_NONE;
-         ret = 0;
-@@ -13047,7 +13047,7 @@ qemuDomainGetJobStats(virDomainPtr dom,
-     if (qemuDomainGetJobStatsInternal(driver, vm, completed, &jobInfo) < 0)
-         goto cleanup;
- 
--    if (jobInfo.type == VIR_DOMAIN_JOB_NONE) {
-+    if (jobInfo.status == QEMU_DOMAIN_JOB_STATUS_NONE) {
-         *type = VIR_DOMAIN_JOB_NONE;
-         *params = NULL;
-         *nparams = 0;
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 60722cbf6c..500f467f25 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -965,7 +965,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
-             goto cleanup;
- 
-         if (priv->job.abortJob) {
--            priv->job.current->type = VIR_DOMAIN_JOB_CANCELLED;
-+            priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_CANCELED;
-             virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"),
-                            qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
-                            _("canceled by client"));
-@@ -1334,19 +1334,19 @@ qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
- {
-     switch ((qemuMonitorMigrationStatus) jobInfo->stats.status) {
-     case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
--        jobInfo->type = VIR_DOMAIN_JOB_COMPLETED;
-+        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
-         break;
- 
-     case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE:
--        jobInfo->type = VIR_DOMAIN_JOB_NONE;
-+        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_NONE;
-         break;
- 
-     case QEMU_MONITOR_MIGRATION_STATUS_ERROR:
--        jobInfo->type = VIR_DOMAIN_JOB_FAILED;
-+        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
-         break;
- 
-     case QEMU_MONITOR_MIGRATION_STATUS_CANCELLED:
--        jobInfo->type = VIR_DOMAIN_JOB_CANCELLED;
-+        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_CANCELED;
-         break;
- 
-     case QEMU_MONITOR_MIGRATION_STATUS_SETUP:
-@@ -1433,32 +1433,30 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
-     else if (qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0)
-         return -1;
- 
--    switch (jobInfo->type) {
--    case VIR_DOMAIN_JOB_NONE:
-+    switch (jobInfo->status) {
-+    case QEMU_DOMAIN_JOB_STATUS_NONE:
-         virReportError(VIR_ERR_OPERATION_FAILED, _("%s: %s"),
-                        qemuMigrationJobName(vm), _("is not active"));
-         return -1;
- 
--    case VIR_DOMAIN_JOB_FAILED:
-+    case QEMU_DOMAIN_JOB_STATUS_FAILED:
-         virReportError(VIR_ERR_OPERATION_FAILED, _("%s: %s"),
-                        qemuMigrationJobName(vm), _("unexpectedly failed"));
-         return -1;
- 
--    case VIR_DOMAIN_JOB_CANCELLED:
-+    case QEMU_DOMAIN_JOB_STATUS_CANCELED:
-         virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"),
-                        qemuMigrationJobName(vm), _("canceled by client"));
-         return -1;
- 
--    case VIR_DOMAIN_JOB_COMPLETED:
-+    case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
-         /* Fetch statistics of a completed migration */
-         if (events && updateJobStats &&
-             qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0)
-             return -1;
-         break;
- 
--    case VIR_DOMAIN_JOB_BOUNDED:
--    case VIR_DOMAIN_JOB_UNBOUNDED:
--    case VIR_DOMAIN_JOB_LAST:
-+    case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
-         break;
-     }
-     return 0;
-@@ -1516,7 +1514,7 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
-      * will continue waiting until the migrate state changes to completed.
-      */
-     if (flags & QEMU_MIGRATION_COMPLETED_POSTCOPY &&
--        jobInfo->type == VIR_DOMAIN_JOB_UNBOUNDED &&
-+        jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
-         jobInfo->stats.status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY) {
-         VIR_DEBUG("Migration switched to post-copy");
-         if (updateStats &&
-@@ -1525,18 +1523,18 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
-         return 1;
-     }
- 
--    if (jobInfo->type == VIR_DOMAIN_JOB_COMPLETED)
-+    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_COMPLETED)
-         return 1;
-     else
-         return 0;
- 
-  error:
--    if (jobInfo->type == VIR_DOMAIN_JOB_UNBOUNDED) {
-+    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE) {
-         /* The migration was aborted by us rather than QEMU itself. */
--        jobInfo->type = VIR_DOMAIN_JOB_FAILED;
-+        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
-         return -2;
--    } else if (jobInfo->type == VIR_DOMAIN_JOB_COMPLETED) {
--        jobInfo->type = VIR_DOMAIN_JOB_FAILED;
-+    } else if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_COMPLETED) {
-+        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
-         return -1;
-     } else {
-         return -1;
-@@ -1561,7 +1559,7 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
- 
-     flags |= QEMU_MIGRATION_COMPLETED_UPDATE_STATS;
- 
--    jobInfo->type = VIR_DOMAIN_JOB_UNBOUNDED;
-+    jobInfo->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
-     while ((rv = qemuMigrationCompleted(driver, vm, asyncJob,
-                                         dconn, flags)) != 1) {
-         if (rv < 0)
-@@ -1569,7 +1567,7 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
- 
-         if (events) {
-             if (virDomainObjWait(vm) < 0) {
--                jobInfo->type = VIR_DOMAIN_JOB_FAILED;
-+                jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
-                 return -2;
-             }
-         } else {
-@@ -3744,7 +3742,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
-          * as this is a critical section so we are guaranteed
-          * priv->job.abortJob will not change */
-         ignore_value(qemuDomainObjExitMonitor(driver, vm));
--        priv->job.current->type = VIR_DOMAIN_JOB_CANCELLED;
-+        priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_CANCELED;
-         virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"),
-                        qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
-                        _("canceled by client"));
-@@ -3878,8 +3876,8 @@ qemuMigrationRun(virQEMUDriverPtr driver,
-         ignore_value(virTimeMillisNow(&priv->job.completed->sent));
-     }
- 
--    if (priv->job.current->type == VIR_DOMAIN_JOB_UNBOUNDED && !inPostCopy)
--        priv->job.current->type = VIR_DOMAIN_JOB_FAILED;
-+    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE && !inPostCopy)
-+        priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
- 
-     cookieFlags |= QEMU_MIGRATION_COOKIE_NETWORK |
-                    QEMU_MIGRATION_COOKIE_STATS;
-@@ -3921,7 +3919,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
-     goto cleanup;
- 
-  cancelPostCopy:
--    priv->job.current->type = VIR_DOMAIN_JOB_FAILED;
-+    priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
-     if (inPostCopy)
-         goto cancel;
-     else
-@@ -5640,7 +5638,7 @@ qemuMigrationJobStart(virQEMUDriverPtr driver,
-         return -1;
- 
-     qemuDomainObjSetAsyncJobMask(vm, mask);
--    priv->job.current->type = VIR_DOMAIN_JOB_UNBOUNDED;
-+    priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
- 
-     return 0;
- }
-diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
-index 5f8595fdba..4914c77ef0 100644
---- a/src/qemu/qemu_migration_cookie.c
-+++ b/src/qemu/qemu_migration_cookie.c
-@@ -974,7 +974,7 @@ qemuMigrationCookieStatisticsXMLParse(xmlXPathContextPtr ctxt)
-         goto cleanup;
- 
-     stats = &jobInfo->stats;
--    jobInfo->type = VIR_DOMAIN_JOB_COMPLETED;
-+    jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
- 
-     virXPathULongLong("string(./started[1])", ctxt, &jobInfo->started);
-     virXPathULongLong("string(./stopped[1])", ctxt, &jobInfo->stopped);
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 6ce33c0134..3235cebad0 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3950,7 +3950,7 @@ qemuProcessBeginJob(virQEMUDriverPtr driver,
-         return -1;
- 
-     qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
--    priv->job.current->type = VIR_DOMAIN_JOB_UNBOUNDED;
-+    priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
- 
-     return 0;
- }
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-json-Fix-daemon-crash-on-handling-domain-shutdown-event.patch b/SOURCES/libvirt-qemu-json-Fix-daemon-crash-on-handling-domain-shutdown-event.patch
deleted file mode 100644
index b2501ff..0000000
--- a/SOURCES/libvirt-qemu-json-Fix-daemon-crash-on-handling-domain-shutdown-event.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From e42a328573e2cfc9e2715d2497ca98b55c067878 Mon Sep 17 00:00:00 2001
-Message-Id: <e42a328573e2cfc9e2715d2497ca98b55c067878@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Wed, 31 May 2017 08:21:34 +0200
-Subject: [PATCH] qemu: json: Fix daemon crash on handling domain shutdown
- event
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1384007
-
-commit a8eba5036 added further checking of the guest shutdown cause, but
-this enhancement is available since qemu 2.10, causing a crash because
-of a NULL pointer dereference on older qemus.
-
-Thread 1 "libvirtd" received signal SIGSEGV, Segmentation fault.
-0x00007ffff72441af in virJSONValueObjectGet (object=0x0,
-                                             key=0x7fffd5ef11bf "guest")
-    at util/virjson.c:769
-769	    if (object->type != VIR_JSON_TYPE_OBJECT)
-(gdb) bt
-0  in virJSONValueObjectGet
-1  in virJSONValueObjectGetBoolean
-2  in qemuMonitorJSONHandleShutdown
-3  in qemuMonitorJSONIOProcessEvent
-4  in qemuMonitorJSONIOProcessLine
-5  in qemuMonitorJSONIOProcess
-6  in qemuMonitorIOProcess
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-(cherry picked from commit f9b69c828994ceea61759d4be43f66da67559033)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_monitor_json.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
-index f22df3007..a244403b5 100644
---- a/src/qemu/qemu_monitor_json.c
-+++ b/src/qemu/qemu_monitor_json.c
-@@ -528,7 +528,7 @@ static void qemuMonitorJSONHandleShutdown(qemuMonitorPtr mon, virJSONValuePtr da
-     bool guest = false;
-     virTristateBool guest_initiated = VIR_TRISTATE_BOOL_ABSENT;
- 
--    if (virJSONValueObjectGetBoolean(data, "guest", &guest) == 0)
-+    if (data && virJSONValueObjectGetBoolean(data, "guest", &guest) == 0)
-         guest_initiated = guest ? VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO;
- 
-     qemuMonitorEmitShutdown(mon, guest_initiated);
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-migration-Refresh-device-information-after-transferring-state.patch b/SOURCES/libvirt-qemu-migration-Refresh-device-information-after-transferring-state.patch
new file mode 100644
index 0000000..46c76e1
--- /dev/null
+++ b/SOURCES/libvirt-qemu-migration-Refresh-device-information-after-transferring-state.patch
@@ -0,0 +1,113 @@
+From c043762bfe04d7b10030b76fae12473b031c3c0a Mon Sep 17 00:00:00 2001
+Message-Id: <c043762bfe04d7b10030b76fae12473b031c3c0a@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Fri, 2 Feb 2018 11:05:00 +0100
+Subject: [PATCH] qemu: migration: Refresh device information after
+ transferring state
+
+In my first approach in 4b480d10768c I overlooked the comment in
+qemuMigrationRunIncoming stating that during actual migration the
+qemuMigrationRunIncoming does not wait until the migration is complete
+but rather offloads that to the Finish phase of migration.
+
+This means that during actual migration qemuProcessRefreshState was
+called prior to qemu actually transferring the full state and thus the
+queries did not get the correct information. The approach worked only
+for restore, where we wait for the migration to finish during qemu
+startup.
+
+Fix the issue by calling qemuProcessRefreshState both from
+qemuProcessStart if there's no incomming migration and from
+qemuMigrationFinish so that the code actually works as expected.
+
+(cherry picked from commit 93db7eea1b86408e02852a8c886d473f4f5007e3)
+
+ https://bugzilla.redhat.com/show_bug.cgi?id=1463168
+---
+ src/qemu/qemu_migration.c |  9 +++++++++
+ src/qemu/qemu_process.c   | 17 ++++++++++-------
+ src/qemu/qemu_process.h   |  4 ++++
+ 3 files changed, 23 insertions(+), 7 deletions(-)
+
+diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
+index a50bb7206c..0968dd62a4 100644
+--- a/src/qemu/qemu_migration.c
++++ b/src/qemu/qemu_migration.c
+@@ -5351,6 +5351,15 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
+             goto endjob;
+     }
+ 
++    /* Now that the state data was transferred we can refresh the actual state
++     * of the devices */
++    if (qemuProcessRefreshState(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0) {
++        /* Similarly to the case above v2 protocol will not be able to recover
++         * from this. Let's ignore this and perhaps stuff will not break. */
++        if (v3proto)
++            goto endjob;
++    }
++
+     if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY)
+         inPostCopy = true;
+ 
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index 3bb4b14948..caf967dac5 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -6080,7 +6080,7 @@ qemuProcessLaunch(virConnectPtr conn,
+  * function is called after a deferred migration finishes so that we can update
+  * state influenced by the migration stream.
+  */
+-static int
++int
+ qemuProcessRefreshState(virQEMUDriverPtr driver,
+                         virDomainObjPtr vm,
+                         qemuDomainAsyncJob asyncJob)
+@@ -6121,9 +6121,6 @@ qemuProcessFinishStartup(virConnectPtr conn,
+     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+     int ret = -1;
+ 
+-    if (qemuProcessRefreshState(driver, vm, asyncJob) < 0)
+-        goto cleanup;
+-
+     if (startCPUs) {
+         VIR_DEBUG("Starting domain CPUs");
+         if (qemuProcessStartCPUs(driver, vm, conn,
+@@ -6227,11 +6224,17 @@ qemuProcessStart(virConnectPtr conn,
+                                  VIR_DOMAIN_PAUSED_USER) < 0)
+         goto stop;
+ 
+-    /* Keep watching qemu log for errors during incoming migration, otherwise
+-     * unset reporting errors from qemu log. */
+-    if (!incoming)
++    if (!incoming) {
++        /* Keep watching qemu log for errors during incoming migration, otherwise
++         * unset reporting errors from qemu log. */
+         qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL);
+ 
++        /* Refresh state of devices from qemu. During migration this needs to
++         * happen after the state information is fully transferred. */
++        if (qemuProcessRefreshState(driver, vm, asyncJob) < 0)
++            goto stop;
++    }
++
+     ret = 0;
+ 
+  cleanup:
+diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
+index cd9a720313..b383ff309b 100644
+--- a/src/qemu/qemu_process.h
++++ b/src/qemu/qemu_process.h
+@@ -129,6 +129,10 @@ int qemuProcessFinishStartup(virConnectPtr conn,
+                              bool startCPUs,
+                              virDomainPausedReason pausedReason);
+ 
++int qemuProcessRefreshState(virQEMUDriverPtr driver,
++                            virDomainObjPtr vm,
++                            qemuDomainAsyncJob asyncJob);
++
+ typedef enum {
+     VIR_QEMU_PROCESS_STOP_MIGRATED      = 1 << 0,
+     VIR_QEMU_PROCESS_STOP_NO_RELABEL    = 1 << 1,
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemu-migration-don-t-expose-incomplete-job-as-complete.patch b/SOURCES/libvirt-qemu-migration-don-t-expose-incomplete-job-as-complete.patch
deleted file mode 100644
index 7e87b62..0000000
--- a/SOURCES/libvirt-qemu-migration-don-t-expose-incomplete-job-as-complete.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 547c0e17e665d7a1051d8670b2f9e44783dbaf58 Mon Sep 17 00:00:00 2001
-Message-Id: <547c0e17e665d7a1051d8670b2f9e44783dbaf58@dist-git>
-From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
-Date: Fri, 1 Sep 2017 09:49:31 +0300
-Subject: [PATCH] qemu: migration: don't expose incomplete job as complete
-
-In case of real migration (not migrating to file on save, dump etc)
-migration info is not complete at time qemu finishes migration
-in normal (non postcopy) mode. We need to update disks stats,
-downtime info etc. Thus let's not expose this job status as
-completed.
-
-To archive this let's set status to 'qemu completed' after
-qemu reports migration is finished. It is not visible as complete
-job to clients. Cookie code on confirm phase will finally turn
-job into completed. As we don't need more things to do when
-migrating to file status is set to 'completed' as before
-in this case.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit 3f2d6d829eb8de0348fcbd58d654b29d5c5bebc2)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530130
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c    |  1 +
- src/qemu/qemu_domain.h    |  1 +
- src/qemu/qemu_driver.c    |  1 +
- src/qemu/qemu_migration.c | 13 +++++++++----
- 4 files changed, 12 insertions(+), 4 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index e81d682c00..9a80e409b9 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -398,6 +398,7 @@ qemuDomainJobStatusToType(qemuDomainJobStatus status)
- 
-     case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
-     case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
-+    case QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED:
-     case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
-         return VIR_DOMAIN_JOB_UNBOUNDED;
- 
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 0cf54d99ae..cc458e1224 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -103,6 +103,7 @@ typedef enum {
-     QEMU_DOMAIN_JOB_STATUS_NONE = 0,
-     QEMU_DOMAIN_JOB_STATUS_ACTIVE,
-     QEMU_DOMAIN_JOB_STATUS_MIGRATING,
-+    QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED,
-     QEMU_DOMAIN_JOB_STATUS_POSTCOPY,
-     QEMU_DOMAIN_JOB_STATUS_COMPLETED,
-     QEMU_DOMAIN_JOB_STATUS_FAILED,
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 931f3d344d..d2dd704868 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -12972,6 +12972,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
- 
-     if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
-         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
-+        jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED ||
-         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-         if (fetch)
-             ret = qemuMigrationFetchJobStatus(driver, vm, QEMU_ASYNC_JOB_NONE,
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index c8cd7ebfa3..aabd0913ad 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -1338,7 +1338,7 @@ qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
-         break;
- 
-     case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
--        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
-+        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED;
-         break;
- 
-     case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE:
-@@ -1461,6 +1461,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
- 
-     case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
-     case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
-+    case QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED:
-     case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
-         break;
-     }
-@@ -1527,19 +1528,19 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
-         return 1;
-     }
- 
--    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_COMPLETED)
-+    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED)
-         return 1;
-     else
-         return 0;
- 
-  error:
--    /* state can not be active at this point */
-+    /* state can not be active or completed at this point */
-     if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
-         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-         /* The migration was aborted by us rather than QEMU itself. */
-         jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
-         return -2;
--    } else if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_COMPLETED) {
-+    } else if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED) {
-         jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
-         return -1;
-     } else {
-@@ -1592,6 +1593,10 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
-     if (VIR_ALLOC(priv->job.completed) == 0)
-         *priv->job.completed = *jobInfo;
- 
-+    if (asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT &&
-+        jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED)
-+        jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
-+
-     return 0;
- }
- 
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-migration-fix-race-on-cancelling-drive-mirror.patch b/SOURCES/libvirt-qemu-migration-fix-race-on-cancelling-drive-mirror.patch
deleted file mode 100644
index c1c5b82..0000000
--- a/SOURCES/libvirt-qemu-migration-fix-race-on-cancelling-drive-mirror.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From 48fc7e172ed82fbe8b377c11cff2c9d47fbb37c8 Mon Sep 17 00:00:00 2001
-Message-Id: <48fc7e172ed82fbe8b377c11cff2c9d47fbb37c8@dist-git>
-From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
-Date: Fri, 7 Apr 2017 14:06:25 +0300
-Subject: [PATCH] qemu: migration: fix race on cancelling drive mirror
-
-0feebab2 adds calling qemuBlockNodeNamesDetect for completed job
-on updating block jobs. This affects cancelling drive mirror logic as
-this function drops vm lock. Now we have to recheck all disks
-before the disk with the completed block job before going
-to wait for block job events.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit bc82d1eaf66bfdfde80a64e7feedb60c6d1d2505)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530129
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_migration.c | 15 +++++++++++++++
- 1 file changed, 15 insertions(+)
-
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index d2b691bd2b..60722cbf6c 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -654,9 +654,11 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
- {
-     size_t i;
-     size_t active = 0;
-+    size_t completed = 0;
-     int status;
-     bool failed = false;
- 
-+ retry:
-     for (i = 0; i < vm->def->ndisks; i++) {
-         virDomainDiskDefPtr disk = vm->def->disks[i];
-         qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-@@ -683,6 +685,19 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
-         default:
-             active++;
-         }
-+
-+        if (status == VIR_DOMAIN_BLOCK_JOB_COMPLETED)
-+            completed++;
-+    }
-+
-+    /* Updating completed block job drops the lock thus we have to recheck
-+     * block jobs for disks that reside before the disk(s) with completed
-+     * block job.
-+     */
-+    if (completed > 0) {
-+        completed = 0;
-+        active = 0;
-+        goto retry;
-     }
- 
-     if (failed) {
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-mkdir-memory_backing_dir-on-startup.patch b/SOURCES/libvirt-qemu-mkdir-memory_backing_dir-on-startup.patch
deleted file mode 100644
index 649b2ed..0000000
--- a/SOURCES/libvirt-qemu-mkdir-memory_backing_dir-on-startup.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-From d68103f77527b1f7a5a3cf1fdc4029a9181e6799 Mon Sep 17 00:00:00 2001
-Message-Id: <d68103f77527b1f7a5a3cf1fdc4029a9181e6799@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Wed, 31 May 2017 15:20:17 +0200
-Subject: [PATCH] qemu: mkdir memory_backing_dir on startup
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1214369
-
-In 48d9e6cdcc and friends we've allowed users to back guest
-memory by a file inside the host. And in order to keep things
-manageable the memory_backing_dir variable was introduced to
-qemu.conf to specify the directory where the files are kept.
-However, libvirt's policy is that directories are created on
-domain startup if they don't exist. We've missed this one.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-(cherry picked from commit 3bab51e05656332f7952958705e59046ce30daa3)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_driver.c | 12 ++++++++++++
- 1 file changed, 12 insertions(+)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index c31d07a659..b741c1b5a6 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -706,6 +706,11 @@ qemuStateInitialize(bool privileged,
-                              cfg->nvramDir);
-         goto error;
-     }
-+    if (virFileMakePath(cfg->memoryBackingDir) < 0) {
-+        virReportSystemError(errno, _("Failed to create memory backing dir %s"),
-+                             cfg->memoryBackingDir);
-+        goto error;
-+    }
- 
-     qemu_driver->qemuImgBinary = virFindFileInPath("qemu-img");
- 
-@@ -830,6 +835,13 @@ qemuStateInitialize(bool privileged,
-                                  (int) cfg->group);
-             goto error;
-         }
-+        if (chown(cfg->memoryBackingDir, cfg->user, cfg->group) < 0) {
-+            virReportSystemError(errno,
-+                                 _("unable to set ownership of '%s' to %d:%d"),
-+                                 cfg->memoryBackingDir, (int) cfg->user,
-+                                 (int) cfg->group);
-+            goto error;
-+        }
- 
-         run_uid = cfg->user;
-         run_gid = cfg->group;
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-monitor-Don-t-bother-extracting-vCPU-halted-state-in-text-monitor.patch b/SOURCES/libvirt-qemu-monitor-Don-t-bother-extracting-vCPU-halted-state-in-text-monitor.patch
deleted file mode 100644
index 64b7377..0000000
--- a/SOURCES/libvirt-qemu-monitor-Don-t-bother-extracting-vCPU-halted-state-in-text-monitor.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-From 3dfdc7e73f15216b0a9ef5858329c4daf3142ed5 Mon Sep 17 00:00:00 2001
-Message-Id: <3dfdc7e73f15216b0a9ef5858329c4daf3142ed5@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Fri, 19 May 2017 09:44:14 +0200
-Subject: [PATCH] qemu: monitor: Don't bother extracting vCPU halted state in
- text monitor
-
-The code causes the 'offset' variable to be overwritten (possibly with
-NULL if neither of the vCPUs is halted) which causes a crash since the
-variable is still used after that part.
-
-Additionally there's a bug, since strstr() would look up the '(halted)'
-string in the whole string rather than just the currently processed line
-the returned data is completely bogus.
-
-Rather than switching to single line parsing let's remove the code
-altogether since it has a commonly used JSON monitor alternative and
-the data itself is not very useful to report.
-
-The code was introduced in commit cc5e695bde
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1452106
-(cherry picked from commit 6ff99e95771bb33531ea6733a823bc6a30158256)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_monitor_text.c | 6 ------
- 1 file changed, 6 deletions(-)
-
-diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
-index 9c9eeea01..66c94fbcd 100644
---- a/src/qemu/qemu_monitor_text.c
-+++ b/src/qemu/qemu_monitor_text.c
-@@ -552,12 +552,6 @@ qemuMonitorTextQueryCPUs(qemuMonitorPtr mon,
-         cpu.qemu_id = cpuid;
-         cpu.tid = tid;
- 
--        /* Extract halted indicator */
--        if ((offset = strstr(line, "(halted)")) != NULL)
--            cpu.halted = true;
--        else
--            cpu.halted = false;
--
-         if (VIR_APPEND_ELEMENT_COPY(cpus, ncpus, cpu) < 0) {
-             ret = -1;
-             goto cleanup;
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-parse-Allocate-disk-definition-with-private-data.patch b/SOURCES/libvirt-qemu-parse-Allocate-disk-definition-with-private-data.patch
new file mode 100644
index 0000000..9db928d
--- /dev/null
+++ b/SOURCES/libvirt-qemu-parse-Allocate-disk-definition-with-private-data.patch
@@ -0,0 +1,35 @@
+From 53806054c0b1b7ee2c8df5e46fa18b87aaee1ca1 Mon Sep 17 00:00:00 2001
+Message-Id: <53806054c0b1b7ee2c8df5e46fa18b87aaee1ca1@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Mon, 13 Nov 2017 13:37:52 +0100
+Subject: [PATCH] qemu: parse: Allocate disk definition with private data
+
+Use virDomainDiskDefNew instead of VIR_ALLOC in
+qemuParseCommandLineDisk.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1510781
+(cherry picked from commit 994c49ac34181cb664b18856df38c2f5c326ff03)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_parse_command.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
+index 649c3b1ccf..a8d0d7c535 100644
+--- a/src/qemu/qemu_parse_command.c
++++ b/src/qemu/qemu_parse_command.c
+@@ -658,10 +658,8 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
+                           0) < 0)
+         return NULL;
+ 
+-    if (VIR_ALLOC(def) < 0)
++    if (!(def = virDomainDiskDefNew(xmlopt)))
+         goto cleanup;
+-    if (VIR_ALLOC(def->src) < 0)
+-        goto error;
+ 
+     if (qemuDomainIsPSeries(dom))
+         def->bus = VIR_DOMAIN_DISK_BUS_SCSI;
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-prefer-the-PCI-bus-alias-from-status-XML.patch b/SOURCES/libvirt-qemu-prefer-the-PCI-bus-alias-from-status-XML.patch
new file mode 100644
index 0000000..946a89c
--- /dev/null
+++ b/SOURCES/libvirt-qemu-prefer-the-PCI-bus-alias-from-status-XML.patch
@@ -0,0 +1,89 @@
+From 2e8ff390a9ee06b68a2591c761d185539beb49d4 Mon Sep 17 00:00:00 2001
+Message-Id: <2e8ff390a9ee06b68a2591c761d185539beb49d4@dist-git>
+From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
+Date: Thu, 30 Nov 2017 17:45:58 +0100
+Subject: [PATCH] qemu: prefer the PCI bus alias from status XML
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+For some corner cases, virQEMUCapsHasPCIMultiBus depends on the QEMU
+version, which is by design not stored in the status XML and therefore
+it cannot be fixed for all existing running domains.
+
+Prefer the controller alias read from the status XML when formatting
+PCI addresses and only fall back to using virQEMUCapsHasPCIMultiBus
+if the alias is a user alias.
+
+This fixes hotplug after daemon restart for domains not using user
+aliases.
+
+Partially reverts commit 937f3195.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1518148
+(cherry picked from commit dacfc6b10bcff1c275d21a37edf0bc83e0947492)
+Signed-off-by: Ján Tomko <jtomko@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c | 42 ++++++++++++++++++++++--------------------
+ 1 file changed, 22 insertions(+), 20 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 624a50d0b3..b462c7cf09 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -318,29 +318,31 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
+ 
+             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
+                 cont->idx == info->addr.pci.bus) {
++                contAlias = cont->info.alias;
+                 contIsPHB = virDomainControllerIsPSeriesPHB(cont);
+                 contTargetIndex = cont->opts.pciopts.targetIndex;
+ 
+-                /* When domain has builtin pci-root controller we don't put it
+-                 * onto cmd line. Therefore we can't set its alias. In that
+-                 * case, use the default one. */
+-                if (!qemuDomainIsPSeries(domainDef) &&
+-                    cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) {
+-                    if (virQEMUCapsHasPCIMultiBus(qemuCaps, domainDef))
+-                        contAlias = "pci.0";
+-                    else
+-                        contAlias = "pci";
+-                } else if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
+-                    contAlias = "pcie.0";
+-                } else {
+-                    contAlias = cont->info.alias;
+-                    if (!contAlias) {
+-                        virReportError(VIR_ERR_INTERNAL_ERROR,
+-                                       _("Device alias was not set for PCI "
+-                                         "controller with index %u required "
+-                                         "for device at address %s"),
+-                                       info->addr.pci.bus, devStr);
+-                        goto cleanup;
++                if (!contAlias) {
++                    virReportError(VIR_ERR_INTERNAL_ERROR,
++                                   _("Device alias was not set for PCI "
++                                     "controller with index %u required "
++                                     "for device at address %s"),
++                                   info->addr.pci.bus, devStr);
++                    goto cleanup;
++                }
++
++                if (virDomainDeviceAliasIsUserAlias(contAlias)) {
++                    /* When domain has builtin pci-root controller we don't put it
++                     * onto cmd line. Therefore we can't set its alias. In that
++                     * case, use the default one. */
++                    if (!qemuDomainIsPSeries(domainDef) &&
++                        cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) {
++                        if (virQEMUCapsHasPCIMultiBus(qemuCaps, domainDef))
++                            contAlias = "pci.0";
++                        else
++                            contAlias = "pci";
++                    } else if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
++                        contAlias = "pcie.0";
+                     }
+                 }
+                 break;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-process-Clean-automatic-NUMA-cpu-pinning-information-on-shutdown.patch b/SOURCES/libvirt-qemu-process-Clean-automatic-NUMA-cpu-pinning-information-on-shutdown.patch
deleted file mode 100644
index 2e2d155..0000000
--- a/SOURCES/libvirt-qemu-process-Clean-automatic-NUMA-cpu-pinning-information-on-shutdown.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From 9cde726d82715272f2b06580dde9a65882263e85 Mon Sep 17 00:00:00 2001
-Message-Id: <9cde726d82715272f2b06580dde9a65882263e85@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Fri, 28 Apr 2017 10:45:16 +0200
-Subject: [PATCH] qemu: process: Clean automatic NUMA/cpu pinning information
- on shutdown
-
-Clean the stale data after shutting down the VM. Otherwise the data
-would be leaked on next VM start. This happens due to the fact that the
-private data object is not freed on destroy of the VM.
-
-(cherry picked from commit 1730cdc665a499afc28683a4ce21493f967411b7)
-https://bugzilla.redhat.com/show_bug.cgi?id=1445627
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 027c831e6..5d2d0662b 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -6433,6 +6433,12 @@ void qemuProcessStop(virQEMUDriverPtr driver,
-     priv->qemuCaps = NULL;
-     VIR_FREE(priv->pidfile);
- 
-+    /* remove automatic pinning data */
-+    virBitmapFree(priv->autoNodeset);
-+    priv->autoNodeset = NULL;
-+    virBitmapFree(priv->autoCpuset);
-+    priv->autoCpuset = NULL;
-+
-     /* The "release" hook cleans up additional resources */
-     if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
-         char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-process-Clean-up-priv-migTLSAlias.patch b/SOURCES/libvirt-qemu-process-Clean-up-priv-migTLSAlias.patch
deleted file mode 100644
index 00c7fc8..0000000
--- a/SOURCES/libvirt-qemu-process-Clean-up-priv-migTLSAlias.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 3bd19fa5ff139e72fcb0e2982969263d554f6940 Mon Sep 17 00:00:00 2001
-Message-Id: <3bd19fa5ff139e72fcb0e2982969263d554f6940@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Fri, 28 Apr 2017 10:45:18 +0200
-Subject: [PATCH] qemu: process: Clean up priv->migTLSAlias
-
-The alias would be leaked, since it's not freed on the vm stop path.
-
-(cherry picked from commit 8c1fee5f12e607a775199b65915715bb5a2b581d)
-https://bugzilla.redhat.com/show_bug.cgi?id=1445627
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index c23982db6..2eee70203 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -6443,6 +6443,9 @@ void qemuProcessStop(virQEMUDriverPtr driver,
-     virDomainUSBAddressSetFree(priv->usbaddrs);
-     priv->usbaddrs = NULL;
- 
-+    /* clean up migration data */
-+    VIR_FREE(priv->migTLSAlias);
-+
-     /* The "release" hook cleans up additional resources */
-     if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
-         char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-process-Clear-priv-namespaces-on-VM-shutdown.patch b/SOURCES/libvirt-qemu-process-Clear-priv-namespaces-on-VM-shutdown.patch
deleted file mode 100644
index 14fe565..0000000
--- a/SOURCES/libvirt-qemu-process-Clear-priv-namespaces-on-VM-shutdown.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From eb52df58d1dc63812430728f173699665e936cdf Mon Sep 17 00:00:00 2001
-Message-Id: <eb52df58d1dc63812430728f173699665e936cdf@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 23 May 2017 16:33:26 +0200
-Subject: [PATCH] qemu: process: Clear priv->namespaces on VM shutdown
-
-Otherwise the private data entry would be kept across instances of the
-same VM even if it's not configured to do so.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1453142
-(cherry picked from commit 5203975f37e24f7b7156f0251f19f5001a6bd6eb)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index df5ba575a..6f0d07242 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -6447,6 +6447,10 @@ void qemuProcessStop(virQEMUDriverPtr driver,
-     /* clean up migration data */
-     VIR_FREE(priv->migTLSAlias);
- 
-+    /* clear previously used namespaces */
-+    virBitmapFree(priv->namespaces);
-+    priv->namespaces = NULL;
-+
-     /* The "release" hook cleans up additional resources */
-     if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
-         char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-process-Don-t-leak-priv-usbaddrs-after-VM-restart.patch b/SOURCES/libvirt-qemu-process-Don-t-leak-priv-usbaddrs-after-VM-restart.patch
deleted file mode 100644
index 071fdca..0000000
--- a/SOURCES/libvirt-qemu-process-Don-t-leak-priv-usbaddrs-after-VM-restart.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From 197373d62cfb74faf62e0b1334afcb73fcf25550 Mon Sep 17 00:00:00 2001
-Message-Id: <197373d62cfb74faf62e0b1334afcb73fcf25550@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Fri, 28 Apr 2017 10:45:17 +0200
-Subject: [PATCH] qemu: process: Don't leak priv->usbaddrs after VM restart
-
-Since the private data structure is not freed upon stopping a VM, the
-usbaddrs pointer would be leaked:
-
-==15388== 136 (16 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 893 of 1,019
-==15388==    at 0x4C2CF55: calloc (vg_replace_malloc.c:711)
-==15388==    by 0x54BF64A: virAlloc (viralloc.c:144)
-==15388==    by 0x5547588: virDomainUSBAddressSetCreate (domain_addr.c:1608)
-==15388==    by 0x144D38A2: qemuDomainAssignUSBAddresses (qemu_domain_address.c:2458)
-==15388==    by 0x144D38A2: qemuDomainAssignAddresses (qemu_domain_address.c:2515)
-==15388==    by 0x144ED1E3: qemuProcessPrepareDomain (qemu_process.c:5398)
-==15388==    by 0x144F51FF: qemuProcessStart (qemu_process.c:5979)
-[...]
-
-(cherry picked from commit 3ab802d689796ebac6545267d5db248e13a9a0e6)
-https://bugzilla.redhat.com/show_bug.cgi?id=1445627
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 5d2d0662b..c23982db6 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -6439,6 +6439,10 @@ void qemuProcessStop(virQEMUDriverPtr driver,
-     virBitmapFree(priv->autoCpuset);
-     priv->autoCpuset = NULL;
- 
-+    /* remove address data */
-+    virDomainUSBAddressSetFree(priv->usbaddrs);
-+    priv->usbaddrs = NULL;
-+
-     /* The "release" hook cleans up additional resources */
-     if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
-         char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-process-Move-handling-of-non-backing-files-into-qemuDomainDetermineDiskChain.patch b/SOURCES/libvirt-qemu-process-Move-handling-of-non-backing-files-into-qemuDomainDetermineDiskChain.patch
new file mode 100644
index 0000000..280f520
--- /dev/null
+++ b/SOURCES/libvirt-qemu-process-Move-handling-of-non-backing-files-into-qemuDomainDetermineDiskChain.patch
@@ -0,0 +1,88 @@
+From 3ad4635badd77642d59d3789286da72abb66ee72 Mon Sep 17 00:00:00 2001
+Message-Id: <3ad4635badd77642d59d3789286da72abb66ee72@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Fri, 1 Dec 2017 15:57:02 +0100
+Subject: [PATCH] qemu: process: Move handling of non-backing files into
+ qemuDomainDetermineDiskChain
+
+Until now we would skip loading of the backing chain for files which
+don't support backing chains only when starting up the VM. Move the
+check from qemuProcessPrepareHostStorage with some adaptations so that's
+always applied.
+
+(cherry picked from commit 24e47ee2b93312742f73a785b9ca788df4677749)
+
+ Conflicts:
+	src/qemu/qemu_domain.c:
+        - since quite lot of the blockdev saga was not backported and
+        the previous commit is different this one does not apply as
+        well.
+
+        The changes are to accomodate the not-backported change in
+        return code logic of qemuDomainDetermineDiskChain which in this
+        instance initializes ret to 0 instead of -1, which was changed
+        in a patch that was not backported.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1509110
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c  | 17 +++++++++++++++++
+ src/qemu/qemu_process.c | 10 ----------
+ 2 files changed, 17 insertions(+), 10 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 13d120040b..33cb3df949 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -6358,6 +6358,23 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
+     if (force_probe)
+         virStorageSourceBackingStoreClear(disk->src);
+ 
++    /* There is no need to check the backing chain for disks without backing
++     * support */
++    if (virStorageSourceIsLocalStorage(disk->src) &&
++        disk->src->format > VIR_STORAGE_FILE_NONE &&
++        disk->src->format < VIR_STORAGE_FILE_BACKING) {
++
++        if (!virFileExists(disk->src->path)) {
++            if (report_broken)
++                virStorageFileReportBrokenChain(errno, disk->src, disk->src);
++
++            ret = -1;
++            goto cleanup;
++        }
++
++        goto cleanup;
++    }
++
+     if (virStorageSourceHasBacking(disk->src))
+         goto cleanup;
+ 
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index f7808227a8..91426ad3c3 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -5554,20 +5554,10 @@ qemuProcessPrepareHostStorage(virQEMUDriverPtr driver,
+     for (i = vm->def->ndisks; i > 0; i--) {
+         size_t idx = i - 1;
+         virDomainDiskDefPtr disk = vm->def->disks[idx];
+-        virStorageFileFormat format = virDomainDiskGetFormat(disk);
+ 
+         if (virStorageSourceIsEmpty(disk->src))
+             continue;
+ 
+-        /* There is no need to check the backing chain for disks
+-         * without backing support, the fact that the file exists is
+-         * more than enough */
+-        if (virStorageSourceIsLocalStorage(disk->src) &&
+-            format > VIR_STORAGE_FILE_NONE &&
+-            format < VIR_STORAGE_FILE_BACKING &&
+-            virFileExists(virDomainDiskGetSource(disk)))
+-            continue;
+-
+         if (qemuDomainDetermineDiskChain(driver, vm, disk, true, true) >= 0)
+             continue;
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-process-Save-vcpu-ordering-information-on-reconnect.patch b/SOURCES/libvirt-qemu-process-Save-vcpu-ordering-information-on-reconnect.patch
deleted file mode 100644
index 5cc3b93..0000000
--- a/SOURCES/libvirt-qemu-process-Save-vcpu-ordering-information-on-reconnect.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From 8df453dfaafbd0001dcdc828eb8b2479b61dc74b Mon Sep 17 00:00:00 2001
-Message-Id: <8df453dfaafbd0001dcdc828eb8b2479b61dc74b@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 6 Jun 2017 12:28:01 +0200
-Subject: [PATCH] qemu: process: Save vcpu ordering information on reconnect
-
-vCPU ordering information would not be updated if a vCPU emerged or
-disappeared during the time libvirtd is not running. This allowed to
-create invalid configuration like:
-
-    [...]
-    <vcpu id='56' enabled='yes' hotpluggable='yes' order='57'/>
-    <vcpu id='57' enabled='yes' hotpluggable='yes' order='58'/>
-    <vcpu id='58' enabled='yes' hotpluggable='yes'/>
-
-Call the function that records the information on reconnect.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1451251
-(cherry picked from commit ad3c6b229bcc91177db29d307e8ccc22c6c43565)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_process.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 998dbeb6b5..7e51ca819a 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3492,6 +3492,8 @@ qemuProcessReconnect(void *opaque)
-     if (qemuDomainRefreshVcpuInfo(driver, obj, QEMU_ASYNC_JOB_NONE, true) < 0)
-         goto error;
- 
-+    qemuDomainVcpuPersistOrder(obj->def);
-+
-     if (qemuSecurityReserveLabel(driver->securityManager, obj->def, obj->pid) < 0)
-         goto error;
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-refactor-qemuBuildIOMMUCommandLine.patch b/SOURCES/libvirt-qemu-refactor-qemuBuildIOMMUCommandLine.patch
deleted file mode 100644
index 111466e..0000000
--- a/SOURCES/libvirt-qemu-refactor-qemuBuildIOMMUCommandLine.patch
+++ /dev/null
@@ -1,77 +0,0 @@
-From 657451fe2a5e8b55adbae643ac818b496c9cbc0c Mon Sep 17 00:00:00 2001
-Message-Id: <657451fe2a5e8b55adbae643ac818b496c9cbc0c@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Tue, 16 May 2017 10:44:51 +0200
-Subject: [PATCH] qemu: refactor qemuBuildIOMMUCommandLine
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Introduce a separate buffer for options and use a helper
-variable for def->iommu.
-
-(cherry picked from commit b595cc05e83288b743d48904964e4dcb547a2d26)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_command.c | 21 +++++++++++++++------
- 1 file changed, 15 insertions(+), 6 deletions(-)
-
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 4d3a3d8ca..b27b9f8ad 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -6664,33 +6664,42 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
-                           const virDomainDef *def,
-                           virQEMUCapsPtr qemuCaps)
- {
--    if (!def->iommu)
-+    virBuffer opts = VIR_BUFFER_INITIALIZER;
-+    const virDomainIOMMUDef *iommu = def->iommu;
-+    int ret = -1;
-+
-+    if (!iommu)
-         return 0;
- 
-     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU))
-         return 0; /* Already handled via -machine */
- 
--    switch (def->iommu->model) {
-+    switch (iommu->model) {
-     case VIR_DOMAIN_IOMMU_MODEL_INTEL:
-         if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                            _("IOMMU device: '%s' is not supported with "
-                              "this QEMU binary"),
--                           virDomainIOMMUModelTypeToString(def->iommu->model));
-+                           virDomainIOMMUModelTypeToString(iommu->model));
-             return -1;
-         }
-         if (!qemuDomainIsQ35(def)) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                            _("IOMMU device: '%s' is only supported with "
-                              "Q35 machines"),
--                           virDomainIOMMUModelTypeToString(def->iommu->model));
-+                           virDomainIOMMUModelTypeToString(iommu->model));
-             return -1;
-         }
--        virCommandAddArgList(cmd, "-device", "intel-iommu", NULL);
-+        virBufferAddLit(&opts, "intel-iommu");
-     case VIR_DOMAIN_IOMMU_MODEL_LAST:
-         break;
-     }
--    return 0;
-+    virCommandAddArg(cmd, "-device");
-+    virCommandAddArgBuffer(cmd, &opts);
-+
-+    ret = 0;
-+    virBufferFreeAndReset(&opts);
-+    return ret;
- }
- 
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemu-refactor-qemuDomainMachine-functions.patch b/SOURCES/libvirt-qemu-refactor-qemuDomainMachine-functions.patch
deleted file mode 100644
index 8a34730..0000000
--- a/SOURCES/libvirt-qemu-refactor-qemuDomainMachine-functions.patch
+++ /dev/null
@@ -1,797 +0,0 @@
-From c3d1e1be0a0c972106fa25161777cf0a86c53d06 Mon Sep 17 00:00:00 2001
-Message-Id: <c3d1e1be0a0c972106fa25161777cf0a86c53d06@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Wed, 19 Apr 2017 09:51:14 +0200
-Subject: [PATCH] qemu: refactor qemuDomainMachine* functions
-
-Introduce new wrapper functions without *Machine* in the function
-name that take the whole virDomainDef structure as argument and
-call the existing functions with *Machine* in the function name.
-
-Change the arguments of existing functions to *machine* and *arch*
-because they don't need the whole virDomainDef structure and they
-could be used in places where we don't have virDomainDef.
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit ac97658d4fe5ce2b4f4949813ded6e2d77b07ee8)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1441964
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_alias.c          |   4 +-
- src/qemu/qemu_capabilities.c   |  10 ++--
- src/qemu/qemu_command.c        |  42 ++++++-------
- src/qemu/qemu_domain.c         | 131 ++++++++++++++++++++++++++++-------------
- src/qemu/qemu_domain.h         |  28 ++++++---
- src/qemu/qemu_domain_address.c |  24 ++++----
- src/qemu/qemu_hotplug.c        |  14 ++---
- src/qemu/qemu_parse_command.c  |   8 +--
- 8 files changed, 161 insertions(+), 100 deletions(-)
-
-diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
-index 05e1293ef..914b2b94d 100644
---- a/src/qemu/qemu_alias.c
-+++ b/src/qemu/qemu_alias.c
-@@ -152,14 +152,14 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef,
-          * first (and currently only) IDE controller is an integrated
-          * controller hardcoded with id "ide"
-          */
--        if (qemuDomainMachineHasBuiltinIDE(domainDef) &&
-+        if (qemuDomainHasBuiltinIDE(domainDef) &&
-             controller->idx == 0)
-             return VIR_STRDUP(controller->info.alias, "ide");
-     } else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) {
-         /* for any Q35 machine, the first SATA controller is the
-          * integrated one, and it too is hardcoded with id "ide"
-          */
--        if (qemuDomainMachineIsQ35(domainDef) && controller->idx == 0)
-+        if (qemuDomainIsQ35(domainDef) && controller->idx == 0)
-             return VIR_STRDUP(controller->info.alias, "ide");
-     } else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) {
-         /* first USB device is "usb", others are normal "usb%d" */
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index a8125102c..b7c2c3705 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -2284,7 +2284,7 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
-     /* If 'virt' supports PCI, it supports multibus.
-      * No extra conditions here for simplicity.
-      */
--    if (qemuDomainMachineIsVirt(def))
-+    if (qemuDomainIsVirt(def))
-         return true;
- 
-     return false;
-@@ -5333,7 +5333,7 @@ virQEMUCapsSupportsChardev(const virDomainDef *def,
-         return false;
- 
-     if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) {
--        if (!qemuDomainMachineIsPSeries(def))
-+        if (!qemuDomainIsPSeries(def))
-             return false;
-         /* only pseries need -device spapr-vty with -chardev */
-         if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
-@@ -5360,8 +5360,8 @@ virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps,
-     if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_VMPORT_OPT))
-         return false;
- 
--    return qemuDomainMachineIsI440FX(def) ||
--        qemuDomainMachineIsQ35(def) ||
-+    return qemuDomainIsI440FX(def) ||
-+        qemuDomainIsQ35(def) ||
-         STREQ(def->os.machine, "isapc");
- }
- 
-@@ -5373,7 +5373,7 @@ virQEMUCapsSupportsSMM(virQEMUCapsPtr qemuCaps,
-     if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_SMM_OPT))
-         return false;
- 
--    return qemuDomainMachineIsQ35(def);
-+    return qemuDomainIsQ35(def);
- }
- 
- 
-diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
-index 8ec4ec3a6..ff7f47e06 100644
---- a/src/qemu/qemu_command.c
-+++ b/src/qemu/qemu_command.c
-@@ -1390,7 +1390,7 @@ qemuCheckCCWS390AddressSupport(const virDomainDef *def,
-                                const char *devicename)
- {
-     if (info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
--        if (!qemuDomainMachineIsS390CCW(def)) {
-+        if (!qemuDomainIsS390CCW(def)) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                            _("cannot use CCW address type for device "
-                              "'%s' using machine type '%s'"),
-@@ -2294,7 +2294,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
- 
-         /* PowerPC pseries based VMs do not support floppy device */
-         if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
--            qemuDomainMachineIsPSeries(def)) {
-+            qemuDomainIsPSeries(def)) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                            _("PowerPC pseries machines do not support floppy device"));
-             return -1;
-@@ -2345,7 +2345,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
-                                 disk->info.alias) < 0)
-                     return -1;
- 
--                if (!qemuDomainMachineNeedsFDC(def)) {
-+                if (!qemuDomainNeedsFDC(def)) {
-                     virCommandAddArg(cmd, "-global");
-                     virCommandAddArgFormat(cmd, "isa-fdc.%s", optstr);
-                 } else {
-@@ -2360,7 +2360,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
-                                     bootindex) < 0)
-                         return -1;
- 
--                    if (!qemuDomainMachineNeedsFDC(def)) {
-+                    if (!qemuDomainNeedsFDC(def)) {
-                         virCommandAddArg(cmd, "-global");
-                         virCommandAddArgFormat(cmd, "isa-fdc.%s", optstr);
-                     } else {
-@@ -3076,7 +3076,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
-          * specified, or one with a single IDE contraller had multiple
-          * ide controllers specified.
-          */
--        if (qemuDomainMachineHasBuiltinIDE(domainDef))
-+        if (qemuDomainHasBuiltinIDE(domainDef))
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                            _("Only a single IDE controller is supported "
-                              "for this machine type"));
-@@ -3174,18 +3174,18 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
- 
-             /* first SATA controller on Q35 machines is implicit */
-             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA &&
--                cont->idx == 0 && qemuDomainMachineIsQ35(def))
-+                cont->idx == 0 && qemuDomainIsQ35(def))
-                     continue;
- 
-             /* first IDE controller is implicit on various machines */
-             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE &&
--                cont->idx == 0 && qemuDomainMachineHasBuiltinIDE(def))
-+                cont->idx == 0 && qemuDomainHasBuiltinIDE(def))
-                     continue;
- 
-             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
-                 cont->model == -1 &&
--                !qemuDomainMachineIsQ35(def) &&
--                !qemuDomainMachineIsVirt(def)) {
-+                !qemuDomainIsQ35(def) &&
-+                !qemuDomainIsVirt(def)) {
- 
-                 /* An appropriate default USB controller model should already
-                  * have been selected in qemuDomainDeviceDefPostParse(); if
-@@ -3222,8 +3222,8 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
-      * not to add one either. Add a legacy USB controller, unless we're
-      * creating a kind of guest we want to keep legacy-free */
-     if (usbcontroller == 0 &&
--        !qemuDomainMachineIsQ35(def) &&
--        !qemuDomainMachineIsVirt(def) &&
-+        !qemuDomainIsQ35(def) &&
-+        !qemuDomainIsVirt(def) &&
-         !ARCH_IS_S390(def->os.arch))
-         virCommandAddArg(cmd, "-usb");
- 
-@@ -4104,7 +4104,7 @@ qemuBuildNVRAMCommandLine(virCommandPtr cmd,
-     if (!def->nvram)
-         return 0;
- 
--    if (qemuDomainMachineIsPSeries(def)) {
-+    if (qemuDomainIsPSeries(def)) {
-         if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVRAM)) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                            _("nvram device is not supported by "
-@@ -6484,7 +6484,7 @@ qemuBuildPMCommandLine(virCommandPtr cmd,
-     if (def->pm.s3) {
-         const char *pm_object = "PIIX4_PM";
- 
--        if (qemuDomainMachineIsQ35(def) &&
-+        if (qemuDomainIsQ35(def) &&
-             virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_DISABLE_S3)) {
-             pm_object = "ICH9-LPC";
-         } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX_DISABLE_S3)) {
-@@ -6501,7 +6501,7 @@ qemuBuildPMCommandLine(virCommandPtr cmd,
-     if (def->pm.s4) {
-         const char *pm_object = "PIIX4_PM";
- 
--        if (qemuDomainMachineIsQ35(def) &&
-+        if (qemuDomainIsQ35(def) &&
-             virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_DISABLE_S4)) {
-             pm_object = "ICH9-LPC";
-         } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX_DISABLE_S4)) {
-@@ -6686,7 +6686,7 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
-                            virDomainIOMMUModelTypeToString(def->iommu->model));
-             return -1;
-         }
--        if (!qemuDomainMachineIsQ35(def)) {
-+        if (!qemuDomainIsQ35(def)) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                            _("IOMMU device: '%s' is only supported with "
-                              "Q35 machines"),
-@@ -6720,13 +6720,13 @@ qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
-             case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
-                 hoststr = "i440FX-pcihost";
-                 cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
--                machine = qemuDomainMachineIsI440FX(def);
-+                machine = qemuDomainIsI440FX(def);
-                 break;
- 
-             case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
-                 hoststr = "q35-pcihost";
-                 cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_Q35_PCI_HOLE64_SIZE);
--                machine = qemuDomainMachineIsQ35(def);
-+                machine = qemuDomainIsQ35(def);
-                 break;
- 
-             default:
-@@ -7332,7 +7332,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
- 
-         if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON) {
-             if (def->gic_version != VIR_GIC_VERSION_NONE) {
--                if (!qemuDomainMachineIsVirt(def)) {
-+                if (!qemuDomainIsVirt(def)) {
-                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                                    _("gic-version option is available "
-                                      "only for ARM virt machine"));
-@@ -7361,7 +7361,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
-             virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU)) {
-             switch (def->iommu->model) {
-             case VIR_DOMAIN_IOMMU_MODEL_INTEL:
--                if (!qemuDomainMachineIsQ35(def)) {
-+                if (!qemuDomainIsQ35(def)) {
-                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                                    _("IOMMU device: '%s' is only supported with "
-                                      "Q35 machines"),
-@@ -9624,7 +9624,7 @@ qemuBuildPanicCommandLine(virCommandPtr cmd,
-             /* For pSeries guests, the firmware provides the same
-              * functionality as the pvpanic device. The address
-              * cannot be configured by the user */
--            if (!qemuDomainMachineIsPSeries(def)) {
-+            if (!qemuDomainIsPSeries(def)) {
-                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                                _("only pSeries guests support panic device "
-                                  "of model 'pseries'"));
-@@ -10050,7 +10050,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
- {
-     virBuffer cmd = VIR_BUFFER_INITIALIZER;
- 
--    if (qemuDomainMachineIsPSeries(def)) {
-+    if (qemuDomainIsPSeries(def)) {
-         if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
-             serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) {
-             virBufferAsprintf(&cmd, "spapr-vty,chardev=char%s",
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index f383a6cf2..3150e8760 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -2334,7 +2334,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
-             addDefaultUSB = false;
-             break;
-         }
--        if (qemuDomainMachineIsQ35(def)) {
-+        if (qemuDomainIsQ35(def)) {
-             addPCIeRoot = true;
-             addImplicitSATA = true;
- 
-@@ -2351,7 +2351,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
-                 addDefaultUSB = false;
-             break;
-         }
--        if (qemuDomainMachineIsI440FX(def))
-+        if (qemuDomainIsI440FX(def))
-             addPCIRoot = true;
-         break;
- 
-@@ -2359,7 +2359,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
-     case VIR_ARCH_AARCH64:
-         addDefaultUSB = false;
-         addDefaultMemballoon = false;
--        if (qemuDomainMachineIsVirt(def))
-+        if (qemuDomainIsVirt(def))
-             addPCIeRoot = virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX);
-         break;
- 
-@@ -2371,7 +2371,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
-         /* For pSeries guests, the firmware provides the same
-          * functionality as the pvpanic device, so automatically
-          * add the definition if not already present */
--        if (qemuDomainMachineIsPSeries(def))
-+        if (qemuDomainIsPSeries(def))
-             addPanicDevice = true;
-         break;
- 
-@@ -2521,7 +2521,7 @@ qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def,
-      * was not included in the domain XML, we need to choose a suitable
-      * GIC version ourselves */
-     if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ABSENT &&
--        qemuDomainMachineIsVirt(def)) {
-+        qemuDomainIsVirt(def)) {
- 
-         VIR_DEBUG("Looking for usable GIC version in domain capabilities");
-         for (version = VIR_GIC_VERSION_LAST - 1;
-@@ -2909,7 +2909,7 @@ qemuDomainDefValidate(const virDomainDef *def,
-         /* These are the QEMU implementation limitations. But we
-          * have to live with them for now. */
- 
--        if (!qemuDomainMachineIsQ35(def)) {
-+        if (!qemuDomainIsQ35(def)) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                            _("Secure boot is supported with q35 machine types only"));
-             goto cleanup;
-@@ -3008,7 +3008,7 @@ qemuDomainDefaultNetModel(const virDomainDef *def,
-         if (STREQ(def->os.machine, "versatilepb"))
-             return "smc91c111";
- 
--        if (qemuDomainMachineIsVirt(def))
-+        if (qemuDomainIsVirt(def))
-             return "virtio";
- 
-         /* Incomplete. vexpress (and a few others) use this, but not all
-@@ -3167,14 +3167,14 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
- 
-     case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
-         if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS &&
--            !qemuDomainMachineIsI440FX(def)) {
-+            !qemuDomainIsI440FX(def)) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                            _("pci-expander-bus controllers are only supported "
-                              "on 440fx-based machinetypes"));
-             return -1;
-         }
-         if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS &&
--            !qemuDomainMachineIsQ35(def)) {
-+            !qemuDomainIsQ35(def)) {
-             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                            _("pcie-expander-bus controllers are only supported "
-                              "on q35-based machinetypes"));
-@@ -3329,7 +3329,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
- 
-     if (dev->type == VIR_DOMAIN_DEVICE_PANIC &&
-         dev->data.panic->model == VIR_DOMAIN_PANIC_MODEL_DEFAULT) {
--        if (qemuDomainMachineIsPSeries(def))
-+        if (qemuDomainIsPSeries(def))
-             dev->data.panic->model = VIR_DOMAIN_PANIC_MODEL_PSERIES;
-         else if (ARCH_IS_S390(def->os.arch))
-             dev->data.panic->model = VIR_DOMAIN_PANIC_MODEL_S390;
-@@ -4016,7 +4016,7 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
-          * because other architectures and machine types were introduced
-          * when libvirt already supported <controller type='usb'/>.
-          */
--        if (ARCH_IS_X86(def->os.arch) && qemuDomainMachineIsI440FX(def) &&
-+        if (ARCH_IS_X86(def->os.arch) && qemuDomainIsI440FX(def) &&
-             usb && usb->idx == 0 &&
-             (usb->model == -1 ||
-              usb->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI)) {
-@@ -5849,26 +5849,40 @@ qemuFindAgentConfig(virDomainDefPtr def)
- 
- 
- bool
--qemuDomainMachineIsQ35(const virDomainDef *def)
-+qemuDomainIsQ35(const virDomainDef *def)
- {
--    return (STRPREFIX(def->os.machine, "pc-q35") ||
--            STREQ(def->os.machine, "q35"));
-+    return qemuDomainMachineIsQ35(def->os.machine);
- }
- 
- 
- bool
--qemuDomainMachineIsI440FX(const virDomainDef *def)
-+qemuDomainMachineIsQ35(const char *machine)
- {
--    return (STREQ(def->os.machine, "pc") ||
--            STRPREFIX(def->os.machine, "pc-0.") ||
--            STRPREFIX(def->os.machine, "pc-1.") ||
--            STRPREFIX(def->os.machine, "pc-i440") ||
--            STRPREFIX(def->os.machine, "rhel"));
-+    return (STRPREFIX(machine, "pc-q35") ||
-+            STREQ(machine, "q35"));
- }
- 
- 
- bool
--qemuDomainMachineHasPCIRoot(const virDomainDef *def)
-+qemuDomainIsI440FX(const virDomainDef *def)
-+{
-+    return qemuDomainMachineIsI440FX(def->os.machine);
-+}
-+
-+
-+bool
-+qemuDomainMachineIsI440FX(const char *machine)
-+{
-+    return (STREQ(machine, "pc") ||
-+            STRPREFIX(machine, "pc-0.") ||
-+            STRPREFIX(machine, "pc-1.") ||
-+            STRPREFIX(machine, "pc-i440") ||
-+            STRPREFIX(machine, "rhel"));
-+}
-+
-+
-+bool
-+qemuDomainHasPCIRoot(const virDomainDef *def)
- {
-     int root = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0);
- 
-@@ -5883,7 +5897,7 @@ qemuDomainMachineHasPCIRoot(const virDomainDef *def)
- 
- 
- bool
--qemuDomainMachineHasPCIeRoot(const virDomainDef *def)
-+qemuDomainHasPCIeRoot(const virDomainDef *def)
- {
-     int root = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0);
- 
-@@ -5898,9 +5912,16 @@ qemuDomainMachineHasPCIeRoot(const virDomainDef *def)
- 
- 
- bool
--qemuDomainMachineNeedsFDC(const virDomainDef *def)
-+qemuDomainNeedsFDC(const virDomainDef *def)
- {
--    char *p = STRSKIP(def->os.machine, "pc-q35-");
-+    return qemuDomainMachineNeedsFDC(def->os.machine);
-+}
-+
-+
-+bool
-+qemuDomainMachineNeedsFDC(const char *machine)
-+{
-+    const char *p = STRSKIP(machine, "pc-q35-");
- 
-     if (p) {
-         if (STRPREFIX(p, "1.") ||
-@@ -5919,21 +5940,36 @@ qemuDomainMachineNeedsFDC(const virDomainDef *def)
- 
- 
- bool
--qemuDomainMachineIsS390CCW(const virDomainDef *def)
-+qemuDomainIsS390CCW(const virDomainDef *def)
- {
--    return STRPREFIX(def->os.machine, "s390-ccw");
-+    return qemuDomainMachineIsS390CCW(def->os.machine);
- }
- 
- 
- bool
--qemuDomainMachineIsVirt(const virDomainDef *def)
-+qemuDomainMachineIsS390CCW(const char *machine)
- {
--    if (def->os.arch != VIR_ARCH_ARMV7L &&
--        def->os.arch != VIR_ARCH_AARCH64)
-+    return STRPREFIX(machine, "s390-ccw");
-+}
-+
-+
-+bool
-+qemuDomainIsVirt(const virDomainDef *def)
-+{
-+    return qemuDomainMachineIsVirt(def->os.machine, def->os.arch);
-+}
-+
-+
-+bool
-+qemuDomainMachineIsVirt(const char *machine,
-+                        const virArch arch)
-+{
-+    if (arch != VIR_ARCH_ARMV7L &&
-+        arch != VIR_ARCH_AARCH64)
-         return false;
- 
--    if (STRNEQ(def->os.machine, "virt") &&
--        !STRPREFIX(def->os.machine, "virt-"))
-+    if (STRNEQ(machine, "virt") &&
-+        !STRPREFIX(machine, "virt-"))
-         return false;
- 
-     return true;
-@@ -5941,13 +5977,21 @@ qemuDomainMachineIsVirt(const virDomainDef *def)
- 
- 
- bool
--qemuDomainMachineIsPSeries(const virDomainDef *def)
-+qemuDomainIsPSeries(const virDomainDef *def)
- {
--    if (!ARCH_IS_PPC64(def->os.arch))
-+    return qemuDomainMachineIsPSeries(def->os.machine, def->os.arch);
-+}
-+
-+
-+bool
-+qemuDomainMachineIsPSeries(const char *machine,
-+                           const virArch arch)
-+{
-+    if (!ARCH_IS_PPC64(arch))
-         return false;
- 
--    if (STRNEQ(def->os.machine, "pseries") &&
--        !STRPREFIX(def->os.machine, "pseries-"))
-+    if (STRNEQ(machine, "pseries") &&
-+        !STRPREFIX(machine, "pseries-"))
-         return false;
- 
-     return true;
-@@ -6149,12 +6193,19 @@ qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
- 
- 
- bool
--qemuDomainMachineHasBuiltinIDE(const virDomainDef *def)
-+qemuDomainHasBuiltinIDE(const virDomainDef *def)
- {
--    return qemuDomainMachineIsI440FX(def) ||
--        STREQ(def->os.machine, "malta") ||
--        STREQ(def->os.machine, "sun4u") ||
--        STREQ(def->os.machine, "g3beige");
-+    return qemuDomainMachineHasBuiltinIDE(def->os.machine);
-+}
-+
-+
-+bool
-+qemuDomainMachineHasBuiltinIDE(const char *machine)
-+{
-+    return qemuDomainMachineIsI440FX(machine) ||
-+        STREQ(machine, "malta") ||
-+        STREQ(machine, "sun4u") ||
-+        STREQ(machine, "g3beige");
- }
- 
- 
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index 91573ff06..0e32bb9ea 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -677,15 +677,25 @@ void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
- 
- virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);
- 
--bool qemuDomainMachineIsQ35(const virDomainDef *def);
--bool qemuDomainMachineIsI440FX(const virDomainDef *def);
--bool qemuDomainMachineHasPCIRoot(const virDomainDef *def);
--bool qemuDomainMachineHasPCIeRoot(const virDomainDef *def);
--bool qemuDomainMachineNeedsFDC(const virDomainDef *def);
--bool qemuDomainMachineIsS390CCW(const virDomainDef *def);
--bool qemuDomainMachineIsVirt(const virDomainDef *def);
--bool qemuDomainMachineIsPSeries(const virDomainDef *def);
--bool qemuDomainMachineHasBuiltinIDE(const virDomainDef *def);
-+bool qemuDomainIsQ35(const virDomainDef *def);
-+bool qemuDomainIsI440FX(const virDomainDef *def);
-+bool qemuDomainHasPCIRoot(const virDomainDef *def);
-+bool qemuDomainHasPCIeRoot(const virDomainDef *def);
-+bool qemuDomainNeedsFDC(const virDomainDef *def);
-+bool qemuDomainIsS390CCW(const virDomainDef *def);
-+bool qemuDomainIsVirt(const virDomainDef *def);
-+bool qemuDomainIsPSeries(const virDomainDef *def);
-+bool qemuDomainHasBuiltinIDE(const virDomainDef *def);
-+
-+bool qemuDomainMachineIsQ35(const char *machine);
-+bool qemuDomainMachineIsI440FX(const char *machine);
-+bool qemuDomainMachineNeedsFDC(const char *machine);
-+bool qemuDomainMachineIsS390CCW(const char *machine);
-+bool qemuDomainMachineIsVirt(const char *machine,
-+                             const virArch arch);
-+bool qemuDomainMachineIsPSeries(const char *machine,
-+                                const virArch arch);
-+bool qemuDomainMachineHasBuiltinIDE(const char *machine);
- 
- int qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
-                                       virDomainObjPtr vm);
-diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
-index 22d8bf67d..064d05079 100644
---- a/src/qemu/qemu_domain_address.c
-+++ b/src/qemu/qemu_domain_address.c
-@@ -88,7 +88,7 @@ qemuDomainSetSCSIControllerModel(const virDomainDef *def,
-             return -1;
-         }
-     } else {
--        if (qemuDomainMachineIsPSeries(def)) {
-+        if (qemuDomainIsPSeries(def)) {
-             *model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
-         } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) {
-             *model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC;
-@@ -245,7 +245,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
- 
-     for (i = 0; i < def->nserials; i++) {
-         if (def->serials[i]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
--            qemuDomainMachineIsPSeries(def))
-+            qemuDomainIsPSeries(def))
-             def->serials[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
-         if (qemuDomainAssignSpaprVIOAddress(def, &def->serials[i]->info,
-                                             VIO_ADDR_SERIAL) < 0)
-@@ -253,7 +253,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
-     }
- 
-     if (def->nvram) {
--        if (qemuDomainMachineIsPSeries(def))
-+        if (qemuDomainIsPSeries(def))
-             def->nvram->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
-         if (qemuDomainAssignSpaprVIOAddress(def, &def->nvram->info,
-                                             VIO_ADDR_NVRAM) < 0)
-@@ -375,7 +375,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def,
-     int ret = -1;
-     virDomainCCWAddressSetPtr addrs = NULL;
- 
--    if (qemuDomainMachineIsS390CCW(def) &&
-+    if (qemuDomainIsS390CCW(def) &&
-         virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
-         qemuDomainPrimeVirtioDeviceAddresses(
-             def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
-@@ -445,13 +445,13 @@ qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def,
-         return;
- 
-     if (!(STRPREFIX(def->os.machine, "vexpress-") ||
--          qemuDomainMachineIsVirt(def)))
-+          qemuDomainIsVirt(def)))
-         return;
- 
-     /* We use virtio-mmio by default on mach-virt guests only if they already
-      * have at least one virtio-mmio device: in all other cases, we prefer
-      * virtio-pci */
--    if (qemuDomainMachineHasPCIeRoot(def) &&
-+    if (qemuDomainHasPCIeRoot(def) &&
-         !qemuDomainHasVirtioMMIODevices(def)) {
-         qemuDomainPrimeVirtioDeviceAddresses(def,
-                                              VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI);
-@@ -826,7 +826,7 @@ qemuDomainFillDevicePCIConnectFlagsIterInit(virDomainDefPtr def,
- 
-     data->driver = driver;
- 
--    if (qemuDomainMachineHasPCIeRoot(def)) {
-+    if (qemuDomainHasPCIeRoot(def)) {
-         data->pcieFlags = (VIR_PCI_CONNECT_TYPE_PCIE_DEVICE |
-                            VIR_PCI_CONNECT_HOTPLUGGABLE);
-     } else {
-@@ -1479,12 +1479,12 @@ qemuDomainValidateDevicePCISlotsChipsets(virDomainDefPtr def,
-                                          virQEMUCapsPtr qemuCaps,
-                                          virDomainPCIAddressSetPtr addrs)
- {
--    if (qemuDomainMachineIsI440FX(def) &&
-+    if (qemuDomainIsI440FX(def) &&
-         qemuDomainValidateDevicePCISlotsPIIX3(def, qemuCaps, addrs) < 0) {
-         return -1;
-     }
- 
--    if (qemuDomainMachineIsQ35(def) &&
-+    if (qemuDomainIsQ35(def) &&
-         qemuDomainValidateDevicePCISlotsQ35(def, qemuCaps, addrs) < 0) {
-         return -1;
-     }
-@@ -1845,7 +1845,7 @@ qemuDomainSupportsPCI(virDomainDefPtr def,
-     if (STREQ(def->os.machine, "versatilepb"))
-         return true;
- 
--    if (qemuDomainMachineIsVirt(def) &&
-+    if (qemuDomainIsVirt(def) &&
-         virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX))
-         return true;
- 
-@@ -2024,7 +2024,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
-          * all *actual* devices.
-          */
- 
--        if (qemuDomainMachineHasPCIRoot(def)) {
-+        if (qemuDomainHasPCIRoot(def)) {
-             /* This is a dummy info used to reserve a slot for a
-              * legacy PCI device that doesn't exist, but may in the
-              * future, e.g.  if another device is hotplugged into the
-@@ -2066,7 +2066,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
- 
-         if (max_idx <= 0 &&
-             addrs->nbuses > max_idx + 1 &&
--            qemuDomainMachineHasPCIeRoot(def)) {
-+            qemuDomainHasPCIeRoot(def)) {
-             virDomainDeviceInfo info = {
-                 .pciConnectFlags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
-                                     VIR_PCI_CONNECT_TYPE_PCIE_DEVICE)
-diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
-index a6dac6f09..37b8d455c 100644
---- a/src/qemu/qemu_hotplug.c
-+++ b/src/qemu/qemu_hotplug.c
-@@ -329,7 +329,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
-     qemuDomainSecretInfoPtr encinfo;
- 
-     if (!disk->info.type) {
--        if (qemuDomainMachineIsS390CCW(vm->def) &&
-+        if (qemuDomainIsS390CCW(vm->def) &&
-             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
-             disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
-         else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
-@@ -497,7 +497,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
-     }
- 
-     if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
--        if (qemuDomainMachineIsS390CCW(vm->def) &&
-+        if (qemuDomainIsS390CCW(vm->def) &&
-             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
-             controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
-         else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
-@@ -1141,7 +1141,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
-             goto cleanup;
-     }
- 
--    if (qemuDomainMachineIsS390CCW(vm->def) &&
-+    if (qemuDomainIsS390CCW(vm->def) &&
-         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
-         net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
-         if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def)))
-@@ -2079,7 +2079,7 @@ qemuDomainAttachRNGDevice(virConnectPtr conn,
-         goto cleanup;
- 
-     if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
--        if (qemuDomainMachineIsS390CCW(vm->def) &&
-+        if (qemuDomainIsS390CCW(vm->def) &&
-             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
-             rng->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
-         } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
-@@ -2620,7 +2620,7 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driver,
-         goto cleanup;
- 
-     if (hostdev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
--        if (qemuDomainMachineIsS390CCW(vm->def) &&
-+        if (qemuDomainIsS390CCW(vm->def) &&
-             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
-             hostdev->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
-     }
-@@ -4447,7 +4447,7 @@ qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver,
-         goto cleanup;
-     }
- 
--    if (qemuDomainMachineIsS390CCW(vm->def) &&
-+    if (qemuDomainIsS390CCW(vm->def) &&
-         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
-         if (!virDomainDeviceAddressIsValid(&detach->info,
-                                            VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
-@@ -5007,7 +5007,7 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
-                                              virDomainNetGetActualHostdev(detach));
-         goto cleanup;
-     }
--    if (qemuDomainMachineIsS390CCW(vm->def) &&
-+    if (qemuDomainIsS390CCW(vm->def) &&
-         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
-         if (!virDomainDeviceAddressIsValid(&detach->info,
-                                            VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
-diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
-index fc176c168..af9063c02 100644
---- a/src/qemu/qemu_parse_command.c
-+++ b/src/qemu/qemu_parse_command.c
-@@ -654,7 +654,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
-     if (VIR_ALLOC(def->src) < 0)
-         goto error;
- 
--    if (qemuDomainMachineIsPSeries(dom))
-+    if (qemuDomainIsPSeries(dom))
-         def->bus = VIR_DOMAIN_DISK_BUS_SCSI;
-     else
-        def->bus = VIR_DOMAIN_DISK_BUS_IDE;
-@@ -746,7 +746,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
-         } else if (STREQ(keywords[i], "if")) {
-             if (STREQ(values[i], "ide")) {
-                 def->bus = VIR_DOMAIN_DISK_BUS_IDE;
--                if (qemuDomainMachineIsPSeries(dom)) {
-+                if (qemuDomainIsPSeries(dom)) {
-                     virReportError(VIR_ERR_INTERNAL_ERROR,
-                                    _("pseries systems do not support ide devices '%s'"), val);
-                     goto error;
-@@ -1950,7 +1950,7 @@ qemuParseCommandLine(virCapsPtr caps,
-             }
-             if (STREQ(arg, "-cdrom")) {
-                 disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
--                if (qemuDomainMachineIsPSeries(def))
-+                if (qemuDomainIsPSeries(def))
-                     disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
-                 if (VIR_STRDUP(disk->dst, "hdc") < 0)
-                     goto error;
-@@ -1965,7 +1965,7 @@ qemuParseCommandLine(virCapsPtr caps,
-                         disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
-                     else
-                         disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
--                   if (qemuDomainMachineIsPSeries(def))
-+                   if (qemuDomainIsPSeries(def))
-                        disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
-                 }
-                 if (VIR_STRDUP(disk->dst, arg + 1) < 0)
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-remove-input-device-after-receiving-the-event.patch b/SOURCES/libvirt-qemu-remove-input-device-after-receiving-the-event.patch
new file mode 100644
index 0000000..7f2ff69
--- /dev/null
+++ b/SOURCES/libvirt-qemu-remove-input-device-after-receiving-the-event.patch
@@ -0,0 +1,46 @@
+From 4f65cfb51fcef877737edeb75f4a06a9988e592e Mon Sep 17 00:00:00 2001
+Message-Id: <4f65cfb51fcef877737edeb75f4a06a9988e592e@dist-git>
+From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
+Date: Thu, 14 Dec 2017 17:01:33 +0100
+Subject: [PATCH] qemu: remove input device after receiving the event
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Also call qemuDomainRemoveInputDevice if we receive the
+event after the Detach API ends.
+
+Commit 67486bb failed to include this.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1524837
+Signed-off-by: Ján Tomko <jtomko@redhat.com>
+Reviewed-by: Erik Skultety <eskultet@redhat.com>
+(cherry picked from commit 8d51042ef873d2a868d505f0eff32346ba041a95)
+Signed-off-by: Ján Tomko <jtomko@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 eab9ad794a..f1056627f2 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -4368,10 +4368,13 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
+         ret = qemuDomainRemoveShmemDevice(driver, vm, dev->data.shmem);
+         break;
+ 
++    case VIR_DOMAIN_DEVICE_INPUT:
++        ret = qemuDomainRemoveInputDevice(vm, dev->data.input);
++        break;
++
+     case VIR_DOMAIN_DEVICE_NONE:
+     case VIR_DOMAIN_DEVICE_LEASE:
+     case VIR_DOMAIN_DEVICE_FS:
+-    case VIR_DOMAIN_DEVICE_INPUT:
+     case VIR_DOMAIN_DEVICE_SOUND:
+     case VIR_DOMAIN_DEVICE_VIDEO:
+     case VIR_DOMAIN_DEVICE_WATCHDOG:
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-rename-QEMU_CAPS_SCLP_S390-to-QEMU_CAPS_DEVICE_SCLPCONSOLE.patch b/SOURCES/libvirt-qemu-rename-QEMU_CAPS_SCLP_S390-to-QEMU_CAPS_DEVICE_SCLPCONSOLE.patch
new file mode 100644
index 0000000..24decf5
--- /dev/null
+++ b/SOURCES/libvirt-qemu-rename-QEMU_CAPS_SCLP_S390-to-QEMU_CAPS_DEVICE_SCLPCONSOLE.patch
@@ -0,0 +1,83 @@
+From 25bfc26066807438fe1f738f6f90100cc5da6e42 Mon Sep 17 00:00:00 2001
+Message-Id: <25bfc26066807438fe1f738f6f90100cc5da6e42@dist-git>
+From: Pino Toscano <ptoscano@redhat.com>
+Date: Wed, 29 Nov 2017 16:22:52 +0100
+Subject: [PATCH] qemu: rename QEMU_CAPS_SCLP_S390 to
+ QEMU_CAPS_DEVICE_SCLPCONSOLE
+
+Give a better name to the capability for the sclpconsole device.
+
+Signed-off-by: Pino Toscano <ptoscano@redhat.com>
+Reviewed-by: Andrea Bolognani <abologna@redhat.com>
+(cherry picked from commit 98b55862efb3aad3d96223286f417d1b85921a68)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+https://bugzilla.redhat.com/show_bug.cgi?id=1511421
+https://bugzilla.redhat.com/show_bug.cgi?id=1512929
+https://bugzilla.redhat.com/show_bug.cgi?id=1512934
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c | 2 +-
+ src/qemu/qemu_capabilities.h | 2 +-
+ src/qemu/qemu_command.c      | 4 ++--
+ tests/qemuxml2argvtest.c     | 2 +-
+ 4 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 0defa9a3e4..374a2e79a7 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -1604,7 +1604,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
+     { "ich9-ahci", QEMU_CAPS_ICH9_AHCI },
+     { "virtio-blk-s390", QEMU_CAPS_VIRTIO_S390 },
+     { "virtio-blk-ccw", QEMU_CAPS_VIRTIO_CCW },
+-    { "sclpconsole", QEMU_CAPS_SCLP_S390 },
++    { "sclpconsole", QEMU_CAPS_DEVICE_SCLPCONSOLE },
+     { "lsi53c895a", QEMU_CAPS_SCSI_LSI },
+     { "virtio-scsi-pci", QEMU_CAPS_VIRTIO_SCSI },
+     { "virtio-scsi-s390", QEMU_CAPS_VIRTIO_SCSI },
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index 65b969a0ea..f115738b6b 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -220,7 +220,7 @@ typedef enum {
+     QEMU_CAPS_DEVICE_CIRRUS_VGA, /* -device cirrus-vga */
+     QEMU_CAPS_DEVICE_VMWARE_SVGA, /* -device vmware-svga */
+     QEMU_CAPS_DEVICE_VIDEO_PRIMARY, /* -device safe for primary video device */
+-    QEMU_CAPS_SCLP_S390, /* -device sclp* */
++    QEMU_CAPS_DEVICE_SCLPCONSOLE, /* -device sclpconsole */
+ 
+     /* 125 */
+     QEMU_CAPS_DEVICE_USB_SERIAL, /* -device usb-serial */
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 65b6a59d3f..092d820b1d 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -9420,9 +9420,9 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
+         switch (console->targetType) {
+         case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP:
+         case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM:
+-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCLP_S390)) {
++            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCLPCONSOLE)) {
+                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+-                               _("sclp console requires QEMU to support s390-sclp"));
++                               _("sclpconsole is not supported in this QEMU binary"));
+                 return -1;
+             }
+ 
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 70c72e4e64..747ad24663 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -1333,7 +1333,7 @@ mymain(void)
+     DO_TEST("console-sclp",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_VIRTIO_S390,
+-            QEMU_CAPS_SCLP_S390);
++            QEMU_CAPS_DEVICE_SCLPCONSOLE);
+     DO_TEST("channel-spicevmc",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_SPICE,
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-report-IDE-bus-in-domain-capabilities-only-if-it-s-supported.patch b/SOURCES/libvirt-qemu-report-IDE-bus-in-domain-capabilities-only-if-it-s-supported.patch
deleted file mode 100644
index 7ded9ac..0000000
--- a/SOURCES/libvirt-qemu-report-IDE-bus-in-domain-capabilities-only-if-it-s-supported.patch
+++ /dev/null
@@ -1,113 +0,0 @@
-From 09f3f5a0fa779a4a151f1aeba1ec82d935beb248 Mon Sep 17 00:00:00 2001
-Message-Id: <09f3f5a0fa779a4a151f1aeba1ec82d935beb248@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Wed, 19 Apr 2017 09:51:15 +0200
-Subject: [PATCH] qemu: report IDE bus in domain capabilities only if it's
- supported
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1441964
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 8ddd44806b62cec11072a5cccd4b1ab0da315425)
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_capabilities.c                                 | 4 +++-
- tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml | 1 -
- tests/domaincapsschemadata/qemu_2.6.0-gicv3-virt.aarch64.xml | 1 -
- tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml            | 1 -
- tests/domaincapsschemadata/qemu_2.6.0.ppc64le.xml            | 1 -
- tests/domaincapsschemadata/qemu_2.7.0.s390x.xml              | 1 -
- tests/domaincapsschemadata/qemu_2.8.0.s390x.xml              | 1 -
- 7 files changed, 3 insertions(+), 7 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index b7c2c3705..950a42bae 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -5512,8 +5512,10 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
-         (STRNEQ(machine, "pseries") && !STRPREFIX(machine, "pseries-")))
-         VIR_DOMAIN_CAPS_ENUM_SET(disk->diskDevice, VIR_DOMAIN_DISK_DEVICE_FLOPPY);
- 
-+    if (qemuDomainMachineHasBuiltinIDE(machine))
-+        VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_IDE);
-+
-     VIR_DOMAIN_CAPS_ENUM_SET(disk->bus,
--                             VIR_DOMAIN_DISK_BUS_IDE,
-                              VIR_DOMAIN_DISK_BUS_SCSI,
-                              VIR_DOMAIN_DISK_BUS_VIRTIO,
-                              /* VIR_DOMAIN_DISK_BUS_SD */);
-diff --git a/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml
-index 1fa7f6dff..54b89dc72 100644
---- a/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml
-+++ b/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml
-@@ -63,7 +63,6 @@
-         <value>lun</value>
-       </enum>
-       <enum name='bus'>
--        <value>ide</value>
-         <value>fdc</value>
-         <value>scsi</value>
-         <value>virtio</value>
-diff --git a/tests/domaincapsschemadata/qemu_2.6.0-gicv3-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0-gicv3-virt.aarch64.xml
-index d60fc1df9..60bf2f54f 100644
---- a/tests/domaincapsschemadata/qemu_2.6.0-gicv3-virt.aarch64.xml
-+++ b/tests/domaincapsschemadata/qemu_2.6.0-gicv3-virt.aarch64.xml
-@@ -63,7 +63,6 @@
-         <value>lun</value>
-       </enum>
-       <enum name='bus'>
--        <value>ide</value>
-         <value>fdc</value>
-         <value>scsi</value>
-         <value>virtio</value>
-diff --git a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
-index fcc6f50e0..1a980927c 100644
---- a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
-+++ b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
-@@ -63,7 +63,6 @@
-         <value>lun</value>
-       </enum>
-       <enum name='bus'>
--        <value>ide</value>
-         <value>fdc</value>
-         <value>scsi</value>
-         <value>virtio</value>
-diff --git a/tests/domaincapsschemadata/qemu_2.6.0.ppc64le.xml b/tests/domaincapsschemadata/qemu_2.6.0.ppc64le.xml
-index 755c4f447..4ecf8651b 100644
---- a/tests/domaincapsschemadata/qemu_2.6.0.ppc64le.xml
-+++ b/tests/domaincapsschemadata/qemu_2.6.0.ppc64le.xml
-@@ -37,7 +37,6 @@
-         <value>lun</value>
-       </enum>
-       <enum name='bus'>
--        <value>ide</value>
-         <value>scsi</value>
-         <value>virtio</value>
-         <value>usb</value>
-diff --git a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml
-index 999e2795d..dc6d2d8f0 100644
---- a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml
-+++ b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml
-@@ -32,7 +32,6 @@
-         <value>lun</value>
-       </enum>
-       <enum name='bus'>
--        <value>ide</value>
-         <value>fdc</value>
-         <value>scsi</value>
-         <value>virtio</value>
-diff --git a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml
-index 0b8135bc5..53c3190f2 100644
---- a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml
-+++ b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml
-@@ -113,7 +113,6 @@
-         <value>lun</value>
-       </enum>
-       <enum name='bus'>
--        <value>ide</value>
-         <value>fdc</value>
-         <value>scsi</value>
-         <value>virtio</value>
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-snapshot-Disallow-snapshot-of-unsupported-shared-disks.patch b/SOURCES/libvirt-qemu-snapshot-Disallow-snapshot-of-unsupported-shared-disks.patch
new file mode 100644
index 0000000..3fe4631
--- /dev/null
+++ b/SOURCES/libvirt-qemu-snapshot-Disallow-snapshot-of-unsupported-shared-disks.patch
@@ -0,0 +1,69 @@
+From 6f750627ca303b962cf2c610b9cd27bae0fc1439 Mon Sep 17 00:00:00 2001
+Message-Id: <6f750627ca303b962cf2c610b9cd27bae0fc1439@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 23 Nov 2017 19:02:20 +0100
+Subject: [PATCH] qemu: snapshot: Disallow snapshot of unsupported shared disks
+
+Creating a snapshot would introduce a possibly unsupported member for
+sharing into the backing chain. Add a check to prevent that from
+happening.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511480
+(cherry picked from commit 9b2fbfa6f6b535b9f41a7503531d43d86d7a8868)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_driver.c | 24 ++++++++++++++++++++++++
+ 1 file changed, 24 insertions(+)
+
+diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
+index aa6a326bb4..620028fe07 100644
+--- a/src/qemu/qemu_driver.c
++++ b/src/qemu/qemu_driver.c
+@@ -13952,6 +13952,24 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
+ }
+ 
+ 
++static int
++qemuDomainSnapshotPrepareDiskShared(virDomainSnapshotDiskDefPtr snapdisk,
++                                    virDomainDiskDefPtr domdisk)
++{
++    if (!domdisk->src->shared || domdisk->src->readonly)
++        return 0;
++
++    if (!qemuBlockStorageSourceSupportsConcurrentAccess(snapdisk->src)) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("shared access for disk '%s' requires use of "
++                         "supported storage format"), domdisk->dst);
++        return -1;
++    }
++
++    return 0;
++}
++
++
+ static int
+ qemuDomainSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDefPtr snapdisk,
+                                               virDomainDiskDefPtr domdisk)
+@@ -14014,6 +14032,9 @@ qemuDomainSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDefPtr snapdi
+         return -1;
+     }
+ 
++    if (qemuDomainSnapshotPrepareDiskShared(snapdisk, domdisk) < 0)
++        return -1;
++
+     return 0;
+ }
+ 
+@@ -14073,6 +14094,9 @@ qemuDomainSnapshotPrepareDiskExternalActive(virDomainSnapshotDiskDefPtr snapdisk
+         return -1;
+     }
+ 
++    if (qemuDomainSnapshotPrepareDiskShared(snapdisk, domdisk) < 0)
++        return -1;
++
+     return 0;
+ }
+ 
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemu-snapshot-Load-data-necessary-for-relative-block-commit-to-work.patch b/SOURCES/libvirt-qemu-snapshot-Load-data-necessary-for-relative-block-commit-to-work.patch
deleted file mode 100644
index d7192a8..0000000
--- a/SOURCES/libvirt-qemu-snapshot-Load-data-necessary-for-relative-block-commit-to-work.patch
+++ /dev/null
@@ -1,97 +0,0 @@
-From a1c6dd1700b461d84c6db3d62468c60f4e3b0a55 Mon Sep 17 00:00:00 2001
-Message-Id: <a1c6dd1700b461d84c6db3d62468c60f4e3b0a55@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 14:45:38 +0200
-Subject: [PATCH] qemu: snapshot: Load data necessary for relative block commit
- to work
-
-Commit 7456c4f5f introduced a regression by not reloading the backing
-chain of a disk after snapshot. The regression was caused as
-src->relPath was not set and thus the block commit code could not
-determine the relative path.
-
-This patch adds code that will load the backing store string if
-VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT and store it in the correct place
-when a snapshot is successfully completed.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1461303
-(cherry picked from commit e20853e1d32ff517e6feec3146066ec433fc39e6)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_driver.c | 19 +++++++++++++++++--
- 1 file changed, 17 insertions(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index c7c5e28ca3..a2fb41b91a 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -14094,6 +14094,7 @@ struct _qemuDomainSnapshotDiskData {
-     bool created; /* @src was created by the snapshot code */
-     bool prepared; /* @src was prepared using qemuDomainDiskChainElementPrepare */
-     virDomainDiskDefPtr disk;
-+    char *relPath; /* relative path component to fill into original disk */
- 
-     virStorageSourcePtr persistsrc;
-     virDomainDiskDefPtr persistdisk;
-@@ -14127,6 +14128,7 @@ qemuDomainSnapshotDiskDataFree(qemuDomainSnapshotDiskDataPtr data,
-             virStorageSourceFree(data[i].src);
-         }
-         virStorageSourceFree(data[i].persistsrc);
-+        VIR_FREE(data[i].relPath);
-     }
- 
-     VIR_FREE(data);
-@@ -14142,11 +14144,13 @@ qemuDomainSnapshotDiskDataFree(qemuDomainSnapshotDiskDataPtr data,
- static qemuDomainSnapshotDiskDataPtr
- qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr driver,
-                                   virDomainObjPtr vm,
--                                  virDomainSnapshotObjPtr snap)
-+                                  virDomainSnapshotObjPtr snap,
-+                                  bool reuse)
- {
-     size_t i;
-     qemuDomainSnapshotDiskDataPtr ret;
-     qemuDomainSnapshotDiskDataPtr dd;
-+    char *backingStoreStr;
- 
-     if (VIR_ALLOC_N(ret, snap->def->ndisks) < 0)
-         return NULL;
-@@ -14170,6 +14174,16 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr driver,
- 
-         dd->initialized = true;
- 
-+        /* relative backing store paths need to be updated so that relative
-+         * block commit still works */
-+        if (reuse &&
-+            (backingStoreStr = virStorageFileGetBackingStoreStr(dd->src))) {
-+            if (virStorageIsRelative(backingStoreStr))
-+                VIR_STEAL_PTR(dd->relPath, backingStoreStr);
-+            else
-+                VIR_FREE(backingStoreStr);
-+        }
-+
-         /* Note that it's unsafe to assume that the disks in the persistent
-          * definition match up with the disks in the live definition just by
-          * checking that the target name is the same. We've done that
-@@ -14213,6 +14227,7 @@ qemuDomainSnapshotUpdateDiskSources(qemuDomainSnapshotDiskDataPtr dd,
-     if (dd->initialized)
-         virStorageFileDeinit(dd->src);
- 
-+    VIR_STEAL_PTR(dd->disk->src->relPath, dd->relPath);
-     VIR_STEAL_PTR(dd->src->backingStore, dd->disk->src);
-     VIR_STEAL_PTR(dd->disk->src, dd->src);
- 
-@@ -14326,7 +14341,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
- 
-     /* prepare a list of objects to use in the vm definition so that we don't
-      * have to roll back later */
--    if (!(diskdata = qemuDomainSnapshotDiskDataCollect(driver, vm, snap)))
-+    if (!(diskdata = qemuDomainSnapshotDiskDataCollect(driver, vm, snap, reuse)))
-         goto cleanup;
- 
-     cfg = virQEMUDriverGetConfig(driver);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemu-start-all-async-job-with-job-status-active.patch b/SOURCES/libvirt-qemu-start-all-async-job-with-job-status-active.patch
deleted file mode 100644
index 5f7bbfc..0000000
--- a/SOURCES/libvirt-qemu-start-all-async-job-with-job-status-active.patch
+++ /dev/null
@@ -1,107 +0,0 @@
-From 2726e0de1158ab7788f16cd91df53a48b882a716 Mon Sep 17 00:00:00 2001
-Message-Id: <2726e0de1158ab7788f16cd91df53a48b882a716@dist-git>
-From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
-Date: Fri, 1 Sep 2017 09:49:27 +0300
-Subject: [PATCH] qemu: start all async job with job status active
-
-Setting status to none has little value - getting job status
-will not return even elapsed time.
-
-After this patch getting job stats stays correct in a sence
-it will not fetch migration stats because it consults
-stats.status before doing the fetch.
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit b6868c3cdd711e012c6cb1ec0e0a3cac4ea92a33)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530130
-
-Conflicts:
-	src/qemu/qemu_migration.c
-            - commit e87d4b9e2f is not backported
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c    | 1 +
- src/qemu/qemu_driver.c    | 2 --
- src/qemu/qemu_migration.c | 4 ----
- src/qemu/qemu_process.c   | 4 ----
- 4 files changed, 1 insertion(+), 10 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 329ec6e2ce..4b1ead7d0a 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -3811,6 +3811,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
-         qemuDomainObjResetAsyncJob(priv);
-         if (VIR_ALLOC(priv->job.current) < 0)
-             goto cleanup;
-+        priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
-         priv->job.asyncJob = asyncJob;
-         priv->job.asyncOwner = virThreadSelfID();
-         priv->job.asyncOwnerAPI = virThreadJobGet();
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index ecba87a121..8972897a28 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -3299,8 +3299,6 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
-         goto endjob;
-     }
- 
--    priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
--
-     /* Pause */
-     if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
-         was_running = true;
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 1726349f94..9f7aad6680 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -1563,7 +1563,6 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
- 
-     flags |= QEMU_MIGRATION_COMPLETED_UPDATE_STATS;
- 
--    jobInfo->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
-     while ((rv = qemuMigrationCompleted(driver, vm, asyncJob,
-                                         dconn, flags)) != 1) {
-         if (rv < 0)
-@@ -5624,7 +5623,6 @@ qemuMigrationJobStart(virQEMUDriverPtr driver,
-                       virDomainObjPtr vm,
-                       qemuDomainAsyncJob job)
- {
--    qemuDomainObjPrivatePtr priv = vm->privateData;
-     virDomainJobOperation op;
-     unsigned long long mask;
- 
-@@ -5642,8 +5640,6 @@ qemuMigrationJobStart(virQEMUDriverPtr driver,
-         return -1;
- 
-     qemuDomainObjSetAsyncJobMask(vm, mask);
--    priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
--
-     return 0;
- }
- 
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 25de367afc..1633652fdc 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -3943,15 +3943,11 @@ qemuProcessBeginJob(virQEMUDriverPtr driver,
-                     virDomainObjPtr vm,
-                     virDomainJobOperation operation)
- {
--    qemuDomainObjPrivatePtr priv = vm->privateData;
--
-     if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_START,
-                                    operation) < 0)
-         return -1;
- 
-     qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
--    priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
--
-     return 0;
- }
- 
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-switch-s390-s390x-default-console-back-to-serial.patch b/SOURCES/libvirt-qemu-switch-s390-s390x-default-console-back-to-serial.patch
new file mode 100644
index 0000000..830b9e0
--- /dev/null
+++ b/SOURCES/libvirt-qemu-switch-s390-s390x-default-console-back-to-serial.patch
@@ -0,0 +1,108 @@
+From 6fe46c6d8b1bfdd1f5d3e54798077e1db5b4180c Mon Sep 17 00:00:00 2001
+Message-Id: <6fe46c6d8b1bfdd1f5d3e54798077e1db5b4180c@dist-git>
+From: Pino Toscano <ptoscano@redhat.com>
+Date: Wed, 29 Nov 2017 16:23:16 +0100
+Subject: [PATCH] qemu: switch s390/s390x default console back to serial
+
+Now that <serial> and <console> on s390/s390x behave a bit more like the
+other architectures, remove this extra differentation, and use sclp
+console by default for new guests.  New virtio consoles can still be
+added, and it is actually needed because of the limited number of
+instances for sclp and sclplm.
+
+This reverts commit b1c88c14764e0b043a269d454a83a6ac7af34eac, whose
+reasons are not totally clear.
+
+Signed-off-by: Pino Toscano <ptoscano@redhat.com>
+Reviewed-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
+(cherry picked from commit 220c1f70dc96b1066cefbfe50f30e3111a2ecdc6)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1449265
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c                                          | 7 -------
+ tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args    | 5 +----
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml | 8 ++++++--
+ tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml | 6 ------
+ 4 files changed, 7 insertions(+), 19 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 91c0e163e1..1b5f439621 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -4255,13 +4255,6 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
+                           virQEMUDriverPtr driver,
+                           unsigned int parseFlags)
+ {
+-    /* set the default console type for S390 arches */
+-    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+-        chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
+-        ARCH_IS_S390(def->os.arch)) {
+-        chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
+-    }
+-
+     /* Historically, isa-serial and the default matched, so in order to
+      * maintain backwards compatibility we map them here. The actual default
+      * will be picked below based on the architecture and machine type. */
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args
+index c405fb59ee..20968f7945 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args
+@@ -18,8 +18,5 @@ QEMU_AUDIO_DRV=none \
+ server,nowait \
+ -mon chardev=charmonitor,id=monitor,mode=readline \
+ -boot c \
+--device virtio-serial-ccw,id=virtio-serial0,devno=fe.0.0000 \
+ -chardev pty,id=charserial0 \
+--device sclpconsole,chardev=charserial0,id=serial0 \
+--chardev pty,id=charconsole1 \
+--device virtconsole,chardev=charconsole1,id=console1
++-device sclpconsole,chardev=charserial0,id=serial0
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml
+index 7eb1a765ab..0f278f2c9d 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml
+@@ -14,9 +14,13 @@
+   <on_crash>destroy</on_crash>
+   <devices>
+     <emulator>/usr/bin/qemu-system-s390x</emulator>
+-    <controller type='virtio-serial' index='0'/>
++    <serial type='pty'>
++      <target type='sclp-serial' port='0'>
++        <model name='sclpconsole'/>
++      </target>
++    </serial>
+     <console type='pty'>
+-      <target type='virtio' port='0'/>
++      <target type='serial' port='0'/>
+     </console>
+     <memballoon model='none'/>
+     <panic model='s390'/>
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml
+index db3023b7a6..9c9b4dd27a 100644
+--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml
+@@ -14,9 +14,6 @@
+   <on_crash>destroy</on_crash>
+   <devices>
+     <emulator>/usr/bin/qemu-system-s390x</emulator>
+-    <controller type='virtio-serial' index='0'>
+-      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+-    </controller>
+     <serial type='pty'>
+       <target type='sclp-serial' port='0'>
+         <model name='sclpconsole'/>
+@@ -25,9 +22,6 @@
+     <console type='pty'>
+       <target type='serial' port='0'/>
+     </console>
+-    <console type='pty'>
+-      <target type='virtio' port='0'/>
+-    </console>
+     <memballoon model='none'/>
+     <panic model='s390'/>
+   </devices>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu-take-current-async-job-into-account-in-qemuBlockNodeNamesDetect.patch b/SOURCES/libvirt-qemu-take-current-async-job-into-account-in-qemuBlockNodeNamesDetect.patch
deleted file mode 100644
index f286c50..0000000
--- a/SOURCES/libvirt-qemu-take-current-async-job-into-account-in-qemuBlockNodeNamesDetect.patch
+++ /dev/null
@@ -1,340 +0,0 @@
-From b40b5b2f59acd26c7238d9bfc48364d06e44a97f Mon Sep 17 00:00:00 2001
-Message-Id: <b40b5b2f59acd26c7238d9bfc48364d06e44a97f@dist-git>
-From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
-Date: Fri, 7 Apr 2017 14:06:24 +0300
-Subject: [PATCH] qemu: take current async job into account in
- qemuBlockNodeNamesDetect
-
-Becase it can be called during migration out (namely on cancelling
-blockjobs).
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-(cherry picked from commit dd8e40790be7c88b476a93e2fa63fe086caa0cf8)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1530129
-
-Conflicts:
-	src/qemu/qemu_process.c
-            - context
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_block.c     |  6 ++++--
- src/qemu/qemu_block.h     |  4 +++-
- src/qemu/qemu_blockjob.c  |  9 ++++++---
- src/qemu/qemu_blockjob.h  |  4 ++++
- src/qemu/qemu_driver.c    | 11 ++++++-----
- src/qemu/qemu_migration.c | 28 ++++++++++++++++------------
- src/qemu/qemu_process.c   |  2 +-
- 7 files changed, 40 insertions(+), 24 deletions(-)
-
-diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
-index 586d56809d..29b5c4756e 100644
---- a/src/qemu/qemu_block.c
-+++ b/src/qemu/qemu_block.c
-@@ -336,7 +336,8 @@ qemuBlockDiskDetectNodes(virDomainDiskDefPtr disk,
- 
- int
- qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
--                         virDomainObjPtr vm)
-+                         virDomainObjPtr vm,
-+                         qemuDomainAsyncJob asyncJob)
- {
-     qemuDomainObjPrivatePtr priv = vm->privateData;
-     virHashTablePtr disktable = NULL;
-@@ -350,7 +351,8 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
-     if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_NAMED_BLOCK_NODES))
-         return 0;
- 
--    qemuDomainObjEnterMonitor(driver, vm);
-+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
-+        return -1;
- 
-     disktable = qemuMonitorGetBlockInfo(qemuDomainGetMonitor(vm));
-     data = qemuMonitorQueryNamedBlockNodes(qemuDomainGetMonitor(vm));
-diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
-index 9d6a246435..2af15a65a0 100644
---- a/src/qemu/qemu_block.h
-+++ b/src/qemu/qemu_block.h
-@@ -22,6 +22,7 @@
- # include "internal.h"
- 
- # include "qemu_conf.h"
-+# include "qemu_domain.h"
- 
- # include "virhash.h"
- # include "virjson.h"
-@@ -46,7 +47,8 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr data);
- 
- int
- qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
--                         virDomainObjPtr vm);
-+                         virDomainObjPtr vm,
-+                         qemuDomainAsyncJob asyncJob);
- 
- virHashTablePtr
- qemuBlockGetNodeData(virJSONValuePtr data);
-diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
-index 0601e68da8..415768ddce 100644
---- a/src/qemu/qemu_blockjob.c
-+++ b/src/qemu/qemu_blockjob.c
-@@ -55,13 +55,14 @@ VIR_LOG_INIT("qemu.qemu_blockjob");
- int
- qemuBlockJobUpdate(virQEMUDriverPtr driver,
-                    virDomainObjPtr vm,
-+                   qemuDomainAsyncJob asyncJob,
-                    virDomainDiskDefPtr disk)
- {
-     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-     int status = diskPriv->blockJobStatus;
- 
-     if (status != -1) {
--        qemuBlockJobEventProcess(driver, vm, disk,
-+        qemuBlockJobEventProcess(driver, vm, disk, asyncJob,
-                                  diskPriv->blockJobType,
-                                  diskPriv->blockJobStatus);
-         diskPriv->blockJobStatus = -1;
-@@ -87,6 +88,7 @@ void
- qemuBlockJobEventProcess(virQEMUDriverPtr driver,
-                          virDomainObjPtr vm,
-                          virDomainDiskDefPtr disk,
-+                         qemuDomainAsyncJob asyncJob,
-                          int type,
-                          int status)
- {
-@@ -167,7 +169,7 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
-         disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
-         ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk,
-                                                   true, true));
--        ignore_value(qemuBlockNodeNamesDetect(driver, vm));
-+        ignore_value(qemuBlockNodeNamesDetect(driver, vm, asyncJob));
-         diskPriv->blockjob = false;
-         break;
- 
-@@ -247,9 +249,10 @@ qemuBlockJobSyncBegin(virDomainDiskDefPtr disk)
- void
- qemuBlockJobSyncEnd(virQEMUDriverPtr driver,
-                     virDomainObjPtr vm,
-+                    qemuDomainAsyncJob asyncJob,
-                     virDomainDiskDefPtr disk)
- {
-     VIR_DEBUG("disk=%s", disk->dst);
--    qemuBlockJobUpdate(driver, vm, disk);
-+    qemuBlockJobUpdate(driver, vm, asyncJob, disk);
-     QEMU_DOMAIN_DISK_PRIVATE(disk)->blockJobSync = false;
- }
-diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h
-index 775ce95ec0..47aa4c1755 100644
---- a/src/qemu/qemu_blockjob.h
-+++ b/src/qemu/qemu_blockjob.h
-@@ -24,19 +24,23 @@
- 
- # include "internal.h"
- # include "qemu_conf.h"
-+# include "qemu_domain.h"
- 
- int qemuBlockJobUpdate(virQEMUDriverPtr driver,
-                        virDomainObjPtr vm,
-+                       qemuDomainAsyncJob asyncJob,
-                        virDomainDiskDefPtr disk);
- void qemuBlockJobEventProcess(virQEMUDriverPtr driver,
-                               virDomainObjPtr vm,
-                               virDomainDiskDefPtr disk,
-+                              qemuDomainAsyncJob asyncJob,
-                               int type,
-                               int status);
- 
- void qemuBlockJobSyncBegin(virDomainDiskDefPtr disk);
- void qemuBlockJobSyncEnd(virQEMUDriverPtr driver,
-                          virDomainObjPtr vm,
-+                         qemuDomainAsyncJob asyncJob,
-                          virDomainDiskDefPtr disk);
- 
- #endif /* __QEMU_BLOCKJOB_H__ */
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index 0943d222b4..501f19fbcc 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -4676,7 +4676,7 @@ processBlockJobEvent(virQEMUDriverPtr driver,
-     }
- 
-     if ((disk = qemuProcessFindDomainDiskByAlias(vm, diskAlias)))
--        qemuBlockJobEventProcess(driver, vm, disk, type, status);
-+        qemuBlockJobEventProcess(driver, vm, disk, QEMU_ASYNC_JOB_NONE, type, status);
- 
-  endjob:
-     qemuDomainObjEndJob(driver, vm);
-@@ -16499,24 +16499,25 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
-              * event to pull and let qemuBlockJobEventProcess() handle
-              * the rest as usual */
-             qemuBlockJobEventProcess(driver, vm, disk,
-+                                     QEMU_ASYNC_JOB_NONE,
-                                      VIR_DOMAIN_BLOCK_JOB_TYPE_PULL,
-                                      VIR_DOMAIN_BLOCK_JOB_CANCELED);
-         } else {
-             qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
--            qemuBlockJobUpdate(driver, vm, disk);
-+            qemuBlockJobUpdate(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
-             while (diskPriv->blockjob) {
-                 if (virDomainObjWait(vm) < 0) {
-                     ret = -1;
-                     goto endjob;
-                 }
--                qemuBlockJobUpdate(driver, vm, disk);
-+                qemuBlockJobUpdate(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
-             }
-         }
-     }
- 
-  endjob:
-     if (disk)
--        qemuBlockJobSyncEnd(driver, vm, disk);
-+        qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
-     qemuDomainObjEndJob(driver, vm);
- 
-  cleanup:
-@@ -20675,7 +20676,7 @@ qemuDomainSetBlockThreshold(virDomainPtr dom,
-         goto endjob;
- 
-     if (!src->nodebacking &&
--        qemuBlockNodeNamesDetect(driver, vm) < 0)
-+        qemuBlockNodeNamesDetect(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
-         goto endjob;
- 
-     if (!src->nodebacking) {
-diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
-index 5eed933a3c..d2b691bd2b 100644
---- a/src/qemu/qemu_migration.c
-+++ b/src/qemu/qemu_migration.c
-@@ -600,7 +600,8 @@ qemuMigrationStopNBDServer(virQEMUDriverPtr driver,
-  */
- static int
- qemuMigrationDriveMirrorReady(virQEMUDriverPtr driver,
--                              virDomainObjPtr vm)
-+                              virDomainObjPtr vm,
-+                              qemuDomainAsyncJob asyncJob)
- {
-     size_t i;
-     size_t notReady = 0;
-@@ -613,7 +614,7 @@ qemuMigrationDriveMirrorReady(virQEMUDriverPtr driver,
-         if (!diskPriv->migrating)
-             continue;
- 
--        status = qemuBlockJobUpdate(driver, vm, disk);
-+        status = qemuBlockJobUpdate(driver, vm, asyncJob, disk);
-         if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) {
-             virReportError(VIR_ERR_OPERATION_FAILED,
-                            _("migration of disk %s failed"),
-@@ -648,6 +649,7 @@ qemuMigrationDriveMirrorReady(virQEMUDriverPtr driver,
- static int
- qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
-                                   virDomainObjPtr vm,
-+                                  qemuDomainAsyncJob asyncJob,
-                                   bool check)
- {
-     size_t i;
-@@ -662,7 +664,7 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
-         if (!diskPriv->migrating)
-             continue;
- 
--        status = qemuBlockJobUpdate(driver, vm, disk);
-+        status = qemuBlockJobUpdate(driver, vm, asyncJob, disk);
-         switch (status) {
-         case VIR_DOMAIN_BLOCK_JOB_FAILED:
-             if (check) {
-@@ -674,7 +676,7 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
-             /* fallthrough */
-         case VIR_DOMAIN_BLOCK_JOB_CANCELED:
-         case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
--            qemuBlockJobSyncEnd(driver, vm, disk);
-+            qemuBlockJobSyncEnd(driver, vm, asyncJob, disk);
-             diskPriv->migrating = false;
-             break;
- 
-@@ -722,7 +724,7 @@ qemuMigrationCancelOneDriveMirror(virQEMUDriverPtr driver,
-     int status;
-     int rv;
- 
--    status = qemuBlockJobUpdate(driver, vm, disk);
-+    status = qemuBlockJobUpdate(driver, vm, asyncJob, disk);
-     switch (status) {
-     case VIR_DOMAIN_BLOCK_JOB_FAILED:
-     case VIR_DOMAIN_BLOCK_JOB_CANCELED:
-@@ -799,12 +801,13 @@ qemuMigrationCancelDriveMirror(virQEMUDriverPtr driver,
-                     err = virSaveLastError();
-                 failed = true;
-             }
--            qemuBlockJobSyncEnd(driver, vm, disk);
-+            qemuBlockJobSyncEnd(driver, vm, asyncJob, disk);
-             diskPriv->migrating = false;
-         }
-     }
- 
--    while ((rv = qemuMigrationDriveMirrorCancelled(driver, vm, check)) != 1) {
-+    while ((rv = qemuMigrationDriveMirrorCancelled(driver, vm, asyncJob,
-+                                                   check)) != 1) {
-         if (check && !failed &&
-             dconn && virConnectIsAlive(dconn) <= 0) {
-             virReportError(VIR_ERR_OPERATION_FAILED, "%s",
-@@ -930,7 +933,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
-         VIR_FREE(nbd_dest);
- 
-         if (qemuDomainObjExitMonitor(driver, vm) < 0 || mon_ret < 0) {
--            qemuBlockJobSyncEnd(driver, vm, disk);
-+            qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, disk);
-             goto cleanup;
-         }
-         diskPriv->migrating = true;
-@@ -941,7 +944,8 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
-         }
-     }
- 
--    while ((rv = qemuMigrationDriveMirrorReady(driver, vm)) != 1) {
-+    while ((rv = qemuMigrationDriveMirrorReady(driver, vm,
-+                                               QEMU_ASYNC_JOB_MIGRATION_OUT)) != 1) {
-         if (rv < 0)
-             goto cleanup;
- 
-@@ -1475,7 +1479,7 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
-         goto error;
- 
-     if (flags & QEMU_MIGRATION_COMPLETED_CHECK_STORAGE &&
--        qemuMigrationDriveMirrorReady(driver, vm) < 0)
-+        qemuMigrationDriveMirrorReady(driver, vm, asyncJob) < 0)
-         goto error;
- 
-     if (flags & QEMU_MIGRATION_COMPLETED_ABORT_ON_ERROR &&
-@@ -5567,7 +5571,7 @@ qemuMigrationCancel(virQEMUDriverPtr driver,
-             VIR_DEBUG("Drive mirror on disk %s is still running", disk->dst);
-         } else {
-             VIR_DEBUG("Drive mirror on disk %s is gone", disk->dst);
--            qemuBlockJobSyncEnd(driver, vm, disk);
-+            qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
-             diskPriv->migrating = false;
-         }
-     }
-@@ -5589,7 +5593,7 @@ qemuMigrationCancel(virQEMUDriverPtr driver,
-             qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
- 
-             if (diskPriv->migrating) {
--                qemuBlockJobSyncEnd(driver, vm, disk);
-+                qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
-                 diskPriv->migrating = false;
-             }
-         }
-diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
-index 5802a553cf..6ce33c0134 100644
---- a/src/qemu/qemu_process.c
-+++ b/src/qemu/qemu_process.c
-@@ -6899,7 +6899,7 @@ qemuProcessReconnect(void *opaque)
-     if (qemuProcessRefreshDisks(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
-         goto error;
- 
--    if (qemuBlockNodeNamesDetect(driver, obj) < 0)
-+    if (qemuBlockNodeNamesDetect(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
-         goto error;
- 
-     if (qemuRefreshVirtioChannelState(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
--- 
-2.15.1
-
diff --git a/SOURCES/libvirt-qemu-use-nec-usb-xhci-as-a-default-controller-for-aarch64-if-available.patch b/SOURCES/libvirt-qemu-use-nec-usb-xhci-as-a-default-controller-for-aarch64-if-available.patch
deleted file mode 100644
index 615c01d..0000000
--- a/SOURCES/libvirt-qemu-use-nec-usb-xhci-as-a-default-controller-for-aarch64-if-available.patch
+++ /dev/null
@@ -1,105 +0,0 @@
-From 86987ff859c7c85f649c5845d2673a1ba5fc4fcc Mon Sep 17 00:00:00 2001
-Message-Id: <86987ff859c7c85f649c5845d2673a1ba5fc4fcc@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Fri, 28 Apr 2017 11:59:48 +0200
-Subject: [PATCH] qemu: use nec-usb-xhci as a default controller for aarch64 if
- available
-
-This is a USB3 controller and it's a better choice than piix3-uhci.
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Acked-by: Andrea Bolognani <abologna@redhat.com>
-(cherry picked from commit 233f8d0bd413c5bda91ed678b705e0a9f7a9e922)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1438682
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c                                |  3 +++
- .../qemuxml2argv-aarch64-usb-controller-nec-xhci.args | 19 +++++++++++++++++++
- .../qemuxml2argv-aarch64-usb-controller-nec-xhci.xml  | 16 ++++++++++++++++
- tests/qemuxml2argvtest.c                              |  4 ++++
- 4 files changed, 42 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-nec-xhci.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-nec-xhci.xml
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index a1a4003af..25ab1f639 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -3248,6 +3248,9 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
-                     /* Explicitly fallback to legacy USB controller for PPC64. */
-                     cont->model = -1;
-                 }
-+            } else if (def->os.arch == VIR_ARCH_AARCH64) {
-+                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
-+                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
-             }
-         }
-         /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-nec-xhci.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-nec-xhci.args
-new file mode 100644
-index 000000000..e97431f8b
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-nec-xhci.args
-@@ -0,0 +1,19 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-aarch64 \
-+-name QEMUGuest1 \
-+-S \
-+-M virt \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-device nec-usb-xhci,id=usb,bus=pcie.0,addr=0x1
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-nec-xhci.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-nec-xhci.xml
-new file mode 100644
-index 000000000..1b7320f43
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-nec-xhci.xml
-@@ -0,0 +1,16 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219100</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='aarch64' machine='virt'>hvm</type>
-+  </os>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-aarch64</emulator>
-+    <controller type='usb' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
-+    </controller>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 81cd2a6ec..ca1d23c10 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -2477,6 +2477,10 @@ mymain(void)
-     DO_TEST("ppc64-usb-controller-legacy",
-             QEMU_CAPS_PIIX3_USB_UHCI);
- 
-+    DO_TEST("aarch64-usb-controller-nec-xhci",
-+            QEMU_CAPS_OBJECT_GPEX,
-+            QEMU_CAPS_NEC_USB_XHCI);
-+
-     DO_TEST_PARSE_FLAGS_ERROR("missing-machine",
-                               VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS,
-                               NONE);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemu-use-qemu-xhci-USB-controller-by-default-for-ppc64-and-aarch64.patch b/SOURCES/libvirt-qemu-use-qemu-xhci-USB-controller-by-default-for-ppc64-and-aarch64.patch
deleted file mode 100644
index 43bce43..0000000
--- a/SOURCES/libvirt-qemu-use-qemu-xhci-USB-controller-by-default-for-ppc64-and-aarch64.patch
+++ /dev/null
@@ -1,160 +0,0 @@
-From 5af922119074c1a74db6bebb272b6b9758c89c63 Mon Sep 17 00:00:00 2001
-Message-Id: <5af922119074c1a74db6bebb272b6b9758c89c63@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Fri, 28 Apr 2017 11:59:51 +0200
-Subject: [PATCH] qemu: use qemu-xhci USB controller by default for ppc64 and
- aarch64
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1438682
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Acked-by: Andrea Bolognani <abologna@redhat.com>
-(cherry picked from commit 568887a32f9985b95d998dd0d675255ea985013f)
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c                                | 11 ++++++++---
- ...qemuxml2argv-aarch64-usb-controller-qemu-xhci.args | 19 +++++++++++++++++++
- .../qemuxml2argv-aarch64-usb-controller-qemu-xhci.xml | 16 ++++++++++++++++
- .../qemuxml2argv-ppc64-usb-controller-qemu-xhci.args  | 19 +++++++++++++++++++
- .../qemuxml2argv-ppc64-usb-controller-qemu-xhci.xml   |  1 +
- tests/qemuxml2argvtest.c                              |  9 +++++++++
- 6 files changed, 72 insertions(+), 3 deletions(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.args
- create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.xml
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 4d7de60cb..2790d7e74 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -3237,9 +3237,12 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
-             } else if (ARCH_IS_PPC64(def->os.arch)) {
-                 /* To not break migration we need to set default USB controller
-                  * for ppc64 to pci-ohci if we cannot change ABI of the VM.
--                 * The nec-usb-xhci controller is used as default only for
--                 * newly defined domains or devices. */
-+                 * The nec-usb-xhci or qemu-xhci controller is used as default
-+                 * only for newly defined domains or devices. */
-                 if ((parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) &&
-+                    virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI)) {
-+                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
-+                } else if ((parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) &&
-                     virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI)) {
-                     cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
-                 } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI)) {
-@@ -3249,7 +3252,9 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
-                     cont->model = -1;
-                 }
-             } else if (def->os.arch == VIR_ARCH_AARCH64) {
--                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
-+                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI))
-+                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
-+                else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
-                     cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
-             }
-         }
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.args
-new file mode 100644
-index 000000000..0aa27f7ab
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.args
-@@ -0,0 +1,19 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-aarch64 \
-+-name QEMUGuest1 \
-+-S \
-+-M virt \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-device qemu-xhci,id=usb,bus=pcie.0,addr=0x1
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.xml
-new file mode 100644
-index 000000000..1b7320f43
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.xml
-@@ -0,0 +1,16 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219100</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='aarch64' machine='virt'>hvm</type>
-+  </os>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-aarch64</emulator>
-+    <controller type='usb' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
-+    </controller>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.args b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.args
-new file mode 100644
-index 000000000..b34e480dd
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.args
-@@ -0,0 +1,19 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/libexec/qemu-system-ppc64 \
-+-name QEMUGuest1 \
-+-S \
-+-M pseries \
-+-m 256 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-boot c \
-+-device qemu-xhci,id=usb,bus=pci.0,addr=0x1 \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.xml b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.xml
-new file mode 120000
-index 000000000..831d9d4f1
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.xml
-@@ -0,0 +1 @@
-+qemuxml2argv-ppc64-usb-controller.xml
-\ No newline at end of file
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 317f17e74..406fbfea4 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -2480,6 +2480,15 @@ mymain(void)
-             QEMU_CAPS_PCI_OHCI);
-     DO_TEST("ppc64-usb-controller-legacy",
-             QEMU_CAPS_PIIX3_USB_UHCI);
-+    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci", NULL, -1, 0,
-+                 VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, GIC_NONE,
-+                 QEMU_CAPS_NEC_USB_XHCI,
-+                 QEMU_CAPS_DEVICE_QEMU_XHCI);
-+
-+    DO_TEST("aarch64-usb-controller-qemu-xhci",
-+            QEMU_CAPS_OBJECT_GPEX,
-+            QEMU_CAPS_NEC_USB_XHCI,
-+            QEMU_CAPS_DEVICE_QEMU_XHCI);
- 
-     DO_TEST("aarch64-usb-controller-nec-xhci",
-             QEMU_CAPS_OBJECT_GPEX,
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemuBuildDeviceAddressStr-Prefer-default-alias-for-PCI-bus.patch b/SOURCES/libvirt-qemuBuildDeviceAddressStr-Prefer-default-alias-for-PCI-bus.patch
new file mode 100644
index 0000000..df59c3a
--- /dev/null
+++ b/SOURCES/libvirt-qemuBuildDeviceAddressStr-Prefer-default-alias-for-PCI-bus.patch
@@ -0,0 +1,81 @@
+From 57dd2427239f4de91c9735b1fa299d08d11a8dac Mon Sep 17 00:00:00 2001
+Message-Id: <57dd2427239f4de91c9735b1fa299d08d11a8dac@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Mon, 20 Nov 2017 11:08:54 +0100
+Subject: [PATCH] qemuBuildDeviceAddressStr: Prefer default alias for PCI bus
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1434451
+
+Just like in 9324f67a572f9b32 we need to put default pci-root
+alias onto the command line instead of the one provided by user.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+(cherry picked from commit 937f319536723fec57ad472b002a159d0f67a77c)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c                            | 30 ++++++++++++++++------
+ .../qemuxml2argvdata/qemuxml2argv-user-aliases.xml |  4 ++-
+ 2 files changed, 25 insertions(+), 9 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 7dc7387a15..dfacff4b12 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -318,16 +318,30 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
+ 
+             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
+                 cont->idx == info->addr.pci.bus) {
+-                contAlias = cont->info.alias;
+                 contIsPHB = virDomainControllerIsPSeriesPHB(cont);
+                 contTargetIndex = cont->opts.pciopts.targetIndex;
+-                if (!contAlias) {
+-                    virReportError(VIR_ERR_INTERNAL_ERROR,
+-                                   _("Device alias was not set for PCI "
+-                                     "controller with index %u required "
+-                                     "for device at address %s"),
+-                                   info->addr.pci.bus, devStr);
+-                    goto cleanup;
++
++                /* When domain has builtin pci-root controller we don't put it
++                 * onto cmd line. Therefore we can't set its alias. In that
++                 * case, use the default one. */
++                if (!qemuDomainIsPSeries(domainDef) &&
++                    cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) {
++                    if (virQEMUCapsHasPCIMultiBus(qemuCaps, domainDef))
++                        contAlias = "pci.0";
++                    else
++                        contAlias = "pci";
++                } else if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
++                    contAlias = "pcie.0";
++                } else {
++                    contAlias = cont->info.alias;
++                    if (!contAlias) {
++                        virReportError(VIR_ERR_INTERNAL_ERROR,
++                                       _("Device alias was not set for PCI "
++                                         "controller with index %u required "
++                                         "for device at address %s"),
++                                       info->addr.pci.bus, devStr);
++                        goto cleanup;
++                    }
+                 }
+                 break;
+             }
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
+index d1cb8fea6f..c760098fe0 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
++++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
+@@ -74,7 +74,9 @@
+       <alias name='ua-SomeWeirdController'/>
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+     </controller>
+-    <controller type='pci' index='0' model='pci-root'/>
++    <controller type='pci' index='0' model='pci-root'>
++      <alias name='ua-MyPCIRootController'/>
++    </controller>
+     <controller type='ide' index='0'>
+       <alias name='ua-DoesAnybodyStillUseIDE'/>
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemuBuildDriveDevStr-Prefer-default-alias-for-SATA-bus.patch b/SOURCES/libvirt-qemuBuildDriveDevStr-Prefer-default-alias-for-SATA-bus.patch
new file mode 100644
index 0000000..ee65ae4
--- /dev/null
+++ b/SOURCES/libvirt-qemuBuildDriveDevStr-Prefer-default-alias-for-SATA-bus.patch
@@ -0,0 +1,114 @@
+From 0d4d7811a11bcd2bf12446425e5e05014faecf52 Mon Sep 17 00:00:00 2001
+Message-Id: <0d4d7811a11bcd2bf12446425e5e05014faecf52@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Mon, 20 Nov 2017 11:08:53 +0100
+Subject: [PATCH] qemuBuildDriveDevStr: Prefer default alias for SATA bus
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1434451
+
+Just like in 9324f67a572f9b32 we need to put default sata alias
+(which is hardcoded to "ide", obvious, right?) onto the command
+line instead of the one provided by user.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+(cherry picked from commit f66e5896ad6013c2f31eef1c909999b33ba8847e)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c                            | 15 ++++++++--
+ .../qemuxml2argv-user-aliases2.args                |  1 +
+ .../qemuxml2argv-user-aliases2.xml                 | 34 ++++++++++++++++++++++
+ tests/qemuxml2argvtest.c                           |  1 +
+ 4 files changed, 48 insertions(+), 3 deletions(-)
+ create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.xml
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 272ef610a3..7dc7387a15 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -2076,9 +2076,18 @@ qemuBuildDriveDevStr(const virDomainDef *def,
+             virBufferAddLit(&opt, "ide-drive");
+         }
+ 
+-        if (!(contAlias = virDomainControllerAliasFind(def, VIR_DOMAIN_CONTROLLER_TYPE_SATA,
+-                                                      disk->info.addr.drive.controller)))
+-           goto error;
++        /* When domain has builtin SATA controller we don't put it onto cmd
++         * line. Therefore we can't set its alias. In that case, use the
++         * default one. */
++        if (qemuDomainIsQ35(def) &&
++            disk->info.addr.drive.controller == 0) {
++            contAlias = "ide";
++        } else {
++            if (!(contAlias = virDomainControllerAliasFind(def,
++                                                           VIR_DOMAIN_CONTROLLER_TYPE_SATA,
++                                                           disk->info.addr.drive.controller)))
++                goto error;
++        }
+         virBufferAsprintf(&opt, ",bus=%s.%d",
+                           contAlias,
+                           disk->info.addr.drive.unit);
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.args b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.args
+new file mode 120000
+index 0000000000..e029bc0ec8
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.args
+@@ -0,0 +1 @@
++qemuxml2argv-boot-floppy-q35.args
+\ No newline at end of file
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.xml b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.xml
+new file mode 100644
+index 0000000000..a288b86117
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.xml
+@@ -0,0 +1,34 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219100</memory>
++  <currentMemory unit='KiB'>219100</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='x86_64' machine='pc-q35-2.4'>hvm</type>
++    <boot dev='fd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-x86_64</emulator>
++    <disk type='file' device='floppy'>
++      <driver name='qemu' type='raw'/>
++      <source file='/tmp/firmware.img'/>
++      <target dev='fda' bus='fdc'/>
++      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
++    </disk>
++    <controller type='sata' index='0'>
++      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
++    </controller>
++    <controller type='pci' index='0' model='pcie-root'>
++      <alias name='ua-MySataController'/>
++    </controller>
++    <controller type='fdc' index='0'/>
++    <input type='mouse' bus='ps2'/>
++    <input type='keyboard' bus='ps2'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index ecc86d045c..ff9c8608aa 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -2827,6 +2827,7 @@ mymain(void)
+             QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_PIIX_DISABLE_S3,
+             QEMU_CAPS_PIIX_DISABLE_S4, QEMU_CAPS_VNC,
+             QEMU_CAPS_HDA_DUPLEX);
++    DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
+ 
+     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
+         virFileDeleteTree(fakerootdir);
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemuBuildDriveDevStr-Prefer-default-aliases-for-IDE-bus.patch b/SOURCES/libvirt-qemuBuildDriveDevStr-Prefer-default-aliases-for-IDE-bus.patch
new file mode 100644
index 0000000..6f4f6e6
--- /dev/null
+++ b/SOURCES/libvirt-qemuBuildDriveDevStr-Prefer-default-aliases-for-IDE-bus.patch
@@ -0,0 +1,67 @@
+From 60d285eca3ab7003a7ebd03e3610616e0a657942 Mon Sep 17 00:00:00 2001
+Message-Id: <60d285eca3ab7003a7ebd03e3610616e0a657942@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Mon, 20 Nov 2017 11:08:51 +0100
+Subject: [PATCH] qemuBuildDriveDevStr: Prefer default aliases for IDE bus
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1434451
+
+When testing user aliases it was discovered that for 440fx
+machine type which has default IDE bus builtin, domain cannot
+start if IDE controller has the user provided alias. This is
+because for 440fx we don't put the IDE controller onto the
+command line (since it is builtin) and therefore any device that
+is plugged onto the bus must use the default alias.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+(cherry picked from commit 9324f67a572f9b32f25bc088fb9f34e736edc612)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c                               | 14 +++++++++++---
+ tests/qemuxml2argvdata/qemuxml2argv-user-aliases.args |  4 ++--
+ 2 files changed, 13 insertions(+), 5 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index aa7079229f..272ef610a3 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -1947,9 +1947,17 @@ qemuBuildDriveDevStr(const virDomainDef *def,
+             virBufferAddLit(&opt, "ide-drive");
+         }
+ 
+-        if (!(contAlias = virDomainControllerAliasFind(def, VIR_DOMAIN_CONTROLLER_TYPE_IDE,
+-                                                       disk->info.addr.drive.controller)))
+-           goto error;
++        /* When domain has builtin IDE controller we don't put it onto cmd
++         * line. Therefore we can't set its alias. In that case, use the
++         * default one. */
++        if (qemuDomainHasBuiltinIDE(def)) {
++            contAlias = "ide";
++        } else {
++            if (!(contAlias = virDomainControllerAliasFind(def,
++                                                           VIR_DOMAIN_CONTROLLER_TYPE_IDE,
++                                                           disk->info.addr.drive.controller)))
++                goto error;
++        }
+         virBufferAsprintf(&opt, ",bus=%s.%d,unit=%d",
+                           contAlias,
+                           disk->info.addr.drive.bus,
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.args b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.args
+index 62fbd567b1..1719c1bc88 100644
+--- a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.args
++++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.args
+@@ -44,8 +44,8 @@ id=drive-ua-myEncryptedDisk1 \
+ id=ua-myEncryptedDisk1 \
+ -drive file=/home/zippy/tmp/install-amd64-minimal-20140619.iso,format=raw,\
+ if=none,media=cdrom,id=drive-ua-WhatAnAwesomeCDROM,readonly=on,cache=none \
+--device ide-drive,bus=ua-DoesAnybodyStillUseIDE.1,unit=0,\
+-drive=drive-ua-WhatAnAwesomeCDROM,id=ua-WhatAnAwesomeCDROM \
++-device ide-drive,bus=ide.1,unit=0,drive=drive-ua-WhatAnAwesomeCDROM,\
++id=ua-WhatAnAwesomeCDROM \
+ -device virtio-net-pci,vlan=0,id=ua-CheckoutThisNIC,mac=52:54:00:d6:c0:0b,\
+ bus=pci.0,addr=0x3 \
+ -net tap,fd=3,vlan=0,name=hostua-CheckoutThisNIC \
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-qemuDomainAttachDeviceMknodHelper-Remove-symlink-before-creating-it.patch b/SOURCES/libvirt-qemuDomainAttachDeviceMknodHelper-Remove-symlink-before-creating-it.patch
index 2c3815a..8c2c606 100644
--- a/SOURCES/libvirt-qemuDomainAttachDeviceMknodHelper-Remove-symlink-before-creating-it.patch
+++ b/SOURCES/libvirt-qemuDomainAttachDeviceMknodHelper-Remove-symlink-before-creating-it.patch
@@ -1,12 +1,11 @@
-From f30ba86ea92bb2a77b9620cea318bc3ebe0bf2a5 Mon Sep 17 00:00:00 2001
-Message-Id: <f30ba86ea92bb2a77b9620cea318bc3ebe0bf2a5@dist-git>
+From 6c4c780eda082ef395b70af89b8b8942b9ad4a9d Mon Sep 17 00:00:00 2001
+Message-Id: <6c4c780eda082ef395b70af89b8b8942b9ad4a9d@dist-git>
 From: Michal Privoznik <mprivozn@redhat.com>
-Date: Tue, 9 Jan 2018 09:34:24 +0100
+Date: Mon, 8 Jan 2018 10:16:19 +0100
 Subject: [PATCH] qemuDomainAttachDeviceMknodHelper: Remove symlink before
  creating it
 
-RHEL-7.5: https://bugzilla.redhat.com/show_bug.cgi?id=1528502
-RHEL-7.4.z: https://bugzilla.redhat.com/show_bug.cgi?id=1532183
+https://bugzilla.redhat.com/show_bug.cgi?id=1528502
 
 So imagine you have /dev/blah symlink which points to /dev/sda.
 You attach /dev/blah as disk to your domain. Libvirt correctly
@@ -30,10 +29,10 @@ Reviewed-by: Andrea Bolognani <abologna@redhat.com>
  1 file changed, 16 insertions(+), 6 deletions(-)
 
 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index dd70bd6367..ade06f07db 100644
+index 8967f2774d..b0c78cc7c4 100644
 --- a/src/qemu/qemu_domain.c
 +++ b/src/qemu/qemu_domain.c
-@@ -8470,13 +8470,23 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
+@@ -9559,13 +9559,23 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
  
      if (isLink) {
          VIR_DEBUG("Creating symlink %s -> %s", data->file, data->target);
diff --git a/SOURCES/libvirt-qemuDomainAttachDeviceMknodRecursive-Don-t-try-to-create-devices-under-preserved-mount-points.patch b/SOURCES/libvirt-qemuDomainAttachDeviceMknodRecursive-Don-t-try-to-create-devices-under-preserved-mount-points.patch
deleted file mode 100644
index 6c60f16..0000000
--- a/SOURCES/libvirt-qemuDomainAttachDeviceMknodRecursive-Don-t-try-to-create-devices-under-preserved-mount-points.patch
+++ /dev/null
@@ -1,276 +0,0 @@
-From c5e142b3b9bc25ed508b8b7b62907ed99daba84d Mon Sep 17 00:00:00 2001
-Message-Id: <c5e142b3b9bc25ed508b8b7b62907ed99daba84d@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Thu, 11 May 2017 15:38:40 +0200
-Subject: [PATCH] qemuDomainAttachDeviceMknodRecursive: Don't try to create
- devices under preserved mount points
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1449510
-
-Just like in previous commit, this fixes the same issue for
-hotplug.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
-(cherry picked from commit b3418f36be75eb4bdecd6aa37cda7a268519ee46)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 114 ++++++++++++++++++++++++++++++++++++++++++-------
- 1 file changed, 98 insertions(+), 16 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 9217747d5..671569f6f 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -8314,6 +8314,8 @@ static int
- qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
-                                      virDomainObjPtr vm,
-                                      const char *file,
-+                                     char * const *devMountsPath,
-+                                     size_t ndevMountsPath,
-                                      unsigned int ttl)
- {
-     struct qemuDomainAttachDeviceMknodData data;
-@@ -8391,20 +8393,36 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
- #endif
- 
-     if (STRPREFIX(file, DEVPREFIX)) {
--        if (qemuSecurityPreFork(driver->securityManager) < 0)
--            goto cleanup;
-+        size_t i;
- 
--        if (virProcessRunInMountNamespace(vm->pid,
--                                          qemuDomainAttachDeviceMknodHelper,
--                                          &data) < 0) {
--            qemuSecurityPostFork(driver->securityManager);
--            goto cleanup;
-+        for (i = 0; i < ndevMountsPath; i++) {
-+            if (STREQ(devMountsPath[i], "/dev"))
-+                continue;
-+            if (STRPREFIX(file, devMountsPath[i]))
-+                break;
-+        }
-+
-+        if (i == ndevMountsPath) {
-+            if (qemuSecurityPreFork(driver->securityManager) < 0)
-+                goto cleanup;
-+
-+            if (virProcessRunInMountNamespace(vm->pid,
-+                                              qemuDomainAttachDeviceMknodHelper,
-+                                              &data) < 0) {
-+                qemuSecurityPostFork(driver->securityManager);
-+                goto cleanup;
-+            }
-+            qemuSecurityPostFork(driver->securityManager);
-+        } else {
-+            VIR_DEBUG("Skipping dev %s because of %s mount point",
-+                      file, devMountsPath[i]);
-         }
--        qemuSecurityPostFork(driver->securityManager);
-     }
- 
-     if (isLink &&
--        qemuDomainAttachDeviceMknodRecursive(driver, vm, target, ttl -1) < 0)
-+        qemuDomainAttachDeviceMknodRecursive(driver, vm, target,
-+                                             devMountsPath, ndevMountsPath,
-+                                             ttl -1) < 0)
-         goto cleanup;
- 
-     ret = 0;
-@@ -8421,11 +8439,15 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
- static int
- qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver,
-                             virDomainObjPtr vm,
--                            const char *file)
-+                            const char *file,
-+                            char * const *devMountsPath,
-+                            size_t ndevMountsPath)
- {
-     long symloop_max = sysconf(_SC_SYMLOOP_MAX);
- 
--    return qemuDomainAttachDeviceMknodRecursive(driver, vm, file, symloop_max);
-+    return qemuDomainAttachDeviceMknodRecursive(driver, vm, file,
-+                                                devMountsPath, ndevMountsPath,
-+                                                symloop_max);
- }
- 
- 
-@@ -8465,6 +8487,9 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
-                              virDomainObjPtr vm,
-                              virStorageSourcePtr src)
- {
-+    virQEMUDriverConfigPtr cfg = NULL;
-+    char **devMountsPath = NULL;
-+    size_t ndevMountsPath = 0;
-     virStorageSourcePtr next;
-     struct stat sb;
-     int ret = -1;
-@@ -8472,6 +8497,12 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
-     if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
-         return 0;
- 
-+    cfg = virQEMUDriverGetConfig(driver);
-+    if (qemuDomainGetPreservedMounts(cfg, vm,
-+                                     &devMountsPath, NULL,
-+                                     &ndevMountsPath) < 0)
-+        goto cleanup;
-+
-     for (next = src; next; next = next->backingStore) {
-         if (virStorageSourceIsEmpty(next) ||
-             !virStorageSourceIsLocalStorage(next)) {
-@@ -8490,12 +8521,15 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
- 
-         if (qemuDomainAttachDeviceMknod(driver,
-                                         vm,
--                                        next->path) < 0)
-+                                        next->path,
-+                                        devMountsPath, ndevMountsPath) < 0)
-             goto cleanup;
-     }
- 
-     ret = 0;
-  cleanup:
-+    virStringListFreeCount(devMountsPath, ndevMountsPath);
-+    virObjectUnref(cfg);
-     return ret;
- }
- 
-@@ -8520,6 +8554,9 @@ qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driver,
-                                 virDomainObjPtr vm,
-                                 virDomainHostdevDefPtr hostdev)
- {
-+    virQEMUDriverConfigPtr cfg = NULL;
-+    char **devMountsPath = NULL;
-+    size_t ndevMountsPath = 0;
-     int ret = -1;
-     char **path = NULL;
-     size_t i, npaths = 0;
-@@ -8530,10 +8567,17 @@ qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driver,
-     if (qemuDomainGetHostdevPath(NULL, hostdev, false, &npaths, &path, NULL) < 0)
-         goto cleanup;
- 
-+    cfg = virQEMUDriverGetConfig(driver);
-+    if (qemuDomainGetPreservedMounts(cfg, vm,
-+                                     &devMountsPath, NULL,
-+                                     &ndevMountsPath) < 0)
-+        goto cleanup;
-+
-     for (i = 0; i < npaths; i++) {
-         if (qemuDomainAttachDeviceMknod(driver,
-                                         vm,
--                                        path[i]) < 0)
-+                                        path[i],
-+                                        devMountsPath, ndevMountsPath) < 0)
-         goto cleanup;
-     }
- 
-@@ -8542,6 +8586,8 @@ qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driver,
-     for (i = 0; i < npaths; i++)
-         VIR_FREE(path[i]);
-     VIR_FREE(path);
-+    virStringListFreeCount(devMountsPath, ndevMountsPath);
-+    virObjectUnref(cfg);
-     return ret;
- }
- 
-@@ -8581,6 +8627,9 @@ qemuDomainNamespaceSetupMemory(virQEMUDriverPtr driver,
-                                virDomainObjPtr vm,
-                                virDomainMemoryDefPtr mem)
- {
-+    virQEMUDriverConfigPtr cfg = NULL;
-+    char **devMountsPath = NULL;
-+    size_t ndevMountsPath = 0;
-     int ret = -1;
- 
-     if (mem->model != VIR_DOMAIN_MEMORY_MODEL_NVDIMM)
-@@ -8589,10 +8638,19 @@ qemuDomainNamespaceSetupMemory(virQEMUDriverPtr driver,
-     if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
-         return 0;
- 
--    if (qemuDomainAttachDeviceMknod(driver, vm, mem->nvdimmPath) < 0)
-+    cfg = virQEMUDriverGetConfig(driver);
-+    if (qemuDomainGetPreservedMounts(cfg, vm,
-+                                     &devMountsPath, NULL,
-+                                     &ndevMountsPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainAttachDeviceMknod(driver, vm, mem->nvdimmPath,
-+                                    devMountsPath, ndevMountsPath) < 0)
-         goto cleanup;
-     ret = 0;
-  cleanup:
-+    virStringListFreeCount(devMountsPath, ndevMountsPath);
-+    virObjectUnref(cfg);
-     return ret;
- }
- 
-@@ -8623,6 +8681,9 @@ qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driver,
-                                 virDomainObjPtr vm,
-                                 virDomainChrDefPtr chr)
- {
-+    virQEMUDriverConfigPtr cfg = NULL;
-+    char **devMountsPath = NULL;
-+    size_t ndevMountsPath = 0;
-     const char *path;
-     int ret = -1;
- 
-@@ -8634,12 +8695,21 @@ qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driver,
- 
-     path = chr->source->data.file.path;
- 
-+    cfg = virQEMUDriverGetConfig(driver);
-+    if (qemuDomainGetPreservedMounts(cfg, vm,
-+                                     &devMountsPath, NULL,
-+                                     &ndevMountsPath) < 0)
-+        goto cleanup;
-+
-     if (qemuDomainAttachDeviceMknod(driver,
-                                     vm,
--                                    path) < 0)
-+                                    path,
-+                                    devMountsPath, ndevMountsPath) < 0)
-         goto cleanup;
-     ret = 0;
-  cleanup:
-+    virStringListFreeCount(devMountsPath, ndevMountsPath);
-+    virObjectUnref(cfg);
-     return ret;
- }
- 
-@@ -8674,6 +8744,9 @@ qemuDomainNamespaceSetupRNG(virQEMUDriverPtr driver,
-                             virDomainObjPtr vm,
-                             virDomainRNGDefPtr rng)
- {
-+    virQEMUDriverConfigPtr cfg = NULL;
-+    char **devMountsPath = NULL;
-+    size_t ndevMountsPath = 0;
-     const char *path = NULL;
-     int ret = -1;
- 
-@@ -8691,12 +8764,21 @@ qemuDomainNamespaceSetupRNG(virQEMUDriverPtr driver,
-         goto cleanup;
-     }
- 
-+    cfg = virQEMUDriverGetConfig(driver);
-+    if (qemuDomainGetPreservedMounts(cfg, vm,
-+                                     &devMountsPath, NULL,
-+                                     &ndevMountsPath) < 0)
-+        goto cleanup;
-+
-     if (qemuDomainAttachDeviceMknod(driver,
-                                     vm,
--                                    path) < 0)
-+                                    path,
-+                                    devMountsPath, ndevMountsPath) < 0)
-         goto cleanup;
-     ret = 0;
-  cleanup:
-+    virStringListFreeCount(devMountsPath, ndevMountsPath);
-+    virObjectUnref(cfg);
-     return ret;
- }
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemuDomainBuildNamespace-Handle-special-file-mount-points.patch b/SOURCES/libvirt-qemuDomainBuildNamespace-Handle-special-file-mount-points.patch
deleted file mode 100644
index 0191509..0000000
--- a/SOURCES/libvirt-qemuDomainBuildNamespace-Handle-special-file-mount-points.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From 4f54b2f401e4e1a443f6c889cbd2373aaa249d28 Mon Sep 17 00:00:00 2001
-Message-Id: <4f54b2f401e4e1a443f6c889cbd2373aaa249d28@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Mon, 17 Jul 2017 14:48:21 +0200
-Subject: [PATCH] qemuDomainBuildNamespace: Handle special file mount points
-
-RHEL-7.5: https://bugzilla.redhat.com/show_bug.cgi?id=1459592
-RHEL-7.4.z: https://bugzilla.redhat.com/show_bug.cgi?id=1471660
-
-In 290a00e41d I've tried to fix the process of building a
-qemu namespace when dealing with file mount points. What I
-haven't realized then is that we might be dealing not with just
-regular files but also special files (like sockets). Indeed, try
-the following:
-
-1) socat unix-listen:/tmp/soket stdio
-2) touch /dev/socket
-3) mount --bind /tmp/socket /dev/socket
-4) virsh start anyDomain
-
-Problem with my previous approach is that I wasn't creating the
-temporary location (where mount points under /dev are moved) for
-anything but directories and regular files.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Reviewed-by: John Ferlan <jferlan@redhat.com>
-(cherry picked from commit 7154917908d9f712a950a2716c4687e57ccb74e7)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 6ccc9f6f5b..c9c668b892 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -8305,9 +8305,11 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
-             goto cleanup;
-         }
- 
--        /* At this point, devMountsPath is either a regular file or a directory. */
-+        /* At this point, devMountsPath is either:
-+         * a file (regular or special), or
-+         * a directory. */
-         if ((S_ISDIR(sb.st_mode) && virFileMakePath(devMountsSavePath[i]) < 0) ||
--            (S_ISREG(sb.st_mode) && virFileTouch(devMountsSavePath[i], sb.st_mode) < 0)) {
-+            (!S_ISDIR(sb.st_mode) && virFileTouch(devMountsSavePath[i], sb.st_mode) < 0)) {
-             virReportSystemError(errno,
-                                  _("Failed to create %s"),
-                                  devMountsSavePath[i]);
--- 
-2.13.3
-
diff --git a/SOURCES/libvirt-qemuDomainBuildNamespace-Move-dev-mountpoints-later.patch b/SOURCES/libvirt-qemuDomainBuildNamespace-Move-dev-mountpoints-later.patch
deleted file mode 100644
index e821e4a..0000000
--- a/SOURCES/libvirt-qemuDomainBuildNamespace-Move-dev-mountpoints-later.patch
+++ /dev/null
@@ -1,121 +0,0 @@
-From 2cc49072ced64daa446a90b802191496b4d28e69 Mon Sep 17 00:00:00 2001
-Message-Id: <2cc49072ced64daa446a90b802191496b4d28e69@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Thu, 11 May 2017 15:38:37 +0200
-Subject: [PATCH] qemuDomainBuildNamespace: Move /dev/* mountpoints later
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1449510
-
-When setting up mount namespace for a qemu domain the following
-steps are executed:
-
-1) get list of mountpoints under /dev/
-2) move them to /var/run/libvirt/qemu/$domName.ext
-3) start constructing new device tree under /var/run/libvirt/qemu/$domName.dev
-4) move the mountpoint of the new device tree to /dev
-5) restore original mountpoints from step 2)
-
-Note the problem with this approach is that if some device in step
-3) requires access to a mountpoint from step 2) it will fail as
-the mountpoint is not there anymore. For instance consider the
-following domain disk configuration:
-
-    <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
-      <source file='/dev/shm/vhostmd0'/>
-      <target dev='vdb' bus='virtio'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
-    </disk>
-
-In this case operation fails as we are unable to create vhostmd0
-in the new device tree because after step 2) there is no /dev/shm
-anymore. Leave aside fact that we shouldn't try to create devices
-living in other mountpoints. That's a separate bug that will be
-addressed later.
-
-Currently, the order described above is rearranged to:
-
-1) get list of mountpoints under /dev/
-2) start constructing new device tree under /var/run/libvirt/qemu/$domName.dev
-3) move them to /var/run/libvirt/qemu/$domName.ext
-4) move the mountpoint of the new device tree to /dev
-5) restore original mountpoints from step 3)
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
-(cherry picked from commit a7cc039dc796f541793955598377807af48341fb)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 48 ++++++++++++++++++++++++------------------------
- 1 file changed, 24 insertions(+), 24 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 2790d7e74..fbb65fab4 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -8026,6 +8026,30 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
-     if (qemuDomainSetupDev(cfg, mgr, vm, devPath) < 0)
-         goto cleanup;
- 
-+    if (qemuDomainSetupAllDisks(cfg, vm, devPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainSetupAllHostdevs(cfg, vm, devPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainSetupAllMemories(cfg, vm, devPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainSetupAllChardevs(cfg, vm, devPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainSetupTPM(cfg, vm, devPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainSetupAllGraphics(cfg, vm, devPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainSetupAllInputs(cfg, vm, devPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainSetupAllRNGs(cfg, vm, devPath) < 0)
-+        goto cleanup;
-+
-     /* Save some mount points because we want to share them with the host */
-     for (i = 0; i < ndevMountsPath; i++) {
-         struct stat sb;
-@@ -8053,30 +8077,6 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
-             goto cleanup;
-     }
- 
--    if (qemuDomainSetupAllDisks(cfg, vm, devPath) < 0)
--        goto cleanup;
--
--    if (qemuDomainSetupAllHostdevs(cfg, vm, devPath) < 0)
--        goto cleanup;
--
--    if (qemuDomainSetupAllMemories(cfg, vm, devPath) < 0)
--        goto cleanup;
--
--    if (qemuDomainSetupAllChardevs(cfg, vm, devPath) < 0)
--        goto cleanup;
--
--    if (qemuDomainSetupTPM(cfg, vm, devPath) < 0)
--        goto cleanup;
--
--    if (qemuDomainSetupAllGraphics(cfg, vm, devPath) < 0)
--        goto cleanup;
--
--    if (qemuDomainSetupAllInputs(cfg, vm, devPath) < 0)
--        goto cleanup;
--
--    if (qemuDomainSetupAllRNGs(cfg, vm, devPath) < 0)
--        goto cleanup;
--
-     if (virFileMoveMount(devPath, "/dev") < 0)
-         goto cleanup;
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemuDomainCreateDeviceRecursive-Don-t-try-to-create-devices-under-preserved-mount-points.patch b/SOURCES/libvirt-qemuDomainCreateDeviceRecursive-Don-t-try-to-create-devices-under-preserved-mount-points.patch
deleted file mode 100644
index 1202ff0..0000000
--- a/SOURCES/libvirt-qemuDomainCreateDeviceRecursive-Don-t-try-to-create-devices-under-preserved-mount-points.patch
+++ /dev/null
@@ -1,97 +0,0 @@
-From 09f7d1ef473ec3e1f21c62abff77d55d79817704 Mon Sep 17 00:00:00 2001
-Message-Id: <09f7d1ef473ec3e1f21c62abff77d55d79817704@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Thu, 11 May 2017 15:38:39 +0200
-Subject: [PATCH] qemuDomainCreateDeviceRecursive: Don't try to create devices
- under preserved mount points
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1449510
-
-While the code allows devices to already be there (by some
-miracle), we shouldn't try to create devices that don't belong to
-us. For instance, we shouldn't try to create /dev/shm/file
-because /dev/shm is a mount point that is preserved. Therefore if
-a file is created there from an outside (e.g. by mgmt application
-or some other daemon running on the system like vhostmd), it
-exists in the qemu namespace too as the mount point is the same.
-It's only /dev and /dev only that is different. The same
-reasoning applies to all other preserved mount points.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
-(cherry picked from commit e30dbf35a1a9e86934272aeef803f91b36d8cbce)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 39 ++++++++++++++++++++++++++++++---------
- 1 file changed, 30 insertions(+), 9 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index bbf865e12..9217747d5 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -7415,6 +7415,8 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr cfg,
- 
- struct qemuDomainCreateDeviceData {
-     const char *path;     /* Path to temp new /dev location */
-+    char * const *devMountsPath;
-+    size_t ndevMountsPath;
- };
- 
- 
-@@ -7468,17 +7470,34 @@ qemuDomainCreateDeviceRecursive(const char *device,
-      * For now, lets hope callers play nice.
-      */
-     if (STRPREFIX(device, DEVPREFIX)) {
--        if (virAsprintf(&devicePath, "%s/%s",
--                        data->path, device + strlen(DEVPREFIX)) < 0)
--            goto cleanup;
-+        size_t i;
- 
--        if (virFileMakeParentPath(devicePath) < 0) {
--            virReportSystemError(errno,
--                                 _("Unable to create %s"),
--                                 devicePath);
--            goto cleanup;
-+        for (i = 0; i < data->ndevMountsPath; i++) {
-+            if (STREQ(data->devMountsPath[i], "/dev"))
-+                continue;
-+            if (STRPREFIX(device, data->devMountsPath[i]))
-+                break;
-+        }
-+
-+        if (i == data->ndevMountsPath) {
-+            /* Okay, @device is in /dev but not in any mount point under /dev.
-+             * Create it. */
-+            if (virAsprintf(&devicePath, "%s/%s",
-+                            data->path, device + strlen(DEVPREFIX)) < 0)
-+                goto cleanup;
-+
-+            if (virFileMakeParentPath(devicePath) < 0) {
-+                virReportSystemError(errno,
-+                                     _("Unable to create %s"),
-+                                     devicePath);
-+                goto cleanup;
-+            }
-+            VIR_DEBUG("Creating dev %s", device);
-+            create = true;
-+        } else {
-+            VIR_DEBUG("Skipping dev %s because of %s mount point",
-+                      device, data->devMountsPath[i]);
-         }
--        create = true;
-     }
- 
-     if (isLink) {
-@@ -8027,6 +8046,8 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
-     }
- 
-     data.path = devPath;
-+    data.devMountsPath = devMountsPath;
-+    data.ndevMountsPath = ndevMountsPath;
- 
-     if (virProcessSetupPrivateMountNS() < 0)
-         goto cleanup;
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemuDomainCreateDeviceRecursive-pass-a-structure-instead-of-bare-path.patch b/SOURCES/libvirt-qemuDomainCreateDeviceRecursive-pass-a-structure-instead-of-bare-path.patch
deleted file mode 100644
index b3c811c..0000000
--- a/SOURCES/libvirt-qemuDomainCreateDeviceRecursive-pass-a-structure-instead-of-bare-path.patch
+++ /dev/null
@@ -1,434 +0,0 @@
-From 382795a4ab74f29b1a5bdf3ea3aa33d17d2add56 Mon Sep 17 00:00:00 2001
-Message-Id: <382795a4ab74f29b1a5bdf3ea3aa33d17d2add56@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Thu, 11 May 2017 15:38:38 +0200
-Subject: [PATCH] qemuDomainCreateDeviceRecursive: pass a structure instead of
- bare path
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1449510
-
-Currently, all we need to do in qemuDomainCreateDeviceRecursive() is to
-take given @device, get all kinds of info on it (major & minor numbers,
-owner, seclabels) and create its copy at a temporary location @path
-(usually /var/run/libvirt/qemu/$domName.dev), if @device live under
-/dev. This is, however, very loose condition, as it also means
-/dev/shm/* is created too. Therefor, we will need to pass more arguments
-into the function for better decision making (e.g. list of mount points
-under /dev). Instead of adding more arguments to all the functions (not
-easily reachable because some functions are callback with strictly
-defined type), lets just turn this one 'const char *' into a 'struct *'.
-New "arguments" can be then added at no cost.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
-(cherry picked from commit 26c14be8d64bc9e3c23b95fff65affc2bf7c86bc)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 106 ++++++++++++++++++++++++++-----------------------
- 1 file changed, 57 insertions(+), 49 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index fbb65fab4..bbf865e12 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -7413,9 +7413,14 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr cfg,
- }
- 
- 
-+struct qemuDomainCreateDeviceData {
-+    const char *path;     /* Path to temp new /dev location */
-+};
-+
-+
- static int
- qemuDomainCreateDeviceRecursive(const char *device,
--                                const char *path,
-+                                const struct qemuDomainCreateDeviceData *data,
-                                 bool allow_noent,
-                                 unsigned int ttl)
- {
-@@ -7464,7 +7469,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
-      */
-     if (STRPREFIX(device, DEVPREFIX)) {
-         if (virAsprintf(&devicePath, "%s/%s",
--                        path, device + strlen(DEVPREFIX)) < 0)
-+                        data->path, device + strlen(DEVPREFIX)) < 0)
-             goto cleanup;
- 
-         if (virFileMakeParentPath(devicePath) < 0) {
-@@ -7525,7 +7530,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
-             tmp = NULL;
-         }
- 
--        if (qemuDomainCreateDeviceRecursive(target, path,
-+        if (qemuDomainCreateDeviceRecursive(target, data,
-                                             allow_noent, ttl - 1) < 0)
-             goto cleanup;
-     } else {
-@@ -7609,12 +7614,12 @@ qemuDomainCreateDeviceRecursive(const char *device,
- 
- static int
- qemuDomainCreateDevice(const char *device,
--                       const char *path,
-+                       const struct qemuDomainCreateDeviceData *data,
-                        bool allow_noent)
- {
-     long symloop_max = sysconf(_SC_SYMLOOP_MAX);
- 
--    return qemuDomainCreateDeviceRecursive(device, path,
-+    return qemuDomainCreateDeviceRecursive(device, data,
-                                            allow_noent, symloop_max);
- }
- 
-@@ -7622,7 +7627,7 @@ qemuDomainCreateDevice(const char *device,
- static int
- qemuDomainPopulateDevices(virQEMUDriverConfigPtr cfg,
-                           virDomainObjPtr vm ATTRIBUTE_UNUSED,
--                          const char *path)
-+                          const struct qemuDomainCreateDeviceData *data)
- {
-     const char *const *devices = (const char *const *) cfg->cgroupDeviceACL;
-     size_t i;
-@@ -7632,7 +7637,7 @@ qemuDomainPopulateDevices(virQEMUDriverConfigPtr cfg,
-         devices = defaultDeviceACL;
- 
-     for (i = 0; devices[i]; i++) {
--        if (qemuDomainCreateDevice(devices[i], path, true) < 0)
-+        if (qemuDomainCreateDevice(devices[i], data, true) < 0)
-             goto cleanup;
-     }
- 
-@@ -7646,7 +7651,7 @@ static int
- qemuDomainSetupDev(virQEMUDriverConfigPtr cfg,
-                    virSecurityManagerPtr mgr,
-                    virDomainObjPtr vm,
--                   const char *path)
-+                   const struct qemuDomainCreateDeviceData *data)
- {
-     char *mount_options = NULL;
-     char *opts = NULL;
-@@ -7668,10 +7673,10 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg,
-                     "mode=755,size=65536%s", mount_options) < 0)
-         goto cleanup;
- 
--    if (virFileSetupDev(path, opts) < 0)
-+    if (virFileSetupDev(data->path, opts) < 0)
-         goto cleanup;
- 
--    if (qemuDomainPopulateDevices(cfg, vm, path) < 0)
-+    if (qemuDomainPopulateDevices(cfg, vm, data) < 0)
-         goto cleanup;
- 
-     ret = 0;
-@@ -7685,7 +7690,7 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg,
- static int
- qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-                     virDomainDiskDefPtr disk,
--                    const char *devPath)
-+                    const struct qemuDomainCreateDeviceData *data)
- {
-     virStorageSourcePtr next;
-     char *dst = NULL;
-@@ -7697,7 +7702,7 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-             continue;
-         }
- 
--        if (qemuDomainCreateDevice(next->path, devPath, false) < 0)
-+        if (qemuDomainCreateDevice(next->path, data, false) < 0)
-             goto cleanup;
-     }
- 
-@@ -7711,7 +7716,7 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
- static int
- qemuDomainSetupAllDisks(virQEMUDriverConfigPtr cfg,
-                         virDomainObjPtr vm,
--                        const char *devPath)
-+                        const struct qemuDomainCreateDeviceData *data)
- {
-     size_t i;
-     VIR_DEBUG("Setting up disks");
-@@ -7719,7 +7724,7 @@ qemuDomainSetupAllDisks(virQEMUDriverConfigPtr cfg,
-     for (i = 0; i < vm->def->ndisks; i++) {
-         if (qemuDomainSetupDisk(cfg,
-                                 vm->def->disks[i],
--                                devPath) < 0)
-+                                data) < 0)
-             return -1;
-     }
- 
-@@ -7731,7 +7736,7 @@ qemuDomainSetupAllDisks(virQEMUDriverConfigPtr cfg,
- static int
- qemuDomainSetupHostdev(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-                        virDomainHostdevDefPtr dev,
--                       const char *devPath)
-+                       const struct qemuDomainCreateDeviceData *data)
- {
-     int ret = -1;
-     char **path = NULL;
-@@ -7741,7 +7746,7 @@ qemuDomainSetupHostdev(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-         goto cleanup;
- 
-     for (i = 0; i < npaths; i++) {
--        if (qemuDomainCreateDevice(path[i], devPath, false) < 0)
-+        if (qemuDomainCreateDevice(path[i], data, false) < 0)
-             goto cleanup;
-     }
- 
-@@ -7757,7 +7762,7 @@ qemuDomainSetupHostdev(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
- static int
- qemuDomainSetupAllHostdevs(virQEMUDriverConfigPtr cfg,
-                            virDomainObjPtr vm,
--                           const char *devPath)
-+                           const struct qemuDomainCreateDeviceData *data)
- {
-     size_t i;
- 
-@@ -7765,7 +7770,7 @@ qemuDomainSetupAllHostdevs(virQEMUDriverConfigPtr cfg,
-     for (i = 0; i < vm->def->nhostdevs; i++) {
-         if (qemuDomainSetupHostdev(cfg,
-                                    vm->def->hostdevs[i],
--                                   devPath) < 0)
-+                                   data) < 0)
-             return -1;
-     }
-     VIR_DEBUG("Setup all hostdevs");
-@@ -7776,19 +7781,19 @@ qemuDomainSetupAllHostdevs(virQEMUDriverConfigPtr cfg,
- static int
- qemuDomainSetupMemory(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-                       virDomainMemoryDefPtr mem,
--                      const char *devPath)
-+                      const struct qemuDomainCreateDeviceData *data)
- {
-     if (mem->model != VIR_DOMAIN_MEMORY_MODEL_NVDIMM)
-         return 0;
- 
--    return qemuDomainCreateDevice(mem->nvdimmPath, devPath, false);
-+    return qemuDomainCreateDevice(mem->nvdimmPath, data, false);
- }
- 
- 
- static int
- qemuDomainSetupAllMemories(virQEMUDriverConfigPtr cfg,
-                            virDomainObjPtr vm,
--                           const char *devPath)
-+                           const struct qemuDomainCreateDeviceData *data)
- {
-     size_t i;
- 
-@@ -7796,7 +7801,7 @@ qemuDomainSetupAllMemories(virQEMUDriverConfigPtr cfg,
-     for (i = 0; i < vm->def->nmems; i++) {
-         if (qemuDomainSetupMemory(cfg,
-                                   vm->def->mems[i],
--                                  devPath) < 0)
-+                                  data) < 0)
-             return -1;
-     }
-     VIR_DEBUG("Setup all memories");
-@@ -7809,26 +7814,26 @@ qemuDomainSetupChardev(virDomainDefPtr def ATTRIBUTE_UNUSED,
-                        virDomainChrDefPtr dev,
-                        void *opaque)
- {
--    const char *devPath = opaque;
-+    const struct qemuDomainCreateDeviceData *data = opaque;
- 
-     if (dev->source->type != VIR_DOMAIN_CHR_TYPE_DEV)
-         return 0;
- 
--    return qemuDomainCreateDevice(dev->source->data.file.path, devPath, false);
-+    return qemuDomainCreateDevice(dev->source->data.file.path, data, false);
- }
- 
- 
- static int
- qemuDomainSetupAllChardevs(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-                            virDomainObjPtr vm,
--                           const char *devPath)
-+                           const struct qemuDomainCreateDeviceData *data)
- {
-     VIR_DEBUG("Setting up chardevs");
- 
-     if (virDomainChrDefForeach(vm->def,
-                                true,
-                                qemuDomainSetupChardev,
--                               (void *) devPath) < 0)
-+                               (void *) data) < 0)
-         return -1;
- 
-     VIR_DEBUG("Setup all chardevs");
-@@ -7839,7 +7844,7 @@ qemuDomainSetupAllChardevs(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
- static int
- qemuDomainSetupTPM(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-                    virDomainObjPtr vm,
--                   const char *devPath)
-+                   const struct qemuDomainCreateDeviceData *data)
- {
-     virDomainTPMDefPtr dev = vm->def->tpm;
- 
-@@ -7851,7 +7856,7 @@ qemuDomainSetupTPM(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-     switch (dev->type) {
-     case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
-         if (qemuDomainCreateDevice(dev->data.passthrough.source.data.file.path,
--                                   devPath, false) < 0)
-+                                   data, false) < 0)
-             return -1;
-         break;
- 
-@@ -7868,7 +7873,7 @@ qemuDomainSetupTPM(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
- static int
- qemuDomainSetupGraphics(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-                         virDomainGraphicsDefPtr gfx,
--                        const char *devPath)
-+                        const struct qemuDomainCreateDeviceData *data)
- {
-     const char *rendernode = gfx->data.spice.rendernode;
- 
-@@ -7877,14 +7882,14 @@ qemuDomainSetupGraphics(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-         !rendernode)
-         return 0;
- 
--    return qemuDomainCreateDevice(rendernode, devPath, false);
-+    return qemuDomainCreateDevice(rendernode, data, false);
- }
- 
- 
- static int
- qemuDomainSetupAllGraphics(virQEMUDriverConfigPtr cfg,
-                            virDomainObjPtr vm,
--                           const char *devPath)
-+                           const struct qemuDomainCreateDeviceData *data)
- {
-     size_t i;
- 
-@@ -7892,7 +7897,7 @@ qemuDomainSetupAllGraphics(virQEMUDriverConfigPtr cfg,
-     for (i = 0; i < vm->def->ngraphics; i++) {
-         if (qemuDomainSetupGraphics(cfg,
-                                     vm->def->graphics[i],
--                                    devPath) < 0)
-+                                    data) < 0)
-             return -1;
-     }
- 
-@@ -7904,13 +7909,13 @@ qemuDomainSetupAllGraphics(virQEMUDriverConfigPtr cfg,
- static int
- qemuDomainSetupInput(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-                      virDomainInputDefPtr input,
--                     const char *devPath)
-+                     const struct qemuDomainCreateDeviceData *data)
- {
-     int ret = -1;
- 
-     switch ((virDomainInputType) input->type) {
-     case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
--        if (qemuDomainCreateDevice(input->source.evdev, devPath, false) < 0)
-+        if (qemuDomainCreateDevice(input->source.evdev, data, false) < 0)
-             goto cleanup;
-         break;
- 
-@@ -7931,7 +7936,7 @@ qemuDomainSetupInput(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
- static int
- qemuDomainSetupAllInputs(virQEMUDriverConfigPtr cfg,
-                          virDomainObjPtr vm,
--                         const char *devPath)
-+                         const struct qemuDomainCreateDeviceData *data)
- {
-     size_t i;
- 
-@@ -7939,7 +7944,7 @@ qemuDomainSetupAllInputs(virQEMUDriverConfigPtr cfg,
-     for (i = 0; i < vm->def->ninputs; i++) {
-         if (qemuDomainSetupInput(cfg,
-                                  vm->def->inputs[i],
--                                 devPath) < 0)
-+                                 data) < 0)
-             return -1;
-     }
-     VIR_DEBUG("Setup all inputs");
-@@ -7950,11 +7955,11 @@ qemuDomainSetupAllInputs(virQEMUDriverConfigPtr cfg,
- static int
- qemuDomainSetupRNG(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
-                    virDomainRNGDefPtr rng,
--                   const char *devPath)
-+                   const struct qemuDomainCreateDeviceData *data)
- {
-     switch ((virDomainRNGBackend) rng->backend) {
-     case VIR_DOMAIN_RNG_BACKEND_RANDOM:
--        if (qemuDomainCreateDevice(rng->source.file, devPath, false) < 0)
-+        if (qemuDomainCreateDevice(rng->source.file, data, false) < 0)
-             return -1;
- 
-     case VIR_DOMAIN_RNG_BACKEND_EGD:
-@@ -7970,7 +7975,7 @@ qemuDomainSetupRNG(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
- static int
- qemuDomainSetupAllRNGs(virQEMUDriverConfigPtr cfg,
-                        virDomainObjPtr vm,
--                       const char *devPath)
-+                       const struct qemuDomainCreateDeviceData *data)
- {
-     size_t i;
- 
-@@ -7978,7 +7983,7 @@ qemuDomainSetupAllRNGs(virQEMUDriverConfigPtr cfg,
-     for (i = 0; i < vm->def->nrngs; i++) {
-         if (qemuDomainSetupRNG(cfg,
-                                vm->def->rngs[i],
--                               devPath) < 0)
-+                               data) < 0)
-             return -1;
-     }
- 
-@@ -7992,6 +7997,7 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
-                          virSecurityManagerPtr mgr,
-                          virDomainObjPtr vm)
- {
-+    struct qemuDomainCreateDeviceData data;
-     char *devPath = NULL;
-     char **devMountsPath = NULL, **devMountsSavePath = NULL;
-     size_t ndevMountsPath = 0, i;
-@@ -8020,34 +8026,36 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
-         goto cleanup;
-     }
- 
-+    data.path = devPath;
-+
-     if (virProcessSetupPrivateMountNS() < 0)
-         goto cleanup;
- 
--    if (qemuDomainSetupDev(cfg, mgr, vm, devPath) < 0)
-+    if (qemuDomainSetupDev(cfg, mgr, vm, &data) < 0)
-         goto cleanup;
- 
--    if (qemuDomainSetupAllDisks(cfg, vm, devPath) < 0)
-+    if (qemuDomainSetupAllDisks(cfg, vm, &data) < 0)
-         goto cleanup;
- 
--    if (qemuDomainSetupAllHostdevs(cfg, vm, devPath) < 0)
-+    if (qemuDomainSetupAllHostdevs(cfg, vm, &data) < 0)
-         goto cleanup;
- 
--    if (qemuDomainSetupAllMemories(cfg, vm, devPath) < 0)
-+    if (qemuDomainSetupAllMemories(cfg, vm, &data) < 0)
-         goto cleanup;
- 
--    if (qemuDomainSetupAllChardevs(cfg, vm, devPath) < 0)
-+    if (qemuDomainSetupAllChardevs(cfg, vm, &data) < 0)
-         goto cleanup;
- 
--    if (qemuDomainSetupTPM(cfg, vm, devPath) < 0)
-+    if (qemuDomainSetupTPM(cfg, vm, &data) < 0)
-         goto cleanup;
- 
--    if (qemuDomainSetupAllGraphics(cfg, vm, devPath) < 0)
-+    if (qemuDomainSetupAllGraphics(cfg, vm, &data) < 0)
-         goto cleanup;
- 
--    if (qemuDomainSetupAllInputs(cfg, vm, devPath) < 0)
-+    if (qemuDomainSetupAllInputs(cfg, vm, &data) < 0)
-         goto cleanup;
- 
--    if (qemuDomainSetupAllRNGs(cfg, vm, devPath) < 0)
-+    if (qemuDomainSetupAllRNGs(cfg, vm, &data) < 0)
-         goto cleanup;
- 
-     /* Save some mount points because we want to share them with the host */
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemuDomainDetachDeviceUnlink-Don-t-unlink-files-we-haven-t-created.patch b/SOURCES/libvirt-qemuDomainDetachDeviceUnlink-Don-t-unlink-files-we-haven-t-created.patch
deleted file mode 100644
index 630c82a..0000000
--- a/SOURCES/libvirt-qemuDomainDetachDeviceUnlink-Don-t-unlink-files-we-haven-t-created.patch
+++ /dev/null
@@ -1,203 +0,0 @@
-From 8767eb1b444bcd825f382f150cd064171fdcba81 Mon Sep 17 00:00:00 2001
-Message-Id: <8767eb1b444bcd825f382f150cd064171fdcba81@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Thu, 11 May 2017 15:38:41 +0200
-Subject: [PATCH] qemuDomainDetachDeviceUnlink: Don't unlink files we haven't
- created
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1449510
-
-Even though there are several checks before calling this function
-and for some scenarios we don't call it at all (e.g. on disk hot
-unplug), it may be possible to sneak in some weird files (e.g. if
-domain would have RNG with /dev/shm/some_file as its backend). No
-matter how improbable, we shouldn't unlink it as we would be
-unlinking a file from the host which we haven't created in the
-first place.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
-(cherry picked from commit 2f0b3b103b329b0b9656ac4fc8b5f94a5c2fa051)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/qemu/qemu_domain.c | 86 ++++++++++++++++++++++++++++++++++++++++++++------
- 1 file changed, 76 insertions(+), 10 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 671569f6f..5ef3d0577 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -8471,14 +8471,32 @@ qemuDomainDetachDeviceUnlinkHelper(pid_t pid ATTRIBUTE_UNUSED,
- static int
- qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
-                              virDomainObjPtr vm,
--                             const char *file)
-+                             const char *file,
-+                             char * const *devMountsPath,
-+                             size_t ndevMountsPath)
- {
--    if (virProcessRunInMountNamespace(vm->pid,
--                                      qemuDomainDetachDeviceUnlinkHelper,
--                                      (void *)file) < 0)
--        return -1;
-+    int ret = -1;
-+    size_t i;
- 
--    return 0;
-+    if (STRPREFIX(file, DEVPREFIX)) {
-+        for (i = 0; i < ndevMountsPath; i++) {
-+            if (STREQ(devMountsPath[i], "/dev"))
-+                continue;
-+            if (STRPREFIX(file, devMountsPath[i]))
-+                break;
-+        }
-+
-+        if (i == ndevMountsPath) {
-+            if (virProcessRunInMountNamespace(vm->pid,
-+                                              qemuDomainDetachDeviceUnlinkHelper,
-+                                              (void *)file) < 0)
-+                goto cleanup;
-+        }
-+    }
-+
-+    ret = 0;
-+ cleanup:
-+    return ret;
- }
- 
- 
-@@ -8597,6 +8615,9 @@ qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr driver,
-                                    virDomainObjPtr vm,
-                                    virDomainHostdevDefPtr hostdev)
- {
-+    virQEMUDriverConfigPtr cfg = NULL;
-+    char **devMountsPath = NULL;
-+    size_t ndevMountsPath = 0;
-     int ret = -1;
-     char **path = NULL;
-     size_t i, npaths = 0;
-@@ -8608,8 +8629,15 @@ qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr driver,
-                                  &npaths, &path, NULL) < 0)
-         goto cleanup;
- 
-+    cfg = virQEMUDriverGetConfig(driver);
-+    if (qemuDomainGetPreservedMounts(cfg, vm,
-+                                     &devMountsPath, NULL,
-+                                     &ndevMountsPath) < 0)
-+        goto cleanup;
-+
-     for (i = 0; i < npaths; i++) {
--        if (qemuDomainDetachDeviceUnlink(driver, vm, path[i]) < 0)
-+        if (qemuDomainDetachDeviceUnlink(driver, vm, path[i],
-+                                         devMountsPath, ndevMountsPath) < 0)
-             goto cleanup;
-     }
- 
-@@ -8618,6 +8646,8 @@ qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr driver,
-     for (i = 0; i < npaths; i++)
-         VIR_FREE(path[i]);
-     VIR_FREE(path);
-+    virStringListFreeCount(devMountsPath, ndevMountsPath);
-+    virObjectUnref(cfg);
-     return ret;
- }
- 
-@@ -8660,6 +8690,9 @@ qemuDomainNamespaceTeardownMemory(virQEMUDriverPtr driver,
-                                   virDomainObjPtr vm,
-                                   virDomainMemoryDefPtr mem)
- {
-+    virQEMUDriverConfigPtr cfg = NULL;
-+    char **devMountsPath = NULL;
-+    size_t ndevMountsPath = 0;
-     int ret = -1;
- 
-     if (mem->model != VIR_DOMAIN_MEMORY_MODEL_NVDIMM)
-@@ -8668,10 +8701,19 @@ qemuDomainNamespaceTeardownMemory(virQEMUDriverPtr driver,
-     if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
-         return 0;
- 
--    if (qemuDomainDetachDeviceUnlink(driver, vm, mem->nvdimmPath) < 0)
-+    cfg = virQEMUDriverGetConfig(driver);
-+    if (qemuDomainGetPreservedMounts(cfg, vm,
-+                                     &devMountsPath, NULL,
-+                                     &ndevMountsPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainDetachDeviceUnlink(driver, vm, mem->nvdimmPath,
-+                                     devMountsPath, ndevMountsPath) < 0)
-         goto cleanup;
-     ret = 0;
-  cleanup:
-+    virStringListFreeCount(devMountsPath, ndevMountsPath);
-+    virObjectUnref(cfg);
-     return ret;
- }
- 
-@@ -8719,6 +8761,9 @@ qemuDomainNamespaceTeardownChardev(virQEMUDriverPtr driver,
-                                    virDomainObjPtr vm,
-                                    virDomainChrDefPtr chr)
- {
-+    virQEMUDriverConfigPtr cfg = NULL;
-+    char **devMountsPath = NULL;
-+    size_t ndevMountsPath = 0;
-     int ret = -1;
-     const char *path = NULL;
- 
-@@ -8730,11 +8775,20 @@ qemuDomainNamespaceTeardownChardev(virQEMUDriverPtr driver,
- 
-     path = chr->source->data.file.path;
- 
--    if (qemuDomainDetachDeviceUnlink(driver, vm, path) < 0)
-+    cfg = virQEMUDriverGetConfig(driver);
-+    if (qemuDomainGetPreservedMounts(cfg, vm,
-+                                     &devMountsPath, NULL,
-+                                     &ndevMountsPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainDetachDeviceUnlink(driver, vm, path,
-+                                     devMountsPath, ndevMountsPath) < 0)
-         goto cleanup;
- 
-     ret = 0;
-  cleanup:
-+    virStringListFreeCount(devMountsPath, ndevMountsPath);
-+    virObjectUnref(cfg);
-     return ret;
- }
- 
-@@ -8788,6 +8842,9 @@ qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr driver,
-                                virDomainObjPtr vm,
-                                virDomainRNGDefPtr rng)
- {
-+    virQEMUDriverConfigPtr cfg = NULL;
-+    char **devMountsPath = NULL;
-+    size_t ndevMountsPath = 0;
-     int ret = -1;
-     const char *path = NULL;
- 
-@@ -8805,11 +8862,20 @@ qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr driver,
-         goto cleanup;
-     }
- 
--    if (qemuDomainDetachDeviceUnlink(driver, vm, path) < 0)
-+    cfg = virQEMUDriverGetConfig(driver);
-+    if (qemuDomainGetPreservedMounts(cfg, vm,
-+                                     &devMountsPath, NULL,
-+                                     &ndevMountsPath) < 0)
-+        goto cleanup;
-+
-+    if (qemuDomainDetachDeviceUnlink(driver, vm, path,
-+                                     devMountsPath, ndevMountsPath) < 0)
-         goto cleanup;
- 
-     ret = 0;
-  cleanup:
-+    virStringListFreeCount(devMountsPath, ndevMountsPath);
-+    virObjectUnref(cfg);
-     return ret;
- }
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-qemuDomainRemoveMemoryDevice-unlink-memory-backing-file.patch b/SOURCES/libvirt-qemuDomainRemoveMemoryDevice-unlink-memory-backing-file.patch
new file mode 100644
index 0000000..b568c9f
--- /dev/null
+++ b/SOURCES/libvirt-qemuDomainRemoveMemoryDevice-unlink-memory-backing-file.patch
@@ -0,0 +1,96 @@
+From 9c5a70bc8c9332de2e769226efe81cb95b1ce2a4 Mon Sep 17 00:00:00 2001
+Message-Id: <9c5a70bc8c9332de2e769226efe81cb95b1ce2a4@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Fri, 2 Feb 2018 11:12:36 +0100
+Subject: [PATCH] qemuDomainRemoveMemoryDevice: unlink() memory backing file
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1461214
+
+Since fec8f9c49af we try to use predictable file names for
+'memory-backend-file' objects. But that made us provide full path
+to qemu when hot plugging the object while previously we provided
+merely a directory. But this makes qemu behave differently. If
+qemu sees a path terminated with a directory it calls mkstemp()
+and unlinks the file immediately. But if it sees full path it
+just calls open(path, O_CREAT ..); and never unlinks the file.
+Therefore it's up to libvirt to unlink the file and not leave it
+behind.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+(cherry picked from commit 4d83a6722f5b9c10ee85d5a5ffee364ac0e7b8af)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+---
+ src/qemu/qemu_hotplug.c |  3 +++
+ src/qemu/qemu_process.c | 26 ++++++++++++++++++++++++++
+ src/qemu/qemu_process.h |  4 ++++
+ 3 files changed, 33 insertions(+)
+
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index f1056627f2..831e014d9c 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -3803,6 +3803,9 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
+     if (qemuDomainNamespaceTeardownMemory(driver, vm, mem) <  0)
+         VIR_WARN("Unable to remove memory device from /dev");
+ 
++    if (qemuProcessDestroyMemoryBackingPath(driver, vm, mem) < 0)
++        VIR_WARN("Unable to destroy memory backing path");
++
+     virDomainMemoryDefFree(mem);
+ 
+     /* fix the balloon size */
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index caf967dac5..3853112924 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -3491,6 +3491,32 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
+ }
+ 
+ 
++int
++qemuProcessDestroyMemoryBackingPath(virQEMUDriverPtr driver,
++                                    virDomainObjPtr vm,
++                                    virDomainMemoryDefPtr mem)
++{
++    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
++    char *path = NULL;
++    int ret = -1;
++
++    if (qemuGetMemoryBackingPath(vm->def, cfg, mem->info.alias, &path) < 0)
++        goto cleanup;
++
++    if (unlink(path) < 0 &&
++        errno != ENOENT) {
++        virReportSystemError(errno, _("Unable to remove %s"), path);
++        goto cleanup;
++    }
++
++    ret = 0;
++ cleanup:
++    VIR_FREE(path);
++    virObjectUnref(cfg);
++    return ret;
++}
++
++
+ static int
+ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
+                             virDomainGraphicsDefPtr graphics,
+diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
+index b383ff309b..8d210282f8 100644
+--- a/src/qemu/qemu_process.h
++++ b/src/qemu/qemu_process.h
+@@ -43,6 +43,10 @@ int qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
+                                        virDomainMemoryDefPtr mem,
+                                        bool build);
+ 
++int qemuProcessDestroyMemoryBackingPath(virQEMUDriverPtr driver,
++                                        virDomainObjPtr vm,
++                                        virDomainMemoryDefPtr mem);
++
+ void qemuProcessAutostartAll(virQEMUDriverPtr driver);
+ void qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver);
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-qemuStateInitialize-Don-t-leak-memoryBackingPath.patch b/SOURCES/libvirt-qemuStateInitialize-Don-t-leak-memoryBackingPath.patch
new file mode 100644
index 0000000..8d460f7
--- /dev/null
+++ b/SOURCES/libvirt-qemuStateInitialize-Don-t-leak-memoryBackingPath.patch
@@ -0,0 +1,43 @@
+From 05c1435a164d9ada81d5159302f5b531b871efdf Mon Sep 17 00:00:00 2001
+Message-Id: <05c1435a164d9ada81d5159302f5b531b871efdf@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Fri, 1 Dec 2017 15:48:39 +0100
+Subject: [PATCH] qemuStateInitialize: Don't leak @memoryBackingPath
+
+==899== 39 bytes in 1 blocks are definitely lost in loss record 732 of 1,003
+==899==    at 0x4C2AEDF: malloc (vg_replace_malloc.c:299)
+==899==    by 0x8B68CE7: vasprintf (in /lib64/libc-2.25.so)
+==899==    by 0x55498D2: virVasprintfInternal (virstring.c:708)
+==899==    by 0x55499E7: virAsprintfInternal (virstring.c:729)
+==899==    by 0x2BECFFF0: qemuGetMemoryBackingBasePath (qemu_conf.c:1757)
+==899==    by 0x2BF23225: qemuStateInitialize (qemu_driver.c:893)
+==899==    by 0x563073D: virStateInitialize (libvirt.c:770)
+==899==    by 0x124CC4: daemonRunStateInit (libvirtd.c:834)
+==899==    by 0x55521CD: virThreadHelper (virthread.c:206)
+==899==    by 0x88D9686: start_thread (in /lib64/libpthread-2.25.so)
+==899==    by 0x8BEAEFE: clone (in /lib64/libc-2.25.so)
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+(cherry picked from commit 3eb840904a088a89d05821d975ed4624962431f3)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1519759
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_driver.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
+index d0d29747cf..fa73fc30d6 100644
+--- a/src/qemu/qemu_driver.c
++++ b/src/qemu/qemu_driver.c
+@@ -904,6 +904,7 @@ qemuStateInitialize(bool privileged,
+         virFileUpdatePerm(memoryBackingPath,
+                           0, S_IXGRP | S_IXOTH) < 0)
+         goto error;
++    VIR_FREE(memoryBackingPath);
+ 
+     if (!(qemu_driver->closeCallbacks = virCloseCallbacksNew()))
+         goto error;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu_capabilities-Introcude-QEMU_CAPS_NUMA_DIST.patch b/SOURCES/libvirt-qemu_capabilities-Introcude-QEMU_CAPS_NUMA_DIST.patch
new file mode 100644
index 0000000..035b91e
--- /dev/null
+++ b/SOURCES/libvirt-qemu_capabilities-Introcude-QEMU_CAPS_NUMA_DIST.patch
@@ -0,0 +1,115 @@
+From 92a9394006873d494610bad839255363c36e65c3 Mon Sep 17 00:00:00 2001
+Message-Id: <92a9394006873d494610bad839255363c36e65c3@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Mon, 4 Dec 2017 13:38:51 +0100
+Subject: [PATCH] qemu_capabilities: Introcude QEMU_CAPS_NUMA_DIST
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1454889
+
+This capability says if qemu is capable of specifying distances
+between NUMA nodes on the command line. Unfortunately, there's no
+real way to check this and thus we have to go with version check.
+QEMU introduced this in 0f203430dd8 (and friend) which was
+released in 2.10.0.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 13e148ebda9ef0a064aa811aa14bcbb35c157ceb)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+
+ Conflicts:
+	src/qemu/qemu_capabilities.c
+	src/qemu/qemu_capabilities.h
+	tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml
+	tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml
+	tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+	tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+
+        - Context as some capabilities are not backported.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c                      | 6 +++++-
+ src/qemu/qemu_capabilities.h                      | 2 +-
+ tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml  | 1 +
+ tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml  | 1 +
+ tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 +
+ 5 files changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index ae5448eaaa..d1677144b7 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -449,7 +449,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
+ 
+               /* 275 */
+               "sclplmconsole",
+-
++              "numa.dist",
+               "disk-share-rw",
+ 
+               "isa-serial",
+@@ -4808,6 +4808,10 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
+         virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
+     }
+ 
++    /* no way to query for -numa dist */
++    if (qemuCaps->version >= 2010000)
++        virQEMUCapsSet(qemuCaps, QEMU_CAPS_NUMA_DIST);
++
+     if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0)
+         goto cleanup;
+ 
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index c809f83404..3e016b7c79 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -435,7 +435,7 @@ typedef enum {
+ 
+     /* 275 */
+     QEMU_CAPS_DEVICE_SCLPLMCONSOLE, /* -device sclplmconsole */
+-
++    QEMU_CAPS_NUMA_DIST, /* -numa dist */
+     QEMU_CAPS_DISK_SHARE_RW, /* share-rw=on for concurrent disk access */
+ 
+     QEMU_CAPS_DEVICE_ISA_SERIAL, /* -device isa-serial */
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+index 23356f4092..09cce92067 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+@@ -179,6 +179,7 @@
+   <flag name='virtio-blk.num-queues'/>
+   <flag name='machine.pseries.resize-hpt'/>
+   <flag name='spapr-vty'/>
++  <flag name='numa.dist'/>
+   <flag name='disk-share-rw'/>
+   <flag name='isa-serial'/>
+   <version>2010000</version>
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+index 463c30c77a..00fe1cffa7 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+@@ -142,6 +142,7 @@
+   <flag name='vxhs'/>
+   <flag name='virtio-blk.num-queues'/>
+   <flag name='sclplmconsole'/>
++  <flag name='numa.dist'/>
+   <flag name='disk-share-rw'/>
+   <version>2010000</version>
+   <kvmVersion>0</kvmVersion>
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+index e04e530b95..2417251678 100644
+--- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+@@ -224,6 +224,7 @@
+   <flag name='virtio-gpu.max_outputs'/>
+   <flag name='vxhs'/>
+   <flag name='virtio-blk.num-queues'/>
++  <flag name='numa.dist'/>
+   <flag name='disk-share-rw'/>
+   <flag name='isa-serial'/>
+   <version>2010000</version>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-qemu_domain-use-correct-default-USB-controller-on-ppc64.patch b/SOURCES/libvirt-qemu_domain-use-correct-default-USB-controller-on-ppc64.patch
deleted file mode 100644
index 578cd7b..0000000
--- a/SOURCES/libvirt-qemu_domain-use-correct-default-USB-controller-on-ppc64.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-From 48c13aa1bbd505a96af170d9efe0e0540efd5b59 Mon Sep 17 00:00:00 2001
-Message-Id: <48c13aa1bbd505a96af170d9efe0e0540efd5b59@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Thu, 20 Apr 2017 09:16:21 +0200
-Subject: [PATCH] qemu_domain: use correct default USB controller on ppc64
-
-The history of USB controller for ppc64 guest is complex and goes
-back to libvirt 1.3.1 where the fun started.
-
-Prior Libvirt 1.3.1 if no model for USB controller was specified
-we've simply passed "-usb" on QEMU command line.
-
-Since Libvirt 1.3.1 there is a patch (8156493d8db) that fixes this
-issue by using "-device pci-ohci,..." but it breaks migration with
-older Libvirts which was agreed that's acceptable.  However this
-patch didn't reflect this change in the domain XML and the model
-was still missing.
-
-Since Libvirt 2.2.0 there is a patch (f55eaccb0c5) that fixes the
-issue with not setting the USB model into domain XML which we need
-to know about to not break the migration and since the default
-model was *pci-ohci* it was used as default in this patch as well.
-
-This patch tries to take all the previous changes into account and
-also change the default for newly defined domains that don't specify
-any model for USB controller.
-
-The VIR_DOMAIN_DEF_PARSE_ABI_UPDATE is set only if new domain is
-defined or new device is added into a domain which means that in
-all other cases we will use the old *pci-ohci* model instead of the
-better and not broken *nec-usb-xhci* model.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1373184
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 90acbc76ece8b94cfd5e5d2ebb675f7692ce7afd)
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/qemu/qemu_domain.c | 16 ++++++++++++----
- 1 file changed, 12 insertions(+), 4 deletions(-)
-
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 3150e8760..c43ff3d63 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -3110,7 +3110,8 @@ qemuDomainShmemDefPostParse(virDomainShmemDefPtr shm)
- static int
- qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
-                                  const virDomainDef *def,
--                                 virQEMUCapsPtr qemuCaps)
-+                                 virQEMUCapsPtr qemuCaps,
-+                                 unsigned int parseFlags)
- {
-     switch ((virDomainControllerType)cont->type) {
-     case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
-@@ -3138,9 +3139,16 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
-                  * address is found */
-                 cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
-             } else if (ARCH_IS_PPC64(def->os.arch)) {
--                /* Default USB controller for ppc64 is pci-ohci */
--                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI))
-+                /* To not break migration we need to set default USB controller
-+                 * for ppc64 to pci-ohci if we cannot change ABI of the VM.
-+                 * The nec-usb-xhci controller is used as default only for
-+                 * newly defined domains or devices. */
-+                if ((parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) &&
-+                    virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI)) {
-+                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
-+                } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI)) {
-                     cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
-+                }
-             } else {
-                 /* Default USB controller for anything else is piix3-uhci */
-                 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
-@@ -3339,7 +3347,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
- 
-     if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER &&
-         qemuDomainControllerDefPostParse(dev->data.controller, def,
--                                         qemuCaps) < 0)
-+                                         qemuCaps, parseFlags) < 0)
-         goto cleanup;
- 
-     if (dev->type == VIR_DOMAIN_DEVICE_SHMEM &&
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-qemuxml2argvtest-add-virtio-options-test-case.patch b/SOURCES/libvirt-qemuxml2argvtest-add-virtio-options-test-case.patch
deleted file mode 100644
index 70cd767..0000000
--- a/SOURCES/libvirt-qemuxml2argvtest-add-virtio-options-test-case.patch
+++ /dev/null
@@ -1,96 +0,0 @@
-From ea26b477bbb8d6f93af2b12840ac6ff0b0deca17 Mon Sep 17 00:00:00 2001
-Message-Id: <ea26b477bbb8d6f93af2b12840ac6ff0b0deca17@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:49:08 +0200
-Subject: [PATCH] qemuxml2argvtest: add virtio-options test case
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Add a test case to demonstrate the addition of new command line options
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 56a28fbb57daa96fc7fe8f0516c8ee937ec3b39b)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-
-Conflicts:
-  Downstream still normalizes machine names.
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- .../qemuxml2argv-virtio-options.args               | 41 ++++++++++++++++++++++
- tests/qemuxml2argvtest.c                           |  9 +++++
- 2 files changed, 50 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-options.args
-
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.args
-new file mode 100644
-index 0000000000..f9f3c2cbad
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.args
-@@ -0,0 +1,41 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-x86_64 \
-+-name QEMUGuest1 \
-+-S \
-+-M pc-0.11 \
-+-m 214 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x8 \
-+-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x9 \
-+-usb \
-+-drive file=/var/lib/libvirt/images/img1,format=raw,if=none,\
-+id=drive-virtio-disk0 \
-+-device virtio-blk-pci,bus=pci.0,addr=0xa,drive=drive-virtio-disk0,\
-+id=virtio-disk0 \
-+-fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \
-+-device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.0,addr=0x3 \
-+-fsdev local,security_model=mapped,writeout=immediate,id=fsdev-fs1,\
-+path=/export/fs2 \
-+-device virtio-9p-pci,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,bus=pci.0,addr=0x4 \
-+-device virtio-net-pci,vlan=0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x6 \
-+-net user,vlan=0,name=hostnet0 \
-+-device virtio-mouse-pci,id=input0,bus=pci.0,addr=0xe \
-+-device virtio-keyboard-pci,id=input1,bus=pci.0,addr=0x10 \
-+-device virtio-tablet-pci,id=input2,bus=pci.0,addr=0x11 \
-+-device virtio-input-host-pci,id=input3,evdev=/dev/input/event1234,bus=pci.0,\
-+addr=0x12 \
-+-device virtio-gpu-pci,id=video0,virgl=on,bus=pci.0,addr=0x2 \
-+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0xc \
-+-object rng-random,id=objrng0,filename=/dev/random \
-+-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0xd
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index bff32200d7..c186780ef1 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -2550,6 +2550,15 @@ mymain(void)
-             QEMU_CAPS_DEVICE_INTEL_IOMMU);
- 
-     DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
-+    DO_TEST("virtio-options", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_KEYBOARD,
-+            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET,
-+            QEMU_CAPS_VIRTIO_INPUT_HOST,
-+            QEMU_CAPS_FSDEV, QEMU_CAPS_FSDEV_WRITEOUT,
-+            QEMU_CAPS_DEVICE_VIRTIO_GPU,
-+            QEMU_CAPS_VIRTIO_GPU_VIRGL,
-+            QEMU_CAPS_DEVICE_VIRTIO_RNG,
-+            QEMU_CAPS_OBJECT_RNG_RANDOM,
-+            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
- 
-     DO_TEST("fd-memory-numa-topology", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE,
-             QEMU_CAPS_KVM);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-qemuxml2xmltest-add-virtio-options-test.patch b/SOURCES/libvirt-qemuxml2xmltest-add-virtio-options-test.patch
deleted file mode 100644
index 7da9710..0000000
--- a/SOURCES/libvirt-qemuxml2xmltest-add-virtio-options-test.patch
+++ /dev/null
@@ -1,136 +0,0 @@
-From 5c213cb256cbe66c368c2978b2ff41ab45dd0e44 Mon Sep 17 00:00:00 2001
-Message-Id: <5c213cb256cbe66c368c2978b2ff41ab45dd0e44@dist-git>
-From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
-Date: Fri, 9 Jun 2017 12:48:58 +0200
-Subject: [PATCH] qemuxml2xmltest: add virtio-options test
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Add a test case with all the virtio devices we know to demonstrate
-the addition of new options.
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 15911ab8201f46b99352eea818c798828b6e4ff1)
-Signed-off-by: Ján Tomko <jtomko@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- .../qemuxml2argv-virtio-options.xml                | 81 ++++++++++++++++++++++
- .../qemuxml2xmlout-virtio-options.xml              |  1 +
- tests/qemuxml2xmltest.c                            |  1 +
- 3 files changed, 83 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
- create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml
-
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-new file mode 100644
-index 0000000000..c88cf649b1
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-@@ -0,0 +1,81 @@
-+<domain type='qemu'>
-+  <name>QEMUGuest1</name>
-+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-+  <memory unit='KiB'>219136</memory>
-+  <currentMemory unit='KiB'>219136</currentMemory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='pc'>hvm</type>
-+    <boot dev='hd'/>
-+  </os>
-+  <clock offset='utc'/>
-+  <on_poweroff>destroy</on_poweroff>
-+  <on_reboot>restart</on_reboot>
-+  <on_crash>destroy</on_crash>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <disk type='file' device='disk'>
-+      <driver name='qemu' type='raw'/>
-+      <source file='/var/lib/libvirt/images/img1'/>
-+      <target dev='vda' bus='virtio'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
-+    </disk>
-+    <controller type='usb' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
-+    </controller>
-+    <controller type='ide' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
-+    </controller>
-+    <controller type='scsi' index='0' model='virtio-scsi'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
-+    </controller>
-+    <controller type='pci' index='0' model='pci-root'/>
-+    <controller type='virtio-serial' index='0'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
-+    </controller>
-+    <filesystem type='mount' accessmode='passthrough'>
-+      <source dir='/export/fs1'/>
-+      <target dir='fs1'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
-+    </filesystem>
-+    <filesystem type='mount' accessmode='mapped'>
-+      <driver type='path' wrpolicy='immediate'/>
-+      <source dir='/export/fs2'/>
-+      <target dir='fs2'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
-+    </filesystem>
-+    <interface type='user'>
-+      <mac address='52:54:56:58:5a:5c'/>
-+      <model type='virtio'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
-+    </interface>
-+    <input type='mouse' bus='virtio'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
-+    </input>
-+    <input type='keyboard' bus='virtio'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
-+    </input>
-+    <input type='tablet' bus='virtio'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
-+    </input>
-+    <input type='passthrough' bus='virtio'>
-+      <source evdev='/dev/input/event1234'/>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
-+    </input>
-+    <input type='mouse' bus='ps2'/>
-+    <input type='keyboard' bus='ps2'/>
-+    <video>
-+      <model type='virtio' heads='1' primary='yes'>
-+        <acceleration accel3d='yes'/>
-+      </model>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
-+    </video>
-+    <memballoon model='virtio'>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
-+    </memballoon>
-+    <rng model='virtio'>
-+      <backend model='random'>/dev/random</backend>
-+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
-+    </rng>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml
-new file mode 120000
-index 0000000000..d757b8aac0
---- /dev/null
-+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml
-@@ -0,0 +1 @@
-+../qemuxml2argvdata/qemuxml2argv-virtio-options.xml
-\ No newline at end of file
-diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
-index 3f7c268e43..72eac5e716 100644
---- a/tests/qemuxml2xmltest.c
-+++ b/tests/qemuxml2xmltest.c
-@@ -1109,6 +1109,7 @@ mymain(void)
- 
-     DO_TEST("memorybacking-set", NONE);
-     DO_TEST("memorybacking-unset", NONE);
-+    DO_TEST("virtio-options", QEMU_CAPS_VIRTIO_SCSI);
- 
-     virObjectUnref(cfg);
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-resctl-stub-out-functions-with-Linux-only-APIs-used.patch b/SOURCES/libvirt-resctl-stub-out-functions-with-Linux-only-APIs-used.patch
new file mode 100644
index 0000000..55611db
--- /dev/null
+++ b/SOURCES/libvirt-resctl-stub-out-functions-with-Linux-only-APIs-used.patch
@@ -0,0 +1,147 @@
+From bd6a2a903f008eef19caa703303492920878174e Mon Sep 17 00:00:00 2001
+Message-Id: <bd6a2a903f008eef19caa703303492920878174e@dist-git>
+From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:34 +0100
+Subject: [PATCH] resctl: stub out functions with Linux-only APIs used
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The flock() function and d_type field in struct dirent are not portable
+to the mingw platform.
+
+Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
+(cherry picked from commit a020ab03fdfc3f95ef8d52908bcfc1aac22a8316)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 47 insertions(+)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index e252aefe31..754820ee46 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -295,6 +295,7 @@ virResctrlAllocNew(void)
+ 
+ 
+ /* Common functions */
++#ifdef __linux__
+ static int
+ virResctrlLockInternal(int op)
+ {
+@@ -321,6 +322,20 @@ virResctrlLockWrite(void)
+     return virResctrlLockInternal(LOCK_EX);
+ }
+ 
++#else
++
++static inline int
++virResctrlLockWrite(void)
++{
++    virReportSystemError(ENOSYS, "%s",
++                         _("resctrlfs not supported on this platform"));
++    return -1;
++}
++
++#endif
++
++
++
+ 
+ static int
+ virResctrlUnlock(int fd)
+@@ -328,6 +343,7 @@ virResctrlUnlock(int fd)
+     if (fd == -1)
+         return 0;
+ 
++#ifdef __linux__
+     /* The lock gets unlocked by closing the fd, which we need to do anyway in
+      * order to clean up properly */
+     if (VIR_CLOSE(fd) < 0) {
+@@ -338,6 +354,7 @@ virResctrlUnlock(int fd)
+             virReportSystemError(errno, "%s", _("Cannot unlock resctrlfs"));
+         return -1;
+     }
++#endif /* ! __linux__ */
+ 
+     return 0;
+ }
+@@ -369,6 +386,8 @@ virResctrlInfoIsEmpty(virResctrlInfoPtr resctrl)
+ }
+ 
+ 
++#ifdef __linux__
++
+ int
+ virResctrlGetInfo(virResctrlInfoPtr resctrl)
+ {
+@@ -495,6 +514,18 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
+     return ret;
+ }
+ 
++#else /* ! __linux__ */
++
++int
++virResctrlGetInfo(virResctrlInfoPtr resctrl ATTRIBUTE_UNUSED)
++{
++    virReportSystemError(ENOSYS, "%s",
++                         _("Cache tune not supported on this platform"));
++    return -1;
++}
++
++#endif /* ! __linux__ */
++
+ 
+ int
+ virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
+@@ -632,6 +663,8 @@ virResctrlAllocGetType(virResctrlAllocPtr resctrl,
+ }
+ 
+ 
++#ifdef __linux__
++
+ static int
+ virResctrlAllocUpdateMask(virResctrlAllocPtr resctrl,
+                           unsigned int level,
+@@ -659,6 +692,8 @@ virResctrlAllocUpdateMask(virResctrlAllocPtr resctrl,
+     return virBitmapCopy(a_type->masks[cache], mask);
+ }
+ 
++#endif
++
+ 
+ static int
+ virResctrlAllocUpdateSize(virResctrlAllocPtr resctrl,
+@@ -878,6 +913,8 @@ virResctrlAllocFormat(virResctrlAllocPtr resctrl)
+ }
+ 
+ 
++#ifdef __linux__
++
+ static int
+ virResctrlAllocParseProcessCache(virResctrlInfoPtr resctrl,
+                                  virResctrlAllocPtr alloc,
+@@ -1180,7 +1217,17 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
+     goto cleanup;
+ }
+ 
++#else /* ! __linux__ */
+ 
++virResctrlAllocPtr
++virResctrlAllocGetUnused(virResctrlInfoPtr resctrl ATTRIBUTE_UNUSED)
++{
++    virReportSystemError(ENOSYS, "%s",
++                         _("Cache tune not supported on this platform"));
++    return NULL;
++}
++
++#endif /* ! __linux__ */
+ 
+ static int
+ virResctrlAllocSetMask(virResctrlAllocPerTypePtr a_type,
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-resctrl-Add-functions-to-work-with-resctrl-allocations.patch b/SOURCES/libvirt-resctrl-Add-functions-to-work-with-resctrl-allocations.patch
new file mode 100644
index 0000000..5d87ef3
--- /dev/null
+++ b/SOURCES/libvirt-resctrl-Add-functions-to-work-with-resctrl-allocations.patch
@@ -0,0 +1,1360 @@
+From 5fb3ec71e0e67f1f1c0157c9c9038c5136820799 Mon Sep 17 00:00:00 2001
+Message-Id: <5fb3ec71e0e67f1f1c0157c9c9038c5136820799@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:29 +0100
+Subject: [PATCH] resctrl: Add functions to work with resctrl allocations
+
+With this commit we finally have a way to read and manipulate basic resctrl
+settings.  Locking is done only on exposed functions that read/write from/to
+resctrlfs.  Not in functions that are exposed in virresctrlpriv.h as those are
+only supposed to be used from tests.
+
+More information about how resctrl works:
+
+  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/x86/intel_rdt_ui.txt
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit a64c761c275c61517360cf1f5af5461fc5b93138)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Conflicts:
+
+ - whitespace due to 3e7db8d3e8538bcd5deb1b111fb1233fc18831aa
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/Makefile.am           |    2 +-
+ src/libvirt_private.syms  |   10 +
+ src/util/virresctrl.c     | 1174 ++++++++++++++++++++++++++++++++++++++++++++-
+ src/util/virresctrl.h     |   49 ++
+ src/util/virresctrlpriv.h |   27 ++
+ 5 files changed, 1260 insertions(+), 2 deletions(-)
+ create mode 100644 src/util/virresctrlpriv.h
+
+diff --git a/src/Makefile.am b/src/Makefile.am
+index b74856ba78..6b24a47afe 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -167,7 +167,7 @@ UTIL_SOURCES =							\
+ 		util/virprocess.c util/virprocess.h		\
+ 		util/virqemu.c util/virqemu.h			\
+ 		util/virrandom.h util/virrandom.c		\
+-		util/virresctrl.h util/virresctrl.c		\
++		util/virresctrl.h util/virresctrl.c util/virresctrlpriv.h \
+ 		util/virrotatingfile.h util/virrotatingfile.c   \
+ 		util/virscsi.c util/virscsi.h			\
+ 		util/virscsihost.c util/virscsihost.h		\
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 02bad6c0ce..ee75e09767 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -2547,6 +2547,16 @@ virRandomInt;
+ # util/virresctrl.h
+ virCacheTypeFromString;
+ virCacheTypeToString;
++virResctrlAllocAddPID;
++virResctrlAllocCreate;
++virResctrlAllocForeachSize;
++virResctrlAllocFormat;
++virResctrlAllocGetID;
++virResctrlAllocGetUnused;
++virResctrlAllocNew;
++virResctrlAllocRemove;
++virResctrlAllocSetID;
++virResctrlAllocSetSize;
+ virResctrlGetInfo;
+ virResctrlInfoGetCache;
+ virResctrlInfoNew;
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index d439e7792c..e252aefe31 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -18,8 +18,12 @@
+ 
+ #include <config.h>
+ 
+-#include "virresctrl.h"
++#include <sys/file.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <fcntl.h>
+ 
++#include "virresctrlpriv.h"
+ #include "c-ctype.h"
+ #include "count-one-bits.h"
+ #include "viralloc.h"
+@@ -152,6 +156,193 @@ virResctrlInfoNew(void)
+ }
+ 
+ 
++/* Alloc-related definitions and AllocClass-related functions */
++
++/*
++ * virResctrlAlloc represents one allocation (in XML under cputune/cachetune and
++ * consequently a directory under /sys/fs/resctrl).  Since it can have multiple
++ * parts of multiple caches allocated it is represented as bunch of nested
++ * sparse arrays (by sparse I mean array of pointers so that each might be NULL
++ * in case there is no allocation for that particular one (level, cache, ...)).
++ *
++ * Since one allocation can be made for caches on different levels, the first
++ * nested sparse array is of types virResctrlAllocPerLevel.  For example if you
++ * have allocation for level 3 cache, there will be three NULL pointers and then
++ * allocated pointer to virResctrlAllocPerLevel.  That way you can access it by
++ * `alloc[level]` as O(1) is desired instead of crawling through normal arrays
++ * or lists in three nested loops.  The code uses a lot of direct accesses.
++ *
++ * Each virResctrlAllocPerLevel can have allocations for different cache
++ * allocation types.  You can allocate instruction cache (VIR_CACHE_TYPE_CODE),
++ * data cache (VIR_CACHE_TYPE_DATA) or unified cache (VIR_CACHE_TYPE_BOTH).
++ * Those allocations are kept in sparse array of virResctrlAllocPerType pointers.
++ *
++ * For each virResctrlAllocPerType users can request some size of the cache to
++ * be allocated.  That's what the sparse array `sizes` is for.  Non-NULL
++ * pointers represent requested size allocations.  The array is indexed by host
++ * cache id (gotten from `/sys/devices/system/cpu/cpuX/cache/indexY/id`).  Users
++ * can see this information e.g. in the output of `virsh capabilities` (for that
++ * information there's the other struct, namely `virResctrlInfo`).
++ *
++ * When allocation is being created we need to find unused part of the cache for
++ * all of them.  While doing that we store the bitmask in a sparse array of
++ * virBitmaps named `masks` indexed the same way as `sizes`.  The upper bounds
++ * of the sparse arrays are stored in nmasks or nsizes, respectively.
++ */
++typedef struct _virResctrlAllocPerType virResctrlAllocPerType;
++typedef virResctrlAllocPerType *virResctrlAllocPerTypePtr;
++struct _virResctrlAllocPerType {
++    /* There could be bool saying whether this is set or not, but since everything
++     * in virResctrlAlloc (and most of libvirt) goes with pointer arrays we would
++     * have to have one more level of allocation anyway, so this stays faithful to
++     * the concept */
++    unsigned long long **sizes;
++    size_t nsizes;
++
++    /* Mask for each cache */
++    virBitmapPtr *masks;
++    size_t nmasks;
++};
++
++typedef struct _virResctrlAllocPerLevel virResctrlAllocPerLevel;
++typedef virResctrlAllocPerLevel *virResctrlAllocPerLevelPtr;
++struct _virResctrlAllocPerLevel {
++    virResctrlAllocPerTypePtr *types; /* Indexed with enum virCacheType */
++    /* There is no `ntypes` member variable as it is always allocated for
++     * VIR_CACHE_TYPE_LAST number of items */
++};
++
++struct _virResctrlAlloc {
++    virObject parent;
++
++    virResctrlAllocPerLevelPtr *levels;
++    size_t nlevels;
++
++    /* The identifier (any unique string for now) */
++    char *id;
++    /* libvirt-generated path in /sys/fs/resctrl for this particular
++     * allocation */
++    char *path;
++};
++
++static virClassPtr virResctrlAllocClass;
++
++static void
++virResctrlAllocDispose(void *obj)
++{
++    size_t i = 0;
++    size_t j = 0;
++    size_t k = 0;
++
++    virResctrlAllocPtr resctrl = obj;
++
++    for (i = 0; i < resctrl->nlevels; i++) {
++        virResctrlAllocPerLevelPtr level = resctrl->levels[i];
++
++        if (!level)
++            continue;
++
++        for (j = 0; j < VIR_CACHE_TYPE_LAST; j++) {
++            virResctrlAllocPerTypePtr type = level->types[j];
++
++            if (!type)
++                continue;
++
++            for (k = 0; k < type->nsizes; k++)
++                VIR_FREE(type->sizes[k]);
++
++            for (k = 0; k < type->nmasks; k++)
++                virBitmapFree(type->masks[k]);
++
++            VIR_FREE(type->sizes);
++            VIR_FREE(type->masks);
++            VIR_FREE(type);
++        }
++        VIR_FREE(level->types);
++        VIR_FREE(level);
++    }
++
++    VIR_FREE(resctrl->id);
++    VIR_FREE(resctrl->path);
++    VIR_FREE(resctrl->levels);
++}
++
++
++static int
++virResctrlAllocOnceInit(void)
++{
++    if (!(virResctrlAllocClass = virClassNew(virClassForObject(),
++                                             "virResctrlAlloc",
++                                             sizeof(virResctrlAlloc),
++                                             virResctrlAllocDispose)))
++        return -1;
++
++    return 0;
++}
++
++
++VIR_ONCE_GLOBAL_INIT(virResctrlAlloc)
++
++
++virResctrlAllocPtr
++virResctrlAllocNew(void)
++{
++    if (virResctrlAllocInitialize() < 0)
++        return NULL;
++
++    return virObjectNew(virResctrlAllocClass);
++}
++
++
++/* Common functions */
++static int
++virResctrlLockInternal(int op)
++{
++    int fd = open(SYSFS_RESCTRL_PATH, O_DIRECTORY | O_CLOEXEC);
++
++    if (fd < 0) {
++        virReportSystemError(errno, "%s", _("Cannot open resctrlfs"));
++        return -1;
++    }
++
++    if (flock(fd, op) < 0) {
++        virReportSystemError(errno, "%s", _("Cannot lock resctrlfs"));
++        VIR_FORCE_CLOSE(fd);
++        return -1;
++    }
++
++    return fd;
++}
++
++
++static inline int
++virResctrlLockWrite(void)
++{
++    return virResctrlLockInternal(LOCK_EX);
++}
++
++
++static int
++virResctrlUnlock(int fd)
++{
++    if (fd == -1)
++        return 0;
++
++    /* The lock gets unlocked by closing the fd, which we need to do anyway in
++     * order to clean up properly */
++    if (VIR_CLOSE(fd) < 0) {
++        virReportSystemError(errno, "%s", _("Cannot close resctrlfs"));
++
++        /* Trying to save the already broken */
++        if (flock(fd, LOCK_UN) < 0)
++            virReportSystemError(errno, "%s", _("Cannot unlock resctrlfs"));
++        return -1;
++    }
++
++    return 0;
++}
++
++
+ /* Info-related functions */
+ static bool
+ virResctrlInfoIsEmpty(virResctrlInfoPtr resctrl)
+@@ -367,3 +558,984 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
+     VIR_FREE(*controls);
+     goto cleanup;
+ }
++
++
++/* Alloc-related functions */
++bool
++virResctrlAllocIsEmpty(virResctrlAllocPtr resctrl)
++{
++    size_t i = 0;
++    size_t j = 0;
++    size_t k = 0;
++
++    if (!resctrl)
++        return true;
++
++    for (i = 0; i < resctrl->nlevels; i++) {
++        virResctrlAllocPerLevelPtr a_level = resctrl->levels[i];
++
++        if (!a_level)
++            continue;
++
++        for (j = 0; j < VIR_CACHE_TYPE_LAST; j++) {
++            virResctrlAllocPerTypePtr a_type = a_level->types[j];
++
++            if (!a_type)
++                continue;
++
++            for (k = 0; k < a_type->nsizes; k++) {
++                if (a_type->sizes[k])
++                    return false;
++            }
++
++            for (k = 0; k < a_type->nmasks; k++) {
++                if (a_type->masks[k])
++                    return false;
++            }
++        }
++    }
++
++    return true;
++}
++
++
++static virResctrlAllocPerTypePtr
++virResctrlAllocGetType(virResctrlAllocPtr resctrl,
++                       unsigned int level,
++                       virCacheType type)
++{
++    virResctrlAllocPerLevelPtr a_level = NULL;
++
++    if (resctrl->nlevels <= level &&
++        VIR_EXPAND_N(resctrl->levels, resctrl->nlevels, level - resctrl->nlevels + 1) < 0)
++        return NULL;
++
++    if (!resctrl->levels[level]) {
++        virResctrlAllocPerTypePtr *types = NULL;
++
++        if (VIR_ALLOC_N(types, VIR_CACHE_TYPE_LAST) < 0)
++            return NULL;
++
++        if (VIR_ALLOC(resctrl->levels[level]) < 0) {
++            VIR_FREE(types);
++            return NULL;
++        }
++        resctrl->levels[level]->types = types;
++    }
++
++    a_level = resctrl->levels[level];
++
++    if (!a_level->types[type] && VIR_ALLOC(a_level->types[type]) < 0)
++        return NULL;
++
++    return a_level->types[type];
++}
++
++
++static int
++virResctrlAllocUpdateMask(virResctrlAllocPtr resctrl,
++                          unsigned int level,
++                          virCacheType type,
++                          unsigned int cache,
++                          virBitmapPtr mask)
++{
++    virResctrlAllocPerTypePtr a_type = virResctrlAllocGetType(resctrl, level, type);
++
++    if (!a_type)
++        return -1;
++
++    if (a_type->nmasks <= cache &&
++        VIR_EXPAND_N(a_type->masks, a_type->nmasks,
++                     cache - a_type->nmasks + 1) < 0)
++        return -1;
++
++    if (!a_type->masks[cache]) {
++        a_type->masks[cache] = virBitmapNew(virBitmapSize(mask));
++
++        if (!a_type->masks[cache])
++            return -1;
++    }
++
++    return virBitmapCopy(a_type->masks[cache], mask);
++}
++
++
++static int
++virResctrlAllocUpdateSize(virResctrlAllocPtr resctrl,
++                          unsigned int level,
++                          virCacheType type,
++                          unsigned int cache,
++                          unsigned long long size)
++{
++    virResctrlAllocPerTypePtr a_type = virResctrlAllocGetType(resctrl, level, type);
++
++    if (!a_type)
++        return -1;
++
++    if (a_type->nsizes <= cache &&
++        VIR_EXPAND_N(a_type->sizes, a_type->nsizes,
++                     cache - a_type->nsizes + 1) < 0)
++        return -1;
++
++    if (!a_type->sizes[cache] && VIR_ALLOC(a_type->sizes[cache]) < 0)
++        return -1;
++
++    *(a_type->sizes[cache]) = size;
++
++    return 0;
++}
++
++
++/*
++ * Check if there is an allocation for this level/type/cache already.  Called
++ * before updating the structure.  VIR_CACHE_TYPE_BOTH collides with any type,
++ * the other types collide with itself.  This code basically checks if either:
++ * `alloc[level]->types[type]->sizes[cache]`
++ * or
++ * `alloc[level]->types[VIR_CACHE_TYPE_BOTH]->sizes[cache]`
++ * is non-NULL.  All the fuzz around it is checking for NULL pointers along
++ * the way.
++ */
++static bool
++virResctrlAllocCheckCollision(virResctrlAllocPtr alloc,
++                              unsigned int level,
++                              virCacheType type,
++                              unsigned int cache)
++{
++    virResctrlAllocPerLevelPtr a_level = NULL;
++    virResctrlAllocPerTypePtr a_type = NULL;
++
++    if (!alloc)
++        return false;
++
++    if (alloc->nlevels <= level)
++        return false;
++
++    a_level = alloc->levels[level];
++
++    if (!a_level)
++        return false;
++
++    a_type = a_level->types[VIR_CACHE_TYPE_BOTH];
++
++    /* If there is an allocation for type 'both', there can be no other
++     * allocation for the same cache */
++    if (a_type && a_type->nsizes > cache && a_type->sizes[cache])
++        return true;
++
++    if (type == VIR_CACHE_TYPE_BOTH) {
++        a_type = a_level->types[VIR_CACHE_TYPE_CODE];
++
++        if (a_type && a_type->nsizes > cache && a_type->sizes[cache])
++            return true;
++
++        a_type = a_level->types[VIR_CACHE_TYPE_DATA];
++
++        if (a_type && a_type->nsizes > cache && a_type->sizes[cache])
++            return true;
++    } else {
++        a_type = a_level->types[type];
++
++        if (a_type && a_type->nsizes > cache && a_type->sizes[cache])
++            return true;
++    }
++
++    return false;
++}
++
++
++int
++virResctrlAllocSetSize(virResctrlAllocPtr resctrl,
++                       unsigned int level,
++                       virCacheType type,
++                       unsigned int cache,
++                       unsigned long long size)
++{
++    if (virResctrlAllocCheckCollision(resctrl, level, type, cache)) {
++        virReportError(VIR_ERR_XML_ERROR,
++                       _("Colliding cache allocations for cache "
++                         "level '%u' id '%u', type '%s'"),
++                       level, cache, virCacheTypeToString(type));
++        return -1;
++    }
++
++    return virResctrlAllocUpdateSize(resctrl, level, type, cache, size);
++}
++
++
++int
++virResctrlAllocForeachSize(virResctrlAllocPtr resctrl,
++                           virResctrlAllocForeachSizeCallback cb,
++                           void *opaque)
++{
++    int ret = 0;
++    unsigned int level = 0;
++    unsigned int type = 0;
++    unsigned int cache = 0;
++
++    if (!resctrl)
++        return 0;
++
++    for (level = 0; level < resctrl->nlevels; level++) {
++        virResctrlAllocPerLevelPtr a_level = resctrl->levels[level];
++
++        if (!a_level)
++            continue;
++
++        for (type = 0; type < VIR_CACHE_TYPE_LAST; type++) {
++            virResctrlAllocPerTypePtr a_type = a_level->types[type];
++
++            if (!a_type)
++                continue;
++
++            for (cache = 0; cache < a_type->nsizes; cache++) {
++                unsigned long long *size = a_type->sizes[cache];
++
++                if (!size)
++                    continue;
++
++                ret = cb(level, type, cache, *size, opaque);
++                if (ret < 0)
++                    return ret;
++            }
++        }
++    }
++
++    return 0;
++}
++
++
++int
++virResctrlAllocSetID(virResctrlAllocPtr alloc,
++                     const char *id)
++{
++    if (!id) {
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("Resctrl allocation 'id' cannot be NULL"));
++        return -1;
++    }
++
++    return VIR_STRDUP(alloc->id, id);
++}
++
++
++const char *
++virResctrlAllocGetID(virResctrlAllocPtr alloc)
++{
++    return alloc->id;
++}
++
++
++char *
++virResctrlAllocFormat(virResctrlAllocPtr resctrl)
++{
++    virBuffer buf = VIR_BUFFER_INITIALIZER;
++    unsigned int level = 0;
++    unsigned int type = 0;
++    unsigned int cache = 0;
++
++    if (!resctrl)
++        return NULL;
++
++    for (level = 0; level < resctrl->nlevels; level++) {
++        virResctrlAllocPerLevelPtr a_level = resctrl->levels[level];
++
++        if (!a_level)
++            continue;
++
++        for (type = 0; type < VIR_CACHE_TYPE_LAST; type++) {
++            virResctrlAllocPerTypePtr a_type = a_level->types[type];
++
++            if (!a_type)
++                continue;
++
++            virBufferAsprintf(&buf, "L%u%s:", level, virResctrlTypeToString(type));
++
++            for (cache = 0; cache < a_type->nmasks; cache++) {
++                virBitmapPtr mask = a_type->masks[cache];
++                char *mask_str = NULL;
++
++                if (!mask)
++                    continue;
++
++                mask_str = virBitmapToString(mask, false, true);
++                if (!mask_str) {
++                    virBufferFreeAndReset(&buf);
++                    return NULL;
++                }
++
++                virBufferAsprintf(&buf, "%u=%s;", cache, mask_str);
++                VIR_FREE(mask_str);
++            }
++
++            virBufferTrim(&buf, ";", 1);
++            virBufferAddChar(&buf, '\n');
++        }
++    }
++
++    virBufferCheckError(&buf);
++    return virBufferContentAndReset(&buf);
++}
++
++
++static int
++virResctrlAllocParseProcessCache(virResctrlInfoPtr resctrl,
++                                 virResctrlAllocPtr alloc,
++                                 unsigned int level,
++                                 virCacheType type,
++                                 char *cache)
++{
++    char *tmp = strchr(cache, '=');
++    unsigned int cache_id = 0;
++    virBitmapPtr mask = NULL;
++    int ret = -1;
++
++    if (!tmp)
++        return 0;
++
++    *tmp = '\0';
++    tmp++;
++
++    if (virStrToLong_uip(cache, NULL, 10, &cache_id) < 0) {
++        virReportError(VIR_ERR_INTERNAL_ERROR,
++                       _("Invalid cache id '%s'"), cache);
++        return -1;
++    }
++
++    mask = virBitmapNewString(tmp);
++    if (!mask)
++        return -1;
++
++    virBitmapShrink(mask, resctrl->levels[level]->types[type]->bits);
++
++    if (virResctrlAllocUpdateMask(alloc, level, type, cache_id, mask) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    virBitmapFree(mask);
++    return ret;
++}
++
++
++static int
++virResctrlAllocParseProcessLine(virResctrlInfoPtr resctrl,
++                                virResctrlAllocPtr alloc,
++                                char *line)
++{
++    char **caches = NULL;
++    char *tmp = NULL;
++    unsigned int level = 0;
++    int type = -1;
++    size_t ncaches = 0;
++    size_t i = 0;
++    int ret = -1;
++
++    /* For no reason there can be spaces */
++    virSkipSpaces((const char **) &line);
++
++    /* Skip lines that don't concern caches, e.g. MB: etc. */
++    if (line[0] != 'L')
++        return 0;
++
++    /* And lines that we can't parse too */
++    tmp = strchr(line, ':');
++    if (!tmp)
++        return 0;
++
++    *tmp = '\0';
++    tmp++;
++
++    if (virStrToLong_uip(line + 1, &line, 10, &level) < 0) {
++        virReportError(VIR_ERR_INTERNAL_ERROR,
++                       _("Cannot parse resctrl schema level '%s'"),
++                       line + 1);
++        return -1;
++    }
++
++    type = virResctrlTypeFromString(line);
++    if (type < 0) {
++        virReportError(VIR_ERR_INTERNAL_ERROR,
++                       _("Cannot parse resctrl schema level '%s'"),
++                       line + 1);
++        return -1;
++    }
++
++    caches = virStringSplitCount(tmp, ";", 0, &ncaches);
++    if (!caches)
++        return 0;
++
++    for (i = 0; i < ncaches; i++) {
++        if (virResctrlAllocParseProcessCache(resctrl, alloc, level, type, caches[i]) < 0)
++            goto cleanup;
++    }
++
++    ret = 0;
++ cleanup:
++    virStringListFree(caches);
++    return ret;
++}
++
++
++static int
++virResctrlAllocParse(virResctrlInfoPtr resctrl,
++                     virResctrlAllocPtr alloc,
++                     const char *schemata)
++{
++    char **lines = NULL;
++    size_t nlines = 0;
++    size_t i = 0;
++    int ret = -1;
++
++    lines = virStringSplitCount(schemata, "\n", 0, &nlines);
++    for (i = 0; i < nlines; i++) {
++        if (virResctrlAllocParseProcessLine(resctrl, alloc, lines[i]) < 0)
++            goto cleanup;
++    }
++
++    ret = 0;
++ cleanup:
++    virStringListFree(lines);
++    return ret;
++}
++
++
++static void
++virResctrlAllocSubtractPerType(virResctrlAllocPerTypePtr dst,
++                               virResctrlAllocPerTypePtr src)
++{
++    size_t i = 0;
++
++    if (!dst || !src)
++        return;
++
++    for (i = 0; i < dst->nmasks && i < src->nmasks; i++) {
++        if (dst->masks[i] && src->masks[i])
++            virBitmapSubtract(dst->masks[i], src->masks[i]);
++    }
++}
++
++
++static void
++virResctrlAllocSubtract(virResctrlAllocPtr dst,
++                        virResctrlAllocPtr src)
++{
++    size_t i = 0;
++    size_t j = 0;
++
++    if (!src)
++        return;
++
++    for (i = 0; i < dst->nlevels && i < src->nlevels; i++) {
++        if (dst->levels[i] && src->levels[i]) {
++            for (j = 0; j < VIR_CACHE_TYPE_LAST; j++) {
++                virResctrlAllocSubtractPerType(dst->levels[i]->types[j],
++                                               src->levels[i]->types[j]);
++            }
++        }
++    }
++}
++
++
++static virResctrlAllocPtr
++virResctrlAllocNewFromInfo(virResctrlInfoPtr info)
++{
++    size_t i = 0;
++    size_t j = 0;
++    size_t k = 0;
++    virResctrlAllocPtr ret = virResctrlAllocNew();
++    virBitmapPtr mask = NULL;
++
++    if (!ret)
++        return NULL;
++
++    for (i = 0; i < info->nlevels; i++) {
++        virResctrlInfoPerLevelPtr i_level = info->levels[i];
++
++        if (!i_level)
++            continue;
++
++        for (j = 0; j < VIR_CACHE_TYPE_LAST; j++) {
++            virResctrlInfoPerTypePtr i_type = i_level->types[j];
++
++            if (!i_type)
++                continue;
++
++            virBitmapFree(mask);
++            mask = virBitmapNew(i_type->bits);
++            if (!mask)
++                goto error;
++            virBitmapSetAll(mask);
++
++            for (k = 0; k <= i_type->max_cache_id; k++) {
++                if (virResctrlAllocUpdateMask(ret, i, j, k, mask) < 0)
++                    goto error;
++            }
++        }
++    }
++
++ cleanup:
++    virBitmapFree(mask);
++    return ret;
++ error:
++    virObjectUnref(ret);
++    ret = NULL;
++    goto cleanup;
++}
++
++/*
++ * This function creates an allocation that represents all unused parts of all
++ * caches in the system.  It uses virResctrlInfo for creating a new full
++ * allocation with all bits set (using virResctrlAllocNewFromInfo()) and then
++ * scans for all allocations under /sys/fs/resctrl and subtracts each one of
++ * them from it.  That way it can then return an allocation with only bit set
++ * being those that are not mentioned in any other allocation.  It is used for
++ * two things, a) calculating the masks when creating allocations and b) from
++ * tests.
++ */
++virResctrlAllocPtr
++virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
++{
++    virResctrlAllocPtr ret = NULL;
++    virResctrlAllocPtr alloc = NULL;
++    struct dirent *ent = NULL;
++    DIR *dirp = NULL;
++    char *schemata = NULL;
++    int rv = -1;
++
++    if (virResctrlInfoIsEmpty(resctrl)) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                       _("Resource control is not supported on this host"));
++        return NULL;
++    }
++
++    ret = virResctrlAllocNewFromInfo(resctrl);
++    if (!ret)
++        return NULL;
++
++    if (virFileReadValueString(&schemata,
++                               SYSFS_RESCTRL_PATH
++                               "/schemata") < 0) {
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("Could not read schemata file for the default group"));
++        goto error;
++    }
++
++    alloc = virResctrlAllocNew();
++    if (!alloc)
++        goto error;
++
++    if (virResctrlAllocParse(resctrl, alloc, schemata) < 0)
++        goto error;
++
++    virResctrlAllocSubtract(ret, alloc);
++
++    if (virDirOpen(&dirp, SYSFS_RESCTRL_PATH) < 0)
++        goto error;
++
++    while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH)) > 0) {
++        if (ent->d_type != DT_DIR)
++            continue;
++
++        if (STREQ(ent->d_name, "info"))
++            continue;
++
++        VIR_FREE(schemata);
++        rv = virFileReadValueString(&schemata,
++                                    SYSFS_RESCTRL_PATH
++                                    "/%s/schemata",
++                                    ent->d_name);
++        if (rv == -2)
++            continue;
++
++        if (rv < 0) {
++            virReportError(VIR_ERR_INTERNAL_ERROR,
++                           _("Could not read schemata file for group %s"),
++                           ent->d_name);
++            goto error;
++        }
++
++        virObjectUnref(alloc);
++        alloc = virResctrlAllocNew();
++        if (!alloc)
++            goto error;
++
++        if (virResctrlAllocParse(resctrl, alloc, schemata) < 0)
++            goto error;
++
++        virResctrlAllocSubtract(ret, alloc);
++    }
++    if (rv < 0)
++        goto error;
++
++ cleanup:
++    virObjectUnref(alloc);
++    VIR_DIR_CLOSE(dirp);
++    VIR_FREE(schemata);
++    return ret;
++
++ error:
++    virObjectUnref(ret);
++    ret = NULL;
++    goto cleanup;
++}
++
++
++
++static int
++virResctrlAllocSetMask(virResctrlAllocPerTypePtr a_type,
++                       unsigned int cache,
++                       virBitmapPtr mask)
++{
++    if (a_type->nmasks <= cache &&
++        VIR_EXPAND_N(a_type->masks, a_type->nmasks,
++                     cache - a_type->nmasks + 1) < 0)
++        return -1;
++
++    a_type->masks[cache] = mask;
++
++    return 0;
++}
++
++
++/*
++ * Given the information about requested allocation type `a_type`, the host
++ * cache for a particular type `i_type` and unused bits in the system `f_type`
++ * this function tries to find the smallest free space in which the allocation
++ * for cache id `cache` would fit.  We're looking for the smallest place in
++ * order to minimize fragmentation and maximize the possibility of succeeding.
++ */
++static int
++virResctrlAllocFindUnused(virResctrlAllocPerTypePtr a_type,
++                          virResctrlInfoPerTypePtr i_type,
++                          virResctrlAllocPerTypePtr f_type,
++                          unsigned int level,
++                          unsigned int type,
++                          unsigned int cache)
++{
++    unsigned long long *size = a_type->sizes[cache];
++    virBitmapPtr a_mask = NULL;
++    virBitmapPtr f_mask = NULL;
++    unsigned long long need_bits;
++    size_t i = 0;
++    ssize_t pos = -1;
++    ssize_t last_bits = 0;
++    ssize_t last_pos = -1;
++
++    /* If there is no reservation requested we need to set all bits.  That's due
++     * to weird interface of the resctrl sysfs.  It's also the reason why we
++     * cannot reserve the whole cache in one allocation. */
++    if (!size) {
++        a_mask = virBitmapNew(i_type->bits);
++        if (!a_mask)
++            return -1;
++
++        virBitmapSetAll(a_mask);
++
++        if (virResctrlAllocSetMask(a_type, cache, a_mask) < 0) {
++            virBitmapFree(a_mask);
++            return -1;
++        }
++
++        return 0;
++    }
++
++    if (cache >= f_type->nmasks) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("Cache with id %u does not exists for level %d"),
++                       cache, level);
++        return -1;
++    }
++
++    f_mask = f_type->masks[cache];
++    if (!f_mask) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("Cache level %d id %u does not support tuning for "
++                         "scope type '%s'"),
++                       level, cache, virCacheTypeToString(type));
++        return -1;
++    }
++
++    if (*size == i_type->size) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("Cache allocation for the whole cache is not "
++                         "possible, specify size smaller than %llu"),
++                       i_type->size);
++        return -1;
++    }
++
++    need_bits = *size / i_type->control.granularity;
++
++    if (*size % i_type->control.granularity) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("Cache allocation of size %llu is not "
++                         "divisible by granularity %llu"),
++                       *size, i_type->control.granularity);
++        return -1;
++    }
++
++    if (need_bits < i_type->min_cbm_bits) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("Cache allocation of size %llu is smaller "
++                         "than the minimum allowed allocation %llu"),
++                       *size,
++                       i_type->control.granularity * i_type->min_cbm_bits);
++        return -1;
++    }
++
++    while ((pos = virBitmapNextSetBit(f_mask, pos)) >= 0) {
++        ssize_t pos_clear = virBitmapNextClearBit(f_mask, pos);
++        ssize_t bits;
++
++        if (pos_clear < 0)
++            pos_clear = virBitmapSize(f_mask);
++
++        bits = pos_clear - pos;
++
++        /* Not enough bits, move on and skip all of them */
++        if (bits < need_bits) {
++            pos = pos_clear;
++            continue;
++        }
++
++        /* This fits perfectly */
++        if (bits == need_bits) {
++            last_pos = pos;
++            break;
++        }
++
++        /* Remember the smaller region if we already found on before */
++        if (last_pos < 0 || (last_bits && bits < last_bits)) {
++            last_bits = bits;
++            last_pos = pos;
++        }
++
++        pos = pos_clear;
++    }
++
++    if (last_pos < 0) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("Not enough room for allocation of "
++                         "%llu bytes for level %u cache %u "
++                         "scope type '%s'"),
++                       *size, level, cache,
++                       virCacheTypeToString(type));
++        return -1;
++    }
++
++    a_mask = virBitmapNew(i_type->bits);
++    if (!a_mask)
++        return -1;
++
++    for (i = last_pos; i < last_pos + need_bits; i++) {
++        ignore_value(virBitmapSetBit(a_mask, i));
++        ignore_value(virBitmapClearBit(f_mask, i));
++    }
++
++    if (virResctrlAllocSetMask(a_type, cache, a_mask) < 0) {
++        virBitmapFree(a_mask);
++        return -1;
++    }
++
++    return 0;
++}
++
++
++/*
++ * This function is called when creating an allocation in the system.  What it
++ * does is that it gets all the unused bits using virResctrlAllocGetUnused() and
++ * then tries to find a proper space for every requested allocation effectively
++ * transforming `sizes` into `masks`.
++ */
++static int
++virResctrlAllocMasksAssign(virResctrlInfoPtr resctrl,
++                           virResctrlAllocPtr alloc)
++{
++    int ret = -1;
++    unsigned int level = 0;
++    virResctrlAllocPtr alloc_free = NULL;
++
++    alloc_free = virResctrlAllocGetUnused(resctrl);
++    if (!alloc_free)
++        return -1;
++
++    for (level = 0; level < alloc->nlevels; level++) {
++        virResctrlAllocPerLevelPtr a_level = alloc->levels[level];
++        virResctrlAllocPerLevelPtr f_level = NULL;
++        unsigned int type = 0;
++
++        if (!a_level)
++            continue;
++
++        if (level < alloc_free->nlevels)
++            f_level = alloc_free->levels[level];
++
++        if (!f_level) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                           _("Cache level %d does not support tuning"),
++                           level);
++            goto cleanup;
++        }
++
++        for (type = 0; type < VIR_CACHE_TYPE_LAST; type++) {
++            virResctrlAllocPerTypePtr a_type = a_level->types[type];
++            virResctrlAllocPerTypePtr f_type = f_level->types[type];
++            unsigned int cache = 0;
++
++            if (!a_type)
++                continue;
++
++            if (!f_type) {
++                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                               _("Cache level %d does not support tuning for "
++                                 "scope type '%s'"),
++                               level, virCacheTypeToString(type));
++                goto cleanup;
++            }
++
++            for (cache = 0; cache < a_type->nsizes; cache++) {
++                virResctrlInfoPerLevelPtr i_level = resctrl->levels[level];
++                virResctrlInfoPerTypePtr i_type = i_level->types[type];
++
++                if (virResctrlAllocFindUnused(a_type, i_type, f_type, level, type, cache) < 0)
++                    goto cleanup;
++            }
++        }
++    }
++
++    ret = 0;
++ cleanup:
++    virObjectUnref(alloc_free);
++    return ret;
++}
++
++
++/* This checks if the directory for the alloc exists.  If not it tries to create
++ * it and apply appropriate alloc settings. */
++int
++virResctrlAllocCreate(virResctrlInfoPtr resctrl,
++                      virResctrlAllocPtr alloc,
++                      const char *machinename)
++{
++    char *schemata_path = NULL;
++    char *alloc_str = NULL;
++    int ret = -1;
++    int lockfd = -1;
++
++    if (!alloc)
++        return 0;
++
++    if (!resctrl) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++                       _("Resource control is not supported on this host"));
++        return -1;
++    }
++
++    if (!alloc->id) {
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("Resctrl Allocation ID must be set before creation"));
++        return -1;
++    }
++
++    if (!alloc->path &&
++        virAsprintf(&alloc->path, "%s/%s-%s",
++                    SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
++        return -1;
++
++    if (virFileExists(alloc->path)) {
++        virReportError(VIR_ERR_INTERNAL_ERROR,
++                       _("Path '%s' for resctrl allocation exists"),
++                       alloc->path);
++        goto cleanup;
++    }
++
++    lockfd = virResctrlLockWrite();
++    if (lockfd < 0)
++        goto cleanup;
++
++    if (virResctrlAllocMasksAssign(resctrl, alloc) < 0)
++        goto cleanup;
++
++    alloc_str = virResctrlAllocFormat(alloc);
++    if (!alloc_str)
++        goto cleanup;
++
++    if (virAsprintf(&schemata_path, "%s/schemata", alloc->path) < 0)
++        goto cleanup;
++
++    if (virFileMakePath(alloc->path) < 0) {
++        virReportSystemError(errno,
++                             _("Cannot create resctrl directory '%s'"),
++                             alloc->path);
++        goto cleanup;
++    }
++
++    VIR_DEBUG("Writing resctrl schemata '%s' into '%s'", alloc_str, schemata_path);
++    if (virFileWriteStr(schemata_path, alloc_str, 0) < 0) {
++        rmdir(alloc->path);
++        virReportSystemError(errno,
++                             _("Cannot write into schemata file '%s'"),
++                             schemata_path);
++        goto cleanup;
++    }
++
++    ret = 0;
++ cleanup:
++    virResctrlUnlock(lockfd);
++    VIR_FREE(alloc_str);
++    VIR_FREE(schemata_path);
++    return ret;
++}
++
++
++int
++virResctrlAllocAddPID(virResctrlAllocPtr alloc,
++                      pid_t pid)
++{
++    char *tasks = NULL;
++    char *pidstr = NULL;
++    int ret = 0;
++
++    if (!alloc->path) {
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("Cannot add pid to non-existing resctrl allocation"));
++        return -1;
++    }
++
++    if (virAsprintf(&tasks, "%s/tasks", alloc->path) < 0)
++        return -1;
++
++    if (virAsprintf(&pidstr, "%lld", (long long int) pid) < 0)
++        goto cleanup;
++
++    if (virFileWriteStr(tasks, pidstr, 0) < 0) {
++        virReportSystemError(errno,
++                             _("Cannot write pid in tasks file '%s'"),
++                             tasks);
++        goto cleanup;
++    }
++
++    ret = 0;
++ cleanup:
++    VIR_FREE(tasks);
++    VIR_FREE(pidstr);
++    return ret;
++}
++
++
++int
++virResctrlAllocRemove(virResctrlAllocPtr alloc)
++{
++    int ret = 0;
++
++    if (!alloc->path)
++        return 0;
++
++    VIR_DEBUG("Removing resctrl allocation %s", alloc->path);
++    if (rmdir(alloc->path) != 0 && errno != ENOENT) {
++        ret = -errno;
++        VIR_ERROR(_("Unable to remove %s (%d)"), alloc->path, errno);
++    }
++
++    return ret;
++}
+diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
+index a81ff687de..63a954feaa 100644
+--- a/src/util/virresctrl.h
++++ b/src/util/virresctrl.h
+@@ -65,4 +65,53 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
+                        size_t *ncontrols,
+                        virResctrlInfoPerCachePtr **controls);
+ 
++/* Alloc-related things */
++typedef struct _virResctrlAlloc virResctrlAlloc;
++typedef virResctrlAlloc *virResctrlAllocPtr;
++
++typedef int virResctrlAllocForeachSizeCallback(unsigned int level,
++                                               virCacheType type,
++                                               unsigned int cache,
++                                               unsigned long long size,
++                                               void *opaque);
++
++virResctrlAllocPtr
++virResctrlAllocNew(void);
++
++bool
++virResctrlAllocIsEmpty(virResctrlAllocPtr resctrl);
++
++int
++virResctrlAllocSetSize(virResctrlAllocPtr resctrl,
++                       unsigned int level,
++                       virCacheType type,
++                       unsigned int cache,
++                       unsigned long long size);
++
++int
++virResctrlAllocForeachSize(virResctrlAllocPtr resctrl,
++                           virResctrlAllocForeachSizeCallback cb,
++                           void *opaque);
++
++int
++virResctrlAllocSetID(virResctrlAllocPtr alloc,
++                     const char *id);
++const char *
++virResctrlAllocGetID(virResctrlAllocPtr alloc);
++
++char *
++virResctrlAllocFormat(virResctrlAllocPtr alloc);
++
++int
++virResctrlAllocCreate(virResctrlInfoPtr r_info,
++                      virResctrlAllocPtr alloc,
++                      const char *machinename);
++
++int
++virResctrlAllocAddPID(virResctrlAllocPtr alloc,
++                      pid_t pid);
++
++int
++virResctrlAllocRemove(virResctrlAllocPtr alloc);
++
+ #endif /*  __VIR_RESCTRL_H__ */
+diff --git a/src/util/virresctrlpriv.h b/src/util/virresctrlpriv.h
+new file mode 100644
+index 0000000000..72b115afd1
+--- /dev/null
++++ b/src/util/virresctrlpriv.h
+@@ -0,0 +1,27 @@
++/*
++ * virresctrlpriv.h:
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * This library 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library.  If not, see
++ * <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef __VIR_RESCTRL_PRIV_H__
++# define __VIR_RESCTRL_PRIV_H__
++
++# include "virresctrl.h"
++
++virResctrlAllocPtr
++virResctrlAllocGetUnused(virResctrlInfoPtr resctrl);
++
++#endif /* __VIR_RESCTRL_PRIV_H__ */
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-rpc-Allow-up-to-256K-records-to-be-returned-per-domain-from-virConnectGetAllDomainStats.patch b/SOURCES/libvirt-rpc-Allow-up-to-256K-records-to-be-returned-per-domain-from-virConnectGetAllDomainStats.patch
deleted file mode 100644
index fba6667..0000000
--- a/SOURCES/libvirt-rpc-Allow-up-to-256K-records-to-be-returned-per-domain-from-virConnectGetAllDomainStats.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 289318a23e96a771b8d55cfa2399f094e3bbff68 Mon Sep 17 00:00:00 2001
-Message-Id: <289318a23e96a771b8d55cfa2399f094e3bbff68@dist-git>
-From: "Richard W.M. Jones" <rjones@redhat.com>
-Date: Fri, 26 May 2017 16:05:05 +0200
-Subject: [PATCH] rpc: Allow up to 256K records to be returned per domain from
- virConnectGetAllDomainStats.
-
-The number of records that virConnectGetAllDomainStats can return per
-domain is currently limited to 4096.  This is quite low -- for
-example, a single guest with ~320 disks will hit this limit.  This
-increases the limit to make it much larger.  Note that
-VIR_NET_MESSAGE_MAX still protects the total message size in the case
-where there are many domains and many disks per domain.
-
-I tested this using a guest with 500 disks with no issues.
-
-Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1440683
-(cherry picked from commit 4c70a6f8745714d59d4d66475f639873a0c8e191)
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/remote/remote_protocol.x | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
-index 87b2bd365..3cd9604e9 100644
---- a/src/remote/remote_protocol.x
-+++ b/src/remote/remote_protocol.x
-@@ -233,7 +233,7 @@ const REMOTE_DOMAIN_FSFREEZE_MOUNTPOINTS_MAX = 256;
- const REMOTE_NETWORK_DHCP_LEASES_MAX = 65536;
- 
- /* Upper limit on count of parameters returned via bulk stats API */
--const REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX = 4096;
-+const REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX = 262144;
- 
- /* Upper limit of message size for tunable event. */
- const REMOTE_DOMAIN_EVENT_TUNABLE_MAX = 2048;
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-rpc-Bump-maximum-message-size-to-32M.patch b/SOURCES/libvirt-rpc-Bump-maximum-message-size-to-32M.patch
deleted file mode 100644
index 89de38d..0000000
--- a/SOURCES/libvirt-rpc-Bump-maximum-message-size-to-32M.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From 7babbc316dd636daa4dc16126cb72b2f27d71317 Mon Sep 17 00:00:00 2001
-Message-Id: <7babbc316dd636daa4dc16126cb72b2f27d71317@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Wed, 24 May 2017 14:06:54 +0200
-Subject: [PATCH] rpc: Bump maximum message size to 32M
-
-While most of the APIs are okay with 16M messages, the bulk stats API
-can run into the limit in big configurations. Before we devise a new
-plan for this, bump this limit slightly to accomodate some more configs.
-
-(cherry picked from commit 97863780e8846277842e746186a54c4d2941755b)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1440683
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/rpc/virnetprotocol.x | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/rpc/virnetprotocol.x b/src/rpc/virnetprotocol.x
-index 9ce33b073..ce4525be6 100644
---- a/src/rpc/virnetprotocol.x
-+++ b/src/rpc/virnetprotocol.x
-@@ -40,13 +40,13 @@ const VIR_NET_MESSAGE_INITIAL = 65536;
- const VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX = 262120;
- 
- /* Maximum total message size (serialised). */
--const VIR_NET_MESSAGE_MAX = 16777216;
-+const VIR_NET_MESSAGE_MAX = 33554432;
- 
- /* Size of struct virNetMessageHeader (serialised)*/
- const VIR_NET_MESSAGE_HEADER_MAX = 24;
- 
- /* Size of message payload */
--const VIR_NET_MESSAGE_PAYLOAD_MAX = 16777192;
-+const VIR_NET_MESSAGE_PAYLOAD_MAX = 33554408;
- 
- /* Size of message length field. Not counted in VIR_NET_MESSAGE_MAX
-  * and VIR_NET_MESSAGE_INITIAL.
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-rpc-Double-buffer-size-instead-of-quadrupling-buffer-size.patch b/SOURCES/libvirt-rpc-Double-buffer-size-instead-of-quadrupling-buffer-size.patch
deleted file mode 100644
index d5f8293..0000000
--- a/SOURCES/libvirt-rpc-Double-buffer-size-instead-of-quadrupling-buffer-size.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 94c718948745cb7359002dbfd0e298203e574e02 Mon Sep 17 00:00:00 2001
-Message-Id: <94c718948745cb7359002dbfd0e298203e574e02@dist-git>
-From: "Richard W.M. Jones" <rjones@redhat.com>
-Date: Fri, 26 May 2017 16:05:04 +0200
-Subject: [PATCH] rpc: Double buffer size instead of quadrupling buffer size.
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-When increasing the buffer size up to VIR_NET_MESSAGE_MAX, we
-currently quadruple it each time.  This unfortunately means that we
-cannot allow certain buffer sizes -- for example the current
-VIR_NET_MESSAGE_MAX == 33554432 can never be "hit" since ‘newlen’
-jumps from 16MB to 64MB.
-
-Instead of quadrupling, double it each time.
-
-Thanks: Daniel Berrange.
-Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
-(cherry picked from commit b088f85d42a05a6c0c8418c02a67b48864ba95a3)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1440683
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/rpc/virnetmessage.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
-index c3a2e595c..5908b074a 100644
---- a/src/rpc/virnetmessage.c
-+++ b/src/rpc/virnetmessage.c
-@@ -358,7 +358,8 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
- 
-     /* Try to encode the payload. If the buffer is too small increase it. */
-     while (!(*filter)(&xdr, data, 0)) {
--        unsigned int newlen = (msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX) * 4;
-+        unsigned int newlen = msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX;
-+        newlen *= 2;
- 
-         if (newlen > VIR_NET_MESSAGE_MAX) {
-             virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message payload"));
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-security-Introduce-functions-for-input-device-hot-un-plug.patch b/SOURCES/libvirt-security-Introduce-functions-for-input-device-hot-un-plug.patch
new file mode 100644
index 0000000..b114080
--- /dev/null
+++ b/SOURCES/libvirt-security-Introduce-functions-for-input-device-hot-un-plug.patch
@@ -0,0 +1,255 @@
+From 52568bd61d6fcf0ac32fea4db57527f9fe28c9a5 Mon Sep 17 00:00:00 2001
+Message-Id: <52568bd61d6fcf0ac32fea4db57527f9fe28c9a5@dist-git>
+From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
+Date: Mon, 27 Nov 2017 14:20:59 +0100
+Subject: [PATCH] security: Introduce functions for input device hot(un)plug
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Export the existing DAC and SELinux for separate use and introduce
+functions for stack, nop and the security manager.
+
+(cherry picked from commit d8116b5a0a6364b29e9774323d9aa442ad8c561d)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1509866
+
+Signed-off-by: Ján Tomko <jtomko@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/libvirt_private.syms        |  2 ++
+ src/security/security_dac.c     |  3 +++
+ src/security/security_driver.h  |  9 +++++++++
+ src/security/security_manager.c | 36 ++++++++++++++++++++++++++++++++++++
+ src/security/security_manager.h |  8 ++++++++
+ src/security/security_nop.c     | 11 +++++++++++
+ src/security/security_selinux.c |  3 +++
+ src/security/security_stack.c   | 38 ++++++++++++++++++++++++++++++++++++++
+ 8 files changed, 110 insertions(+)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 3e0bc8730c..65b1143c9b 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -1267,6 +1267,7 @@ virSecurityManagerRestoreAllLabel;
+ virSecurityManagerRestoreDiskLabel;
+ virSecurityManagerRestoreHostdevLabel;
+ virSecurityManagerRestoreImageLabel;
++virSecurityManagerRestoreInputLabel;
+ virSecurityManagerRestoreMemoryLabel;
+ virSecurityManagerRestoreSavedStateLabel;
+ virSecurityManagerSetAllLabel;
+@@ -1276,6 +1277,7 @@ virSecurityManagerSetDiskLabel;
+ virSecurityManagerSetHostdevLabel;
+ virSecurityManagerSetImageFDLabel;
+ virSecurityManagerSetImageLabel;
++virSecurityManagerSetInputLabel;
+ virSecurityManagerSetMemoryLabel;
+ virSecurityManagerSetProcessLabel;
+ virSecurityManagerSetSavedStateLabel;
+diff --git a/src/security/security_dac.c b/src/security/security_dac.c
+index 244b300a9f..24d9264216 100644
+--- a/src/security/security_dac.c
++++ b/src/security/security_dac.c
+@@ -2103,6 +2103,9 @@ virSecurityDriver virSecurityDriverDAC = {
+     .domainSetSecurityMemoryLabel       = virSecurityDACSetMemoryLabel,
+     .domainRestoreSecurityMemoryLabel   = virSecurityDACRestoreMemoryLabel,
+ 
++    .domainSetSecurityInputLabel        = virSecurityDACSetInputLabel,
++    .domainRestoreSecurityInputLabel    = virSecurityDACRestoreInputLabel,
++
+     .domainSetSecurityDaemonSocketLabel = virSecurityDACSetDaemonSocketLabel,
+     .domainSetSecuritySocketLabel       = virSecurityDACSetSocketLabel,
+     .domainClearSecuritySocketLabel     = virSecurityDACClearSocketLabel,
+diff --git a/src/security/security_driver.h b/src/security/security_driver.h
+index 0b3b452486..1b3070d06d 100644
+--- a/src/security/security_driver.h
++++ b/src/security/security_driver.h
+@@ -131,6 +131,12 @@ typedef int (*virSecurityDomainSetMemoryLabel) (virSecurityManagerPtr mgr,
+ typedef int (*virSecurityDomainRestoreMemoryLabel) (virSecurityManagerPtr mgr,
+                                                     virDomainDefPtr def,
+                                                     virDomainMemoryDefPtr mem);
++typedef int (*virSecurityDomainSetInputLabel) (virSecurityManagerPtr mgr,
++                                               virDomainDefPtr def,
++                                               virDomainInputDefPtr input);
++typedef int (*virSecurityDomainRestoreInputLabel) (virSecurityManagerPtr mgr,
++                                                   virDomainDefPtr def,
++                                                   virDomainInputDefPtr input);
+ typedef int (*virSecurityDomainSetPathLabel) (virSecurityManagerPtr mgr,
+                                               virDomainDefPtr def,
+                                               const char *path);
+@@ -163,6 +169,9 @@ struct _virSecurityDriver {
+     virSecurityDomainSetMemoryLabel domainSetSecurityMemoryLabel;
+     virSecurityDomainRestoreMemoryLabel domainRestoreSecurityMemoryLabel;
+ 
++    virSecurityDomainSetInputLabel domainSetSecurityInputLabel;
++    virSecurityDomainRestoreInputLabel domainRestoreSecurityInputLabel;
++
+     virSecurityDomainSetDaemonSocketLabel domainSetSecurityDaemonSocketLabel;
+     virSecurityDomainSetSocketLabel domainSetSecuritySocketLabel;
+     virSecurityDomainClearSocketLabel domainClearSecuritySocketLabel;
+diff --git a/src/security/security_manager.c b/src/security/security_manager.c
+index 60cfc92e77..3cf12188a0 100644
+--- a/src/security/security_manager.c
++++ b/src/security/security_manager.c
+@@ -1116,3 +1116,39 @@ virSecurityManagerRestoreMemoryLabel(virSecurityManagerPtr mgr,
+     virReportUnsupportedError();
+     return -1;
+ }
++
++
++int
++virSecurityManagerSetInputLabel(virSecurityManagerPtr mgr,
++                                virDomainDefPtr vm,
++                                virDomainInputDefPtr input)
++{
++    if (mgr->drv->domainSetSecurityInputLabel) {
++        int ret;
++        virObjectLock(mgr);
++        ret = mgr->drv->domainSetSecurityInputLabel(mgr, vm, input);
++        virObjectUnlock(mgr);
++        return ret;
++    }
++
++    virReportUnsupportedError();
++    return -1;
++}
++
++
++int
++virSecurityManagerRestoreInputLabel(virSecurityManagerPtr mgr,
++                                    virDomainDefPtr vm,
++                                    virDomainInputDefPtr input)
++{
++    if (mgr->drv->domainRestoreSecurityInputLabel) {
++        int ret;
++        virObjectLock(mgr);
++        ret = mgr->drv->domainRestoreSecurityInputLabel(mgr, vm, input);
++        virObjectUnlock(mgr);
++        return ret;
++    }
++
++    virReportUnsupportedError();
++    return -1;
++}
+diff --git a/src/security/security_manager.h b/src/security/security_manager.h
+index 08fb89203a..87fe890692 100644
+--- a/src/security/security_manager.h
++++ b/src/security/security_manager.h
+@@ -172,6 +172,14 @@ int virSecurityManagerRestoreMemoryLabel(virSecurityManagerPtr mgr,
+                                         virDomainDefPtr vm,
+                                         virDomainMemoryDefPtr mem);
+ 
++int virSecurityManagerSetInputLabel(virSecurityManagerPtr mgr,
++                                    virDomainDefPtr vm,
++                                    virDomainInputDefPtr input);
++int virSecurityManagerRestoreInputLabel(virSecurityManagerPtr mgr,
++                                        virDomainDefPtr vm,
++                                        virDomainInputDefPtr input);
++
++
+ int virSecurityManagerDomainSetPathLabel(virSecurityManagerPtr mgr,
+                                          virDomainDefPtr vm,
+                                          const char *path);
+diff --git a/src/security/security_nop.c b/src/security/security_nop.c
+index 527be11e5a..cfb032c686 100644
+--- a/src/security/security_nop.c
++++ b/src/security/security_nop.c
+@@ -254,6 +254,14 @@ virSecurityDomainRestoreMemoryLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSE
+     return 0;
+ }
+ 
++static int
++virSecurityDomainInputLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
++                               virDomainDefPtr def ATTRIBUTE_UNUSED,
++                               virDomainInputDefPtr input ATTRIBUTE_UNUSED)
++{
++    return 0;
++}
++
+ 
+ virSecurityDriver virSecurityDriverNop = {
+     .privateDataLen                     = 0,
+@@ -276,6 +284,9 @@ virSecurityDriver virSecurityDriverNop = {
+     .domainSetSecurityMemoryLabel       = virSecurityDomainSetMemoryLabelNop,
+     .domainRestoreSecurityMemoryLabel   = virSecurityDomainRestoreMemoryLabelNop,
+ 
++    .domainSetSecurityInputLabel        = virSecurityDomainInputLabelNop,
++    .domainRestoreSecurityInputLabel    = virSecurityDomainInputLabelNop,
++
+     .domainSetSecurityDaemonSocketLabel = virSecurityDomainSetDaemonSocketLabelNop,
+     .domainSetSecuritySocketLabel       = virSecurityDomainSetSocketLabelNop,
+     .domainClearSecuritySocketLabel     = virSecurityDomainClearSocketLabelNop,
+diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
+index cd3e411931..d44de72e02 100644
+--- a/src/security/security_selinux.c
++++ b/src/security/security_selinux.c
+@@ -3058,6 +3058,9 @@ virSecurityDriver virSecurityDriverSELinux = {
+     .domainSetSecurityMemoryLabel       = virSecuritySELinuxSetMemoryLabel,
+     .domainRestoreSecurityMemoryLabel   = virSecuritySELinuxRestoreMemoryLabel,
+ 
++    .domainSetSecurityInputLabel        = virSecuritySELinuxSetInputLabel,
++    .domainRestoreSecurityInputLabel    = virSecuritySELinuxRestoreInputLabel,
++
+     .domainSetSecurityDaemonSocketLabel = virSecuritySELinuxSetDaemonSocketLabel,
+     .domainSetSecuritySocketLabel       = virSecuritySELinuxSetSocketLabel,
+     .domainClearSecuritySocketLabel     = virSecuritySELinuxClearSocketLabel,
+diff --git a/src/security/security_stack.c b/src/security/security_stack.c
+index 53eee1692f..cd916382b2 100644
+--- a/src/security/security_stack.c
++++ b/src/security/security_stack.c
+@@ -666,6 +666,41 @@ virSecurityStackRestoreMemoryLabel(virSecurityManagerPtr mgr,
+     return rc;
+ }
+ 
++static int
++virSecurityStackSetInputLabel(virSecurityManagerPtr mgr,
++                              virDomainDefPtr vm,
++                              virDomainInputDefPtr input)
++{
++    virSecurityStackDataPtr priv = virSecurityManagerGetPrivateData(mgr);
++    virSecurityStackItemPtr item = priv->itemsHead;
++    int rc = 0;
++
++    for (; item; item = item->next) {
++        if (virSecurityManagerSetInputLabel(item->securityManager, vm, input) < 0)
++            rc = -1;
++    }
++
++    return rc;
++}
++
++static int
++virSecurityStackRestoreInputLabel(virSecurityManagerPtr mgr,
++                                  virDomainDefPtr vm,
++                                  virDomainInputDefPtr input)
++{
++    virSecurityStackDataPtr priv = virSecurityManagerGetPrivateData(mgr);
++    virSecurityStackItemPtr item = priv->itemsHead;
++    int rc = 0;
++
++    for (; item; item = item->next) {
++        if (virSecurityManagerRestoreInputLabel(item->securityManager,
++                                                vm, input) < 0)
++            rc = -1;
++    }
++
++    return rc;
++}
++
+ static int
+ virSecurityStackDomainSetPathLabel(virSecurityManagerPtr mgr,
+                                    virDomainDefPtr vm,
+@@ -711,6 +746,9 @@ virSecurityDriver virSecurityDriverStack = {
+     .domainSetSecurityMemoryLabel       = virSecurityStackSetMemoryLabel,
+     .domainRestoreSecurityMemoryLabel   = virSecurityStackRestoreMemoryLabel,
+ 
++    .domainSetSecurityInputLabel        = virSecurityStackSetInputLabel,
++    .domainRestoreSecurityInputLabel    = virSecurityStackRestoreInputLabel,
++
+     .domainSetSecurityDaemonSocketLabel = virSecurityStackSetDaemonSocketLabel,
+     .domainSetSecuritySocketLabel       = virSecurityStackSetSocketLabel,
+     .domainClearSecuritySocketLabel     = virSecurityStackClearSocketLabel,
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-security-introduce-virSecurityManager-Set-Restore-ChardevLabel.patch b/SOURCES/libvirt-security-introduce-virSecurityManager-Set-Restore-ChardevLabel.patch
new file mode 100644
index 0000000..1e8ec66
--- /dev/null
+++ b/SOURCES/libvirt-security-introduce-virSecurityManager-Set-Restore-ChardevLabel.patch
@@ -0,0 +1,267 @@
+From 093bf98d1a85c1032228bb5bc2089bdd67949e48 Mon Sep 17 00:00:00 2001
+Message-Id: <093bf98d1a85c1032228bb5bc2089bdd67949e48@dist-git>
+From: Pavel Hrdina <phrdina@redhat.com>
+Date: Tue, 5 Dec 2017 14:02:33 +0100
+Subject: [PATCH] security: introduce
+ virSecurityManager(Set|Restore)ChardevLabel
+
+SELinux and DAC drivers already have both functions but they were not
+exported as public API of security manager.
+
+Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit 1b4f66ec80d7751d4f4c858ffc8d5e3b936e72de)
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1465833
+
+Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
+Reviewed-by: Erik Skultety <eskultet@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/libvirt_private.syms        |  2 ++
+ src/security/security_dac.c     |  3 +++
+ src/security/security_driver.h  | 11 +++++++++++
+ src/security/security_manager.c | 40 ++++++++++++++++++++++++++++++++++++++
+ src/security/security_manager.h | 10 ++++++++++
+ src/security/security_nop.c     | 20 +++++++++++++++++++
+ src/security/security_selinux.c |  3 +++
+ src/security/security_stack.c   | 43 +++++++++++++++++++++++++++++++++++++++++
+ 8 files changed, 132 insertions(+)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 19c1ecc408..cb76bbac87 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -1273,6 +1273,7 @@ virSecurityManagerPreFork;
+ virSecurityManagerReleaseLabel;
+ virSecurityManagerReserveLabel;
+ virSecurityManagerRestoreAllLabel;
++virSecurityManagerRestoreChardevLabel;
+ virSecurityManagerRestoreDiskLabel;
+ virSecurityManagerRestoreHostdevLabel;
+ virSecurityManagerRestoreImageLabel;
+@@ -1280,6 +1281,7 @@ virSecurityManagerRestoreInputLabel;
+ virSecurityManagerRestoreMemoryLabel;
+ virSecurityManagerRestoreSavedStateLabel;
+ virSecurityManagerSetAllLabel;
++virSecurityManagerSetChardevLabel;
+ virSecurityManagerSetChildProcessLabel;
+ virSecurityManagerSetDaemonSocketLabel;
+ virSecurityManagerSetDiskLabel;
+diff --git a/src/security/security_dac.c b/src/security/security_dac.c
+index 24d9264216..4e787fb038 100644
+--- a/src/security/security_dac.c
++++ b/src/security/security_dac.c
+@@ -2135,4 +2135,7 @@ virSecurityDriver virSecurityDriverDAC = {
+     .getBaseLabel                       = virSecurityDACGetBaseLabel,
+ 
+     .domainSetPathLabel                 = virSecurityDACDomainSetPathLabel,
++
++    .domainSetSecurityChardevLabel      = virSecurityDACSetChardevLabel,
++    .domainRestoreSecurityChardevLabel  = virSecurityDACRestoreChardevLabel,
+ };
+diff --git a/src/security/security_driver.h b/src/security/security_driver.h
+index 1b3070d06d..47dad8ba20 100644
+--- a/src/security/security_driver.h
++++ b/src/security/security_driver.h
+@@ -140,6 +140,14 @@ typedef int (*virSecurityDomainRestoreInputLabel) (virSecurityManagerPtr mgr,
+ typedef int (*virSecurityDomainSetPathLabel) (virSecurityManagerPtr mgr,
+                                               virDomainDefPtr def,
+                                               const char *path);
++typedef int (*virSecurityDomainSetChardevLabel) (virSecurityManagerPtr mgr,
++                                                 virDomainDefPtr def,
++                                                 virDomainChrSourceDefPtr dev_source,
++                                                 bool chardevStdioLogd);
++typedef int (*virSecurityDomainRestoreChardevLabel) (virSecurityManagerPtr mgr,
++                                                     virDomainDefPtr def,
++                                                     virDomainChrSourceDefPtr dev_source,
++                                                     bool chardevStdioLogd);
+ 
+ 
+ struct _virSecurityDriver {
+@@ -201,6 +209,9 @@ struct _virSecurityDriver {
+     virSecurityDriverGetBaseLabel getBaseLabel;
+ 
+     virSecurityDomainSetPathLabel domainSetPathLabel;
++
++    virSecurityDomainSetChardevLabel domainSetSecurityChardevLabel;
++    virSecurityDomainRestoreChardevLabel domainRestoreSecurityChardevLabel;
+ };
+ 
+ virSecurityDriverPtr virSecurityDriverLookup(const char *name,
+diff --git a/src/security/security_manager.c b/src/security/security_manager.c
+index 3cf12188a0..9249aba1fa 100644
+--- a/src/security/security_manager.c
++++ b/src/security/security_manager.c
+@@ -1152,3 +1152,43 @@ virSecurityManagerRestoreInputLabel(virSecurityManagerPtr mgr,
+     virReportUnsupportedError();
+     return -1;
+ }
++
++
++int
++virSecurityManagerSetChardevLabel(virSecurityManagerPtr mgr,
++                                  virDomainDefPtr def,
++                                  virDomainChrSourceDefPtr dev_source,
++                                  bool chardevStdioLogd)
++{
++    if (mgr->drv->domainSetSecurityChardevLabel) {
++        int ret;
++        virObjectLock(mgr);
++        ret = mgr->drv->domainSetSecurityChardevLabel(mgr, def, dev_source,
++                                                      chardevStdioLogd);
++        virObjectUnlock(mgr);
++        return ret;
++    }
++
++    virReportUnsupportedError();
++    return -1;
++}
++
++
++int
++virSecurityManagerRestoreChardevLabel(virSecurityManagerPtr mgr,
++                                      virDomainDefPtr def,
++                                      virDomainChrSourceDefPtr dev_source,
++                                      bool chardevStdioLogd)
++{
++    if (mgr->drv->domainRestoreSecurityChardevLabel) {
++        int ret;
++        virObjectLock(mgr);
++        ret = mgr->drv->domainRestoreSecurityChardevLabel(mgr, def, dev_source,
++                                                          chardevStdioLogd);
++        virObjectUnlock(mgr);
++        return ret;
++    }
++
++    virReportUnsupportedError();
++    return -1;
++}
+diff --git a/src/security/security_manager.h b/src/security/security_manager.h
+index 87fe890692..acc0dab374 100644
+--- a/src/security/security_manager.h
++++ b/src/security/security_manager.h
+@@ -184,4 +184,14 @@ int virSecurityManagerDomainSetPathLabel(virSecurityManagerPtr mgr,
+                                          virDomainDefPtr vm,
+                                          const char *path);
+ 
++int virSecurityManagerSetChardevLabel(virSecurityManagerPtr mgr,
++                                      virDomainDefPtr def,
++                                      virDomainChrSourceDefPtr dev_source,
++                                      bool chardevStdioLogd);
++
++int virSecurityManagerRestoreChardevLabel(virSecurityManagerPtr mgr,
++                                          virDomainDefPtr def,
++                                          virDomainChrSourceDefPtr dev_source,
++                                          bool chardevStdioLogd);
++
+ #endif /* VIR_SECURITY_MANAGER_H__ */
+diff --git a/src/security/security_nop.c b/src/security/security_nop.c
+index cfb032c686..ff739f8199 100644
+--- a/src/security/security_nop.c
++++ b/src/security/security_nop.c
+@@ -262,6 +262,23 @@ virSecurityDomainInputLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
+     return 0;
+ }
+ 
++static int
++virSecurityDomainSetChardevLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
++                                    virDomainDefPtr def ATTRIBUTE_UNUSED,
++                                    virDomainChrSourceDefPtr dev_source ATTRIBUTE_UNUSED,
++                                    bool chardevStdioLogd ATTRIBUTE_UNUSED)
++{
++    return 0;
++}
++
++static int
++virSecurityDomainRestoreChardevLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
++                                        virDomainDefPtr def ATTRIBUTE_UNUSED,
++                                        virDomainChrSourceDefPtr dev_source ATTRIBUTE_UNUSED,
++                                        bool chardevStdioLogd ATTRIBUTE_UNUSED)
++{
++    return 0;
++}
+ 
+ virSecurityDriver virSecurityDriverNop = {
+     .privateDataLen                     = 0,
+@@ -314,4 +331,7 @@ virSecurityDriver virSecurityDriverNop = {
+     .domainGetSecurityMountOptions      = virSecurityDomainGetMountOptionsNop,
+ 
+     .getBaseLabel                       = virSecurityGetBaseLabel,
++
++    .domainSetSecurityChardevLabel      = virSecurityDomainSetChardevLabelNop,
++    .domainRestoreSecurityChardevLabel  = virSecurityDomainRestoreChardevLabelNop,
+ };
+diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
+index d44de72e02..0121b22da5 100644
+--- a/src/security/security_selinux.c
++++ b/src/security/security_selinux.c
+@@ -3089,4 +3089,7 @@ virSecurityDriver virSecurityDriverSELinux = {
+     .getBaseLabel                       = virSecuritySELinuxGetBaseLabel,
+ 
+     .domainSetPathLabel                 = virSecuritySELinuxDomainSetPathLabel,
++
++    .domainSetSecurityChardevLabel      = virSecuritySELinuxSetChardevLabel,
++    .domainRestoreSecurityChardevLabel  = virSecuritySELinuxRestoreChardevLabel,
+ };
+diff --git a/src/security/security_stack.c b/src/security/security_stack.c
+index cd916382b2..0375e7d89d 100644
+--- a/src/security/security_stack.c
++++ b/src/security/security_stack.c
+@@ -719,6 +719,46 @@ virSecurityStackDomainSetPathLabel(virSecurityManagerPtr mgr,
+     return rc;
+ }
+ 
++static int
++virSecurityStackDomainSetChardevLabel(virSecurityManagerPtr mgr,
++                                      virDomainDefPtr def,
++                                      virDomainChrSourceDefPtr dev_source,
++                                      bool chardevStdioLogd)
++{
++    virSecurityStackDataPtr priv = virSecurityManagerGetPrivateData(mgr);
++    virSecurityStackItemPtr item = priv->itemsHead;
++    int rc = 0;
++
++    for (; item; item = item->next) {
++        if (virSecurityManagerSetChardevLabel(item->securityManager,
++                                              def, dev_source,
++                                              chardevStdioLogd) < 0)
++            rc = -1;
++    }
++
++    return rc;
++}
++
++static int
++virSecurityStackDomainRestoreChardevLabel(virSecurityManagerPtr mgr,
++                                          virDomainDefPtr def,
++                                          virDomainChrSourceDefPtr dev_source,
++                                          bool chardevStdioLogd)
++{
++    virSecurityStackDataPtr priv = virSecurityManagerGetPrivateData(mgr);
++    virSecurityStackItemPtr item = priv->itemsHead;
++    int rc = 0;
++
++    for (; item; item = item->next) {
++        if (virSecurityManagerRestoreChardevLabel(item->securityManager,
++                                                  def, dev_source,
++                                                  chardevStdioLogd) < 0)
++            rc = -1;
++    }
++
++    return rc;
++}
++
+ virSecurityDriver virSecurityDriverStack = {
+     .privateDataLen                     = sizeof(virSecurityStackData),
+     .name                               = "stack",
+@@ -778,4 +818,7 @@ virSecurityDriver virSecurityDriverStack = {
+     .getBaseLabel                       = virSecurityStackGetBaseLabel,
+ 
+     .domainSetPathLabel                 = virSecurityStackDomainSetPathLabel,
++
++    .domainSetSecurityChardevLabel      = virSecurityStackDomainSetChardevLabel,
++    .domainRestoreSecurityChardevLabel  = virSecurityStackDomainRestoreChardevLabel,
+ };
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-storage-Add-helper-to-retrieve-the-backing-store-string-of-a-storage-volume.patch b/SOURCES/libvirt-storage-Add-helper-to-retrieve-the-backing-store-string-of-a-storage-volume.patch
deleted file mode 100644
index cd45168..0000000
--- a/SOURCES/libvirt-storage-Add-helper-to-retrieve-the-backing-store-string-of-a-storage-volume.patch
+++ /dev/null
@@ -1,94 +0,0 @@
-From a4d89750b7d61aa561b9b9956bf354e39f434b01 Mon Sep 17 00:00:00 2001
-Message-Id: <a4d89750b7d61aa561b9b9956bf354e39f434b01@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 14:45:37 +0200
-Subject: [PATCH] storage: Add helper to retrieve the backing store string of a
- storage volume
-
-It is necessary for some parts of the code to refresh just data
-based on the based on the backing store string. Add a convenience
-function that will retrieve this data.
-
-(cherry picked from commit d97cfdc891f262e1b0cd3ed05f7ca2bb7ef7de1c)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461303
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/storage/storage_driver.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
- src/storage/storage_driver.h |  3 +++
- 2 files changed, 47 insertions(+)
-
-diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
-index 61c5e7eff1..21af949170 100644
---- a/src/storage/storage_driver.c
-+++ b/src/storage/storage_driver.c
-@@ -3370,6 +3370,50 @@ virStorageFileGetMetadata(virStorageSourcePtr src,
- }
- 
- 
-+/**
-+ * virStorageFileGetBackingStoreStr:
-+ * @src: storage object
-+ *
-+ * Extracts the backing store string as stored in the storage volume described
-+ * by @src and returns it to the user. Caller is responsible for freeing it.
-+ * In case when the string can't be retrieved or does not exist NULL is
-+ * returned.
-+ */
-+char *
-+virStorageFileGetBackingStoreStr(virStorageSourcePtr src)
-+{
-+    virStorageSourcePtr tmp = NULL;
-+    char *buf = NULL;
-+    ssize_t headerLen;
-+    char *ret = NULL;
-+
-+    /* exit if we can't load information about the current image */
-+    if (!virStorageFileSupportsBackingChainTraversal(src))
-+        return NULL;
-+
-+    if (virStorageFileAccess(src, F_OK) < 0)
-+        return NULL;
-+
-+    if ((headerLen = virStorageFileReadHeader(src, VIR_STORAGE_MAX_HEADER,
-+                                              &buf)) < 0)
-+        return NULL;
-+
-+    if (!(tmp = virStorageSourceCopy(src, false)))
-+        goto cleanup;
-+
-+    if (virStorageFileGetMetadataInternal(tmp, buf, headerLen, NULL) < 0)
-+        goto cleanup;
-+
-+    VIR_STEAL_PTR(ret, tmp->backingStoreRaw);
-+
-+ cleanup:
-+    VIR_FREE(buf);
-+    virStorageSourceFree(tmp);
-+
-+    return ret;
-+}
-+
-+
- static int
- virStorageAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
-                                  virStoragePoolDefPtr pooldef)
-diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h
-index 530bc33880..ade05f7156 100644
---- a/src/storage/storage_driver.h
-+++ b/src/storage/storage_driver.h
-@@ -54,6 +54,9 @@ int virStorageFileGetMetadata(virStorageSourcePtr src,
-                               bool report_broken)
-     ATTRIBUTE_NONNULL(1);
- 
-+char *virStorageFileGetBackingStoreStr(virStorageSourcePtr src)
-+    ATTRIBUTE_NONNULL(1);
-+
- int virStorageTranslateDiskSourcePool(virConnectPtr conn,
-                                       virDomainDiskDefPtr def);
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-storage-Don-t-dereference-driver-object-if-virStorageSource-is-not-initialized.patch b/SOURCES/libvirt-storage-Don-t-dereference-driver-object-if-virStorageSource-is-not-initialized.patch
new file mode 100644
index 0000000..7efb592
--- /dev/null
+++ b/SOURCES/libvirt-storage-Don-t-dereference-driver-object-if-virStorageSource-is-not-initialized.patch
@@ -0,0 +1,71 @@
+From ef9bacb8ce672161449683f748d4df76c4b78a54 Mon Sep 17 00:00:00 2001
+Message-Id: <ef9bacb8ce672161449683f748d4df76c4b78a54@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 7 Dec 2017 13:45:50 +0100
+Subject: [PATCH] storage: Don't dereference driver object if virStorageSource
+ is not initialized
+
+virStorageFileReportBrokenChain uses data from the driver private data
+pointer to print the user and group. This would lead to a crash in call
+paths where we did not initialize the storage backend as recently added
+in commit 24e47ee2b93 to qemuDomainDetermineDiskChain.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1522682
+(cherry picked from commit 2d07f1f0ebd44b0348daa61afa0de34f3f838c22)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/storage/storage_source.c | 36 +++++++++++++++++++++++++-----------
+ 1 file changed, 25 insertions(+), 11 deletions(-)
+
+diff --git a/src/storage/storage_source.c b/src/storage/storage_source.c
+index 469d3a00bc..aaec988e9a 100644
+--- a/src/storage/storage_source.c
++++ b/src/storage/storage_source.c
+@@ -404,19 +404,33 @@ virStorageFileReportBrokenChain(int errcode,
+                                 virStorageSourcePtr src,
+                                 virStorageSourcePtr parent)
+ {
+-    unsigned int access_user = src->drv->uid;
+-    unsigned int access_group = src->drv->gid;
+ 
+-    if (src == parent) {
+-        virReportSystemError(errcode,
+-                             _("Cannot access storage file '%s' "
+-                               "(as uid:%u, gid:%u)"),
+-                             src->path, access_user, access_group);
++    if (src->drv) {
++        unsigned int access_user = src->drv->uid;
++        unsigned int access_group = src->drv->gid;
++
++        if (src == parent) {
++            virReportSystemError(errcode,
++                                 _("Cannot access storage file '%s' "
++                                   "(as uid:%u, gid:%u)"),
++                                 src->path, access_user, access_group);
++        } else {
++            virReportSystemError(errcode,
++                                 _("Cannot access backing file '%s' "
++                                   "of storage file '%s' (as uid:%u, gid:%u)"),
++                                 src->path, parent->path, access_user, access_group);
++        }
+     } else {
+-        virReportSystemError(errcode,
+-                             _("Cannot access backing file '%s' "
+-                               "of storage file '%s' (as uid:%u, gid:%u)"),
+-                             src->path, parent->path, access_user, access_group);
++        if (src == parent) {
++            virReportSystemError(errcode,
++                                 _("Cannot access storage file '%s'"),
++                                 src->path);
++        } else {
++            virReportSystemError(errcode,
++                                 _("Cannot access backing file '%s' "
++                                   "of storage file '%s'"),
++                                 src->path, parent->path);
++        }
+     }
+ }
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-storage-Extract-error-reporting-for-broken-chains.patch b/SOURCES/libvirt-storage-Extract-error-reporting-for-broken-chains.patch
new file mode 100644
index 0000000..7da590b
--- /dev/null
+++ b/SOURCES/libvirt-storage-Extract-error-reporting-for-broken-chains.patch
@@ -0,0 +1,99 @@
+From ebf7011f8358288cccba7017fb5337e2d70fdc3b Mon Sep 17 00:00:00 2001
+Message-Id: <ebf7011f8358288cccba7017fb5337e2d70fdc3b@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Fri, 1 Dec 2017 15:57:00 +0100
+Subject: [PATCH] storage: Extract error reporting for broken chains
+
+Simplify reporting the error if backing chain is broken for further
+callers by extracting it into a separate function.
+
+(cherry picked from commit b4daf6af9adba96fc5e0bd68d49602a67639b053)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1509110
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/storage/storage_source.c | 47 +++++++++++++++++++++++++++++++-------------
+ src/storage/storage_source.h |  4 ++++
+ 2 files changed, 37 insertions(+), 14 deletions(-)
+
+diff --git a/src/storage/storage_source.c b/src/storage/storage_source.c
+index 419fa3d43f..469d3a00bc 100644
+--- a/src/storage/storage_source.c
++++ b/src/storage/storage_source.c
+@@ -389,6 +389,38 @@ virStorageFileChown(const virStorageSource *src,
+ }
+ 
+ 
++/**
++ * virStorageFileReportBrokenChain:
++ *
++ * @errcode: errno when accessing @src
++ * @src: inaccessible file in the backing chain of @parent
++ * @parent: root virStorageSource being checked
++ *
++ * Reports the correct error message if @src is missing in the backing chain
++ * for @parent.
++ */
++void
++virStorageFileReportBrokenChain(int errcode,
++                                virStorageSourcePtr src,
++                                virStorageSourcePtr parent)
++{
++    unsigned int access_user = src->drv->uid;
++    unsigned int access_group = src->drv->gid;
++
++    if (src == parent) {
++        virReportSystemError(errcode,
++                             _("Cannot access storage file '%s' "
++                               "(as uid:%u, gid:%u)"),
++                             src->path, access_user, access_group);
++    } else {
++        virReportSystemError(errcode,
++                             _("Cannot access backing file '%s' "
++                               "of storage file '%s' (as uid:%u, gid:%u)"),
++                             src->path, parent->path, access_user, access_group);
++    }
++}
++
++
+ /* Recursive workhorse for virStorageFileGetMetadata.  */
+ static int
+ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
+@@ -418,20 +450,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
+         return -1;
+ 
+     if (virStorageFileAccess(src, F_OK) < 0) {
+-        if (src == parent) {
+-            virReportSystemError(errno,
+-                                 _("Cannot access storage file '%s' "
+-                                   "(as uid:%u, gid:%u)"),
+-                                 src->path, (unsigned int)uid,
+-                                 (unsigned int)gid);
+-        } else {
+-            virReportSystemError(errno,
+-                                 _("Cannot access backing file '%s' "
+-                                   "of storage file '%s' (as uid:%u, gid:%u)"),
+-                                 src->path, parent->path,
+-                                 (unsigned int)uid, (unsigned int)gid);
+-        }
+-
++        virStorageFileReportBrokenChain(errno, src, parent);
+         goto cleanup;
+     }
+ 
+diff --git a/src/storage/storage_source.h b/src/storage/storage_source.h
+index 6462baf6ae..a20346a12c 100644
+--- a/src/storage/storage_source.h
++++ b/src/storage/storage_source.h
+@@ -51,4 +51,8 @@ int virStorageFileGetMetadata(virStorageSourcePtr src,
+ char *virStorageFileGetBackingStoreStr(virStorageSourcePtr src)
+     ATTRIBUTE_NONNULL(1);
+ 
++void virStorageFileReportBrokenChain(int errcode,
++                                     virStorageSourcePtr src,
++                                     virStorageSourcePtr parent);
++
+ #endif /* __VIR_STORAGE_SOURCE_H__ */
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-storage-Fix-capacity-value-for-LUKS-encrypted-volumes.patch b/SOURCES/libvirt-storage-Fix-capacity-value-for-LUKS-encrypted-volumes.patch
deleted file mode 100644
index 8df2f27..0000000
--- a/SOURCES/libvirt-storage-Fix-capacity-value-for-LUKS-encrypted-volumes.patch
+++ /dev/null
@@ -1,158 +0,0 @@
-From 15eb05f245e919ce5674ba4dbf41173eee13d3e4 Mon Sep 17 00:00:00 2001
-Message-Id: <15eb05f245e919ce5674ba4dbf41173eee13d3e4@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Mon, 3 Apr 2017 16:45:08 -0400
-Subject: [PATCH] storage: Fix capacity value for LUKS encrypted volumes
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1371892
-
-The 'capacity' value (e.g. guest logical size) for a LUKS volume is
-smaller than the 'physical' value of the file in the file system, so
-we need to account for that.
-
-When peeking at the encryption information about the volume add a fetch
-of the payload_offset which is described as the offset to the start of
-the volume data (in 512 byte sectors) in QEMU's QCryptoBlockLUKSHeader.
-
-Then adjust the ->capacity appropriately when we determine that the
-volume target encryption has a payload_offset value.
-
-(cherry picked from commit b7d44f450c06803df7df3ad380f7a5c97425c1e6)
-Signed-off-by: John Ferlan <jferlan@redhat.com>
----
- src/storage/storage_util.c      |  3 +++
- src/util/virstorageencryption.h |  1 +
- src/util/virstoragefile.c       | 39 +++++++++++++++++++++++++++++++++++++++
- 3 files changed, 43 insertions(+)
-
-diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
-index 7687eb89a..0ceaab6b9 100644
---- a/src/storage/storage_util.c
-+++ b/src/storage/storage_util.c
-@@ -3436,6 +3436,9 @@ storageBackendProbeTarget(virStorageSourcePtr target,
-         target->capacity = meta->capacity;
- 
-     if (encryption && meta->encryption) {
-+        if (meta->encryption->payload_offset != -1)
-+            target->capacity -= meta->encryption->payload_offset * 512;
-+
-         *encryption = meta->encryption;
-         meta->encryption = NULL;
- 
-diff --git a/src/util/virstorageencryption.h b/src/util/virstorageencryption.h
-index fa439fb72..42f990c49 100644
---- a/src/util/virstorageencryption.h
-+++ b/src/util/virstorageencryption.h
-@@ -70,6 +70,7 @@ typedef struct _virStorageEncryption virStorageEncryption;
- typedef virStorageEncryption *virStorageEncryptionPtr;
- struct _virStorageEncryption {
-     int format; /* virStorageEncryptionFormatType */
-+    int payload_offset;
- 
-     size_t nsecrets;
-     virStorageEncryptionSecretPtr *secrets;
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index 22cdb83e4..a51622aff 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -133,6 +133,8 @@ struct FileEncryptionInfo {
- 
-     int modeOffset; /* Byte offset of the format native encryption mode */
-     char modeValue; /* Value expected at offset */
-+
-+    int payloadOffset; /* start offset of the volume data (in 512 byte sectors) */
- };
- 
- /* Either 'magic' or 'extension' *must* be provided */
-@@ -212,9 +214,18 @@ qedGetBackingStore(char **, int *, const char *, size_t);
- 
- #define LUKS_HDR_MAGIC_LEN 6
- #define LUKS_HDR_VERSION_LEN 2
-+#define LUKS_HDR_CIPHER_NAME_LEN 32
-+#define LUKS_HDR_CIPHER_MODE_LEN 32
-+#define LUKS_HDR_HASH_SPEC_LEN 32
-+#define LUKS_HDR_PAYLOAD_LEN 4
- 
- /* Format described by qemu commit id '3e308f20e' */
- #define LUKS_HDR_VERSION_OFFSET LUKS_HDR_MAGIC_LEN
-+#define LUKS_HDR_PAYLOAD_OFFSET (LUKS_HDR_MAGIC_LEN+\
-+                                 LUKS_HDR_VERSION_LEN+\
-+                                 LUKS_HDR_CIPHER_NAME_LEN+\
-+                                 LUKS_HDR_CIPHER_MODE_LEN+\
-+                                 LUKS_HDR_HASH_SPEC_LEN)
- 
- static struct FileEncryptionInfo const luksEncryptionInfo[] = {
-     {
-@@ -231,6 +242,8 @@ static struct FileEncryptionInfo const luksEncryptionInfo[] = {
- 
-         .modeOffset = -1,
-         .modeValue = -1,
-+
-+        .payloadOffset = LUKS_HDR_PAYLOAD_OFFSET,
-     },
-     { 0 }
- };
-@@ -249,6 +262,8 @@ static struct FileEncryptionInfo const qcow1EncryptionInfo[] = {
- 
-         .modeOffset = QCOW1_HDR_CRYPT,
-         .modeValue = 1,
-+
-+        .payloadOffset = -1,
-     },
-     { 0 }
- };
-@@ -267,6 +282,8 @@ static struct FileEncryptionInfo const qcow2EncryptionInfo[] = {
- 
-         .modeOffset = QCOW2_HDR_CRYPT,
-         .modeValue = 1,
-+
-+        .payloadOffset = -1,
-     },
-     { 0 }
- };
-@@ -921,6 +938,23 @@ virStorageFileHasEncryptionFormat(const struct FileEncryptionInfo *info,
- }
- 
- 
-+static int
-+virStorageFileGetEncryptionPayloadOffset(const struct FileEncryptionInfo *info,
-+                                         char *buf)
-+{
-+    int payload_offset = -1;
-+
-+    if (info->payloadOffset != -1) {
-+        if (info->endian == LV_LITTLE_ENDIAN)
-+            payload_offset = virReadBufInt32LE(buf + info->payloadOffset);
-+        else
-+            payload_offset = virReadBufInt32BE(buf + info->payloadOffset);
-+    }
-+
-+    return payload_offset;
-+}
-+
-+
- /* Given a header in BUF with length LEN, as parsed from the storage file
-  * assuming it has the given FORMAT, populate information into META
-  * with information about the file and its backing store. Return format
-@@ -967,6 +1001,8 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
-                         goto cleanup;
-                     }
-                 }
-+                meta->encryption->payload_offset =
-+                    virStorageFileGetEncryptionPayloadOffset(&fileTypeInfo[meta->format].cryptInfo[i], buf);
-             }
-         }
-     }
-@@ -3423,6 +3459,9 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr src,
-     else
-         goto cleanup;
- 
-+    if (src->encryption && src->encryption->payload_offset != -1)
-+        src->capacity -= src->encryption->payload_offset * 512;
-+
-     ret = 0;
- 
-  cleanup:
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-storage-Fixing-missing-backingStore-tag-from-volume-XML-dumps.patch b/SOURCES/libvirt-storage-Fixing-missing-backingStore-tag-from-volume-XML-dumps.patch
new file mode 100644
index 0000000..7831af6
--- /dev/null
+++ b/SOURCES/libvirt-storage-Fixing-missing-backingStore-tag-from-volume-XML-dumps.patch
@@ -0,0 +1,36 @@
+From 824141ce272f8b145df41554266697151895b8a7 Mon Sep 17 00:00:00 2001
+Message-Id: <824141ce272f8b145df41554266697151895b8a7@dist-git>
+From: Julio Faracco <jcfaracco@gmail.com>
+Date: Wed, 3 Jan 2018 16:06:35 +0100
+Subject: [PATCH] storage: Fixing missing 'backingStore' tag from volume XML
+ dumps.
+
+After commit a693fdb 'vol-dumpxml' missed the ability to show backingStore
+information. This commit adds a volume type for files that fixes this
+problem.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1529663
+
+Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
+(cherry picked from commit d0307a9a766f1eb0f24ad2cc7c7ae730f1bde966)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/storage/storage_util.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
+index 899a557588..9e1b63a436 100644
+--- a/src/storage/storage_util.c
++++ b/src/storage/storage_util.c
+@@ -1957,6 +1957,8 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
+     target->timestamps->ctime = get_stat_ctime(sb);
+     target->timestamps->mtime = get_stat_mtime(sb);
+ 
++    target->type = VIR_STORAGE_TYPE_FILE;
++
+     VIR_FREE(target->perms->label);
+ 
+ #if WITH_SELINUX
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-storage-Introduce-virStorageBackendZeroPartitionTable.patch b/SOURCES/libvirt-storage-Introduce-virStorageBackendZeroPartitionTable.patch
deleted file mode 100644
index 8b72801..0000000
--- a/SOURCES/libvirt-storage-Introduce-virStorageBackendZeroPartitionTable.patch
+++ /dev/null
@@ -1,67 +0,0 @@
-From 5d4d146cfe4ab4e52c8ba0300f6a05949bc558d4 Mon Sep 17 00:00:00 2001
-Message-Id: <5d4d146cfe4ab4e52c8ba0300f6a05949bc558d4@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Wed, 26 Apr 2017 08:41:11 -0400
-Subject: [PATCH] storage: Introduce virStorageBackendZeroPartitionTable
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439132
-
-Create a wrapper/helper that can be used to call the storage backend
-wipe helper - storageBackendVolWipeLocalFile for future use by logical
-and disk backends to clear out the partition table rather than having
-each open code the same algorithm.
-
-(cherry picked from commit e8b02124580e134c8a6d51750016811b1d68b80e)
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/storage/storage_util.c | 22 ++++++++++++++++++++++
- src/storage/storage_util.h |  4 ++++
- 2 files changed, 26 insertions(+)
-
-diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
-index 8dbdc770e..da2396b34 100644
---- a/src/storage/storage_util.c
-+++ b/src/storage/storage_util.c
-@@ -4071,3 +4071,25 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
- 
-     return found;
- }
-+
-+
-+/*
-+ * @path: Path to the device to initialize
-+ * @size: Size to be cleared
-+ *
-+ * Zero out possible partition table information for the specified
-+ * bytes from the start of the @path and from the end of @path
-+ *
-+ * Returns 0 on success, -1 on failure with error message set
-+ */
-+int
-+virStorageBackendZeroPartitionTable(const char *path,
-+                                    unsigned long long size)
-+{
-+    if (storageBackendVolWipeLocalFile(path, VIR_STORAGE_VOL_WIPE_ALG_ZERO,
-+                                       size, false) < 0)
-+        return -1;
-+
-+    return storageBackendVolWipeLocalFile(path, VIR_STORAGE_VOL_WIPE_ALG_ZERO,
-+                                          size, true);
-+}
-diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h
-index fa3b6522c..2c48027f4 100644
---- a/src/storage/storage_util.h
-+++ b/src/storage/storage_util.h
-@@ -163,4 +163,8 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn,
- int virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
-                                  uint32_t scanhost);
- 
-+int
-+virStorageBackendZeroPartitionTable(const char *path,
-+                                    unsigned long long size);
-+
- #endif /* __VIR_STORAGE_UTIL_H__ */
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-storage-Modify-storageBackendWipeLocal-to-allow-zero-from-end-of-device.patch b/SOURCES/libvirt-storage-Modify-storageBackendWipeLocal-to-allow-zero-from-end-of-device.patch
deleted file mode 100644
index 935997b..0000000
--- a/SOURCES/libvirt-storage-Modify-storageBackendWipeLocal-to-allow-zero-from-end-of-device.patch
+++ /dev/null
@@ -1,116 +0,0 @@
-From 73114abb7437db2e4625a64377005ddaf8f17840 Mon Sep 17 00:00:00 2001
-Message-Id: <73114abb7437db2e4625a64377005ddaf8f17840@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Wed, 26 Apr 2017 08:41:10 -0400
-Subject: [PATCH] storage: Modify storageBackendWipeLocal to allow zero from
- end of device
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1439132
-
-Add bool 'zero_end' and logic that would allow a caller to wipe specific
-portions of a target device either from the beginning (the default) or
-from the end when zero_end is true.
-
-This will allow for this code to wipe out partition table information
-from a device.
-
-(cherry picked from commit 859a2d162ac6dd141539819cfc6157724d12bde6)
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/storage/storage_util.c | 40 +++++++++++++++++++++++++++-------------
- 1 file changed, 27 insertions(+), 13 deletions(-)
-
-diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
-index adec9ab6f..8dbdc770e 100644
---- a/src/storage/storage_util.c
-+++ b/src/storage/storage_util.c
-@@ -2516,26 +2516,38 @@ static int
- storageBackendWipeLocal(const char *path,
-                         int fd,
-                         unsigned long long wipe_len,
--                        size_t writebuf_length)
-+                        size_t writebuf_length,
-+                        bool zero_end)
- {
-     int ret = -1, written = 0;
-     unsigned long long remaining = 0;
-+    off_t size;
-     size_t write_size = 0;
-     char *writebuf = NULL;
- 
--    VIR_DEBUG("wiping start: 0 len: %llu", wipe_len);
--
-     if (VIR_ALLOC_N(writebuf, writebuf_length) < 0)
-         goto cleanup;
- 
--    if (lseek(fd, 0, SEEK_SET) < 0) {
--        virReportSystemError(errno,
--                             _("Failed to seek to the start in volume "
--                               "with path '%s'"),
--                             path);
--        goto cleanup;
-+    if (!zero_end) {
-+        if ((size = lseek(fd, 0, SEEK_SET)) < 0) {
-+            virReportSystemError(errno,
-+                                 _("Failed to seek to the start in volume "
-+                                   "with path '%s'"),
-+                                 path);
-+            goto cleanup;
-+        }
-+    } else {
-+        if ((size = lseek(fd, -wipe_len, SEEK_END)) < 0) {
-+            virReportSystemError(errno,
-+                                 _("Failed to seek to %llu bytes to the end "
-+                                   "in volume with path '%s'"),
-+                                 wipe_len, path);
-+            goto cleanup;
-+        }
-     }
- 
-+    VIR_DEBUG("wiping start: %zd len: %llu", (ssize_t) size, wipe_len);
-+
-     remaining = wipe_len;
-     while (remaining > 0) {
- 
-@@ -2573,7 +2585,8 @@ storageBackendWipeLocal(const char *path,
- static int
- storageBackendVolWipeLocalFile(const char *path,
-                                unsigned int algorithm,
--                               unsigned long long allocation)
-+                               unsigned long long allocation,
-+                               bool zero_end)
- {
-     int ret = -1, fd = -1;
-     const char *alg_char = NULL;
-@@ -2648,7 +2661,8 @@ storageBackendVolWipeLocalFile(const char *path,
-         if (S_ISREG(st.st_mode) && st.st_blocks < (st.st_size / DEV_BSIZE)) {
-             ret = storageBackendVolZeroSparseFileLocal(path, st.st_size, fd);
-         } else {
--            ret = storageBackendWipeLocal(path, fd, allocation, st.st_blksize);
-+            ret = storageBackendWipeLocal(path, fd, allocation, st.st_blksize,
-+                                          zero_end);
-         }
-         if (ret < 0)
-             goto cleanup;
-@@ -2686,7 +2700,7 @@ storageBackendVolWipePloop(virStorageVolDefPtr vol,
-         goto cleanup;
- 
-     if (storageBackendVolWipeLocalFile(target_path, algorithm,
--                                       vol->target.allocation) < 0)
-+                                       vol->target.allocation, false) < 0)
-         goto cleanup;
- 
-     if (virFileRemove(disk_desc, 0, 0) < 0) {
-@@ -2735,7 +2749,7 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
-         ret = storageBackendVolWipePloop(vol, algorithm);
-     } else {
-         ret = storageBackendVolWipeLocalFile(vol->target.path, algorithm,
--                                             vol->target.allocation);
-+                                             vol->target.allocation, false);
-     }
- 
-     return ret;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-storage-util-Properly-ignore-errors-when-backing-volume-is-inaccessible.patch b/SOURCES/libvirt-storage-util-Properly-ignore-errors-when-backing-volume-is-inaccessible.patch
new file mode 100644
index 0000000..9984300
--- /dev/null
+++ b/SOURCES/libvirt-storage-util-Properly-ignore-errors-when-backing-volume-is-inaccessible.patch
@@ -0,0 +1,43 @@
+From a921cd57872bf1ed798df6c7268d07c29cba9e32 Mon Sep 17 00:00:00 2001
+Message-Id: <a921cd57872bf1ed798df6c7268d07c29cba9e32@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Tue, 30 Jan 2018 13:02:02 +0100
+Subject: [PATCH] storage: util: Properly ignore errors when backing volume is
+ inaccessible
+
+Commit 000e9504559 tried to fix improper bracketing when refreshing disk
+volume stats for a backing volume. Unfortunately the condition is still
+wrong as in cases as the backing store being inaccessible
+storageBackendUpdateVolTargetInfo returns -2 if instructed to ignore
+errors. The condition does not take this into account.
+
+Dumping XML of a volume which has inacessible backing store would then
+result into:
+
+ # virsh vol-dumpxml http.img --pool default
+ error: An error occurred, but the cause is unknown
+
+Properly ignore -2 for backing volumes.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1540022
+(cherry picked from commit b2c5f28a72465bf047311828c8c66112c8ca84e5)
+---
+ src/storage/storage_util.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
+index 9e1b63a436..61a87b37b6 100644
+--- a/src/storage/storage_util.c
++++ b/src/storage/storage_util.c
+@@ -1918,7 +1918,7 @@ virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
+                                                  withBlockVolFormat,
+                                                  VIR_STORAGE_VOL_OPEN_DEFAULT |
+                                                  VIR_STORAGE_VOL_OPEN_NOERROR,
+-                                                 readflags)) < 0)
++                                                 readflags)) == -1)
+         return ret;
+ 
+     return 0;
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-tests-Add-caps-for-QEMU-2.10.0-on-ppc64.patch b/SOURCES/libvirt-tests-Add-caps-for-QEMU-2.10.0-on-ppc64.patch
new file mode 100644
index 0000000..cbd2234
--- /dev/null
+++ b/SOURCES/libvirt-tests-Add-caps-for-QEMU-2.10.0-on-ppc64.patch
@@ -0,0 +1,21693 @@
+From 436cfb6b1a649ece6a6efcef7b167cfabd263bd7 Mon Sep 17 00:00:00 2001
+Message-Id: <436cfb6b1a649ece6a6efcef7b167cfabd263bd7@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 15 Nov 2017 10:28:53 +0100
+Subject: [PATCH] tests: Add caps for QEMU 2.10.0 on ppc64
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit ab81dafe801396935aa3ae977237dba345624254)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1308743
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ .../qemucapabilitiesdata/caps_2.10.0.ppc64.replies | 20572 +++++++++++++++++++
+ tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml   |  1072 +
+ tests/qemucapabilitiestest.c                       |     1 +
+ 3 files changed, 21645 insertions(+)
+ create mode 100644 tests/qemucapabilitiesdata/caps_2.10.0.ppc64.replies
+ create mode 100644 tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.replies b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.replies
+new file mode 100644
+index 0000000000..065e2b4dc2
+--- /dev/null
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.replies
+@@ -0,0 +1,20572 @@
++{
++  "QMP": {
++    "version": {
++      "qemu": {
++        "micro": 0,
++        "minor": 10,
++        "major": 2
++      },
++      "package": " (v2.10.0)"
++    },
++    "capabilities": [
++    ]
++  }
++}
++
++{
++  "return": {
++  },
++  "id": "libvirt-1"
++}
++
++{
++  "return": {
++    "qemu": {
++      "micro": 0,
++      "minor": 10,
++      "major": 2
++    },
++    "package": " (v2.10.0)"
++  },
++  "id": "libvirt-2"
++}
++
++{
++  "return": {
++    "arch": "ppc64"
++  },
++  "id": "libvirt-3"
++}
++
++{
++  "return": [
++    {
++      "name": "netdev_add"
++    },
++    {
++      "name": "device_add"
++    },
++    {
++      "name": "query-qmp-schema"
++    },
++    {
++      "name": "xen-set-replication"
++    },
++    {
++      "name": "xen-set-global-dirty-log"
++    },
++    {
++      "name": "xen-save-devices-state"
++    },
++    {
++      "name": "xen-load-devices-state"
++    },
++    {
++      "name": "xen-colo-do-checkpoint"
++    },
++    {
++      "name": "x-debug-block-dirty-bitmap-sha256"
++    },
++    {
++      "name": "x-colo-lost-heartbeat"
++    },
++    {
++      "name": "x-blockdev-remove-medium"
++    },
++    {
++      "name": "x-blockdev-insert-medium"
++    },
++    {
++      "name": "x-blockdev-change"
++    },
++    {
++      "name": "transaction"
++    },
++    {
++      "name": "trace-event-set-state"
++    },
++    {
++      "name": "trace-event-get-state"
++    },
++    {
++      "name": "system_wakeup"
++    },
++    {
++      "name": "system_reset"
++    },
++    {
++      "name": "system_powerdown"
++    },
++    {
++      "name": "stop"
++    },
++    {
++      "name": "set_password"
++    },
++    {
++      "name": "set_link"
++    },
++    {
++      "name": "send-key"
++    },
++    {
++      "name": "screendump"
++    },
++    {
++      "name": "ringbuf-write"
++    },
++    {
++      "name": "ringbuf-read"
++    },
++    {
++      "name": "remove-fd"
++    },
++    {
++      "name": "quit"
++    },
++    {
++      "name": "query-xen-replication-status"
++    },
++    {
++      "name": "query-vnc-servers"
++    },
++    {
++      "name": "query-vnc"
++    },
++    {
++      "name": "query-vm-generation-id"
++    },
++    {
++      "name": "query-version"
++    },
++    {
++      "name": "query-uuid"
++    },
++    {
++      "name": "query-tpm-types"
++    },
++    {
++      "name": "query-tpm-models"
++    },
++    {
++      "name": "query-tpm"
++    },
++    {
++      "name": "query-target"
++    },
++    {
++      "name": "query-status"
++    },
++    {
++      "name": "query-rx-filter"
++    },
++    {
++      "name": "query-rocker-ports"
++    },
++    {
++      "name": "query-rocker-of-dpa-groups"
++    },
++    {
++      "name": "query-rocker-of-dpa-flows"
++    },
++    {
++      "name": "query-rocker"
++    },
++    {
++      "name": "query-pci"
++    },
++    {
++      "name": "query-named-block-nodes"
++    },
++    {
++      "name": "query-name"
++    },
++    {
++      "name": "query-migrate-parameters"
++    },
++    {
++      "name": "query-migrate-capabilities"
++    },
++    {
++      "name": "query-migrate-cache-size"
++    },
++    {
++      "name": "query-migrate"
++    },
++    {
++      "name": "query-mice"
++    },
++    {
++      "name": "query-memory-devices"
++    },
++    {
++      "name": "query-memdev"
++    },
++    {
++      "name": "query-machines"
++    },
++    {
++      "name": "query-kvm"
++    },
++    {
++      "name": "query-iothreads"
++    },
++    {
++      "name": "query-hotpluggable-cpus"
++    },
++    {
++      "name": "query-fdsets"
++    },
++    {
++      "name": "query-events"
++    },
++    {
++      "name": "query-dump-guest-memory-capability"
++    },
++    {
++      "name": "query-dump"
++    },
++    {
++      "name": "query-cpus"
++    },
++    {
++      "name": "query-cpu-definitions"
++    },
++    {
++      "name": "query-commands"
++    },
++    {
++      "name": "query-command-line-options"
++    },
++    {
++      "name": "query-chardev-backends"
++    },
++    {
++      "name": "query-chardev"
++    },
++    {
++      "name": "query-blockstats"
++    },
++    {
++      "name": "query-block-jobs"
++    },
++    {
++      "name": "query-block"
++    },
++    {
++      "name": "query-balloon"
++    },
++    {
++      "name": "query-acpi-ospm-status"
++    },
++    {
++      "name": "qom-set"
++    },
++    {
++      "name": "qom-list-types"
++    },
++    {
++      "name": "qom-list"
++    },
++    {
++      "name": "qom-get"
++    },
++    {
++      "name": "qmp_capabilities"
++    },
++    {
++      "name": "pmemsave"
++    },
++    {
++      "name": "object-del"
++    },
++    {
++      "name": "object-add"
++    },
++    {
++      "name": "netdev_del"
++    },
++    {
++      "name": "nbd-server-stop"
++    },
++    {
++      "name": "nbd-server-start"
++    },
++    {
++      "name": "nbd-server-add"
++    },
++    {
++      "name": "migrate_set_speed"
++    },
++    {
++      "name": "migrate_set_downtime"
++    },
++    {
++      "name": "migrate_cancel"
++    },
++    {
++      "name": "migrate-start-postcopy"
++    },
++    {
++      "name": "migrate-set-parameters"
++    },
++    {
++      "name": "migrate-set-capabilities"
++    },
++    {
++      "name": "migrate-set-cache-size"
++    },
++    {
++      "name": "migrate-incoming"
++    },
++    {
++      "name": "migrate"
++    },
++    {
++      "name": "memsave"
++    },
++    {
++      "name": "input-send-event"
++    },
++    {
++      "name": "inject-nmi"
++    },
++    {
++      "name": "human-monitor-command"
++    },
++    {
++      "name": "getfd"
++    },
++    {
++      "name": "expire_password"
++    },
++    {
++      "name": "eject"
++    },
++    {
++      "name": "dump-guest-memory"
++    },
++    {
++      "name": "drive-mirror"
++    },
++    {
++      "name": "drive-backup"
++    },
++    {
++      "name": "device_del"
++    },
++    {
++      "name": "device-list-properties"
++    },
++    {
++      "name": "cpu-add"
++    },
++    {
++      "name": "cpu"
++    },
++    {
++      "name": "cont"
++    },
++    {
++      "name": "closefd"
++    },
++    {
++      "name": "client_migrate_info"
++    },
++    {
++      "name": "chardev-send-break"
++    },
++    {
++      "name": "chardev-remove"
++    },
++    {
++      "name": "chardev-change"
++    },
++    {
++      "name": "chardev-add"
++    },
++    {
++      "name": "change-vnc-password"
++    },
++    {
++      "name": "change-backing-file"
++    },
++    {
++      "name": "change"
++    },
++    {
++      "name": "blockdev-snapshot-sync"
++    },
++    {
++      "name": "blockdev-snapshot-internal-sync"
++    },
++    {
++      "name": "blockdev-snapshot-delete-internal-sync"
++    },
++    {
++      "name": "blockdev-snapshot"
++    },
++    {
++      "name": "blockdev-open-tray"
++    },
++    {
++      "name": "blockdev-mirror"
++    },
++    {
++      "name": "blockdev-del"
++    },
++    {
++      "name": "blockdev-close-tray"
++    },
++    {
++      "name": "blockdev-change-medium"
++    },
++    {
++      "name": "blockdev-backup"
++    },
++    {
++      "name": "blockdev-add"
++    },
++    {
++      "name": "block_set_io_throttle"
++    },
++    {
++      "name": "block_resize"
++    },
++    {
++      "name": "block_passwd"
++    },
++    {
++      "name": "block-stream"
++    },
++    {
++      "name": "block-set-write-threshold"
++    },
++    {
++      "name": "block-job-set-speed"
++    },
++    {
++      "name": "block-job-resume"
++    },
++    {
++      "name": "block-job-pause"
++    },
++    {
++      "name": "block-job-complete"
++    },
++    {
++      "name": "block-job-cancel"
++    },
++    {
++      "name": "block-dirty-bitmap-remove"
++    },
++    {
++      "name": "block-dirty-bitmap-clear"
++    },
++    {
++      "name": "block-dirty-bitmap-add"
++    },
++    {
++      "name": "block-commit"
++    },
++    {
++      "name": "balloon"
++    },
++    {
++      "name": "add_client"
++    },
++    {
++      "name": "add-fd"
++    }
++  ],
++  "id": "libvirt-4"
++}
++
++{
++  "return": {
++    "fd": 16,
++    "fdset-id": 0
++  },
++  "id": "libvirt-5"
++}
++
++{
++  "id": "libvirt-6",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'bogus' not found"
++  }
++}
++
++{
++  "return": {
++    "enabled": true,
++    "present": true
++  },
++  "id": "libvirt-7"
++}
++
++{
++  "return": [
++    {
++      "name": "WATCHDOG"
++    },
++    {
++      "name": "WAKEUP"
++    },
++    {
++      "name": "VSERPORT_CHANGE"
++    },
++    {
++      "name": "VNC_INITIALIZED"
++    },
++    {
++      "name": "VNC_DISCONNECTED"
++    },
++    {
++      "name": "VNC_CONNECTED"
++    },
++    {
++      "name": "SUSPEND_DISK"
++    },
++    {
++      "name": "SUSPEND"
++    },
++    {
++      "name": "STOP"
++    },
++    {
++      "name": "SPICE_MIGRATE_COMPLETED"
++    },
++    {
++      "name": "SPICE_INITIALIZED"
++    },
++    {
++      "name": "SPICE_DISCONNECTED"
++    },
++    {
++      "name": "SPICE_CONNECTED"
++    },
++    {
++      "name": "SHUTDOWN"
++    },
++    {
++      "name": "RTC_CHANGE"
++    },
++    {
++      "name": "RESUME"
++    },
++    {
++      "name": "RESET"
++    },
++    {
++      "name": "QUORUM_REPORT_BAD"
++    },
++    {
++      "name": "QUORUM_FAILURE"
++    },
++    {
++      "name": "POWERDOWN"
++    },
++    {
++      "name": "NIC_RX_FILTER_CHANGED"
++    },
++    {
++      "name": "MIGRATION_PASS"
++    },
++    {
++      "name": "MIGRATION"
++    },
++    {
++      "name": "MEM_UNPLUG_ERROR"
++    },
++    {
++      "name": "GUEST_PANICKED"
++    },
++    {
++      "name": "DUMP_COMPLETED"
++    },
++    {
++      "name": "DEVICE_TRAY_MOVED"
++    },
++    {
++      "name": "DEVICE_DELETED"
++    },
++    {
++      "name": "BLOCK_WRITE_THRESHOLD"
++    },
++    {
++      "name": "BLOCK_JOB_READY"
++    },
++    {
++      "name": "BLOCK_JOB_ERROR"
++    },
++    {
++      "name": "BLOCK_JOB_COMPLETED"
++    },
++    {
++      "name": "BLOCK_JOB_CANCELLED"
++    },
++    {
++      "name": "BLOCK_IO_ERROR"
++    },
++    {
++      "name": "BLOCK_IMAGE_CORRUPTED"
++    },
++    {
++      "name": "BALLOON_CHANGE"
++    },
++    {
++      "name": "ACPI_DEVICE_OST"
++    }
++  ],
++  "id": "libvirt-8"
++}
++
++{
++  "return": [
++    {
++      "name": "vhost-vsock-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "scsi-generic",
++      "parent": "scsi-device"
++    },
++    {
++      "name": "qio-channel-tls",
++      "parent": "qio-channel"
++    },
++    {
++      "name": "virtio-mmio",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "scsi-hd",
++      "parent": "scsi-disk-base"
++    },
++    {
++      "name": "MPC8541E_v11-powerpc64-cpu",
++      "parent": "e500v1-family-powerpc64-cpu"
++    },
++    {
++      "name": "isa-m48t59",
++      "parent": "isa-m48txx"
++    },
++    {
++      "name": "405GPb-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8544E_v11-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "usb-bot",
++      "parent": "usb-storage-dev"
++    },
++    {
++      "name": "chardev-null",
++      "parent": "chardev"
++    },
++    {
++      "name": "750_v3.1-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "dec-21154",
++      "parent": "pci-device"
++    },
++    {
++      "name": "chardev-parallel",
++      "parent": "chardev"
++    },
++    {
++      "name": "qemu-xhci",
++      "parent": "base-xhci"
++    },
++    {
++      "name": "spapr-pci-vfio-host-bridge",
++      "parent": "spapr-pci-host-bridge"
++    },
++    {
++      "name": "e300c2-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "lsi53c895a",
++      "parent": "pci-device"
++    },
++    {
++      "name": "MPC8568-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "401-powerpc64-cpu",
++      "parent": "401-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8379-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-keyboard-pci",
++      "parent": "virtio-input-hid-pci"
++    },
++    {
++      "name": "40p-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "750cxe_v3.1-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8349EA-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "750cxr-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "750cl_v2.0-powerpc64-cpu",
++      "parent": "750cl-family-powerpc64-cpu"
++    },
++    {
++      "name": "G2HiP4-powerpc64-cpu",
++      "parent": "G2-family-powerpc64-cpu"
++    },
++    {
++      "name": "745_v1.0-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "STB04-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "usb-audio",
++      "parent": "usb-device"
++    },
++    {
++      "name": "ide-hd",
++      "parent": "ide-device"
++    },
++    {
++      "name": "virtio-net-device",
++      "parent": "virtio-device"
++    },
++    {
++      "name": "601_v0-powerpc64-cpu",
++      "parent": "601-family-powerpc64-cpu"
++    },
++    {
++      "name": "powernv-chip-POWER9",
++      "parent": "powernv-chip"
++    },
++    {
++      "name": "powernv-chip-POWER8",
++      "parent": "powernv-chip"
++    },
++    {
++      "name": "chardev-pty",
++      "parent": "chardev"
++    },
++    {
++      "name": "ppc4xx-pcihost",
++      "parent": "pci-host-bridge"
++    },
++    {
++      "name": "spapr-vio-bus",
++      "parent": "bus"
++    },
++    {
++      "name": "ppc4xx-host-bridge",
++      "parent": "pci-device"
++    },
++    {
++      "name": "750fx_v2.1-powerpc64-cpu",
++      "parent": "750fx-family-powerpc64-cpu"
++    },
++    {
++      "name": "macio-newworld",
++      "parent": "macio"
++    },
++    {
++      "name": "MPC8377E-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "970fx_v2.1-powerpc64-cpu",
++      "parent": "970-family-powerpc64-cpu"
++    },
++    {
++      "name": "440EPa-powerpc64-cpu",
++      "parent": "440EP-family-powerpc64-cpu"
++    },
++    {
++      "name": "SUNW,fdtwo",
++      "parent": "base-sysbus-fdc"
++    },
++    {
++      "name": "isa-pcspk",
++      "parent": "isa-device"
++    },
++    {
++      "name": "dec-21154-p2p-bridge",
++      "parent": "base-pci-bridge"
++    },
++    {
++      "name": "603e_v4.1-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "7445_v3.3-powerpc64-cpu",
++      "parent": "7445-family-powerpc64-cpu"
++    },
++    {
++      "name": "970MP_v1.1-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "G2leGP3-powerpc64-cpu",
++      "parent": "G2LE-family-powerpc64-cpu"
++    },
++    {
++      "name": "spapr-vscsi",
++      "parent": "vio-spapr-device"
++    },
++    {
++      "name": "loader",
++      "parent": "device"
++    },
++    {
++      "name": "xlnx.xps-ethernetlite",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "7410_v1.0-powerpc64-cpu",
++      "parent": "7410-family-powerpc64-cpu"
++    },
++    {
++      "name": "filter-rewriter",
++      "parent": "netfilter"
++    },
++    {
++      "name": "platform-bus-device",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "403GA-powerpc64-cpu",
++      "parent": "403-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-serial-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "MPC5200_v10-powerpc64-cpu",
++      "parent": "G2LE-family-powerpc64-cpu"
++    },
++    {
++      "name": "750cxe_v2.4b-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "ics",
++      "parent": "ics-base"
++    },
++    {
++      "name": "sysbus-sm501",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "MPC8610-powerpc64-cpu",
++      "parent": "e600-family-powerpc64-cpu"
++    },
++    {
++      "name": "icp",
++      "parent": "device"
++    },
++    {
++      "name": "virtio-crypto-device",
++      "parent": "virtio-device"
++    },
++    {
++      "name": "usb-host",
++      "parent": "usb-device"
++    },
++    {
++      "name": "MPC8548E_v20-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "745_v2.5-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "970fx_v3.1-powerpc64-cpu",
++      "parent": "970-family-powerpc64-cpu"
++    },
++    {
++      "name": "7447_v1.0-powerpc64-cpu",
++      "parent": "7445-family-powerpc64-cpu"
++    },
++    {
++      "name": "7457_v1.2-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    },
++    {
++      "name": "usb-bt-dongle",
++      "parent": "usb-device"
++    },
++    {
++      "name": "qio-channel-rdma",
++      "parent": "qio-channel"
++    },
++    {
++      "name": "virtio-input-host-pci",
++      "parent": "virtio-input-pci"
++    },
++    {
++      "name": "xlnx.xps-intc",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "MPC8343EA-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "e1000",
++      "parent": "e1000-base"
++    },
++    {
++      "name": "mpc8xxx_gpio",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "401F2-powerpc64-cpu",
++      "parent": "401x2-family-powerpc64-cpu"
++    },
++    {
++      "name": "chardev-mux",
++      "parent": "chardev"
++    },
++    {
++      "name": "pseries-2.1-machine",
++      "parent": "spapr-machine"
++    },
++    {
++      "name": "ich9-usb-uhci6",
++      "parent": "pci-uhci-usb"
++    },
++    {
++      "name": "ich9-usb-uhci5",
++      "parent": "pci-uhci-usb"
++    },
++    {
++      "name": "usb-mtp",
++      "parent": "usb-device"
++    },
++    {
++      "name": "ich9-usb-uhci3",
++      "parent": "pci-uhci-usb"
++    },
++    {
++      "name": "cmd646-ide",
++      "parent": "pci-ide"
++    },
++    {
++      "name": "ich9-usb-uhci4",
++      "parent": "pci-uhci-usb"
++    },
++    {
++      "name": "sysbus-ahci",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "e500v2_v22-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "ich9-usb-uhci2",
++      "parent": "pci-uhci-usb"
++    },
++    {
++      "name": "ich9-usb-uhci1",
++      "parent": "pci-uhci-usb"
++    },
++    {
++      "name": "MPC8533E_v11-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "7447A_v1.2-powerpc64-cpu",
++      "parent": "7445-family-powerpc64-cpu"
++    },
++    {
++      "name": "tpci200",
++      "parent": "pci-device"
++    },
++    {
++      "name": "memory-backend-file",
++      "parent": "memory-backend"
++    },
++    {
++      "name": "604r-powerpc64-cpu",
++      "parent": "604E-family-powerpc64-cpu"
++    },
++    {
++      "name": "chardev-socket",
++      "parent": "chardev"
++    },
++    {
++      "name": "sysbus-m48t59",
++      "parent": "sysbus-m48txx"
++    },
++    {
++      "name": "chardev-udp",
++      "parent": "chardev"
++    },
++    {
++      "name": "603e7v2-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "970mp_v1.1-powerpc64-cpu",
++      "parent": "970-family-powerpc64-cpu"
++    },
++    {
++      "name": "uni-north-internal-pci-pcihost",
++      "parent": "pci-host-bridge"
++    },
++    {
++      "name": "rtl8139",
++      "parent": "pci-device"
++    },
++    {
++      "name": "pci-bridge",
++      "parent": "base-pci-bridge"
++    },
++    {
++      "name": "chardev-hci",
++      "parent": "chardev"
++    },
++    {
++      "name": "MPC8347EAT-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "megasas",
++      "parent": "megasas-base"
++    },
++    {
++      "name": "405GPc-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "7455_v2.1-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    },
++    {
++      "name": "7400_v2.8-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "u3-agp",
++      "parent": "pci-device"
++    },
++    {
++      "name": "container",
++      "parent": "object"
++    },
++    {
++      "name": "7450_v2.0-powerpc64-cpu",
++      "parent": "7450-family-powerpc64-cpu"
++    },
++    {
++      "name": "scsi-block",
++      "parent": "scsi-disk-base"
++    },
++    {
++      "name": "7451_v2.3-powerpc64-cpu",
++      "parent": "7450-family-powerpc64-cpu"
++    },
++    {
++      "name": "unimplemented-device",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "603e_v1.1-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "eTSEC",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "scsi-cd",
++      "parent": "scsi-disk-base"
++    },
++    {
++      "name": "uni-north-agp",
++      "parent": "pci-device"
++    },
++    {
++      "name": "440EPX-powerpc64-cpu",
++      "parent": "440EP-family-powerpc64-cpu"
++    },
++    {
++      "name": "POWER8_v2.0-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "MPC5200B_v20-powerpc64-cpu",
++      "parent": "G2LE-family-powerpc64-cpu"
++    },
++    {
++      "name": "usb-uas",
++      "parent": "usb-device"
++    },
++    {
++      "name": "accel",
++      "parent": "object"
++    },
++    {
++      "name": "740p-powerpc64-cpu",
++      "parent": "740-family-powerpc64-cpu"
++    },
++    {
++      "name": "floppy-bus",
++      "parent": "bus"
++    },
++    {
++      "name": "virtio-vga",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "440-Xilinx-powerpc64-cpu",
++      "parent": "440x5-family-powerpc64-cpu"
++    },
++    {
++      "name": "vhost-scsi-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "spapr-rng",
++      "parent": "device"
++    },
++    {
++      "name": "xlnx.xps-timer",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "isa-serial",
++      "parent": "isa-device"
++    },
++    {
++      "name": "virtio-serial-device",
++      "parent": "virtio-device"
++    },
++    {
++      "name": "970_v2.2-powerpc64-cpu",
++      "parent": "970-family-powerpc64-cpu"
++    },
++    {
++      "name": "tls-creds-anon",
++      "parent": "tls-creds"
++    },
++    {
++      "name": "sdhci-pci",
++      "parent": "pci-device"
++    },
++    {
++      "name": "escc",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "POWER7_v2.3-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "chardev-gdb",
++      "parent": "chardev"
++    },
++    {
++      "name": "pc-testdev",
++      "parent": "isa-device"
++    },
++    {
++      "name": "icskvm",
++      "parent": "ics"
++    },
++    {
++      "name": "fw_cfg_mem",
++      "parent": "fw_cfg"
++    },
++    {
++      "name": "603e_v3-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "pseries-2.3-machine",
++      "parent": "spapr-machine"
++    },
++    {
++      "name": "MPC8347T-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "7445_v3.4-powerpc64-cpu",
++      "parent": "7445-family-powerpc64-cpu"
++    },
++    {
++      "name": "taihu-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "icp-kvm",
++      "parent": "icp"
++    },
++    {
++      "name": "MPC8555_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "G2-powerpc64-cpu",
++      "parent": "G2-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-balloon-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "ide-cd",
++      "parent": "ide-device"
++    },
++    {
++      "name": "usb-ccid",
++      "parent": "usb-device"
++    },
++    {
++      "name": "750p-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "745_v2.1-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "pseries-2.2-machine",
++      "parent": "spapr-machine"
++    },
++    {
++      "name": "powernv-cpu-core-POWER8NVL",
++      "parent": "powernv-cpu-core"
++    },
++    {
++      "name": "403GCX-powerpc64-cpu",
++      "parent": "403GCX-family-powerpc64-cpu"
++    },
++    {
++      "name": "sb16",
++      "parent": "isa-device"
++    },
++    {
++      "name": "iothread",
++      "parent": "object"
++    },
++    {
++      "name": "750gl-powerpc64-cpu",
++      "parent": "750gx-family-powerpc64-cpu"
++    },
++    {
++      "name": "filter-redirector",
++      "parent": "netfilter"
++    },
++    {
++      "name": "7410_v1.1-powerpc64-cpu",
++      "parent": "7410-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8347EP-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "755_v2.3-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC5200_v11-powerpc64-cpu",
++      "parent": "G2LE-family-powerpc64-cpu"
++    },
++    {
++      "name": "7450_v1.0-powerpc64-cpu",
++      "parent": "7450-family-powerpc64-cpu"
++    },
++    {
++      "name": "750_v2.2-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "POWER7_v2.3-powerpc64-cpu",
++      "parent": "POWER7-family-powerpc64-cpu"
++    },
++    {
++      "name": "vhost-vsock-device",
++      "parent": "virtio-device"
++    },
++    {
++      "name": "MPC8545E_v21-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "cs4231a",
++      "parent": "isa-device"
++    },
++    {
++      "name": "virtio-input-host-device",
++      "parent": "virtio-input-device"
++    },
++    {
++      "name": "970MP_v1.0-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "403GB-powerpc64-cpu",
++      "parent": "403-family-powerpc64-cpu"
++    },
++    {
++      "name": "G2le-powerpc64-cpu",
++      "parent": "G2LE-family-powerpc64-cpu"
++    },
++    {
++      "name": "i82559er",
++      "parent": "pci-device"
++    },
++    {
++      "name": "MPC8548E_v21-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "745_v2.6-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "755_v2.8-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "604e_v2.4-powerpc64-cpu",
++      "parent": "604E-family-powerpc64-cpu"
++    },
++    {
++      "name": "ivshmem-doorbell",
++      "parent": "ivshmem-common"
++    },
++    {
++      "name": "750cxe_v2.2-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "750cx_v1.0-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "pnv-icp",
++      "parent": "icp"
++    },
++    {
++      "name": "MPC8343-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-rng-device",
++      "parent": "virtio-device"
++    },
++    {
++      "name": "G2leLS-powerpc64-cpu",
++      "parent": "G2LE-family-powerpc64-cpu"
++    },
++    {
++      "name": "spapr-drc-cpu",
++      "parent": "spapr-drc-logical"
++    },
++    {
++      "name": "spapr-iommu-memory-region",
++      "parent": "qemu:iommu-memory-region"
++    },
++    {
++      "name": "isa-parallel",
++      "parent": "isa-device"
++    },
++    {
++      "name": "MPC8548E_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "adlib",
++      "parent": "isa-device"
++    },
++    {
++      "name": "602-powerpc64-cpu",
++      "parent": "602-family-powerpc64-cpu"
++    },
++    {
++      "name": "pci-bridge-seat",
++      "parent": "pci-bridge"
++    },
++    {
++      "name": "hda-micro",
++      "parent": "hda-audio"
++    },
++    {
++      "name": "fw_cfg_io",
++      "parent": "fw_cfg"
++    },
++    {
++      "name": "dc390",
++      "parent": "am53c974"
++    },
++    {
++      "name": "POWER5+_v2.1-powerpc64-cpu",
++      "parent": "POWER5P-family-powerpc64-cpu"
++    },
++    {
++      "name": "740_v3.0-powerpc64-cpu",
++      "parent": "740-family-powerpc64-cpu"
++    },
++    {
++      "name": "7441_v2.1-powerpc64-cpu",
++      "parent": "7440-family-powerpc64-cpu"
++    },
++    {
++      "name": "qemu,register",
++      "parent": "device"
++    },
++    {
++      "name": "pnv-psi",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "IDE",
++      "parent": "bus"
++    },
++    {
++      "name": "MPC8533_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "e300c3-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8641D-powerpc64-cpu",
++      "parent": "e600-family-powerpc64-cpu"
++    },
++    {
++      "name": "401E2-powerpc64-cpu",
++      "parent": "401x2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8347EAP-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "spapr-pci-host-bridge",
++      "parent": "pci-host-bridge"
++    },
++    {
++      "name": "memory-backend-ram",
++      "parent": "memory-backend"
++    },
++    {
++      "name": "am53c974",
++      "parent": "pci-device"
++    },
++    {
++      "name": "pseries-2.5-machine",
++      "parent": "spapr-machine"
++    },
++    {
++      "name": "750cx_v2.0-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "POWER7+_v2.1-powerpc64-cpu",
++      "parent": "POWER7-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-blk-device",
++      "parent": "virtio-device"
++    },
++    {
++      "name": "qio-channel-file",
++      "parent": "qio-channel"
++    },
++    {
++      "name": "745_v1.1-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "601_v1-powerpc64-cpu",
++      "parent": "601-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8544_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "740_v1.0-powerpc64-cpu",
++      "parent": "740-family-powerpc64-cpu"
++    },
++    {
++      "name": "qio-channel-websock",
++      "parent": "qio-channel"
++    },
++    {
++      "name": "pseries-2.4-machine",
++      "parent": "spapr-machine"
++    },
++    {
++      "name": "mc146818rtc",
++      "parent": "isa-device"
++    },
++    {
++      "name": "spapr-nvram",
++      "parent": "vio-spapr-device"
++    },
++    {
++      "name": "POWER9_v1.0-powerpc64-cpu",
++      "parent": "POWER9-family-powerpc64-cpu"
++    },
++    {
++      "name": "chardev-msmouse",
++      "parent": "chardev"
++    },
++    {
++      "name": "uni-north-pci",
++      "parent": "pci-device"
++    },
++    {
++      "name": "chardev-pipe",
++      "parent": "chardev-fd"
++    },
++    {
++      "name": "cryptodev-backend-builtin",
++      "parent": "cryptodev-backend"
++    },
++    {
++      "name": "750fx_v2.2-powerpc64-cpu",
++      "parent": "750fx-family-powerpc64-cpu"
++    },
++    {
++      "name": "hda-output",
++      "parent": "hda-audio"
++    },
++    {
++      "name": "603e_v1.2-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC603-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "mmio_interface",
++      "parent": "device"
++    },
++    {
++      "name": "sysbus-m48t08",
++      "parent": "sysbus-m48txx"
++    },
++    {
++      "name": "raven",
++      "parent": "pci-device"
++    },
++    {
++      "name": "440EPb-powerpc64-cpu",
++      "parent": "440EP-family-powerpc64-cpu"
++    },
++    {
++      "name": "VGA",
++      "parent": "pci-vga"
++    },
++    {
++      "name": "i8257",
++      "parent": "isa-device"
++    },
++    {
++      "name": "sysbus-m48t02",
++      "parent": "sysbus-m48txx"
++    },
++    {
++      "name": "pc87312",
++      "parent": "isa-device"
++    },
++    {
++      "name": "mptsas1068",
++      "parent": "pci-device"
++    },
++    {
++      "name": "edu",
++      "parent": "pci-device"
++    },
++    {
++      "name": "MPC8347P-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-mouse-pci",
++      "parent": "virtio-input-hid-pci"
++    },
++    {
++      "name": "740_v2.0-powerpc64-cpu",
++      "parent": "740-family-powerpc64-cpu"
++    },
++    {
++      "name": "7455_v3.2-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    },
++    {
++      "name": "vfio-pci-igd-lpc-bridge",
++      "parent": "pci-device"
++    },
++    {
++      "name": "spapr-vlan",
++      "parent": "vio-spapr-device"
++    },
++    {
++      "name": "603e_v4-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "HDA",
++      "parent": "bus"
++    },
++    {
++      "name": "7447_v1.1-powerpc64-cpu",
++      "parent": "7445-family-powerpc64-cpu"
++    },
++    {
++      "name": "603e_v2.2-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "pseries-2.8-machine",
++      "parent": "spapr-machine"
++    },
++    {
++      "name": "MPC8543E_v20-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "floppy",
++      "parent": "device"
++    },
++    {
++      "name": "macio-oldworld",
++      "parent": "macio"
++    },
++    {
++      "name": "qemu:memory-region",
++      "parent": "object"
++    },
++    {
++      "name": "adb-keyboard",
++      "parent": "adb-device"
++    },
++    {
++      "name": "G2LS-powerpc64-cpu",
++      "parent": "G2-family-powerpc64-cpu"
++    },
++    {
++      "name": "sysbus-ohci",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "7445_v1.0-powerpc64-cpu",
++      "parent": "7445-family-powerpc64-cpu"
++    },
++    {
++      "name": "pseries-2.7-machine",
++      "parent": "spapr-machine"
++    },
++    {
++      "name": "755_v2.4-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "7450_v1.1-powerpc64-cpu",
++      "parent": "7450-family-powerpc64-cpu"
++    },
++    {
++      "name": "e600-powerpc64-cpu",
++      "parent": "e600-family-powerpc64-cpu"
++    },
++    {
++      "name": "qio-channel-command",
++      "parent": "qio-channel"
++    },
++    {
++      "name": "chardev-ringbuf",
++      "parent": "chardev"
++    },
++    {
++      "name": "usb-serial",
++      "parent": "usb-serial-dev"
++    },
++    {
++      "name": "x2vp20-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "qtest-accel",
++      "parent": "accel"
++    },
++    {
++      "name": "pseries-2.6-machine",
++      "parent": "spapr-machine"
++    },
++    {
++      "name": "750l_v2.0-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "750fl-powerpc64-cpu",
++      "parent": "750fx-family-powerpc64-cpu"
++    },
++    {
++      "name": "vt82c686b-usb-uhci",
++      "parent": "pci-uhci-usb"
++    },
++    {
++      "name": "405D2-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-blk-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "virtio-gpu-device",
++      "parent": "virtio-device"
++    },
++    {
++      "name": "MPC8560_v20-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "750gx_v1.0-powerpc64-cpu",
++      "parent": "750gx-family-powerpc64-cpu"
++    },
++    {
++      "name": "System",
++      "parent": "bus"
++    },
++    {
++      "name": "lsi53c810",
++      "parent": "lsi53c895a"
++    },
++    {
++      "name": "uni-north-agp-pcihost",
++      "parent": "pci-host-bridge"
++    },
++    {
++      "name": "IOP480-powerpc64-cpu",
++      "parent": "IOP480-family-powerpc64-cpu"
++    },
++    {
++      "name": "603e7t-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8548E_v11-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "405GPd-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "603-powerpc64-cpu",
++      "parent": "603-family-powerpc64-cpu"
++    },
++    {
++      "name": "G2GP-powerpc64-cpu",
++      "parent": "G2-family-powerpc64-cpu"
++    },
++    {
++      "name": "7400_v2.9-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "750cxe_v3.1b-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "G2leGP-powerpc64-cpu",
++      "parent": "G2LE-family-powerpc64-cpu"
++    },
++    {
++      "name": "7450_v2.1-powerpc64-cpu",
++      "parent": "7450-family-powerpc64-cpu"
++    },
++    {
++      "name": "chardev-braille",
++      "parent": "chardev"
++    },
++    {
++      "name": "chardev-file",
++      "parent": "chardev-fd"
++    },
++    {
++      "name": "7448_v2.0-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "mac99-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "e300c4-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "750l_v3.0-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC5200B_v21-powerpc64-cpu",
++      "parent": "G2LE-family-powerpc64-cpu"
++    },
++    {
++      "name": "PCIE",
++      "parent": "PCI"
++    },
++    {
++      "name": "qio-dns-resolver",
++      "parent": "object"
++    },
++    {
++      "name": "750cx_v2.1-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "cuda",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "604e_v1.0-powerpc64-cpu",
++      "parent": "604E-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8572E-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-serial-bus",
++      "parent": "bus"
++    },
++    {
++      "name": "vhost-scsi",
++      "parent": "vhost-scsi-common"
++    },
++    {
++      "name": "secondary-vga",
++      "parent": "pci-vga"
++    },
++    {
++      "name": "401D2-powerpc64-cpu",
++      "parent": "401x2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8544_v11-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "e500-ccsr",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "601_v2-powerpc64-cpu",
++      "parent": "601v-family-powerpc64-cpu"
++    },
++    {
++      "name": "405EP-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "ccid-bus",
++      "parent": "bus"
++    },
++    {
++      "name": "pci-ohci",
++      "parent": "pci-device"
++    },
++    {
++      "name": "cfi.pflash02",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "cfi.pflash01",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "pseries-2.9-machine",
++      "parent": "spapr-machine"
++    },
++    {
++      "name": "usb-hub",
++      "parent": "usb-device"
++    },
++    {
++      "name": "750fx_v2.3-powerpc64-cpu",
++      "parent": "750fx-family-powerpc64-cpu"
++    },
++    {
++      "name": "405LP-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8541_v10-powerpc64-cpu",
++      "parent": "e500v1-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8555_v11-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "input-linux",
++      "parent": "object"
++    },
++    {
++      "name": "x2vp4-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "7410_v1.2-powerpc64-cpu",
++      "parent": "7410-family-powerpc64-cpu"
++    },
++    {
++      "name": "7400_v1.0-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "745_v2.2-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "740_v2.1-powerpc64-cpu",
++      "parent": "740-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC5200_v12-powerpc64-cpu",
++      "parent": "G2LE-family-powerpc64-cpu"
++    },
++    {
++      "name": "7448_v1.0-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "xlnx.xps-uartlite",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "e5500-powerpc64-cpu",
++      "parent": "e5500-family-powerpc64-cpu"
++    },
++    {
++      "name": "pci-serial",
++      "parent": "pci-device"
++    },
++    {
++      "name": "403GC-powerpc64-cpu",
++      "parent": "403-family-powerpc64-cpu"
++    },
++    {
++      "name": "ipmi-bmc-extern",
++      "parent": "ipmi-bmc"
++    },
++    {
++      "name": "745_v2.7-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8543_v20-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "i8042",
++      "parent": "isa-device"
++    },
++    {
++      "name": "750cxe_v2.3-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8543E_v21-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "vhost-user-scsi-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "i82559c",
++      "parent": "pci-device"
++    },
++    {
++      "name": "i82559b",
++      "parent": "pci-device"
++    },
++    {
++      "name": "i82559a",
++      "parent": "pci-device"
++    },
++    {
++      "name": "SCSI",
++      "parent": "bus"
++    },
++    {
++      "name": "rocker",
++      "parent": "pci-device"
++    },
++    {
++      "name": "pcnet",
++      "parent": "pci-device"
++    },
++    {
++      "name": "rng-egd",
++      "parent": "rng-backend"
++    },
++    {
++      "name": "MPC8543E_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "405CRa-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "spapr-tce-table",
++      "parent": "device"
++    },
++    {
++      "name": "7400_v2.0-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "chardev-testdev",
++      "parent": "chardev"
++    },
++    {
++      "name": "sm501",
++      "parent": "pci-device"
++    },
++    {
++      "name": "MPC8349-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "e200z5-powerpc64-cpu",
++      "parent": "e200-family-powerpc64-cpu"
++    },
++    {
++      "name": "740_v3.1-powerpc64-cpu",
++      "parent": "740-family-powerpc64-cpu"
++    },
++    {
++      "name": "filter-dump",
++      "parent": "netfilter"
++    },
++    {
++      "name": "MPC8533_v11-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "migration",
++      "parent": "device"
++    },
++    {
++      "name": "i82558b",
++      "parent": "pci-device"
++    },
++    {
++      "name": "G2H4-powerpc64-cpu",
++      "parent": "G2-family-powerpc64-cpu"
++    },
++    {
++      "name": "i82558a",
++      "parent": "pci-device"
++    },
++    {
++      "name": "MPC8560_v21-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "smbus-eeprom",
++      "parent": "smbus-device"
++    },
++    {
++      "name": "host-powerpc64-cpu",
++      "parent": "POWER8E_v2.1-powerpc64-cpu"
++    },
++    {
++      "name": "i82801",
++      "parent": "pci-device"
++    },
++    {
++      "name": "tls-creds-x509",
++      "parent": "tls-creds"
++    },
++    {
++      "name": "virtio-net-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "virtio-keyboard-device",
++      "parent": "virtio-input-hid-device"
++    },
++    {
++      "name": "i82562",
++      "parent": "pci-device"
++    },
++    {
++      "name": "usb-net",
++      "parent": "usb-device"
++    },
++    {
++      "name": "MPC8560_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "POWER7+_v2.1-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "603e_v1.3-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "755_v1.0-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8568E-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "i82557c",
++      "parent": "pci-device"
++    },
++    {
++      "name": "i82557b",
++      "parent": "pci-device"
++    },
++    {
++      "name": "i82557a",
++      "parent": "pci-device"
++    },
++    {
++      "name": "chardev-memory",
++      "parent": "chardev-ringbuf"
++    },
++    {
++      "name": "isa-i8259",
++      "parent": "pic-common"
++    },
++    {
++      "name": "virtio-gpu-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "nec-usb-xhci",
++      "parent": "base-xhci"
++    },
++    {
++      "name": "pc-dimm",
++      "parent": "device"
++    },
++    {
++      "name": "host-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "usb-mouse",
++      "parent": "usb-hid"
++    },
++    {
++      "name": "sdhci-bus",
++      "parent": "sd-bus"
++    },
++    {
++      "name": "i82551",
++      "parent": "pci-device"
++    },
++    {
++      "name": "i82550",
++      "parent": "pci-device"
++    },
++    {
++      "name": "405EZ-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "ich9-ahci",
++      "parent": "pci-device"
++    },
++    {
++      "name": "7455_v3.3-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    },
++    {
++      "name": "sd-bus",
++      "parent": "bus"
++    },
++    {
++      "name": "filter-mirror",
++      "parent": "netfilter"
++    },
++    {
++      "name": "apple-desktop-bus",
++      "parent": "bus"
++    },
++    {
++      "name": "e500v2_v30-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "macio-ide",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "401C2-powerpc64-cpu",
++      "parent": "401x2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8541_v11-powerpc64-cpu",
++      "parent": "e500v1-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-crypto-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "755_v2.0-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "ich9-usb-ehci2",
++      "parent": "pci-ehci-usb"
++    },
++    {
++      "name": "ich9-usb-ehci1",
++      "parent": "pci-ehci-usb"
++    },
++    {
++      "name": "vfio-pci",
++      "parent": "pci-device"
++    },
++    {
++      "name": "prep-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "isa-ide",
++      "parent": "isa-device"
++    },
++    {
++      "name": "pseries-2.10-machine",
++      "parent": "spapr-machine"
++    },
++    {
++      "name": "irq",
++      "parent": "object"
++    },
++    {
++      "name": "405GPR-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "POWER8E_v2.1-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "745_v2.3-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "7410_v1.3-powerpc64-cpu",
++      "parent": "7410-family-powerpc64-cpu"
++    },
++    {
++      "name": "755_v2.5-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8572-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "7450_v1.2-powerpc64-cpu",
++      "parent": "7450-family-powerpc64-cpu"
++    },
++    {
++      "name": "7457_v1.0-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    },
++    {
++      "name": "qio-channel-socket",
++      "parent": "qio-channel"
++    },
++    {
++      "name": "7457A_v1.0-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    },
++    {
++      "name": "POWER8NVL_v1.0-powerpc64-cpu",
++      "parent": "POWER8-family-powerpc64-cpu"
++    },
++    {
++      "name": "750l_v2.1-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8347AT-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "chardev-stdio",
++      "parent": "chardev-fd"
++    },
++    {
++      "name": "piix3-usb-uhci",
++      "parent": "pci-uhci-usb"
++    },
++    {
++      "name": "virtserialport",
++      "parent": "virtio-serial-port"
++    },
++    {
++      "name": "MPC8543E_v11-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "pvscsi",
++      "parent": "pci-device"
++    },
++    {
++      "name": "MPC8548_v20-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "750cxe_v2.4-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "i82378",
++      "parent": "pci-device"
++    },
++    {
++      "name": "604-powerpc64-cpu",
++      "parent": "604-family-powerpc64-cpu"
++    },
++    {
++      "name": "powernv-chip-POWER8NVL",
++      "parent": "powernv-chip"
++    },
++    {
++      "name": "750gx_v1.1-powerpc64-cpu",
++      "parent": "750gx-family-powerpc64-cpu"
++    },
++    {
++      "name": "gus",
++      "parent": "isa-device"
++    },
++    {
++      "name": "e500_v20-powerpc64-cpu",
++      "parent": "e500v1-family-powerpc64-cpu"
++    },
++    {
++      "name": "i82374",
++      "parent": "isa-device"
++    },
++    {
++      "name": "pnv-lpc",
++      "parent": "device"
++    },
++    {
++      "name": "7445_v2.1-powerpc64-cpu",
++      "parent": "7445-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8543_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8540_v20-powerpc64-cpu",
++      "parent": "e500v1-family-powerpc64-cpu"
++    },
++    {
++      "name": "7447A_v1.0-powerpc64-cpu",
++      "parent": "7445-family-powerpc64-cpu"
++    },
++    {
++      "name": "405CRb-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "g3beige-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "7400_v2.1-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "IndustryPack",
++      "parent": "bus"
++    },
++    {
++      "name": "powernv-chip-POWER8E",
++      "parent": "powernv-chip"
++    },
++    {
++      "name": "7441_v2.3-powerpc64-cpu",
++      "parent": "7440-family-powerpc64-cpu"
++    },
++    {
++      "name": "7448_v2.1-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8377-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "401A1-powerpc64-cpu",
++      "parent": "401-family-powerpc64-cpu"
++    },
++    {
++      "name": "603e7-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "cryptodev-backend",
++      "parent": "object"
++    },
++    {
++      "name": "adb-mouse",
++      "parent": "adb-device"
++    },
++    {
++      "name": "Npe405L-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "or-irq",
++      "parent": "device"
++    },
++    {
++      "name": "750cx_v2.2-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "ipmi-bmc-sim",
++      "parent": "ipmi-bmc"
++    },
++    {
++      "name": "MPC8343E-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "powernv-cpu-core-POWER9",
++      "parent": "powernv-cpu-core"
++    },
++    {
++      "name": "powernv-cpu-core-POWER8",
++      "parent": "powernv-cpu-core"
++    },
++    {
++      "name": "7451_v2.10-powerpc64-cpu",
++      "parent": "7450-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-rng-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "chardev-vc",
++      "parent": "chardev"
++    },
++    {
++      "name": "usb-ehci",
++      "parent": "pci-ehci-usb"
++    },
++    {
++      "name": "bamboo-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "filter-replay",
++      "parent": "netfilter"
++    },
++    {
++      "name": "G2leGP1-powerpc64-cpu",
++      "parent": "G2LE-family-powerpc64-cpu"
++    },
++    {
++      "name": "603e_v1.4-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "970mp_v1.1-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "virtio-9p-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "dec-21154-sysbus",
++      "parent": "pci-host-bridge"
++    },
++    {
++      "name": "uni-north-pci-pcihost",
++      "parent": "pci-host-bridge"
++    },
++    {
++      "name": "spapr-vty",
++      "parent": "vio-spapr-device"
++    },
++    {
++      "name": "e1000-82545em",
++      "parent": "e1000-base"
++    },
++    {
++      "name": "chardev-wctablet",
++      "parent": "chardev"
++    },
++    {
++      "name": "7441_v2.10-powerpc64-cpu",
++      "parent": "7440-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8567E-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "POWER5+_v2.1-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "7400_v1.1-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "e1000-82544gc",
++      "parent": "e1000-base"
++    },
++    {
++      "name": "740_v2.2-powerpc64-cpu",
++      "parent": "740-family-powerpc64-cpu"
++    },
++    {
++      "name": "7448_v1.1-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "7455_v3.4-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    },
++    {
++      "name": "POWER8NVL_v1.0-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "prep-systemio",
++      "parent": "isa-device"
++    },
++    {
++      "name": "MPC8547E_v20-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "745_v2.8-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "e500-spin",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "MPC8543_v21-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "755_v2.1-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8349E-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "filter-buffer",
++      "parent": "netfilter"
++    },
++    {
++      "name": "mpc8544ds-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "pci-serial-4x",
++      "parent": "pci-device"
++    },
++    {
++      "name": "401B2-powerpc64-cpu",
++      "parent": "401x2-family-powerpc64-cpu"
++    },
++    {
++      "name": "ich9-intel-hda",
++      "parent": "intel-hda-generic"
++    },
++    {
++      "name": "virtio-9p-device",
++      "parent": "virtio-device"
++    },
++    {
++      "name": "MPC8347AP-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "ivshmem",
++      "parent": "ivshmem-common"
++    },
++    {
++      "name": "e500v2_v20-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8379E-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-scsi-pci",
++      "parent": "virtio-pci"
++    },
++    {
++      "name": "qemu-console",
++      "parent": "object"
++    },
++    {
++      "name": "e200z6-powerpc64-cpu",
++      "parent": "e200-family-powerpc64-cpu"
++    },
++    {
++      "name": "7457A_v1.1-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8555E_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "isa-ipmi-bt",
++      "parent": "isa-device"
++    },
++    {
++      "name": "ppce500-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "virtio-pci-bus",
++      "parent": "virtio-bus"
++    },
++    {
++      "name": "750l_v2.2-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "ISA",
++      "parent": "bus"
++    },
++    {
++      "name": "MPC8541E_v10-powerpc64-cpu",
++      "parent": "e500v1-family-powerpc64-cpu"
++    },
++    {
++      "name": "ipoctal232",
++      "parent": "ipack-device"
++    },
++    {
++      "name": "mpc8544-guts",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "MPC8548_v21-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "spapr-drc-lmb",
++      "parent": "spapr-drc-logical"
++    },
++    {
++      "name": "pci-testdev",
++      "parent": "pci-device"
++    },
++    {
++      "name": "405GPa-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "piix4-usb-uhci",
++      "parent": "pci-uhci-usb"
++    },
++    {
++      "name": "7400_v2.6-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-tablet-device",
++      "parent": "virtio-input-hid-device"
++    },
++    {
++      "name": "Npe405H2-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "750_v3.0-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "powernv-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "ES1370",
++      "parent": "pci-device"
++    },
++    {
++      "name": "603e7v-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "openpic",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "Npe405H-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8548_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8545_v20-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8567-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "755_v1.1-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "e500_v10-powerpc64-cpu",
++      "parent": "e500v1-family-powerpc64-cpu"
++    },
++    {
++      "name": "750cxe_v3.0-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "G2HiP3-powerpc64-cpu",
++      "parent": "G2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8378-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8343A-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "STB03-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "tcg-accel",
++      "parent": "accel"
++    },
++    {
++      "name": "750_v1.0-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtconsole",
++      "parent": "virtserialport"
++    },
++    {
++      "name": "MPC8540_v10-powerpc64-cpu",
++      "parent": "e500v1-family-powerpc64-cpu"
++    },
++    {
++      "name": "750l_v3.2-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "pci-serial-2x",
++      "parent": "pci-device"
++    },
++    {
++      "name": "ne2k_isa",
++      "parent": "isa-device"
++    },
++    {
++      "name": "isa-fdc",
++      "parent": "isa-device"
++    },
++    {
++      "name": "chardev-serial",
++      "parent": "chardev-fd"
++    },
++    {
++      "name": "scsi-disk",
++      "parent": "scsi-disk-base"
++    },
++    {
++      "name": "colo-compare",
++      "parent": "object"
++    },
++    {
++      "name": "spapr-drc-pci",
++      "parent": "spapr-drc-physical"
++    },
++    {
++      "name": "745_v2.4-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-mmio-bus",
++      "parent": "virtio-bus"
++    },
++    {
++      "name": "virtio-tablet-pci",
++      "parent": "virtio-input-hid-pci"
++    },
++    {
++      "name": "e1000e",
++      "parent": "pci-device"
++    },
++    {
++      "name": "usb-bus",
++      "parent": "bus"
++    },
++    {
++      "name": "7445_v3.2-powerpc64-cpu",
++      "parent": "7445-family-powerpc64-cpu"
++    },
++    {
++      "name": "rs6000-mc",
++      "parent": "isa-device"
++    },
++    {
++      "name": "usb-storage",
++      "parent": "usb-storage-dev"
++    },
++    {
++      "name": "PCI",
++      "parent": "bus"
++    },
++    {
++      "name": "kvm-openpic",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "esp",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "vhost-user-scsi",
++      "parent": "vhost-scsi-common"
++    },
++    {
++      "name": "virtex-ml507-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "usb-kbd",
++      "parent": "usb-hid"
++    },
++    {
++      "name": "750_v2.0-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "e500-host-bridge",
++      "parent": "pci-device"
++    },
++    {
++      "name": "7410_v1.4-powerpc64-cpu",
++      "parent": "7410-family-powerpc64-cpu"
++    },
++    {
++      "name": "ne2k_pci",
++      "parent": "pci-device"
++    },
++    {
++      "name": "Npe4GS3-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "isabus-bridge",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "970mp_v1.0-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "ivshmem-plain",
++      "parent": "ivshmem-common"
++    },
++    {
++      "name": "755_v2.6-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "604e_v2.2-powerpc64-cpu",
++      "parent": "604E-family-powerpc64-cpu"
++    },
++    {
++      "name": "qio-channel-buffer",
++      "parent": "qio-channel"
++    },
++    {
++      "name": "970fx_v3.0-powerpc64-cpu",
++      "parent": "970-family-powerpc64-cpu"
++    },
++    {
++      "name": "7457_v1.1-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    },
++    {
++      "name": "pnv-occ",
++      "parent": "device"
++    },
++    {
++      "name": "u3-agp-pcihost",
++      "parent": "pci-host-bridge"
++    },
++    {
++      "name": "spapr-vio-bridge",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "secret",
++      "parent": "object"
++    },
++    {
++      "name": "hda-duplex",
++      "parent": "hda-audio"
++    },
++    {
++      "name": "raven-pcihost",
++      "parent": "pci-host-bridge"
++    },
++    {
++      "name": "allwinner-ahci",
++      "parent": "sysbus-ahci"
++    },
++    {
++      "name": "nvme",
++      "parent": "pci-device"
++    },
++    {
++      "name": "sysbus-fdc",
++      "parent": "base-sysbus-fdc"
++    },
++    {
++      "name": "405D4-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8544E_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "virtio-balloon-device",
++      "parent": "virtio-device"
++    },
++    {
++      "name": "MPC8641-powerpc64-cpu",
++      "parent": "e600-family-powerpc64-cpu"
++    },
++    {
++      "name": "none-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "750fx_v1.0-powerpc64-cpu",
++      "parent": "750fx-family-powerpc64-cpu"
++    },
++    {
++      "name": "750gx_v1.2-powerpc64-cpu",
++      "parent": "750gx-family-powerpc64-cpu"
++    },
++    {
++      "name": "megasas-gen2",
++      "parent": "megasas-base"
++    },
++    {
++      "name": "AC97",
++      "parent": "pci-device"
++    },
++    {
++      "name": "usb-tablet",
++      "parent": "usb-hid"
++    },
++    {
++      "name": "970fx_v1.0-powerpc64-cpu",
++      "parent": "970-family-powerpc64-cpu"
++    },
++    {
++      "name": "usb-wacom-tablet",
++      "parent": "usb-device"
++    },
++    {
++      "name": "e300c1-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "e500v2_v21-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8540_v21-powerpc64-cpu",
++      "parent": "e500v1-family-powerpc64-cpu"
++    },
++    {
++      "name": "7400_v2.2-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8543_v11-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8533E_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "7447A_v1.1-powerpc64-cpu",
++      "parent": "7445-family-powerpc64-cpu"
++    },
++    {
++      "name": "405CRc-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "740e-powerpc64-cpu",
++      "parent": "740-family-powerpc64-cpu"
++    },
++    {
++      "name": "usb-braille",
++      "parent": "usb-serial-dev"
++    },
++    {
++      "name": "440-Xilinx-w-dfpu-powerpc64-cpu",
++      "parent": "440x5wDFPU-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8555E_v11-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "970mp_v1.0-powerpc64-cpu",
++      "parent": "970-family-powerpc64-cpu"
++    },
++    {
++      "name": "603e7v1-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "e500mc-powerpc64-cpu",
++      "parent": "e500mc-family-powerpc64-cpu"
++    },
++    {
++      "name": "e500v2_v10-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8378E-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "intel-hda",
++      "parent": "intel-hda-generic"
++    },
++    {
++      "name": "kvm-accel",
++      "parent": "accel"
++    },
++    {
++      "name": "virtio-scsi-device",
++      "parent": "virtio-scsi-common"
++    },
++    {
++      "name": "603p-powerpc64-cpu",
++      "parent": "603E-family-powerpc64-cpu"
++    },
++    {
++      "name": "7400_v2.7-powerpc64-cpu",
++      "parent": "7400-family-powerpc64-cpu"
++    },
++    {
++      "name": "grackle",
++      "parent": "pci-device"
++    },
++    {
++      "name": "970_v2.2-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "Cobra-powerpc64-cpu",
++      "parent": "401-family-powerpc64-cpu"
++    },
++    {
++      "name": "POWER8E_v2.1-powerpc64-cpu",
++      "parent": "POWER8-family-powerpc64-cpu"
++    },
++    {
++      "name": "750fx_v2.0-powerpc64-cpu",
++      "parent": "750fx-family-powerpc64-cpu"
++    },
++    {
++      "name": "970fx_v2.0-powerpc64-cpu",
++      "parent": "970-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8548_v11-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8545_v21-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "i2c-bus",
++      "parent": "bus"
++    },
++    {
++      "name": "virtio-mouse-device",
++      "parent": "virtio-input-hid-device"
++    },
++    {
++      "name": "750e-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "isa-pit",
++      "parent": "pit-common"
++    },
++    {
++      "name": "macio-nvram",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "POWER9_v1.0-spapr-cpu-core",
++      "parent": "spapr-cpu-core"
++    },
++    {
++      "name": "powernv-cpu-core-POWER8E",
++      "parent": "powernv-cpu-core"
++    },
++    {
++      "name": "grackle-pcihost",
++      "parent": "pci-host-bridge"
++    },
++    {
++      "name": "ide-drive",
++      "parent": "ide-device"
++    },
++    {
++      "name": "ref405ep-machine",
++      "parent": "machine"
++    },
++    {
++      "name": "MPC8349A-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "401G2-powerpc64-cpu",
++      "parent": "401x2-family-powerpc64-cpu"
++    },
++    {
++      "name": "generic-sdhci",
++      "parent": "sys-bus-device"
++    },
++    {
++      "name": "POWER8_v2.0-powerpc64-cpu",
++      "parent": "POWER8-family-powerpc64-cpu"
++    },
++    {
++      "name": "i6300esb",
++      "parent": "pci-device"
++    },
++    {
++      "name": "STB25-powerpc64-cpu",
++      "parent": "405-family-powerpc64-cpu"
++    },
++    {
++      "name": "sd-card",
++      "parent": "device"
++    },
++    {
++      "name": "MPC8547E_v21-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "7455_v1.0-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    },
++    {
++      "name": "745_v2.0-powerpc64-cpu",
++      "parent": "745-family-powerpc64-cpu"
++    },
++    {
++      "name": "755_v2.2-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "e500-pcihost",
++      "parent": "pci-host-bridge"
++    },
++    {
++      "name": "vmxnet3",
++      "parent": "pci-device"
++    },
++    {
++      "name": "750_v2.1-powerpc64-cpu",
++      "parent": "750-family-powerpc64-cpu"
++    },
++    {
++      "name": "MPC8545E_v20-powerpc64-cpu",
++      "parent": "e500v2-family-powerpc64-cpu"
++    },
++    {
++      "name": "uni-north-internal-pci",
++      "parent": "pci-device"
++    },
++    {
++      "name": "spapr-rtc",
++      "parent": "device"
++    },
++    {
++      "name": "MPC8347ET-powerpc64-cpu",
++      "parent": "e300-family-powerpc64-cpu"
++    },
++    {
++      "name": "755_v2.7-powerpc64-cpu",
++      "parent": "755-family-powerpc64-cpu"
++    },
++    {
++      "name": "750cxe_v2.1-powerpc64-cpu",
++      "parent": "750cx-family-powerpc64-cpu"
++    },
++    {
++      "name": "rng-random",
++      "parent": "rng-backend"
++    },
++    {
++      "name": "750cl_v1.0-powerpc64-cpu",
++      "parent": "750cl-family-powerpc64-cpu"
++    },
++    {
++      "name": "7457A_v1.2-powerpc64-cpu",
++      "parent": "7455-family-powerpc64-cpu"
++    }
++  ],
++  "id": "libvirt-9"
++}
++
++{
++  "return": [
++    {
++      "name": "secs",
++      "type": "uint32"
++    },
++    {
++      "name": "request-merging",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "min_io_size",
++      "type": "uint16"
++    },
++    {
++      "name": "event_idx",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "serial",
++      "type": "str"
++    },
++    {
++      "name": "heads",
++      "type": "uint32"
++    },
++    {
++      "name": "ioeventfd",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "multifunction",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "rombar",
++      "type": "uint32"
++    },
++    {
++      "name": "scsi",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "cyls",
++      "type": "uint32"
++    },
++    {
++      "name": "x-disable-pcie",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "logical_block_size",
++      "description": "A power of two between 512 and 32768",
++      "type": "uint16"
++    },
++    {
++      "name": "indirect_desc",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "iothread",
++      "type": "link<iothread>"
++    },
++    {
++      "name": "disable-modern",
++      "type": "bool"
++    },
++    {
++      "name": "drive",
++      "description": "Node name or ID of a block device to use as a backend",
++      "type": "str"
++    },
++    {
++      "name": "disable-legacy",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "command_serr_enable",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-lnkctl-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "werror",
++      "description": "Error handling policy, report/ignore/enospc/stop/auto",
++      "type": "BlockdevOnError"
++    },
++    {
++      "name": "bootindex",
++      "type": "int32"
++    },
++    {
++      "name": "discard_granularity",
++      "type": "uint32"
++    },
++    {
++      "name": "rerror",
++      "description": "Error handling policy, report/ignore/enospc/stop/auto",
++      "type": "BlockdevOnError"
++    },
++    {
++      "name": "page-per-vq",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-deverr-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-pm-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "any_layout",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-lnksta-dllla",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "share-rw",
++      "type": "bool"
++    },
++    {
++      "name": "physical_block_size",
++      "description": "A power of two between 512 and 32768",
++      "type": "uint16"
++    },
++    {
++      "name": "config-wce",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "class",
++      "type": "uint32"
++    },
++    {
++      "name": "addr",
++      "description": "Slot and optional function number, example: 06.0 or 06",
++      "type": "int32"
++    },
++    {
++      "name": "migrate-extra",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "modern-pio-notify",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "vectors",
++      "type": "uint32"
++    },
++    {
++      "name": "iommu_platform",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-extcap-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "virtio-backend",
++      "type": "child<virtio-blk-device>"
++    },
++    {
++      "name": "x-ignore-backend-features",
++      "type": "bool"
++    },
++    {
++      "name": "notify_on_empty",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "write-cache",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "num-queues",
++      "type": "uint16"
++    },
++    {
++      "name": "opt_io_size",
++      "type": "uint32"
++    },
++    {
++      "name": "ats",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "virtio-pci-bus-master-bug-migration",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "romfile",
++      "type": "str"
++    }
++  ],
++  "id": "libvirt-10"
++}
++
++{
++  "return": [
++    {
++      "name": "ctrl_mac_addr",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "romfile",
++      "type": "str"
++    },
++    {
++      "name": "x-pcie-lnksta-dllla",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "status",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "notify_on_empty",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "command_serr_enable",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-pm-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "indirect_desc",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "guest_csum",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "ctrl_rx",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "ctrl_vq",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "bootindex",
++      "type": "int32"
++    },
++    {
++      "name": "multifunction",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "disable-modern",
++      "type": "bool"
++    },
++    {
++      "name": "mrg_rxbuf",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "host_tso6",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-txtimer",
++      "type": "uint32"
++    },
++    {
++      "name": "host_tso4",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "rombar",
++      "type": "uint32"
++    },
++    {
++      "name": "ctrl_rx_extra",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "gso",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "page-per-vq",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-disable-pcie",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-ignore-backend-features",
++      "type": "bool"
++    },
++    {
++      "name": "vlan",
++      "description": "Integer VLAN id to connect to",
++      "type": "int32"
++    },
++    {
++      "name": "x-txburst",
++      "type": "int32"
++    },
++    {
++      "name": "iommu_platform",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-lnkctl-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "host_mtu",
++      "type": "uint16"
++    },
++    {
++      "name": "ctrl_vlan",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "virtio-backend",
++      "type": "child<virtio-net-device>"
++    },
++    {
++      "name": "event_idx",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "vectors",
++      "type": "uint32"
++    },
++    {
++      "name": "guest_announce",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "host_ecn",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "addr",
++      "description": "Slot and optional function number, example: 06.0 or 06",
++      "type": "int32"
++    },
++    {
++      "name": "ats",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "host_ufo",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "guest_tso4",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "guest_tso6",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "ctrl_guest_offloads",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "csum",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "modern-pio-notify",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "ioeventfd",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "mq",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "any_layout",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "guest_ecn",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "guest_ufo",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "virtio-pci-bus-master-bug-migration",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "mac",
++      "description": "Ethernet 6-byte MAC Address, example: 52:54:00:12:34:56",
++      "type": "str"
++    },
++    {
++      "name": "tx_queue_size",
++      "type": "uint16"
++    },
++    {
++      "name": "disable-legacy",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "tx",
++      "type": "str"
++    },
++    {
++      "name": "x-pcie-extcap-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-mtu-bypass-backend",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-deverr-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "netdev",
++      "description": "ID of a netdev to use as a backend",
++      "type": "str"
++    },
++    {
++      "name": "migrate-extra",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "rx_queue_size",
++      "type": "uint16"
++    }
++  ],
++  "id": "libvirt-11"
++}
++
++{
++  "return": [
++    {
++      "name": "event_idx",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "ioeventfd",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "multifunction",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "rombar",
++      "type": "uint32"
++    },
++    {
++      "name": "x-disable-pcie",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "indirect_desc",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "cmd_per_lun",
++      "type": "uint32"
++    },
++    {
++      "name": "disable-modern",
++      "type": "bool"
++    },
++    {
++      "name": "num_queues",
++      "type": "uint32"
++    },
++    {
++      "name": "disable-legacy",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "command_serr_enable",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-lnkctl-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "hotplug",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "page-per-vq",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-deverr-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-pm-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-lnksta-dllla",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "max_sectors",
++      "type": "uint32"
++    },
++    {
++      "name": "param_change",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "any_layout",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "iothread",
++      "type": "link<iothread>"
++    },
++    {
++      "name": "addr",
++      "description": "Slot and optional function number, example: 06.0 or 06",
++      "type": "int32"
++    },
++    {
++      "name": "migrate-extra",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "modern-pio-notify",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "vectors",
++      "type": "uint32"
++    },
++    {
++      "name": "x-pcie-extcap-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "virtio-backend",
++      "type": "child<virtio-scsi-device>"
++    },
++    {
++      "name": "x-ignore-backend-features",
++      "type": "bool"
++    },
++    {
++      "name": "notify_on_empty",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "iommu_platform",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "ats",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "virtio-pci-bus-master-bug-migration",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "romfile",
++      "type": "str"
++    }
++  ],
++  "id": "libvirt-12"
++}
++
++{
++  "id": "libvirt-13",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'virtio-blk-ccw' not found"
++  }
++}
++
++{
++  "id": "libvirt-14",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'virtio-net-ccw' not found"
++  }
++}
++
++{
++  "id": "libvirt-15",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'virtio-scsi-ccw' not found"
++  }
++}
++
++{
++  "id": "libvirt-16",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'virtio-blk-s390' not found"
++  }
++}
++
++{
++  "id": "libvirt-17",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'virtio-net-s390' not found"
++  }
++}
++
++{
++  "id": "libvirt-18",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'pci-assign' not found"
++  }
++}
++
++{
++  "id": "libvirt-19",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'kvm-pci-assign' not found"
++  }
++}
++
++{
++  "return": [
++    {
++      "name": "x-pci-sub-device-id",
++      "type": "uint32"
++    },
++    {
++      "name": "x-no-kvm-msi",
++      "type": "bool"
++    },
++    {
++      "name": "rombar",
++      "type": "uint32"
++    },
++    {
++      "name": "x-pcie-lnksta-dllla",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-igd-opregion",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-vga",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pci-vendor-id",
++      "type": "uint32"
++    },
++    {
++      "name": "multifunction",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "bootindex",
++      "type": "int32"
++    },
++    {
++      "name": "x-req",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-igd-gms",
++      "type": "uint32"
++    },
++    {
++      "name": "romfile",
++      "type": "str"
++    },
++    {
++      "name": "x-no-kvm-intx",
++      "type": "bool"
++    },
++    {
++      "name": "x-pci-device-id",
++      "type": "uint32"
++    },
++    {
++      "name": "host",
++      "description": "Address (bus/device/function) of the host device, example: 04:10.0",
++      "type": "str"
++    },
++    {
++      "name": "x-no-kvm-msix",
++      "type": "bool"
++    },
++    {
++      "name": "x-intx-mmap-timeout-ms",
++      "type": "uint32"
++    },
++    {
++      "name": "command_serr_enable",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-extcap-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "addr",
++      "description": "Slot and optional function number, example: 06.0 or 06",
++      "type": "int32"
++    },
++    {
++      "name": "x-pci-sub-vendor-id",
++      "type": "uint32"
++    },
++    {
++      "name": "sysfsdev",
++      "type": "str"
++    },
++    {
++      "name": "x-no-mmap",
++      "type": "bool"
++    }
++  ],
++  "id": "libvirt-20"
++}
++
++{
++  "return": [
++    {
++      "name": "serial",
++      "type": "str"
++    },
++    {
++      "name": "port_index",
++      "type": "uint16"
++    },
++    {
++      "name": "dpofua",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "bootindex",
++      "type": "int32"
++    },
++    {
++      "name": "logical_block_size",
++      "description": "A power of two between 512 and 32768",
++      "type": "uint16"
++    },
++    {
++      "name": "discard_granularity",
++      "type": "uint32"
++    },
++    {
++      "name": "lun",
++      "type": "uint32"
++    },
++    {
++      "name": "max_unmap_size",
++      "type": "uint64"
++    },
++    {
++      "name": "drive",
++      "description": "Node name or ID of a block device to use as a backend",
++      "type": "str"
++    },
++    {
++      "name": "port_wwn",
++      "type": "uint64"
++    },
++    {
++      "name": "write-cache",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "share-rw",
++      "type": "bool"
++    },
++    {
++      "name": "opt_io_size",
++      "type": "uint32"
++    },
++    {
++      "name": "min_io_size",
++      "type": "uint16"
++    },
++    {
++      "name": "product",
++      "type": "str"
++    },
++    {
++      "name": "scsi-id",
++      "type": "uint32"
++    },
++    {
++      "name": "channel",
++      "type": "uint32"
++    },
++    {
++      "name": "vendor",
++      "type": "str"
++    },
++    {
++      "name": "wwn",
++      "type": "uint64"
++    },
++    {
++      "name": "werror",
++      "description": "Error handling policy, report/ignore/enospc/stop/auto",
++      "type": "BlockdevOnError"
++    },
++    {
++      "name": "removable",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "rerror",
++      "description": "Error handling policy, report/ignore/enospc/stop/auto",
++      "type": "BlockdevOnError"
++    },
++    {
++      "name": "ver",
++      "type": "str"
++    },
++    {
++      "name": "physical_block_size",
++      "description": "A power of two between 512 and 32768",
++      "type": "uint16"
++    },
++    {
++      "name": "max_io_size",
++      "type": "uint64"
++    }
++  ],
++  "id": "libvirt-21"
++}
++
++{
++  "return": [
++    {
++      "name": "serial",
++      "type": "str"
++    },
++    {
++      "name": "logical_block_size",
++      "description": "A power of two between 512 and 32768",
++      "type": "uint16"
++    },
++    {
++      "name": "discard_granularity",
++      "type": "uint32"
++    },
++    {
++      "name": "drive",
++      "description": "Node name or ID of a block device to use as a backend",
++      "type": "str"
++    },
++    {
++      "name": "bootindex",
++      "type": "int32"
++    },
++    {
++      "name": "write-cache",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "share-rw",
++      "type": "bool"
++    },
++    {
++      "name": "opt_io_size",
++      "type": "uint32"
++    },
++    {
++      "name": "min_io_size",
++      "type": "uint16"
++    },
++    {
++      "name": "unit",
++      "type": "uint32"
++    },
++    {
++      "name": "wwn",
++      "type": "uint64"
++    },
++    {
++      "name": "werror",
++      "description": "Error handling policy, report/ignore/enospc/stop/auto",
++      "type": "BlockdevOnError"
++    },
++    {
++      "name": "model",
++      "type": "str"
++    },
++    {
++      "name": "rerror",
++      "description": "Error handling policy, report/ignore/enospc/stop/auto",
++      "type": "BlockdevOnError"
++    },
++    {
++      "name": "ver",
++      "type": "str"
++    },
++    {
++      "name": "physical_block_size",
++      "description": "A power of two between 512 and 32768",
++      "type": "uint16"
++    }
++  ],
++  "id": "libvirt-22"
++}
++
++{
++  "id": "libvirt-23",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'PIIX4_PM' not found"
++  }
++}
++
++{
++  "id": "libvirt-24",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'usb-redir' not found"
++  }
++}
++
++{
++  "return": [
++    {
++      "name": "isobufs",
++      "type": "uint32"
++    },
++    {
++      "name": "hostaddr",
++      "type": "uint32"
++    },
++    {
++      "name": "msos-desc",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "productid",
++      "type": "uint32"
++    },
++    {
++      "name": "serial",
++      "type": "str"
++    },
++    {
++      "name": "bootindex",
++      "type": "int32"
++    },
++    {
++      "name": "isobsize",
++      "type": "uint32"
++    },
++    {
++      "name": "port",
++      "type": "str"
++    },
++    {
++      "name": "vendorid",
++      "type": "uint32"
++    },
++    {
++      "name": "pipeline",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "attached",
++      "type": "bool"
++    },
++    {
++      "name": "hostport",
++      "type": "str"
++    },
++    {
++      "name": "full-path",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "loglevel",
++      "type": "uint32"
++    },
++    {
++      "name": "hostbus",
++      "type": "uint32"
++    }
++  ],
++  "id": "libvirt-25"
++}
++
++{
++  "return": [
++    {
++      "name": "bootindex",
++      "type": "int32"
++    },
++    {
++      "name": "drive",
++      "description": "Node name or ID of a block device to use as a backend",
++      "type": "str"
++    },
++    {
++      "name": "lun",
++      "type": "uint32"
++    },
++    {
++      "name": "channel",
++      "type": "uint32"
++    },
++    {
++      "name": "scsi-id",
++      "type": "uint32"
++    }
++  ],
++  "id": "libvirt-26"
++}
++
++{
++  "id": "libvirt-27",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'i440FX-pcihost' not found"
++  }
++}
++
++{
++  "id": "libvirt-28",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'q35-pcihost' not found"
++  }
++}
++
++{
++  "return": [
++    {
++      "name": "serial",
++      "type": "str"
++    },
++    {
++      "name": "msos-desc",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "logical_block_size",
++      "description": "A power of two between 512 and 32768",
++      "type": "uint16"
++    },
++    {
++      "name": "discard_granularity",
++      "type": "uint32"
++    },
++    {
++      "name": "drive",
++      "description": "Node name or ID of a block device to use as a backend",
++      "type": "str"
++    },
++    {
++      "name": "bootindex",
++      "type": "int32"
++    },
++    {
++      "name": "write-cache",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "share-rw",
++      "type": "bool"
++    },
++    {
++      "name": "opt_io_size",
++      "type": "uint32"
++    },
++    {
++      "name": "min_io_size",
++      "type": "uint16"
++    },
++    {
++      "name": "port",
++      "type": "str"
++    },
++    {
++      "name": "attached",
++      "type": "bool"
++    },
++    {
++      "name": "full-path",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "removable",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "physical_block_size",
++      "description": "A power of two between 512 and 32768",
++      "type": "uint16"
++    }
++  ],
++  "id": "libvirt-29"
++}
++
++{
++  "id": "libvirt-30",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'kvm-pit' not found"
++  }
++}
++
++{
++  "return": [
++    {
++      "name": "rombar",
++      "type": "uint32"
++    },
++    {
++      "name": "x-pcie-lnksta-dllla",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "mmio",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "multifunction",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "qemu-extended-regs",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "big-endian-framebuffer",
++      "type": "bool"
++    },
++    {
++      "name": "romfile",
++      "type": "str"
++    },
++    {
++      "name": "vgamem_mb",
++      "type": "uint32"
++    },
++    {
++      "name": "x-pcie-extcap-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "command_serr_enable",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "addr",
++      "description": "Slot and optional function number, example: 06.0 or 06",
++      "type": "int32"
++    }
++  ],
++  "id": "libvirt-31"
++}
++
++{
++  "id": "libvirt-32",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'vmware-svga' not found"
++  }
++}
++
++{
++  "id": "libvirt-33",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'qxl' not found"
++  }
++}
++
++{
++  "return": [
++    {
++      "name": "event_idx",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "yres",
++      "type": "uint32"
++    },
++    {
++      "name": "ioeventfd",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "multifunction",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "rombar",
++      "type": "uint32"
++    },
++    {
++      "name": "xres",
++      "type": "uint32"
++    },
++    {
++      "name": "x-disable-pcie",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "indirect_desc",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "disable-modern",
++      "type": "bool"
++    },
++    {
++      "name": "disable-legacy",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "command_serr_enable",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-lnkctl-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "page-per-vq",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-deverr-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-pm-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "max_outputs",
++      "type": "uint32"
++    },
++    {
++      "name": "x-pcie-lnksta-dllla",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "any_layout",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "addr",
++      "description": "Slot and optional function number, example: 06.0 or 06",
++      "type": "int32"
++    },
++    {
++      "name": "migrate-extra",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "modern-pio-notify",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "vectors",
++      "type": "uint32"
++    },
++    {
++      "name": "x-pcie-extcap-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "virtio-backend",
++      "type": "child<virtio-gpu-device>"
++    },
++    {
++      "name": "max_hostmem",
++      "type": "size"
++    },
++    {
++      "name": "x-ignore-backend-features",
++      "type": "bool"
++    },
++    {
++      "name": "notify_on_empty",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "iommu_platform",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "ats",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "virtio-pci-bus-master-bug-migration",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "romfile",
++      "type": "str"
++    }
++  ],
++  "id": "libvirt-34"
++}
++
++{
++  "return": [
++    {
++      "name": "notify_on_empty",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "any_layout",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "indirect_desc",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "event_idx",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "yres",
++      "type": "uint32"
++    },
++    {
++      "name": "iommu_platform",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "max_outputs",
++      "type": "uint32"
++    },
++    {
++      "name": "xres",
++      "type": "uint32"
++    },
++    {
++      "name": "max_hostmem",
++      "type": "size"
++    }
++  ],
++  "id": "libvirt-35"
++}
++
++{
++  "id": "libvirt-36",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'ICH9-LPC' not found"
++  }
++}
++
++{
++  "return": [
++    {
++      "name": "guest-stats-polling-interval",
++      "type": "int"
++    },
++    {
++      "name": "event_idx",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "rombar",
++      "type": "uint32"
++    },
++    {
++      "name": "multifunction",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-disable-pcie",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "indirect_desc",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "disable-modern",
++      "type": "bool"
++    },
++    {
++      "name": "disable-legacy",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "command_serr_enable",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-lnkctl-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "guest-stats",
++      "type": "guest statistics"
++    },
++    {
++      "name": "deflate-on-oom",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "page-per-vq",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-deverr-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-pm-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-lnksta-dllla",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "any_layout",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "class",
++      "type": "uint32"
++    },
++    {
++      "name": "addr",
++      "description": "Slot and optional function number, example: 06.0 or 06",
++      "type": "int32"
++    },
++    {
++      "name": "migrate-extra",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "modern-pio-notify",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-extcap-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "virtio-backend",
++      "type": "child<virtio-balloon-device>"
++    },
++    {
++      "name": "x-ignore-backend-features",
++      "type": "bool"
++    },
++    {
++      "name": "notify_on_empty",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "iommu_platform",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "ats",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "virtio-pci-bus-master-bug-migration",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "romfile",
++      "type": "str"
++    }
++  ],
++  "id": "libvirt-37"
++}
++
++{
++  "id": "libvirt-38",
++  "error": {
++    "class": "DeviceNotFound",
++    "desc": "Device 'virtio-balloon-ccw' not found"
++  }
++}
++
++{
++  "return": [
++    {
++      "name": "notify_on_empty",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "any_layout",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "indirect_desc",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "guest-stats",
++      "type": "guest statistics"
++    },
++    {
++      "name": "guest-stats-polling-interval",
++      "type": "int"
++    },
++    {
++      "name": "event_idx",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "iommu_platform",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "deflate-on-oom",
++      "description": "on/off",
++      "type": "bool"
++    }
++  ],
++  "id": "libvirt-39"
++}
++
++{
++  "return": [
++    {
++      "name": "rombar",
++      "type": "uint32"
++    },
++    {
++      "name": "intrs",
++      "type": "uint32"
++    },
++    {
++      "name": "x-pcie-lnksta-dllla",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "msix",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "multifunction",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "msi",
++      "description": "on/off/auto",
++      "type": "OnOffAuto"
++    },
++    {
++      "name": "superspeed-ports-first",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "streams",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "romfile",
++      "type": "str"
++    },
++    {
++      "name": "force-pcie-endcap",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "command_serr_enable",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "x-pcie-extcap-init",
++      "description": "on/off",
++      "type": "bool"
++    },
++    {
++      "name": "addr",
++      "description": "Slot and optional function number, example: 06.0 or 06",
++      "type": "int32"
++    },
++    {
++      "name": "p3",
++      "type": "uint32"
++    },
++    {
++      "name": "p2",
++      "type": "uint32"
++    },
++    {
++      "name": "slots",
++      "type": "uint32"
++    }
++  ],
++  "id": "libvirt-40"
++}
++
++{
++  "return": [
++    {
++      "name": "dynamic-reconfiguration",
++      "type": "bool"
++    },
++    {
++      "name": "ddw",
++      "type": "bool"
++    },
++    {
++      "name": "dma_win_size",
++      "type": "uint64"
++    },
++    {
++      "name": "numa_node",
++      "type": "uint32"
++    },
++    {
++      "name": "pre-2.8-migration",
++      "type": "bool"
++    },
++    {
++      "name": "mem64_win_size",
++      "type": "uint64"
++    },
++    {
++      "name": "pgsz",
++      "type": "uint64"
++    },
++    {
++      "name": "liobn64",
++      "type": "uint32"
++    },
++    {
++      "name": "dma_win_addr",
++      "type": "uint64"
++    },
++    {
++      "name": "io_win_size",
++      "type": "uint64"
++    },
++    {
++      "name": "mem_win_size",
++      "type": "uint64"
++    },
++    {
++      "name": "buid",
++      "type": "uint64"
++    },
++    {
++      "name": "dma64_win_addr",
++      "type": "uint64"
++    },
++    {
++      "name": "mem64_win_addr",
++      "type": "uint64"
++    },
++    {
++      "name": "pcie-extended-configuration-space",
++      "type": "bool"
++    },
++    {
++      "name": "io_win_addr",
++      "type": "uint64"
++    },
++    {
++      "name": "liobn",
++      "type": "uint32"
++    },
++    {
++      "name": "mem_win_addr",
++      "type": "uint64"
++    },
++    {
++      "name": "mem64_win_pciaddr",
++      "type": "uint64"
++    },
++    {
++      "name": "index",
++      "type": "uint32"
++    }
++  ],
++  "id": "libvirt-41"
++}
++
++{
++  "return": [
++    {
++      "hotpluggable-cpus": false,
++      "name": "ref405ep",
++      "cpu-max": 1
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "none",
++      "cpu-max": 1
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "virtex-ml507",
++      "cpu-max": 1
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "powernv",
++      "cpu-max": 2048
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "ppce500",
++      "cpu-max": 32
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "mpc8544ds",
++      "cpu-max": 15
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "bamboo",
++      "cpu-max": 1
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "g3beige",
++      "cpu-max": 1
++    },
++    {
++      "hotpluggable-cpus": true,
++      "name": "pseries-2.10",
++      "is-default": true,
++      "cpu-max": 1024,
++      "alias": "pseries"
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "prep",
++      "cpu-max": 1
++    },
++    {
++      "hotpluggable-cpus": true,
++      "name": "pseries-2.9",
++      "cpu-max": 1024
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "mac99",
++      "cpu-max": 1
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "pseries-2.6",
++      "cpu-max": 1024
++    },
++    {
++      "hotpluggable-cpus": true,
++      "name": "pseries-2.7",
++      "cpu-max": 1024
++    },
++    {
++      "hotpluggable-cpus": true,
++      "name": "pseries-2.8",
++      "cpu-max": 1024
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "pseries-2.4",
++      "cpu-max": 1024
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "pseries-2.5",
++      "cpu-max": 1024
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "pseries-2.2",
++      "cpu-max": 1024
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "taihu",
++      "cpu-max": 1
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "pseries-2.3",
++      "cpu-max": 1024
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "pseries-2.1",
++      "cpu-max": 1024
++    },
++    {
++      "hotpluggable-cpus": false,
++      "name": "40p",
++      "cpu-max": 1
++    }
++  ],
++  "id": "libvirt-42"
++}
++
++{
++  "return": [
++    {
++      "name": "default",
++      "typename": "604-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "ppc",
++      "typename": "604-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "ppc32",
++      "typename": "604-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "ppc64",
++      "typename": "970fx_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "970mp",
++      "typename": "970mp_v1.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "970fx",
++      "typename": "970fx_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "970",
++      "typename": "970_v2.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER9",
++      "typename": "POWER9_v1.0-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER8NVL",
++      "typename": "POWER8NVL_v1.0-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER8",
++      "typename": "host-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER8E",
++      "typename": "POWER8E_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER7+",
++      "typename": "POWER7+_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER7",
++      "typename": "POWER7_v2.3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER5gs",
++      "typename": "POWER5+_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER5+",
++      "typename": "POWER5+_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Apollo7PM",
++      "typename": "7457A_v1.0-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7457A",
++      "typename": "7457A_v1.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7447A",
++      "typename": "7447A_v1.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Apollo7",
++      "typename": "7457_v1.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7457",
++      "typename": "7457_v1.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7447",
++      "typename": "7447_v1.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Apollo6",
++      "typename": "7455_v3.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7455",
++      "typename": "7455_v3.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7445",
++      "typename": "7445_v3.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7451",
++      "typename": "7451_v2.3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7441",
++      "typename": "7441_v2.3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Vger",
++      "typename": "7450_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7450",
++      "typename": "7450_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7448",
++      "typename": "7448_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Nitro",
++      "typename": "7410_v1.4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7410",
++      "typename": "7410_v1.4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "G4",
++      "typename": "7400_v2.9-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Max",
++      "typename": "7400_v2.9-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7400",
++      "typename": "7400_v2.9-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Goldfinger",
++      "typename": "755_v2.8-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "755",
++      "typename": "755_v2.8-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "745",
++      "typename": "745_v2.8-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "LoneStar",
++      "typename": "750l_v3.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750l",
++      "typename": "750l_v3.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750gx",
++      "typename": "750gx_v1.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750fx",
++      "typename": "750fx_v2.3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750cxe",
++      "typename": "750cxe_v3.1b-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750cx",
++      "typename": "750cx_v2.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750cl",
++      "typename": "750cl_v2.0-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Conan/Doyle",
++      "typename": "750p-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "G3",
++      "typename": "750_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Typhoon",
++      "typename": "750_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750",
++      "typename": "750_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Arthur",
++      "typename": "740_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "740",
++      "typename": "740_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Mach5",
++      "typename": "604r-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Sirocco",
++      "typename": "604e_v2.4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "604e",
++      "typename": "604e_v2.4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Goldeneye",
++      "typename": "603e7t-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "603r",
++      "typename": "603e7t-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Vaillant",
++      "typename": "603e7v-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Stretch",
++      "typename": "603e_v4.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "603e",
++      "typename": "603e_v4.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Vanilla",
++      "typename": "603-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "601v",
++      "typename": "601_v2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "601",
++      "typename": "601_v2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8560",
++      "typename": "MPC8560_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8555E",
++      "typename": "MPC8555E_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8555",
++      "typename": "MPC8555_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8548E",
++      "typename": "MPC8548E_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8548",
++      "typename": "MPC8548_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8547E",
++      "typename": "MPC8547E_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8545E",
++      "typename": "MPC8545E_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8545",
++      "typename": "MPC8545_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8544E",
++      "typename": "MPC8544E_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8544",
++      "typename": "MPC8544_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8543E",
++      "typename": "MPC8543E_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8543",
++      "typename": "MPC8543_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8541E",
++      "typename": "MPC8541E_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8541",
++      "typename": "MPC8541_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8540",
++      "typename": "MPC8540_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8533E",
++      "typename": "MPC8533E_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8533",
++      "typename": "MPC8533_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "e500v2",
++      "typename": "e500v2_v22-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "e500v1",
++      "typename": "e500_v20-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "e500",
++      "typename": "e500v2_v22-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8347EA",
++      "typename": "MPC8347EAT-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8347E",
++      "typename": "MPC8347ET-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8347A",
++      "typename": "MPC8347AT-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8347",
++      "typename": "MPC8347T-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "e300",
++      "typename": "e300c3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "e200",
++      "typename": "e200z6-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8280",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8275",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8272",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8271",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8270",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8266_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8266_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8266",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8265_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8265_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8265",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8264_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8264_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8264",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8260_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8260_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8260",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8255_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8255_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8255",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8250_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8250_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8250",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8248",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8247",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8245",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8241",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "PowerQUICC-II",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC82xx",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC5200B",
++      "typename": "MPC5200B_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC5200",
++      "typename": "MPC5200_v12-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC52xx",
++      "typename": "MPC5200_v12-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8240",
++      "typename": "603-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "440EP",
++      "typename": "440EPb-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "x2vp50",
++      "typename": "x2vp20-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "x2vp7",
++      "typename": "x2vp4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "405GPe",
++      "typename": "405CRc-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "405GP",
++      "typename": "405GPd-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "405CR",
++      "typename": "405CRc-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "405",
++      "typename": "405D4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "403",
++      "typename": "403GC-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7457A_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cl_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.7",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347ET",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8545E_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7455_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8547E_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "STB25",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER8_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401G2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8349A",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750e",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8545_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970fx_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fx_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER8E_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "Cobra",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.7",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603p",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8378E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500v2_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500mc",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e7v1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970mp_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8555E_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "440-Xilinx-w-dfpu",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740e",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405CRc",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7447A_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8533E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8540_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500v2_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e300c1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970fx_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750gx_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fx_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8641",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8544E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405D4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7457_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970fx_v3.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "604e_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.6",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "Npe4GS3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7410_v1.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7445_v3.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750l_v3.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8540_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "STB03",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8343A",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8378",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2HiP3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v3.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8567",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8545_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "Npe405H",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e7v",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v3.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "Npe405H2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.6",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405GPa",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8541E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750l_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8555E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7457A_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e200z6",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8379E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500v2_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347AP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401B2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8349E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.8",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8547E_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7455_v3.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7448_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8567E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7441_v2.10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v1.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2leGP1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7451_v2.10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8343E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cx_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "Npe405L",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e7",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401A1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8377",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7448_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7441_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405CRb",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7447A_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8540_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7445_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750gx_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "604",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v2.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543E_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347AT",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750l_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER8NVL_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7457A_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7457_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7450_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8572",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.5",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7410_v1.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405GPR",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8541_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401C2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500v2_v30",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7455_v3.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405EZ",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8568E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v1.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8560_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "host",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8560_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2H4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8533_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v3.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e200z5",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8349",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405CRa",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543E_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.7",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "403GC",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e5500",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7448_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC5200_v12",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7410_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "x2vp4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8555_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8541_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405LP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fx_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405EP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "601_v2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8544_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401D2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8572E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "604e_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cx_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC5200B_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750l_v3.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e300c4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7448_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7450_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2leGP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v3.1b",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.9",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2GP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405GPd",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548E_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e7t",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "IOP480",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750gx_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8560_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405D2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fl",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750l_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "x2vp20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e600",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7450_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7445_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2LS",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543E_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7447_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7455_v3.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347P",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "440EPb",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC603",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fx_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER9_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8544_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "601_v1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER7+_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cx_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347EAP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401E2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8641D",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e300c3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8533_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7441_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v3.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER5+_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "602",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2leLS",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8343",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cx_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "604e_v2.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.8",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.6",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548E_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2le",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "403GB",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8545E_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER7_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7450_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC5200_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347EP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7410_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750gl",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "403GCX",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750p",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8555_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7445_v3.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347T",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "440-Xilinx",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740p",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC5200B_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "440EPX",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7451_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7450_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.8",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7455_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405GPc",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347EAT",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970mp_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e7v2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "604r",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7447A_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8533E_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500v2_v22",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401F2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8343EA",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7457_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7447_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970fx_v3.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.5",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548E_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8610",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v2.4b",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC5200_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "403GA",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7410_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2leGP3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7445_v3.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v4.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "440EPa",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970fx_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8377E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fx_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "601_v0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "STB04",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2HiP4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cl_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxr",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8349EA",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v3.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8379",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8568",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e300c2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v3.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8544E_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405GPb",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8541E_v11",
++      "typename": "",
++      "static": false
++    }
++  ],
++  "id": "libvirt-43"
++}
++
++{
++  "return": [
++  ],
++  "id": "libvirt-44"
++}
++
++{
++  "return": [
++  ],
++  "id": "libvirt-45"
++}
++
++{
++  "return": [
++    {
++      "parameters": [
++        {
++          "name": "timeout",
++          "help": "Request timeout in seconds (default 0 = no timeout)",
++          "type": "number"
++        },
++        {
++          "name": "initiator-name",
++          "help": "Initiator iqn name to use when connecting",
++          "type": "string"
++        },
++        {
++          "name": "header-digest",
++          "help": "HeaderDigest setting. {CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}",
++          "type": "string"
++        },
++        {
++          "name": "password-secret",
++          "help": "ID of the secret providing password for CHAP authentication to target",
++          "type": "string"
++        },
++        {
++          "name": "password",
++          "help": "password for CHAP authentication to target",
++          "type": "string"
++        },
++        {
++          "name": "user",
++          "help": "username for CHAP authentication to target",
++          "type": "string"
++        }
++      ],
++      "option": "iscsi"
++    },
++    {
++      "parameters": [
++        {
++          "name": "non-adaptive",
++          "type": "boolean"
++        },
++        {
++          "name": "lossy",
++          "type": "boolean"
++        },
++        {
++          "name": "acl",
++          "type": "boolean"
++        },
++        {
++          "name": "x509verify",
++          "type": "string"
++        },
++        {
++          "name": "tls",
++          "type": "boolean"
++        },
++        {
++          "name": "sasl",
++          "type": "boolean"
++        },
++        {
++          "name": "key-delay-ms",
++          "type": "number"
++        },
++        {
++          "name": "lock-key-sync",
++          "type": "boolean"
++        },
++        {
++          "name": "reverse",
++          "type": "boolean"
++        },
++        {
++          "name": "password",
++          "type": "boolean"
++        },
++        {
++          "name": "ipv6",
++          "type": "boolean"
++        },
++        {
++          "name": "ipv4",
++          "type": "boolean"
++        },
++        {
++          "name": "to",
++          "type": "number"
++        },
++        {
++          "name": "connections",
++          "type": "number"
++        },
++        {
++          "name": "head",
++          "type": "number"
++        },
++        {
++          "name": "display",
++          "type": "string"
++        },
++        {
++          "name": "share",
++          "type": "string"
++        },
++        {
++          "name": "x509",
++          "type": "string"
++        },
++        {
++          "name": "tls-creds",
++          "type": "string"
++        },
++        {
++          "name": "websocket",
++          "type": "string"
++        },
++        {
++          "name": "vnc",
++          "type": "string"
++        }
++      ],
++      "option": "vnc"
++    },
++    {
++      "parameters": [
++        {
++          "name": "dmode",
++          "type": "number"
++        },
++        {
++          "name": "fmode",
++          "type": "number"
++        },
++        {
++          "name": "sock_fd",
++          "type": "number"
++        },
++        {
++          "name": "socket",
++          "type": "string"
++        },
++        {
++          "name": "readonly",
++          "type": "boolean"
++        },
++        {
++          "name": "writeout",
++          "type": "string"
++        },
++        {
++          "name": "security_model",
++          "type": "string"
++        },
++        {
++          "name": "mount_tag",
++          "type": "string"
++        },
++        {
++          "name": "path",
++          "type": "string"
++        },
++        {
++          "name": "fsdriver",
++          "type": "string"
++        }
++      ],
++      "option": "virtfs"
++    },
++    {
++      "parameters": [
++        {
++          "name": "throttling.iops-size",
++          "help": "when limiting by iops max size of an I/O in bytes",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-write-max-length",
++          "help": "length of the bps-write-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-read-max-length",
++          "help": "length of the bps-read-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-total-max-length",
++          "help": "length of the bps-total-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-write-max-length",
++          "help": "length of the iops-write-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-read-max-length",
++          "help": "length of the iops-read-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-total-max-length",
++          "help": "length of the iops-total-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-write-max",
++          "help": "total bytes write burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-read-max",
++          "help": "total bytes read burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-total-max",
++          "help": "total bytes burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-write-max",
++          "help": "I/O operations write burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-read-max",
++          "help": "I/O operations read burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-total-max",
++          "help": "I/O operations burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-write",
++          "help": "limit write bytes per second",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-read",
++          "help": "limit read bytes per second",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-total",
++          "help": "limit total bytes per second",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-write",
++          "help": "limit write operations per second",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-read",
++          "help": "limit read operations per second",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-total",
++          "help": "limit total I/O operations per second",
++          "type": "number"
++        },
++        {
++          "name": "dmode",
++          "type": "number"
++        },
++        {
++          "name": "fmode",
++          "type": "number"
++        },
++        {
++          "name": "sock_fd",
++          "type": "number"
++        },
++        {
++          "name": "socket",
++          "type": "string"
++        },
++        {
++          "name": "readonly",
++          "type": "boolean"
++        },
++        {
++          "name": "writeout",
++          "type": "string"
++        },
++        {
++          "name": "security_model",
++          "type": "string"
++        },
++        {
++          "name": "path",
++          "type": "string"
++        },
++        {
++          "name": "fsdriver",
++          "type": "string"
++        }
++      ],
++      "option": "fsdev"
++    },
++    {
++      "parameters": [
++        {
++          "name": "string",
++          "help": "Sets content of the blob to be inserted from a string",
++          "type": "string"
++        },
++        {
++          "name": "file",
++          "help": "Sets the name of the file from which\nthe fw_cfg blob will be loaded",
++          "type": "string"
++        },
++        {
++          "name": "name",
++          "help": "Sets the fw_cfg name of the blob to be inserted",
++          "type": "string"
++        }
++      ],
++      "option": "fw_cfg"
++    },
++    {
++      "parameters": [
++        {
++          "name": "arg",
++          "type": "string"
++        },
++        {
++          "name": "target",
++          "type": "string"
++        },
++        {
++          "name": "enable",
++          "type": "boolean"
++        }
++      ],
++      "option": "semihosting-config"
++    },
++    {
++      "parameters": [
++        {
++          "name": "rrsnapshot",
++          "type": "string"
++        },
++        {
++          "name": "rrfile",
++          "type": "string"
++        },
++        {
++          "name": "rr",
++          "type": "string"
++        },
++        {
++          "name": "sleep",
++          "type": "boolean"
++        },
++        {
++          "name": "align",
++          "type": "boolean"
++        },
++        {
++          "name": "shift",
++          "type": "string"
++        }
++      ],
++      "option": "icount"
++    },
++    {
++      "parameters": [
++      ],
++      "option": "numa"
++    },
++    {
++      "parameters": [
++        {
++          "name": "debug-threads",
++          "help": "When enabled, name the individual threads; defaults off.\nNOTE: The thread names are for debugging and not a\nstable API.",
++          "type": "boolean"
++        },
++        {
++          "name": "process",
++          "help": "Sets the name of the QEMU process, as shown in top etc",
++          "type": "string"
++        },
++        {
++          "name": "guest",
++          "help": "Sets the name of the guest.\nThis name will be displayed in the SDL window caption.\nThe name will also be used for the VNC server",
++          "type": "string"
++        }
++      ],
++      "option": "name"
++    },
++    {
++      "parameters": [
++        {
++          "name": "timestamp",
++          "type": "boolean"
++        }
++      ],
++      "option": "msg"
++    },
++    {
++      "parameters": [
++        {
++          "name": "mlock",
++          "type": "boolean"
++        }
++      ],
++      "option": "realtime"
++    },
++    {
++      "parameters": [
++      ],
++      "option": "tpmdev"
++    },
++    {
++      "parameters": [
++      ],
++      "option": "object"
++    },
++    {
++      "parameters": [
++        {
++          "name": "opaque",
++          "help": "free-form string used to describe fd",
++          "type": "string"
++        },
++        {
++          "name": "set",
++          "help": "ID of the fd set to add fd to",
++          "type": "number"
++        },
++        {
++          "name": "fd",
++          "help": "file descriptor of which a duplicate is added to fd set",
++          "type": "number"
++        }
++      ],
++      "option": "add-fd"
++    },
++    {
++      "parameters": [
++        {
++          "name": "enable",
++          "type": "boolean"
++        }
++      ],
++      "option": "sandbox"
++    },
++    {
++      "parameters": [
++        {
++          "name": "strict",
++          "type": "boolean"
++        },
++        {
++          "name": "reboot-timeout",
++          "type": "string"
++        },
++        {
++          "name": "splash-time",
++          "type": "string"
++        },
++        {
++          "name": "splash",
++          "type": "string"
++        },
++        {
++          "name": "menu",
++          "type": "boolean"
++        },
++        {
++          "name": "once",
++          "type": "string"
++        },
++        {
++          "name": "order",
++          "type": "string"
++        }
++      ],
++      "option": "boot-opts"
++    },
++    {
++      "parameters": [
++        {
++          "name": "maxcpus",
++          "type": "number"
++        },
++        {
++          "name": "threads",
++          "type": "number"
++        },
++        {
++          "name": "cores",
++          "type": "number"
++        },
++        {
++          "name": "sockets",
++          "type": "number"
++        },
++        {
++          "name": "cpus",
++          "type": "number"
++        }
++      ],
++      "option": "smp-opts"
++    },
++    {
++      "parameters": [
++        {
++          "name": "maxmem",
++          "type": "size"
++        },
++        {
++          "name": "slots",
++          "type": "number"
++        },
++        {
++          "name": "size",
++          "type": "size"
++        }
++      ],
++      "option": "memory"
++    },
++    {
++      "parameters": [
++        {
++          "name": "thread",
++          "help": "Enable/disable multi-threaded TCG",
++          "type": "string"
++        },
++        {
++          "name": "accel",
++          "help": "Select the type of accelerator",
++          "type": "string"
++        }
++      ],
++      "option": "accel"
++    },
++    {
++      "parameters": [
++        {
++          "name": "loadparm",
++          "help": "Up to 8 chars in set of [A-Za-z0-9. ](lower case chars converted to upper case) to pass to machine loader, boot manager, and guest kernel",
++          "type": "string"
++        },
++        {
++          "name": "dea-key-wrap",
++          "help": "enable/disable DEA key wrapping using the CPACF wrapping key",
++          "type": "boolean"
++        },
++        {
++          "name": "aes-key-wrap",
++          "help": "enable/disable AES key wrapping using the CPACF wrapping key",
++          "type": "boolean"
++        },
++        {
++          "name": "suppress-vmdesc",
++          "help": "Set on to disable self-describing migration",
++          "type": "boolean"
++        },
++        {
++          "name": "iommu",
++          "help": "Set on/off to enable/disable Intel IOMMU (VT-d)",
++          "type": "boolean"
++        },
++        {
++          "name": "firmware",
++          "help": "firmware image",
++          "type": "string"
++        },
++        {
++          "name": "usb",
++          "help": "Set on/off to enable/disable usb",
++          "type": "boolean"
++        },
++        {
++          "name": "mem-merge",
++          "help": "enable/disable memory merge support",
++          "type": "boolean"
++        },
++        {
++          "name": "dump-guest-core",
++          "help": "Include guest memory in  a core dump",
++          "type": "boolean"
++        },
++        {
++          "name": "dt_compatible",
++          "help": "Overrides the \"compatible\" property of the dt root node",
++          "type": "string"
++        },
++        {
++          "name": "phandle_start",
++          "help": "The first phandle ID we may generate dynamically",
++          "type": "number"
++        },
++        {
++          "name": "dumpdtb",
++          "help": "Dump current dtb to a file and quit",
++          "type": "string"
++        },
++        {
++          "name": "dtb",
++          "help": "Linux kernel device tree file",
++          "type": "string"
++        },
++        {
++          "name": "append",
++          "help": "Linux kernel command line",
++          "type": "string"
++        },
++        {
++          "name": "initrd",
++          "help": "Linux initial ramdisk file",
++          "type": "string"
++        },
++        {
++          "name": "kernel",
++          "help": "Linux kernel image file",
++          "type": "string"
++        },
++        {
++          "name": "kvm_shadow_mem",
++          "help": "KVM shadow MMU size",
++          "type": "size"
++        },
++        {
++          "name": "kernel_irqchip",
++          "help": "use KVM in-kernel irqchip",
++          "type": "boolean"
++        },
++        {
++          "name": "accel",
++          "help": "accelerator list",
++          "type": "string"
++        },
++        {
++          "name": "type",
++          "help": "emulated machine",
++          "type": "string"
++        }
++      ],
++      "option": "machine"
++    },
++    {
++      "parameters": [
++        {
++          "name": "romfile",
++          "type": "string"
++        },
++        {
++          "name": "bootindex",
++          "type": "number"
++        }
++      ],
++      "option": "option-rom"
++    },
++    {
++      "parameters": [
++        {
++          "name": "file",
++          "type": "string"
++        },
++        {
++          "name": "events",
++          "type": "string"
++        },
++        {
++          "name": "enable",
++          "type": "string"
++        }
++      ],
++      "option": "trace"
++    },
++    {
++      "parameters": [
++        {
++          "name": "pretty",
++          "type": "boolean"
++        },
++        {
++          "name": "default",
++          "type": "boolean"
++        },
++        {
++          "name": "chardev",
++          "type": "string"
++        },
++        {
++          "name": "mode",
++          "type": "string"
++        }
++      ],
++      "option": "mon"
++    },
++    {
++      "parameters": [
++        {
++          "name": "value",
++          "type": "string"
++        },
++        {
++          "name": "property",
++          "type": "string"
++        },
++        {
++          "name": "driver",
++          "type": "string"
++        }
++      ],
++      "option": "global"
++    },
++    {
++      "parameters": [
++        {
++          "name": "driftfix",
++          "type": "string"
++        },
++        {
++          "name": "clock",
++          "type": "string"
++        },
++        {
++          "name": "base",
++          "type": "string"
++        }
++      ],
++      "option": "rtc"
++    },
++    {
++      "parameters": [
++      ],
++      "option": "net"
++    },
++    {
++      "parameters": [
++      ],
++      "option": "netdev"
++    },
++    {
++      "parameters": [
++      ],
++      "option": "device"
++    },
++    {
++      "parameters": [
++        {
++          "name": "logappend",
++          "type": "boolean"
++        },
++        {
++          "name": "logfile",
++          "type": "string"
++        },
++        {
++          "name": "append",
++          "type": "boolean"
++        },
++        {
++          "name": "chardev",
++          "type": "string"
++        },
++        {
++          "name": "size",
++          "type": "size"
++        },
++        {
++          "name": "debug",
++          "type": "number"
++        },
++        {
++          "name": "name",
++          "type": "string"
++        },
++        {
++          "name": "signal",
++          "type": "boolean"
++        },
++        {
++          "name": "mux",
++          "type": "boolean"
++        },
++        {
++          "name": "rows",
++          "type": "number"
++        },
++        {
++          "name": "cols",
++          "type": "number"
++        },
++        {
++          "name": "height",
++          "type": "number"
++        },
++        {
++          "name": "width",
++          "type": "number"
++        },
++        {
++          "name": "tls-creds",
++          "type": "string"
++        },
++        {
++          "name": "tn3270",
++          "type": "boolean"
++        },
++        {
++          "name": "telnet",
++          "type": "boolean"
++        },
++        {
++          "name": "reconnect",
++          "type": "number"
++        },
++        {
++          "name": "delay",
++          "type": "boolean"
++        },
++        {
++          "name": "server",
++          "type": "boolean"
++        },
++        {
++          "name": "wait",
++          "type": "boolean"
++        },
++        {
++          "name": "ipv6",
++          "type": "boolean"
++        },
++        {
++          "name": "ipv4",
++          "type": "boolean"
++        },
++        {
++          "name": "to",
++          "type": "number"
++        },
++        {
++          "name": "localport",
++          "type": "string"
++        },
++        {
++          "name": "localaddr",
++          "type": "string"
++        },
++        {
++          "name": "port",
++          "type": "string"
++        },
++        {
++          "name": "host",
++          "type": "string"
++        },
++        {
++          "name": "path",
++          "type": "string"
++        },
++        {
++          "name": "backend",
++          "type": "string"
++        }
++      ],
++      "option": "chardev"
++    },
++    {
++      "parameters": [
++        {
++          "name": "copy-on-read",
++          "help": "copy read data from backing file into image file",
++          "type": "boolean"
++        },
++        {
++          "name": "werror",
++          "help": "write error action",
++          "type": "string"
++        },
++        {
++          "name": "rerror",
++          "help": "read error action",
++          "type": "string"
++        },
++        {
++          "name": "read-only",
++          "help": "open drive file as read-only",
++          "type": "boolean"
++        },
++        {
++          "name": "file",
++          "help": "file name",
++          "type": "string"
++        },
++        {
++          "name": "serial",
++          "help": "disk serial number",
++          "type": "string"
++        },
++        {
++          "name": "addr",
++          "help": "pci address (virtio only)",
++          "type": "string"
++        },
++        {
++          "name": "boot",
++          "help": "(deprecated, ignored)",
++          "type": "boolean"
++        },
++        {
++          "name": "trans",
++          "help": "chs translation (auto, lba, none)",
++          "type": "string"
++        },
++        {
++          "name": "secs",
++          "help": "number of sectors (ide disk geometry)",
++          "type": "number"
++        },
++        {
++          "name": "heads",
++          "help": "number of heads (ide disk geometry)",
++          "type": "number"
++        },
++        {
++          "name": "cyls",
++          "help": "number of cylinders (ide disk geometry)",
++          "type": "number"
++        },
++        {
++          "name": "if",
++          "help": "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
++          "type": "string"
++        },
++        {
++          "name": "media",
++          "help": "media type (disk, cdrom)",
++          "type": "string"
++        },
++        {
++          "name": "index",
++          "help": "index number",
++          "type": "number"
++        },
++        {
++          "name": "unit",
++          "help": "unit number (i.e. lun for scsi)",
++          "type": "number"
++        },
++        {
++          "name": "bus",
++          "help": "bus number",
++          "type": "number"
++        },
++        {
++          "name": "stats-account-failed",
++          "help": "whether to account for failed I/O operations in the statistics",
++          "type": "boolean"
++        },
++        {
++          "name": "stats-account-invalid",
++          "help": "whether to account for invalid I/O operations in the statistics",
++          "type": "boolean"
++        },
++        {
++          "name": "detect-zeroes",
++          "help": "try to optimize zero writes (off, on, unmap)",
++          "type": "string"
++        },
++        {
++          "name": "throttling.group",
++          "help": "name of the block throttling group",
++          "type": "string"
++        },
++        {
++          "name": "throttling.iops-size",
++          "help": "when limiting by iops max size of an I/O in bytes",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-write-max-length",
++          "help": "length of the bps-write-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-read-max-length",
++          "help": "length of the bps-read-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-total-max-length",
++          "help": "length of the bps-total-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-write-max-length",
++          "help": "length of the iops-write-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-read-max-length",
++          "help": "length of the iops-read-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-total-max-length",
++          "help": "length of the iops-total-max burst period, in seconds",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-write-max",
++          "help": "total bytes write burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-read-max",
++          "help": "total bytes read burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-total-max",
++          "help": "total bytes burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-write-max",
++          "help": "I/O operations write burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-read-max",
++          "help": "I/O operations read burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-total-max",
++          "help": "I/O operations burst",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-write",
++          "help": "limit write bytes per second",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-read",
++          "help": "limit read bytes per second",
++          "type": "number"
++        },
++        {
++          "name": "throttling.bps-total",
++          "help": "limit total bytes per second",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-write",
++          "help": "limit write operations per second",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-read",
++          "help": "limit read operations per second",
++          "type": "number"
++        },
++        {
++          "name": "throttling.iops-total",
++          "help": "limit total I/O operations per second",
++          "type": "number"
++        },
++        {
++          "name": "werror",
++          "help": "write error action",
++          "type": "string"
++        },
++        {
++          "name": "format",
++          "help": "disk format (raw, qcow2, ...)",
++          "type": "string"
++        },
++        {
++          "name": "cache.writeback",
++          "help": "Enable writeback mode",
++          "type": "boolean"
++        },
++        {
++          "name": "aio",
++          "help": "host AIO implementation (threads, native)",
++          "type": "string"
++        },
++        {
++          "name": "snapshot",
++          "help": "enable/disable snapshot mode",
++          "type": "boolean"
++        },
++        {
++          "name": "force-share",
++          "help": "always accept other writers (default: off)",
++          "type": "boolean"
++        },
++        {
++          "name": "discard",
++          "help": "discard operation (ignore/off, unmap/on)",
++          "type": "string"
++        },
++        {
++          "name": "read-only",
++          "help": "Node is opened in read-only mode",
++          "type": "boolean"
++        },
++        {
++          "name": "cache.no-flush",
++          "help": "Ignore flush requests",
++          "type": "boolean"
++        },
++        {
++          "name": "cache.direct",
++          "help": "Bypass software writeback cache on the host",
++          "type": "boolean"
++        },
++        {
++          "name": "driver",
++          "help": "Block driver to use for the node",
++          "type": "string"
++        },
++        {
++          "name": "node-name",
++          "help": "Node name of the block device node",
++          "type": "string"
++        }
++      ],
++      "option": "drive"
++    }
++  ],
++  "id": "libvirt-46"
++}
++
++{
++  "return": [
++    {
++      "state": false,
++      "capability": "xbzrle"
++    },
++    {
++      "state": false,
++      "capability": "rdma-pin-all"
++    },
++    {
++      "state": false,
++      "capability": "auto-converge"
++    },
++    {
++      "state": false,
++      "capability": "zero-blocks"
++    },
++    {
++      "state": false,
++      "capability": "compress"
++    },
++    {
++      "state": false,
++      "capability": "events"
++    },
++    {
++      "state": false,
++      "capability": "postcopy-ram"
++    },
++    {
++      "state": false,
++      "capability": "x-colo"
++    },
++    {
++      "state": false,
++      "capability": "release-ram"
++    },
++    {
++      "state": false,
++      "capability": "block"
++    },
++    {
++      "state": false,
++      "capability": "return-path"
++    }
++  ],
++  "id": "libvirt-47"
++}
++
++{
++  "return": [
++    {
++      "name": "ACPI_DEVICE_OST",
++      "meta-type": "event",
++      "arg-type": "0"
++    },
++    {
++      "name": "BALLOON_CHANGE",
++      "meta-type": "event",
++      "arg-type": "1"
++    },
++    {
++      "name": "BLOCK_IMAGE_CORRUPTED",
++      "meta-type": "event",
++      "arg-type": "2"
++    },
++    {
++      "name": "BLOCK_IO_ERROR",
++      "meta-type": "event",
++      "arg-type": "3"
++    },
++    {
++      "name": "BLOCK_JOB_CANCELLED",
++      "meta-type": "event",
++      "arg-type": "4"
++    },
++    {
++      "name": "BLOCK_JOB_COMPLETED",
++      "meta-type": "event",
++      "arg-type": "5"
++    },
++    {
++      "name": "BLOCK_JOB_ERROR",
++      "meta-type": "event",
++      "arg-type": "6"
++    },
++    {
++      "name": "BLOCK_JOB_READY",
++      "meta-type": "event",
++      "arg-type": "7"
++    },
++    {
++      "name": "BLOCK_WRITE_THRESHOLD",
++      "meta-type": "event",
++      "arg-type": "8"
++    },
++    {
++      "name": "DEVICE_DELETED",
++      "meta-type": "event",
++      "arg-type": "9"
++    },
++    {
++      "name": "DEVICE_TRAY_MOVED",
++      "meta-type": "event",
++      "arg-type": "10"
++    },
++    {
++      "name": "DUMP_COMPLETED",
++      "meta-type": "event",
++      "arg-type": "11"
++    },
++    {
++      "name": "GUEST_PANICKED",
++      "meta-type": "event",
++      "arg-type": "12"
++    },
++    {
++      "name": "MEM_UNPLUG_ERROR",
++      "meta-type": "event",
++      "arg-type": "13"
++    },
++    {
++      "name": "MIGRATION",
++      "meta-type": "event",
++      "arg-type": "14"
++    },
++    {
++      "name": "MIGRATION_PASS",
++      "meta-type": "event",
++      "arg-type": "15"
++    },
++    {
++      "name": "NIC_RX_FILTER_CHANGED",
++      "meta-type": "event",
++      "arg-type": "16"
++    },
++    {
++      "name": "POWERDOWN",
++      "meta-type": "event",
++      "arg-type": "17"
++    },
++    {
++      "name": "QUORUM_FAILURE",
++      "meta-type": "event",
++      "arg-type": "18"
++    },
++    {
++      "name": "QUORUM_REPORT_BAD",
++      "meta-type": "event",
++      "arg-type": "19"
++    },
++    {
++      "name": "RESET",
++      "meta-type": "event",
++      "arg-type": "20"
++    },
++    {
++      "name": "RESUME",
++      "meta-type": "event",
++      "arg-type": "17"
++    },
++    {
++      "name": "RTC_CHANGE",
++      "meta-type": "event",
++      "arg-type": "21"
++    },
++    {
++      "name": "SHUTDOWN",
++      "meta-type": "event",
++      "arg-type": "22"
++    },
++    {
++      "name": "SPICE_CONNECTED",
++      "meta-type": "event",
++      "arg-type": "23"
++    },
++    {
++      "name": "SPICE_DISCONNECTED",
++      "meta-type": "event",
++      "arg-type": "24"
++    },
++    {
++      "name": "SPICE_INITIALIZED",
++      "meta-type": "event",
++      "arg-type": "25"
++    },
++    {
++      "name": "SPICE_MIGRATE_COMPLETED",
++      "meta-type": "event",
++      "arg-type": "17"
++    },
++    {
++      "name": "STOP",
++      "meta-type": "event",
++      "arg-type": "17"
++    },
++    {
++      "name": "SUSPEND",
++      "meta-type": "event",
++      "arg-type": "17"
++    },
++    {
++      "name": "SUSPEND_DISK",
++      "meta-type": "event",
++      "arg-type": "17"
++    },
++    {
++      "name": "VNC_CONNECTED",
++      "meta-type": "event",
++      "arg-type": "26"
++    },
++    {
++      "name": "VNC_DISCONNECTED",
++      "meta-type": "event",
++      "arg-type": "27"
++    },
++    {
++      "name": "VNC_INITIALIZED",
++      "meta-type": "event",
++      "arg-type": "28"
++    },
++    {
++      "name": "VSERPORT_CHANGE",
++      "meta-type": "event",
++      "arg-type": "29"
++    },
++    {
++      "name": "WAKEUP",
++      "meta-type": "event",
++      "arg-type": "17"
++    },
++    {
++      "name": "WATCHDOG",
++      "meta-type": "event",
++      "arg-type": "30"
++    },
++    {
++      "name": "add-fd",
++      "ret-type": "32",
++      "meta-type": "command",
++      "arg-type": "31"
++    },
++    {
++      "name": "add_client",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "33"
++    },
++    {
++      "name": "balloon",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "34"
++    },
++    {
++      "name": "block-commit",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "35"
++    },
++    {
++      "name": "block-dirty-bitmap-add",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "36"
++    },
++    {
++      "name": "block-dirty-bitmap-clear",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "37"
++    },
++    {
++      "name": "block-dirty-bitmap-remove",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "37"
++    },
++    {
++      "name": "block-job-cancel",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "38"
++    },
++    {
++      "name": "block-job-complete",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "39"
++    },
++    {
++      "name": "block-job-pause",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "40"
++    },
++    {
++      "name": "block-job-resume",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "41"
++    },
++    {
++      "name": "block-job-set-speed",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "42"
++    },
++    {
++      "name": "block-set-write-threshold",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "43"
++    },
++    {
++      "name": "block-stream",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "44"
++    },
++    {
++      "name": "block_passwd",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "45"
++    },
++    {
++      "name": "block_resize",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "46"
++    },
++    {
++      "name": "block_set_io_throttle",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "47"
++    },
++    {
++      "name": "blockdev-add",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "48"
++    },
++    {
++      "name": "blockdev-backup",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "49"
++    },
++    {
++      "name": "blockdev-change-medium",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "50"
++    },
++    {
++      "name": "blockdev-close-tray",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "51"
++    },
++    {
++      "name": "blockdev-del",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "52"
++    },
++    {
++      "name": "blockdev-mirror",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "53"
++    },
++    {
++      "name": "blockdev-open-tray",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "54"
++    },
++    {
++      "name": "blockdev-snapshot",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "55"
++    },
++    {
++      "name": "blockdev-snapshot-delete-internal-sync",
++      "ret-type": "57",
++      "meta-type": "command",
++      "arg-type": "56"
++    },
++    {
++      "name": "blockdev-snapshot-internal-sync",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "58"
++    },
++    {
++      "name": "blockdev-snapshot-sync",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "59"
++    },
++    {
++      "name": "change",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "60"
++    },
++    {
++      "name": "change-backing-file",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "61"
++    },
++    {
++      "name": "change-vnc-password",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "62"
++    },
++    {
++      "name": "chardev-add",
++      "ret-type": "64",
++      "meta-type": "command",
++      "arg-type": "63"
++    },
++    {
++      "name": "chardev-change",
++      "ret-type": "64",
++      "meta-type": "command",
++      "arg-type": "65"
++    },
++    {
++      "name": "chardev-remove",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "66"
++    },
++    {
++      "name": "chardev-send-break",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "67"
++    },
++    {
++      "name": "client_migrate_info",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "68"
++    },
++    {
++      "name": "closefd",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "69"
++    },
++    {
++      "name": "cont",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "cpu",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "70"
++    },
++    {
++      "name": "cpu-add",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "71"
++    },
++    {
++      "name": "device-list-properties",
++      "ret-type": "[73]",
++      "meta-type": "command",
++      "arg-type": "72"
++    },
++    {
++      "name": "device_add",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "74"
++    },
++    {
++      "name": "device_del",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "75"
++    },
++    {
++      "name": "drive-backup",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "76"
++    },
++    {
++      "name": "drive-mirror",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "77"
++    },
++    {
++      "name": "dump-guest-memory",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "78"
++    },
++    {
++      "name": "dump-skeys",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "79"
++    },
++    {
++      "name": "eject",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "80"
++    },
++    {
++      "name": "expire_password",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "81"
++    },
++    {
++      "name": "getfd",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "82"
++    },
++    {
++      "name": "human-monitor-command",
++      "ret-type": "str",
++      "meta-type": "command",
++      "arg-type": "83"
++    },
++    {
++      "name": "inject-nmi",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "input-send-event",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "84"
++    },
++    {
++      "name": "memsave",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "85"
++    },
++    {
++      "name": "migrate",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "86"
++    },
++    {
++      "name": "migrate-incoming",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "87"
++    },
++    {
++      "name": "migrate-set-cache-size",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "88"
++    },
++    {
++      "name": "migrate-set-capabilities",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "89"
++    },
++    {
++      "name": "migrate-set-parameters",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "90"
++    },
++    {
++      "name": "migrate-start-postcopy",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "migrate_cancel",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "migrate_set_downtime",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "91"
++    },
++    {
++      "name": "migrate_set_speed",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "92"
++    },
++    {
++      "name": "nbd-server-add",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "93"
++    },
++    {
++      "name": "nbd-server-start",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "94"
++    },
++    {
++      "name": "nbd-server-stop",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "netdev_add",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "95"
++    },
++    {
++      "name": "netdev_del",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "96"
++    },
++    {
++      "name": "object-add",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "97"
++    },
++    {
++      "name": "object-del",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "98"
++    },
++    {
++      "name": "pmemsave",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "99"
++    },
++    {
++      "name": "qmp_capabilities",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "qom-get",
++      "ret-type": "any",
++      "meta-type": "command",
++      "arg-type": "100"
++    },
++    {
++      "name": "qom-list",
++      "ret-type": "[102]",
++      "meta-type": "command",
++      "arg-type": "101"
++    },
++    {
++      "name": "qom-list-types",
++      "ret-type": "[104]",
++      "meta-type": "command",
++      "arg-type": "103"
++    },
++    {
++      "name": "qom-set",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "105"
++    },
++    {
++      "name": "query-acpi-ospm-status",
++      "ret-type": "[106]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-balloon",
++      "ret-type": "107",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-block",
++      "ret-type": "[108]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-block-jobs",
++      "ret-type": "[109]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-blockstats",
++      "ret-type": "[111]",
++      "meta-type": "command",
++      "arg-type": "110"
++    },
++    {
++      "name": "query-chardev",
++      "ret-type": "[112]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-chardev-backends",
++      "ret-type": "[113]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-command-line-options",
++      "ret-type": "[115]",
++      "meta-type": "command",
++      "arg-type": "114"
++    },
++    {
++      "name": "query-commands",
++      "ret-type": "[116]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-cpu-definitions",
++      "ret-type": "[117]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-cpu-model-baseline",
++      "ret-type": "119",
++      "meta-type": "command",
++      "arg-type": "118"
++    },
++    {
++      "name": "query-cpu-model-comparison",
++      "ret-type": "121",
++      "meta-type": "command",
++      "arg-type": "120"
++    },
++    {
++      "name": "query-cpu-model-expansion",
++      "ret-type": "123",
++      "meta-type": "command",
++      "arg-type": "122"
++    },
++    {
++      "name": "query-cpus",
++      "ret-type": "[124]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-dump",
++      "ret-type": "125",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-dump-guest-memory-capability",
++      "ret-type": "126",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-events",
++      "ret-type": "[127]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-fdsets",
++      "ret-type": "[128]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-gic-capabilities",
++      "ret-type": "[129]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-hotpluggable-cpus",
++      "ret-type": "[130]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-iothreads",
++      "ret-type": "[131]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-kvm",
++      "ret-type": "132",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-machines",
++      "ret-type": "[133]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-memdev",
++      "ret-type": "[134]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-memory-devices",
++      "ret-type": "[135]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-mice",
++      "ret-type": "[136]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-migrate",
++      "ret-type": "137",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-migrate-cache-size",
++      "ret-type": "int",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-migrate-capabilities",
++      "ret-type": "[138]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-migrate-parameters",
++      "ret-type": "139",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-name",
++      "ret-type": "140",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-named-block-nodes",
++      "ret-type": "[141]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-pci",
++      "ret-type": "[142]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-qmp-schema",
++      "ret-type": "[143]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-rocker",
++      "ret-type": "145",
++      "meta-type": "command",
++      "arg-type": "144"
++    },
++    {
++      "name": "query-rocker-of-dpa-flows",
++      "ret-type": "[147]",
++      "meta-type": "command",
++      "arg-type": "146"
++    },
++    {
++      "name": "query-rocker-of-dpa-groups",
++      "ret-type": "[149]",
++      "meta-type": "command",
++      "arg-type": "148"
++    },
++    {
++      "name": "query-rocker-ports",
++      "ret-type": "[151]",
++      "meta-type": "command",
++      "arg-type": "150"
++    },
++    {
++      "name": "query-rx-filter",
++      "ret-type": "[153]",
++      "meta-type": "command",
++      "arg-type": "152"
++    },
++    {
++      "name": "query-spice",
++      "ret-type": "154",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-status",
++      "ret-type": "155",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-target",
++      "ret-type": "156",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-tpm",
++      "ret-type": "[157]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-tpm-models",
++      "ret-type": "[158]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-tpm-types",
++      "ret-type": "[159]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-uuid",
++      "ret-type": "160",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-version",
++      "ret-type": "161",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-vm-generation-id",
++      "ret-type": "162",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-vnc",
++      "ret-type": "163",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-vnc-servers",
++      "ret-type": "[164]",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "query-xen-replication-status",
++      "ret-type": "165",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "quit",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "remove-fd",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "166"
++    },
++    {
++      "name": "ringbuf-read",
++      "ret-type": "str",
++      "meta-type": "command",
++      "arg-type": "167"
++    },
++    {
++      "name": "ringbuf-write",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "168"
++    },
++    {
++      "name": "rtc-reset-reinjection",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "screendump",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "169"
++    },
++    {
++      "name": "send-key",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "170"
++    },
++    {
++      "name": "set_link",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "171"
++    },
++    {
++      "name": "set_password",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "172"
++    },
++    {
++      "name": "stop",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "system_powerdown",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "system_reset",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "system_wakeup",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "trace-event-get-state",
++      "ret-type": "[174]",
++      "meta-type": "command",
++      "arg-type": "173"
++    },
++    {
++      "name": "trace-event-set-state",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "175"
++    },
++    {
++      "name": "transaction",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "176"
++    },
++    {
++      "name": "x-blockdev-change",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "177"
++    },
++    {
++      "name": "x-blockdev-insert-medium",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "178"
++    },
++    {
++      "name": "x-blockdev-remove-medium",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "179"
++    },
++    {
++      "name": "x-colo-lost-heartbeat",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "x-debug-block-dirty-bitmap-sha256",
++      "ret-type": "180",
++      "meta-type": "command",
++      "arg-type": "37"
++    },
++    {
++      "name": "xen-colo-do-checkpoint",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "17"
++    },
++    {
++      "name": "xen-load-devices-state",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "181"
++    },
++    {
++      "name": "xen-save-devices-state",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "182"
++    },
++    {
++      "name": "xen-set-global-dirty-log",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "183"
++    },
++    {
++      "name": "xen-set-replication",
++      "ret-type": "17",
++      "meta-type": "command",
++      "arg-type": "184"
++    },
++    {
++      "name": "0",
++      "members": [
++        {
++          "name": "info",
++          "type": "106"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "1",
++      "members": [
++        {
++          "name": "actual",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "2",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "node-name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "msg",
++          "type": "str"
++        },
++        {
++          "name": "offset",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "fatal",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "3",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "node-name",
++          "type": "str"
++        },
++        {
++          "name": "operation",
++          "type": "185"
++        },
++        {
++          "name": "action",
++          "type": "186"
++        },
++        {
++          "name": "nospace",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "reason",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "4",
++      "members": [
++        {
++          "name": "type",
++          "type": "187"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "len",
++          "type": "int"
++        },
++        {
++          "name": "offset",
++          "type": "int"
++        },
++        {
++          "name": "speed",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "5",
++      "members": [
++        {
++          "name": "type",
++          "type": "187"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "len",
++          "type": "int"
++        },
++        {
++          "name": "offset",
++          "type": "int"
++        },
++        {
++          "name": "speed",
++          "type": "int"
++        },
++        {
++          "name": "error",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "6",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "operation",
++          "type": "185"
++        },
++        {
++          "name": "action",
++          "type": "186"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "7",
++      "members": [
++        {
++          "name": "type",
++          "type": "187"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "len",
++          "type": "int"
++        },
++        {
++          "name": "offset",
++          "type": "int"
++        },
++        {
++          "name": "speed",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "8",
++      "members": [
++        {
++          "name": "node-name",
++          "type": "str"
++        },
++        {
++          "name": "amount-exceeded",
++          "type": "int"
++        },
++        {
++          "name": "write-threshold",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "9",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "path",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "10",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "type": "str"
++        },
++        {
++          "name": "tray-open",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "11",
++      "members": [
++        {
++          "name": "result",
++          "type": "125"
++        },
++        {
++          "name": "error",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "12",
++      "members": [
++        {
++          "name": "action",
++          "type": "188"
++        },
++        {
++          "name": "info",
++          "default": null,
++          "type": "189"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "13",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "msg",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "14",
++      "members": [
++        {
++          "name": "status",
++          "type": "190"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "15",
++      "members": [
++        {
++          "name": "pass",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "16",
++      "members": [
++        {
++          "name": "name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "path",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "17",
++      "members": [
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "18",
++      "members": [
++        {
++          "name": "reference",
++          "type": "str"
++        },
++        {
++          "name": "sector-num",
++          "type": "int"
++        },
++        {
++          "name": "sectors-count",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "19",
++      "members": [
++        {
++          "name": "type",
++          "type": "191"
++        },
++        {
++          "name": "error",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "node-name",
++          "type": "str"
++        },
++        {
++          "name": "sector-num",
++          "type": "int"
++        },
++        {
++          "name": "sectors-count",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "20",
++      "members": [
++        {
++          "name": "guest",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "21",
++      "members": [
++        {
++          "name": "offset",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "22",
++      "members": [
++        {
++          "name": "guest",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "23",
++      "members": [
++        {
++          "name": "server",
++          "type": "192"
++        },
++        {
++          "name": "client",
++          "type": "192"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "24",
++      "members": [
++        {
++          "name": "server",
++          "type": "192"
++        },
++        {
++          "name": "client",
++          "type": "192"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "25",
++      "members": [
++        {
++          "name": "server",
++          "type": "193"
++        },
++        {
++          "name": "client",
++          "type": "194"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "26",
++      "members": [
++        {
++          "name": "server",
++          "type": "195"
++        },
++        {
++          "name": "client",
++          "type": "196"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "27",
++      "members": [
++        {
++          "name": "server",
++          "type": "195"
++        },
++        {
++          "name": "client",
++          "type": "197"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "28",
++      "members": [
++        {
++          "name": "server",
++          "type": "195"
++        },
++        {
++          "name": "client",
++          "type": "197"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "29",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        },
++        {
++          "name": "open",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "30",
++      "members": [
++        {
++          "name": "action",
++          "type": "198"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "31",
++      "members": [
++        {
++          "name": "fdset-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "opaque",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "32",
++      "members": [
++        {
++          "name": "fdset-id",
++          "type": "int"
++        },
++        {
++          "name": "fd",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "33",
++      "members": [
++        {
++          "name": "protocol",
++          "type": "str"
++        },
++        {
++          "name": "fdname",
++          "type": "str"
++        },
++        {
++          "name": "skipauth",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "tls",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "34",
++      "members": [
++        {
++          "name": "value",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "35",
++      "members": [
++        {
++          "name": "job-id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "base",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "top",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "backing-file",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "speed",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "filter-node-name",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "36",
++      "members": [
++        {
++          "name": "node",
++          "type": "str"
++        },
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "granularity",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "persistent",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "autoload",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "37",
++      "members": [
++        {
++          "name": "node",
++          "type": "str"
++        },
++        {
++          "name": "name",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "38",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "force",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "39",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "40",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "41",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "42",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "speed",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "43",
++      "members": [
++        {
++          "name": "node-name",
++          "type": "str"
++        },
++        {
++          "name": "write-threshold",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "44",
++      "members": [
++        {
++          "name": "job-id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "base",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "base-node",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "backing-file",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "speed",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "on-error",
++          "default": null,
++          "type": "199"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "45",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "node-name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "password",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "46",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "node-name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "size",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "47",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "bps",
++          "type": "int"
++        },
++        {
++          "name": "bps_rd",
++          "type": "int"
++        },
++        {
++          "name": "bps_wr",
++          "type": "int"
++        },
++        {
++          "name": "iops",
++          "type": "int"
++        },
++        {
++          "name": "iops_rd",
++          "type": "int"
++        },
++        {
++          "name": "iops_wr",
++          "type": "int"
++        },
++        {
++          "name": "bps_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bps_rd_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bps_wr_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_rd_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_wr_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bps_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bps_rd_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bps_wr_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_rd_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_wr_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "group",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "48",
++      "tag": "driver",
++      "variants": [
++        {
++          "case": "blkdebug",
++          "type": "204"
++        },
++        {
++          "case": "blkverify",
++          "type": "205"
++        },
++        {
++          "case": "bochs",
++          "type": "206"
++        },
++        {
++          "case": "cloop",
++          "type": "206"
++        },
++        {
++          "case": "dmg",
++          "type": "206"
++        },
++        {
++          "case": "file",
++          "type": "207"
++        },
++        {
++          "case": "ftp",
++          "type": "208"
++        },
++        {
++          "case": "ftps",
++          "type": "209"
++        },
++        {
++          "case": "gluster",
++          "type": "210"
++        },
++        {
++          "case": "host_cdrom",
++          "type": "207"
++        },
++        {
++          "case": "host_device",
++          "type": "207"
++        },
++        {
++          "case": "http",
++          "type": "211"
++        },
++        {
++          "case": "https",
++          "type": "212"
++        },
++        {
++          "case": "iscsi",
++          "type": "213"
++        },
++        {
++          "case": "luks",
++          "type": "214"
++        },
++        {
++          "case": "nbd",
++          "type": "215"
++        },
++        {
++          "case": "nfs",
++          "type": "216"
++        },
++        {
++          "case": "null-aio",
++          "type": "217"
++        },
++        {
++          "case": "null-co",
++          "type": "217"
++        },
++        {
++          "case": "parallels",
++          "type": "206"
++        },
++        {
++          "case": "qcow2",
++          "type": "218"
++        },
++        {
++          "case": "qcow",
++          "type": "219"
++        },
++        {
++          "case": "qed",
++          "type": "220"
++        },
++        {
++          "case": "quorum",
++          "type": "221"
++        },
++        {
++          "case": "raw",
++          "type": "222"
++        },
++        {
++          "case": "rbd",
++          "type": "223"
++        },
++        {
++          "case": "replication",
++          "type": "224"
++        },
++        {
++          "case": "sheepdog",
++          "type": "225"
++        },
++        {
++          "case": "ssh",
++          "type": "226"
++        },
++        {
++          "case": "vdi",
++          "type": "206"
++        },
++        {
++          "case": "vhdx",
++          "type": "206"
++        },
++        {
++          "case": "vmdk",
++          "type": "220"
++        },
++        {
++          "case": "vpc",
++          "type": "206"
++        },
++        {
++          "case": "vvfat",
++          "type": "227"
++        },
++        {
++          "case": "vxhs",
++          "type": "228"
++        }
++      ],
++      "members": [
++        {
++          "name": "driver",
++          "type": "200"
++        },
++        {
++          "name": "node-name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "discard",
++          "default": null,
++          "type": "201"
++        },
++        {
++          "name": "cache",
++          "default": null,
++          "type": "202"
++        },
++        {
++          "name": "read-only",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "force-share",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "detect-zeroes",
++          "default": null,
++          "type": "203"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "49",
++      "members": [
++        {
++          "name": "job-id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "target",
++          "type": "str"
++        },
++        {
++          "name": "sync",
++          "type": "229"
++        },
++        {
++          "name": "speed",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "compress",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "on-source-error",
++          "default": null,
++          "type": "199"
++        },
++        {
++          "name": "on-target-error",
++          "default": null,
++          "type": "199"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "50",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "filename",
++          "type": "str"
++        },
++        {
++          "name": "format",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "read-only-mode",
++          "default": null,
++          "type": "230"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "51",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "52",
++      "members": [
++        {
++          "name": "node-name",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "53",
++      "members": [
++        {
++          "name": "job-id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "target",
++          "type": "str"
++        },
++        {
++          "name": "replaces",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "sync",
++          "type": "229"
++        },
++        {
++          "name": "speed",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "granularity",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "buf-size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "on-source-error",
++          "default": null,
++          "type": "199"
++        },
++        {
++          "name": "on-target-error",
++          "default": null,
++          "type": "199"
++        },
++        {
++          "name": "filter-node-name",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "54",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "force",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "55",
++      "members": [
++        {
++          "name": "node",
++          "type": "str"
++        },
++        {
++          "name": "overlay",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "56",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "name",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "57",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        },
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "vm-state-size",
++          "type": "int"
++        },
++        {
++          "name": "date-sec",
++          "type": "int"
++        },
++        {
++          "name": "date-nsec",
++          "type": "int"
++        },
++        {
++          "name": "vm-clock-sec",
++          "type": "int"
++        },
++        {
++          "name": "vm-clock-nsec",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "58",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "name",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "59",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "node-name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "snapshot-file",
++          "type": "str"
++        },
++        {
++          "name": "snapshot-node-name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "format",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "mode",
++          "default": null,
++          "type": "231"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "60",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "target",
++          "type": "str"
++        },
++        {
++          "name": "arg",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "61",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "image-node-name",
++          "type": "str"
++        },
++        {
++          "name": "backing-file",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "62",
++      "members": [
++        {
++          "name": "password",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "63",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        },
++        {
++          "name": "backend",
++          "type": "232"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "64",
++      "members": [
++        {
++          "name": "pty",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "65",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        },
++        {
++          "name": "backend",
++          "type": "232"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "66",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "67",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "68",
++      "members": [
++        {
++          "name": "protocol",
++          "type": "str"
++        },
++        {
++          "name": "hostname",
++          "type": "str"
++        },
++        {
++          "name": "port",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "tls-port",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "cert-subject",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "69",
++      "members": [
++        {
++          "name": "fdname",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "70",
++      "members": [
++        {
++          "name": "index",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "71",
++      "members": [
++        {
++          "name": "id",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "72",
++      "members": [
++        {
++          "name": "typename",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[73]",
++      "element-type": "73",
++      "meta-type": "array"
++    },
++    {
++      "name": "73",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "type",
++          "type": "str"
++        },
++        {
++          "name": "description",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "74",
++      "members": [
++        {
++          "name": "driver",
++          "type": "str"
++        },
++        {
++          "name": "bus",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "75",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "76",
++      "members": [
++        {
++          "name": "job-id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "target",
++          "type": "str"
++        },
++        {
++          "name": "format",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "sync",
++          "type": "229"
++        },
++        {
++          "name": "mode",
++          "default": null,
++          "type": "231"
++        },
++        {
++          "name": "speed",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bitmap",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "compress",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "on-source-error",
++          "default": null,
++          "type": "199"
++        },
++        {
++          "name": "on-target-error",
++          "default": null,
++          "type": "199"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "77",
++      "members": [
++        {
++          "name": "job-id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "target",
++          "type": "str"
++        },
++        {
++          "name": "format",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "node-name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "replaces",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "sync",
++          "type": "229"
++        },
++        {
++          "name": "mode",
++          "default": null,
++          "type": "231"
++        },
++        {
++          "name": "speed",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "granularity",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "buf-size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "on-source-error",
++          "default": null,
++          "type": "199"
++        },
++        {
++          "name": "on-target-error",
++          "default": null,
++          "type": "199"
++        },
++        {
++          "name": "unmap",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "78",
++      "members": [
++        {
++          "name": "paging",
++          "type": "bool"
++        },
++        {
++          "name": "protocol",
++          "type": "str"
++        },
++        {
++          "name": "detach",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "begin",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "format",
++          "default": null,
++          "type": "233"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "79",
++      "members": [
++        {
++          "name": "filename",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "80",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "force",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "81",
++      "members": [
++        {
++          "name": "protocol",
++          "type": "str"
++        },
++        {
++          "name": "time",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "82",
++      "members": [
++        {
++          "name": "fdname",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "83",
++      "members": [
++        {
++          "name": "command-line",
++          "type": "str"
++        },
++        {
++          "name": "cpu-index",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "str",
++      "json-type": "string",
++      "meta-type": "builtin"
++    },
++    {
++      "name": "84",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "head",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "events",
++          "type": "[234]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "85",
++      "members": [
++        {
++          "name": "val",
++          "type": "int"
++        },
++        {
++          "name": "size",
++          "type": "int"
++        },
++        {
++          "name": "filename",
++          "type": "str"
++        },
++        {
++          "name": "cpu-index",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "86",
++      "members": [
++        {
++          "name": "uri",
++          "type": "str"
++        },
++        {
++          "name": "blk",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "inc",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "detach",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "87",
++      "members": [
++        {
++          "name": "uri",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "88",
++      "members": [
++        {
++          "name": "value",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "89",
++      "members": [
++        {
++          "name": "capabilities",
++          "type": "[138]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "90",
++      "members": [
++        {
++          "name": "compress-level",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "compress-threads",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "decompress-threads",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "cpu-throttle-initial",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "cpu-throttle-increment",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "tls-creds",
++          "default": null,
++          "type": "235"
++        },
++        {
++          "name": "tls-hostname",
++          "default": null,
++          "type": "235"
++        },
++        {
++          "name": "max-bandwidth",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "downtime-limit",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "x-checkpoint-delay",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "block-incremental",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "91",
++      "members": [
++        {
++          "name": "value",
++          "type": "number"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "92",
++      "members": [
++        {
++          "name": "value",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "93",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "writable",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "94",
++      "members": [
++        {
++          "name": "addr",
++          "type": "236"
++        },
++        {
++          "name": "tls-creds",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "95",
++      "members": [
++        {
++          "name": "type",
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "96",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "97",
++      "members": [
++        {
++          "name": "qom-type",
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "type": "str"
++        },
++        {
++          "name": "props",
++          "default": null,
++          "type": "any"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "98",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "99",
++      "members": [
++        {
++          "name": "val",
++          "type": "int"
++        },
++        {
++          "name": "size",
++          "type": "int"
++        },
++        {
++          "name": "filename",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "100",
++      "members": [
++        {
++          "name": "path",
++          "type": "str"
++        },
++        {
++          "name": "property",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "any",
++      "json-type": "value",
++      "meta-type": "builtin"
++    },
++    {
++      "name": "101",
++      "members": [
++        {
++          "name": "path",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[102]",
++      "element-type": "102",
++      "meta-type": "array"
++    },
++    {
++      "name": "102",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "type",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "103",
++      "members": [
++        {
++          "name": "implements",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "abstract",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[104]",
++      "element-type": "104",
++      "meta-type": "array"
++    },
++    {
++      "name": "104",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "abstract",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "parent",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "105",
++      "members": [
++        {
++          "name": "path",
++          "type": "str"
++        },
++        {
++          "name": "property",
++          "type": "str"
++        },
++        {
++          "name": "value",
++          "type": "any"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[106]",
++      "element-type": "106",
++      "meta-type": "array"
++    },
++    {
++      "name": "106",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "slot",
++          "type": "str"
++        },
++        {
++          "name": "slot-type",
++          "type": "237"
++        },
++        {
++          "name": "source",
++          "type": "int"
++        },
++        {
++          "name": "status",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "107",
++      "members": [
++        {
++          "name": "actual",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[108]",
++      "element-type": "108",
++      "meta-type": "array"
++    },
++    {
++      "name": "108",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "qdev",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "type",
++          "type": "str"
++        },
++        {
++          "name": "removable",
++          "type": "bool"
++        },
++        {
++          "name": "locked",
++          "type": "bool"
++        },
++        {
++          "name": "inserted",
++          "default": null,
++          "type": "141"
++        },
++        {
++          "name": "tray_open",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "io-status",
++          "default": null,
++          "type": "238"
++        },
++        {
++          "name": "dirty-bitmaps",
++          "default": null,
++          "type": "[239]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[109]",
++      "element-type": "109",
++      "meta-type": "array"
++    },
++    {
++      "name": "109",
++      "members": [
++        {
++          "name": "type",
++          "type": "str"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "len",
++          "type": "int"
++        },
++        {
++          "name": "offset",
++          "type": "int"
++        },
++        {
++          "name": "busy",
++          "type": "bool"
++        },
++        {
++          "name": "paused",
++          "type": "bool"
++        },
++        {
++          "name": "speed",
++          "type": "int"
++        },
++        {
++          "name": "io-status",
++          "type": "238"
++        },
++        {
++          "name": "ready",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "110",
++      "members": [
++        {
++          "name": "query-nodes",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[111]",
++      "element-type": "111",
++      "meta-type": "array"
++    },
++    {
++      "name": "111",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "node-name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "stats",
++          "type": "240"
++        },
++        {
++          "name": "parent",
++          "default": null,
++          "type": "111"
++        },
++        {
++          "name": "backing",
++          "default": null,
++          "type": "111"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[112]",
++      "element-type": "112",
++      "meta-type": "array"
++    },
++    {
++      "name": "112",
++      "members": [
++        {
++          "name": "label",
++          "type": "str"
++        },
++        {
++          "name": "filename",
++          "type": "str"
++        },
++        {
++          "name": "frontend-open",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[113]",
++      "element-type": "113",
++      "meta-type": "array"
++    },
++    {
++      "name": "113",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "114",
++      "members": [
++        {
++          "name": "option",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[115]",
++      "element-type": "115",
++      "meta-type": "array"
++    },
++    {
++      "name": "115",
++      "members": [
++        {
++          "name": "option",
++          "type": "str"
++        },
++        {
++          "name": "parameters",
++          "type": "[241]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[116]",
++      "element-type": "116",
++      "meta-type": "array"
++    },
++    {
++      "name": "116",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[117]",
++      "element-type": "117",
++      "meta-type": "array"
++    },
++    {
++      "name": "117",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "migration-safe",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "static",
++          "type": "bool"
++        },
++        {
++          "name": "unavailable-features",
++          "default": null,
++          "type": "[str]"
++        },
++        {
++          "name": "typename",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "118",
++      "members": [
++        {
++          "name": "modela",
++          "type": "242"
++        },
++        {
++          "name": "modelb",
++          "type": "242"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "119",
++      "members": [
++        {
++          "name": "model",
++          "type": "242"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "120",
++      "members": [
++        {
++          "name": "modela",
++          "type": "242"
++        },
++        {
++          "name": "modelb",
++          "type": "242"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "121",
++      "members": [
++        {
++          "name": "result",
++          "type": "243"
++        },
++        {
++          "name": "responsible-properties",
++          "type": "[str]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "122",
++      "members": [
++        {
++          "name": "type",
++          "type": "244"
++        },
++        {
++          "name": "model",
++          "type": "242"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "123",
++      "members": [
++        {
++          "name": "model",
++          "type": "242"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[124]",
++      "element-type": "124",
++      "meta-type": "array"
++    },
++    {
++      "name": "124",
++      "tag": "arch",
++      "variants": [
++        {
++          "case": "x86",
++          "type": "247"
++        },
++        {
++          "case": "sparc",
++          "type": "248"
++        },
++        {
++          "case": "ppc",
++          "type": "249"
++        },
++        {
++          "case": "mips",
++          "type": "250"
++        },
++        {
++          "case": "tricore",
++          "type": "251"
++        },
++        {
++          "case": "other",
++          "type": "252"
++        }
++      ],
++      "members": [
++        {
++          "name": "CPU",
++          "type": "int"
++        },
++        {
++          "name": "current",
++          "type": "bool"
++        },
++        {
++          "name": "halted",
++          "type": "bool"
++        },
++        {
++          "name": "qom_path",
++          "type": "str"
++        },
++        {
++          "name": "thread_id",
++          "type": "int"
++        },
++        {
++          "name": "props",
++          "default": null,
++          "type": "245"
++        },
++        {
++          "name": "arch",
++          "type": "246"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "125",
++      "members": [
++        {
++          "name": "status",
++          "type": "253"
++        },
++        {
++          "name": "completed",
++          "type": "int"
++        },
++        {
++          "name": "total",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "126",
++      "members": [
++        {
++          "name": "formats",
++          "type": "[233]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[127]",
++      "element-type": "127",
++      "meta-type": "array"
++    },
++    {
++      "name": "127",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[128]",
++      "element-type": "128",
++      "meta-type": "array"
++    },
++    {
++      "name": "128",
++      "members": [
++        {
++          "name": "fdset-id",
++          "type": "int"
++        },
++        {
++          "name": "fds",
++          "type": "[254]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[129]",
++      "element-type": "129",
++      "meta-type": "array"
++    },
++    {
++      "name": "129",
++      "members": [
++        {
++          "name": "version",
++          "type": "int"
++        },
++        {
++          "name": "emulated",
++          "type": "bool"
++        },
++        {
++          "name": "kernel",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[130]",
++      "element-type": "130",
++      "meta-type": "array"
++    },
++    {
++      "name": "130",
++      "members": [
++        {
++          "name": "type",
++          "type": "str"
++        },
++        {
++          "name": "vcpus-count",
++          "type": "int"
++        },
++        {
++          "name": "props",
++          "type": "245"
++        },
++        {
++          "name": "qom-path",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[131]",
++      "element-type": "131",
++      "meta-type": "array"
++    },
++    {
++      "name": "131",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        },
++        {
++          "name": "thread-id",
++          "type": "int"
++        },
++        {
++          "name": "poll-max-ns",
++          "type": "int"
++        },
++        {
++          "name": "poll-grow",
++          "type": "int"
++        },
++        {
++          "name": "poll-shrink",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "132",
++      "members": [
++        {
++          "name": "enabled",
++          "type": "bool"
++        },
++        {
++          "name": "present",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[133]",
++      "element-type": "133",
++      "meta-type": "array"
++    },
++    {
++      "name": "133",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "alias",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "is-default",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "cpu-max",
++          "type": "int"
++        },
++        {
++          "name": "hotpluggable-cpus",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[134]",
++      "element-type": "134",
++      "meta-type": "array"
++    },
++    {
++      "name": "134",
++      "members": [
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "size",
++          "type": "int"
++        },
++        {
++          "name": "merge",
++          "type": "bool"
++        },
++        {
++          "name": "dump",
++          "type": "bool"
++        },
++        {
++          "name": "prealloc",
++          "type": "bool"
++        },
++        {
++          "name": "host-nodes",
++          "type": "[int]"
++        },
++        {
++          "name": "policy",
++          "type": "255"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[135]",
++      "element-type": "135",
++      "meta-type": "array"
++    },
++    {
++      "name": "135",
++      "tag": "type",
++      "variants": [
++        {
++          "case": "dimm",
++          "type": "257"
++        }
++      ],
++      "members": [
++        {
++          "name": "type",
++          "type": "256"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[136]",
++      "element-type": "136",
++      "meta-type": "array"
++    },
++    {
++      "name": "136",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "index",
++          "type": "int"
++        },
++        {
++          "name": "current",
++          "type": "bool"
++        },
++        {
++          "name": "absolute",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "137",
++      "members": [
++        {
++          "name": "status",
++          "default": null,
++          "type": "190"
++        },
++        {
++          "name": "ram",
++          "default": null,
++          "type": "258"
++        },
++        {
++          "name": "disk",
++          "default": null,
++          "type": "258"
++        },
++        {
++          "name": "xbzrle-cache",
++          "default": null,
++          "type": "259"
++        },
++        {
++          "name": "total-time",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "expected-downtime",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "downtime",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "setup-time",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "cpu-throttle-percentage",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "error-desc",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "int",
++      "json-type": "int",
++      "meta-type": "builtin"
++    },
++    {
++      "name": "[138]",
++      "element-type": "138",
++      "meta-type": "array"
++    },
++    {
++      "name": "138",
++      "members": [
++        {
++          "name": "capability",
++          "type": "260"
++        },
++        {
++          "name": "state",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "139",
++      "members": [
++        {
++          "name": "compress-level",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "compress-threads",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "decompress-threads",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "cpu-throttle-initial",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "cpu-throttle-increment",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "tls-creds",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "tls-hostname",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "max-bandwidth",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "downtime-limit",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "x-checkpoint-delay",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "block-incremental",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "140",
++      "members": [
++        {
++          "name": "name",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[141]",
++      "element-type": "141",
++      "meta-type": "array"
++    },
++    {
++      "name": "141",
++      "members": [
++        {
++          "name": "file",
++          "type": "str"
++        },
++        {
++          "name": "node-name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "ro",
++          "type": "bool"
++        },
++        {
++          "name": "drv",
++          "type": "str"
++        },
++        {
++          "name": "backing_file",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "backing_file_depth",
++          "type": "int"
++        },
++        {
++          "name": "encrypted",
++          "type": "bool"
++        },
++        {
++          "name": "encryption_key_missing",
++          "type": "bool"
++        },
++        {
++          "name": "detect_zeroes",
++          "type": "203"
++        },
++        {
++          "name": "bps",
++          "type": "int"
++        },
++        {
++          "name": "bps_rd",
++          "type": "int"
++        },
++        {
++          "name": "bps_wr",
++          "type": "int"
++        },
++        {
++          "name": "iops",
++          "type": "int"
++        },
++        {
++          "name": "iops_rd",
++          "type": "int"
++        },
++        {
++          "name": "iops_wr",
++          "type": "int"
++        },
++        {
++          "name": "image",
++          "type": "261"
++        },
++        {
++          "name": "bps_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bps_rd_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bps_wr_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_rd_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_wr_max",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bps_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bps_rd_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "bps_wr_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_rd_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_wr_max_length",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "iops_size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "group",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "cache",
++          "type": "262"
++        },
++        {
++          "name": "write_threshold",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[142]",
++      "element-type": "142",
++      "meta-type": "array"
++    },
++    {
++      "name": "142",
++      "members": [
++        {
++          "name": "bus",
++          "type": "int"
++        },
++        {
++          "name": "devices",
++          "type": "[263]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[143]",
++      "element-type": "143",
++      "meta-type": "array"
++    },
++    {
++      "name": "143",
++      "tag": "meta-type",
++      "variants": [
++        {
++          "case": "builtin",
++          "type": "265"
++        },
++        {
++          "case": "enum",
++          "type": "266"
++        },
++        {
++          "case": "array",
++          "type": "267"
++        },
++        {
++          "case": "object",
++          "type": "268"
++        },
++        {
++          "case": "alternate",
++          "type": "269"
++        },
++        {
++          "case": "command",
++          "type": "270"
++        },
++        {
++          "case": "event",
++          "type": "271"
++        }
++      ],
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "meta-type",
++          "type": "264"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "144",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "145",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "type": "int"
++        },
++        {
++          "name": "ports",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "146",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "tbl-id",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[147]",
++      "element-type": "147",
++      "meta-type": "array"
++    },
++    {
++      "name": "147",
++      "members": [
++        {
++          "name": "cookie",
++          "type": "int"
++        },
++        {
++          "name": "hits",
++          "type": "int"
++        },
++        {
++          "name": "key",
++          "type": "272"
++        },
++        {
++          "name": "mask",
++          "type": "273"
++        },
++        {
++          "name": "action",
++          "type": "274"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "148",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "type",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[149]",
++      "element-type": "149",
++      "meta-type": "array"
++    },
++    {
++      "name": "149",
++      "members": [
++        {
++          "name": "id",
++          "type": "int"
++        },
++        {
++          "name": "type",
++          "type": "int"
++        },
++        {
++          "name": "vlan-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "pport",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "index",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "out-pport",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "group-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "set-vlan-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "pop-vlan",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "group-ids",
++          "default": null,
++          "type": "[int]"
++        },
++        {
++          "name": "set-eth-src",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "set-eth-dst",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "ttl-check",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "150",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[151]",
++      "element-type": "151",
++      "meta-type": "array"
++    },
++    {
++      "name": "151",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "enabled",
++          "type": "bool"
++        },
++        {
++          "name": "link-up",
++          "type": "bool"
++        },
++        {
++          "name": "speed",
++          "type": "int"
++        },
++        {
++          "name": "duplex",
++          "type": "275"
++        },
++        {
++          "name": "autoneg",
++          "type": "276"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "152",
++      "members": [
++        {
++          "name": "name",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[153]",
++      "element-type": "153",
++      "meta-type": "array"
++    },
++    {
++      "name": "153",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "promiscuous",
++          "type": "bool"
++        },
++        {
++          "name": "multicast",
++          "type": "277"
++        },
++        {
++          "name": "unicast",
++          "type": "277"
++        },
++        {
++          "name": "vlan",
++          "type": "277"
++        },
++        {
++          "name": "broadcast-allowed",
++          "type": "bool"
++        },
++        {
++          "name": "multicast-overflow",
++          "type": "bool"
++        },
++        {
++          "name": "unicast-overflow",
++          "type": "bool"
++        },
++        {
++          "name": "main-mac",
++          "type": "str"
++        },
++        {
++          "name": "vlan-table",
++          "type": "[int]"
++        },
++        {
++          "name": "unicast-table",
++          "type": "[str]"
++        },
++        {
++          "name": "multicast-table",
++          "type": "[str]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "154",
++      "members": [
++        {
++          "name": "enabled",
++          "type": "bool"
++        },
++        {
++          "name": "migrated",
++          "type": "bool"
++        },
++        {
++          "name": "host",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "port",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "tls-port",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "auth",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "compiled-version",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "mouse-mode",
++          "type": "278"
++        },
++        {
++          "name": "channels",
++          "default": null,
++          "type": "[194]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "155",
++      "members": [
++        {
++          "name": "running",
++          "type": "bool"
++        },
++        {
++          "name": "singlestep",
++          "type": "bool"
++        },
++        {
++          "name": "status",
++          "type": "279"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "156",
++      "members": [
++        {
++          "name": "arch",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[157]",
++      "element-type": "157",
++      "meta-type": "array"
++    },
++    {
++      "name": "157",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        },
++        {
++          "name": "model",
++          "type": "158"
++        },
++        {
++          "name": "options",
++          "type": "280"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[158]",
++      "element-type": "158",
++      "meta-type": "array"
++    },
++    {
++      "name": "158",
++      "meta-type": "enum",
++      "values": [
++        "tpm-tis"
++      ]
++    },
++    {
++      "name": "[159]",
++      "element-type": "159",
++      "meta-type": "array"
++    },
++    {
++      "name": "159",
++      "meta-type": "enum",
++      "values": [
++        "passthrough"
++      ]
++    },
++    {
++      "name": "160",
++      "members": [
++        {
++          "name": "UUID",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "161",
++      "members": [
++        {
++          "name": "qemu",
++          "type": "281"
++        },
++        {
++          "name": "package",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "162",
++      "members": [
++        {
++          "name": "guid",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "163",
++      "members": [
++        {
++          "name": "enabled",
++          "type": "bool"
++        },
++        {
++          "name": "host",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "family",
++          "default": null,
++          "type": "282"
++        },
++        {
++          "name": "service",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "auth",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "clients",
++          "default": null,
++          "type": "[197]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[164]",
++      "element-type": "164",
++      "meta-type": "array"
++    },
++    {
++      "name": "164",
++      "members": [
++        {
++          "name": "id",
++          "type": "str"
++        },
++        {
++          "name": "server",
++          "type": "[283]"
++        },
++        {
++          "name": "clients",
++          "type": "[197]"
++        },
++        {
++          "name": "auth",
++          "type": "284"
++        },
++        {
++          "name": "vencrypt",
++          "default": null,
++          "type": "285"
++        },
++        {
++          "name": "display",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "165",
++      "members": [
++        {
++          "name": "error",
++          "type": "bool"
++        },
++        {
++          "name": "desc",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "166",
++      "members": [
++        {
++          "name": "fdset-id",
++          "type": "int"
++        },
++        {
++          "name": "fd",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "167",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "size",
++          "type": "int"
++        },
++        {
++          "name": "format",
++          "default": null,
++          "type": "286"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "168",
++      "members": [
++        {
++          "name": "device",
++          "type": "str"
++        },
++        {
++          "name": "data",
++          "type": "str"
++        },
++        {
++          "name": "format",
++          "default": null,
++          "type": "286"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "169",
++      "members": [
++        {
++          "name": "filename",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "170",
++      "members": [
++        {
++          "name": "keys",
++          "type": "[287]"
++        },
++        {
++          "name": "hold-time",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "171",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "up",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "172",
++      "members": [
++        {
++          "name": "protocol",
++          "type": "str"
++        },
++        {
++          "name": "password",
++          "type": "str"
++        },
++        {
++          "name": "connected",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "173",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "vcpu",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[174]",
++      "element-type": "174",
++      "meta-type": "array"
++    },
++    {
++      "name": "174",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "state",
++          "type": "288"
++        },
++        {
++          "name": "vcpu",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "175",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "enable",
++          "type": "bool"
++        },
++        {
++          "name": "ignore-unavailable",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "vcpu",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "176",
++      "members": [
++        {
++          "name": "actions",
++          "type": "[289]"
++        },
++        {
++          "name": "properties",
++          "default": null,
++          "type": "290"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "177",
++      "members": [
++        {
++          "name": "parent",
++          "type": "str"
++        },
++        {
++          "name": "child",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "node",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "178",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "node-name",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "179",
++      "members": [
++        {
++          "name": "device",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "180",
++      "members": [
++        {
++          "name": "sha256",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "181",
++      "members": [
++        {
++          "name": "filename",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "182",
++      "members": [
++        {
++          "name": "filename",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "183",
++      "members": [
++        {
++          "name": "enable",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "184",
++      "members": [
++        {
++          "name": "enable",
++          "type": "bool"
++        },
++        {
++          "name": "primary",
++          "type": "bool"
++        },
++        {
++          "name": "failover",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "bool",
++      "json-type": "boolean",
++      "meta-type": "builtin"
++    },
++    {
++      "name": "185",
++      "meta-type": "enum",
++      "values": [
++        "read",
++        "write"
++      ]
++    },
++    {
++      "name": "186",
++      "meta-type": "enum",
++      "values": [
++        "ignore",
++        "report",
++        "stop"
++      ]
++    },
++    {
++      "name": "187",
++      "meta-type": "enum",
++      "values": [
++        "commit",
++        "stream",
++        "mirror",
++        "backup"
++      ]
++    },
++    {
++      "name": "188",
++      "meta-type": "enum",
++      "values": [
++        "pause",
++        "poweroff"
++      ]
++    },
++    {
++      "name": "189",
++      "tag": "type",
++      "variants": [
++        {
++          "case": "hyper-v",
++          "type": "292"
++        }
++      ],
++      "members": [
++        {
++          "name": "type",
++          "type": "291"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "190",
++      "meta-type": "enum",
++      "values": [
++        "none",
++        "setup",
++        "cancelling",
++        "cancelled",
++        "active",
++        "postcopy-active",
++        "completed",
++        "failed",
++        "colo"
++      ]
++    },
++    {
++      "name": "191",
++      "meta-type": "enum",
++      "values": [
++        "read",
++        "write",
++        "flush"
++      ]
++    },
++    {
++      "name": "192",
++      "members": [
++        {
++          "name": "host",
++          "type": "str"
++        },
++        {
++          "name": "port",
++          "type": "str"
++        },
++        {
++          "name": "family",
++          "type": "282"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "193",
++      "members": [
++        {
++          "name": "host",
++          "type": "str"
++        },
++        {
++          "name": "port",
++          "type": "str"
++        },
++        {
++          "name": "family",
++          "type": "282"
++        },
++        {
++          "name": "auth",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "194",
++      "members": [
++        {
++          "name": "host",
++          "type": "str"
++        },
++        {
++          "name": "port",
++          "type": "str"
++        },
++        {
++          "name": "family",
++          "type": "282"
++        },
++        {
++          "name": "connection-id",
++          "type": "int"
++        },
++        {
++          "name": "channel-type",
++          "type": "int"
++        },
++        {
++          "name": "channel-id",
++          "type": "int"
++        },
++        {
++          "name": "tls",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "195",
++      "members": [
++        {
++          "name": "host",
++          "type": "str"
++        },
++        {
++          "name": "service",
++          "type": "str"
++        },
++        {
++          "name": "family",
++          "type": "282"
++        },
++        {
++          "name": "websocket",
++          "type": "bool"
++        },
++        {
++          "name": "auth",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "196",
++      "members": [
++        {
++          "name": "host",
++          "type": "str"
++        },
++        {
++          "name": "service",
++          "type": "str"
++        },
++        {
++          "name": "family",
++          "type": "282"
++        },
++        {
++          "name": "websocket",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "197",
++      "members": [
++        {
++          "name": "host",
++          "type": "str"
++        },
++        {
++          "name": "service",
++          "type": "str"
++        },
++        {
++          "name": "family",
++          "type": "282"
++        },
++        {
++          "name": "websocket",
++          "type": "bool"
++        },
++        {
++          "name": "x509_dname",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "sasl_username",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "198",
++      "meta-type": "enum",
++      "values": [
++        "reset",
++        "shutdown",
++        "poweroff",
++        "pause",
++        "debug",
++        "none",
++        "inject-nmi"
++      ]
++    },
++    {
++      "name": "199",
++      "meta-type": "enum",
++      "values": [
++        "report",
++        "ignore",
++        "enospc",
++        "stop",
++        "auto"
++      ]
++    },
++    {
++      "name": "200",
++      "meta-type": "enum",
++      "values": [
++        "blkdebug",
++        "blkverify",
++        "bochs",
++        "cloop",
++        "dmg",
++        "file",
++        "ftp",
++        "ftps",
++        "gluster",
++        "host_cdrom",
++        "host_device",
++        "http",
++        "https",
++        "iscsi",
++        "luks",
++        "nbd",
++        "nfs",
++        "null-aio",
++        "null-co",
++        "parallels",
++        "qcow",
++        "qcow2",
++        "qed",
++        "quorum",
++        "raw",
++        "rbd",
++        "replication",
++        "sheepdog",
++        "ssh",
++        "vdi",
++        "vhdx",
++        "vmdk",
++        "vpc",
++        "vvfat",
++        "vxhs"
++      ]
++    },
++    {
++      "name": "201",
++      "meta-type": "enum",
++      "values": [
++        "ignore",
++        "unmap"
++      ]
++    },
++    {
++      "name": "202",
++      "members": [
++        {
++          "name": "direct",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "no-flush",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "203",
++      "meta-type": "enum",
++      "values": [
++        "off",
++        "on",
++        "unmap"
++      ]
++    },
++    {
++      "name": "204",
++      "members": [
++        {
++          "name": "image",
++          "type": "293"
++        },
++        {
++          "name": "config",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "align",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "max-transfer",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "opt-write-zero",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "max-write-zero",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "opt-discard",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "max-discard",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "inject-error",
++          "default": null,
++          "type": "[294]"
++        },
++        {
++          "name": "set-state",
++          "default": null,
++          "type": "[295]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "205",
++      "members": [
++        {
++          "name": "test",
++          "type": "293"
++        },
++        {
++          "name": "raw",
++          "type": "293"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "206",
++      "members": [
++        {
++          "name": "file",
++          "type": "293"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "207",
++      "members": [
++        {
++          "name": "filename",
++          "type": "str"
++        },
++        {
++          "name": "locking",
++          "default": null,
++          "type": "296"
++        },
++        {
++          "name": "aio",
++          "default": null,
++          "type": "297"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "208",
++      "members": [
++        {
++          "name": "url",
++          "type": "str"
++        },
++        {
++          "name": "readahead",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "timeout",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "username",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "password-secret",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "proxy-username",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "proxy-password-secret",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "209",
++      "members": [
++        {
++          "name": "url",
++          "type": "str"
++        },
++        {
++          "name": "readahead",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "timeout",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "username",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "password-secret",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "proxy-username",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "proxy-password-secret",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "sslverify",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "210",
++      "members": [
++        {
++          "name": "volume",
++          "type": "str"
++        },
++        {
++          "name": "path",
++          "type": "str"
++        },
++        {
++          "name": "server",
++          "type": "[298]"
++        },
++        {
++          "name": "debug",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "211",
++      "members": [
++        {
++          "name": "url",
++          "type": "str"
++        },
++        {
++          "name": "readahead",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "timeout",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "username",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "password-secret",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "proxy-username",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "proxy-password-secret",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "cookie",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "cookie-secret",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "212",
++      "members": [
++        {
++          "name": "url",
++          "type": "str"
++        },
++        {
++          "name": "readahead",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "timeout",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "username",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "password-secret",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "proxy-username",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "proxy-password-secret",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "cookie",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "sslverify",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "cookie-secret",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "213",
++      "members": [
++        {
++          "name": "transport",
++          "type": "299"
++        },
++        {
++          "name": "portal",
++          "type": "str"
++        },
++        {
++          "name": "target",
++          "type": "str"
++        },
++        {
++          "name": "lun",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "user",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "password-secret",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "initiator-name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "header-digest",
++          "default": null,
++          "type": "300"
++        },
++        {
++          "name": "timeout",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "214",
++      "members": [
++        {
++          "name": "file",
++          "type": "293"
++        },
++        {
++          "name": "key-secret",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "215",
++      "members": [
++        {
++          "name": "server",
++          "type": "298"
++        },
++        {
++          "name": "export",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "tls-creds",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "216",
++      "members": [
++        {
++          "name": "server",
++          "type": "301"
++        },
++        {
++          "name": "path",
++          "type": "str"
++        },
++        {
++          "name": "user",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "group",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "tcp-syn-count",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "readahead-size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "page-cache-size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "debug",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "217",
++      "members": [
++        {
++          "name": "size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "latency-ns",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "218",
++      "members": [
++        {
++          "name": "file",
++          "type": "293"
++        },
++        {
++          "name": "backing",
++          "default": null,
++          "type": "302"
++        },
++        {
++          "name": "lazy-refcounts",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "pass-discard-request",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "pass-discard-snapshot",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "pass-discard-other",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "overlap-check",
++          "default": null,
++          "type": "303"
++        },
++        {
++          "name": "cache-size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "l2-cache-size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "refcount-cache-size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "cache-clean-interval",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "encrypt",
++          "default": null,
++          "type": "304"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "219",
++      "members": [
++        {
++          "name": "file",
++          "type": "293"
++        },
++        {
++          "name": "backing",
++          "default": null,
++          "type": "302"
++        },
++        {
++          "name": "encrypt",
++          "default": null,
++          "type": "305"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "220",
++      "members": [
++        {
++          "name": "file",
++          "type": "293"
++        },
++        {
++          "name": "backing",
++          "default": null,
++          "type": "302"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "221",
++      "members": [
++        {
++          "name": "blkverify",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "children",
++          "type": "[293]"
++        },
++        {
++          "name": "vote-threshold",
++          "type": "int"
++        },
++        {
++          "name": "rewrite-corrupted",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "read-pattern",
++          "default": null,
++          "type": "306"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "222",
++      "members": [
++        {
++          "name": "file",
++          "type": "293"
++        },
++        {
++          "name": "offset",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "size",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "223",
++      "members": [
++        {
++          "name": "pool",
++          "type": "str"
++        },
++        {
++          "name": "image",
++          "type": "str"
++        },
++        {
++          "name": "conf",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "snapshot",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "user",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "server",
++          "default": null,
++          "type": "[307]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "224",
++      "members": [
++        {
++          "name": "file",
++          "type": "293"
++        },
++        {
++          "name": "mode",
++          "type": "308"
++        },
++        {
++          "name": "top-id",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "225",
++      "members": [
++        {
++          "name": "server",
++          "type": "298"
++        },
++        {
++          "name": "vdi",
++          "type": "str"
++        },
++        {
++          "name": "snap-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "tag",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "226",
++      "members": [
++        {
++          "name": "server",
++          "type": "309"
++        },
++        {
++          "name": "path",
++          "type": "str"
++        },
++        {
++          "name": "user",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "227",
++      "members": [
++        {
++          "name": "dir",
++          "type": "str"
++        },
++        {
++          "name": "fat-type",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "floppy",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "label",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "rw",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "228",
++      "members": [
++        {
++          "name": "vdisk-id",
++          "type": "str"
++        },
++        {
++          "name": "server",
++          "type": "307"
++        },
++        {
++          "name": "tls-creds",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "229",
++      "meta-type": "enum",
++      "values": [
++        "top",
++        "full",
++        "none",
++        "incremental"
++      ]
++    },
++    {
++      "name": "230",
++      "meta-type": "enum",
++      "values": [
++        "retain",
++        "read-only",
++        "read-write"
++      ]
++    },
++    {
++      "name": "231",
++      "meta-type": "enum",
++      "values": [
++        "existing",
++        "absolute-paths"
++      ]
++    },
++    {
++      "name": "232",
++      "tag": "type",
++      "variants": [
++        {
++          "case": "file",
++          "type": "311"
++        },
++        {
++          "case": "serial",
++          "type": "312"
++        },
++        {
++          "case": "parallel",
++          "type": "312"
++        },
++        {
++          "case": "pipe",
++          "type": "312"
++        },
++        {
++          "case": "socket",
++          "type": "313"
++        },
++        {
++          "case": "udp",
++          "type": "314"
++        },
++        {
++          "case": "pty",
++          "type": "315"
++        },
++        {
++          "case": "null",
++          "type": "315"
++        },
++        {
++          "case": "mux",
++          "type": "316"
++        },
++        {
++          "case": "msmouse",
++          "type": "315"
++        },
++        {
++          "case": "wctablet",
++          "type": "315"
++        },
++        {
++          "case": "braille",
++          "type": "315"
++        },
++        {
++          "case": "testdev",
++          "type": "315"
++        },
++        {
++          "case": "stdio",
++          "type": "317"
++        },
++        {
++          "case": "console",
++          "type": "315"
++        },
++        {
++          "case": "spicevmc",
++          "type": "318"
++        },
++        {
++          "case": "spiceport",
++          "type": "319"
++        },
++        {
++          "case": "vc",
++          "type": "320"
++        },
++        {
++          "case": "ringbuf",
++          "type": "321"
++        },
++        {
++          "case": "memory",
++          "type": "321"
++        }
++      ],
++      "members": [
++        {
++          "name": "type",
++          "type": "310"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "233",
++      "meta-type": "enum",
++      "values": [
++        "elf",
++        "kdump-zlib",
++        "kdump-lzo",
++        "kdump-snappy"
++      ]
++    },
++    {
++      "name": "[234]",
++      "element-type": "234",
++      "meta-type": "array"
++    },
++    {
++      "name": "234",
++      "tag": "type",
++      "variants": [
++        {
++          "case": "key",
++          "type": "323"
++        },
++        {
++          "case": "btn",
++          "type": "324"
++        },
++        {
++          "case": "rel",
++          "type": "325"
++        },
++        {
++          "case": "abs",
++          "type": "325"
++        }
++      ],
++      "members": [
++        {
++          "name": "type",
++          "type": "322"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "235",
++      "members": [
++        {
++          "type": "str"
++        },
++        {
++          "type": "null"
++        }
++      ],
++      "meta-type": "alternate"
++    },
++    {
++      "name": "number",
++      "json-type": "number",
++      "meta-type": "builtin"
++    },
++    {
++      "name": "236",
++      "tag": "type",
++      "variants": [
++        {
++          "case": "inet",
++          "type": "327"
++        },
++        {
++          "case": "unix",
++          "type": "328"
++        },
++        {
++          "case": "vsock",
++          "type": "329"
++        },
++        {
++          "case": "fd",
++          "type": "330"
++        }
++      ],
++      "members": [
++        {
++          "name": "type",
++          "type": "326"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "237",
++      "meta-type": "enum",
++      "values": [
++        "DIMM",
++        "CPU"
++      ]
++    },
++    {
++      "name": "238",
++      "meta-type": "enum",
++      "values": [
++        "ok",
++        "failed",
++        "nospace"
++      ]
++    },
++    {
++      "name": "[239]",
++      "element-type": "239",
++      "meta-type": "array"
++    },
++    {
++      "name": "239",
++      "members": [
++        {
++          "name": "name",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "count",
++          "type": "int"
++        },
++        {
++          "name": "granularity",
++          "type": "int"
++        },
++        {
++          "name": "status",
++          "type": "331"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "240",
++      "members": [
++        {
++          "name": "rd_bytes",
++          "type": "int"
++        },
++        {
++          "name": "wr_bytes",
++          "type": "int"
++        },
++        {
++          "name": "rd_operations",
++          "type": "int"
++        },
++        {
++          "name": "wr_operations",
++          "type": "int"
++        },
++        {
++          "name": "flush_operations",
++          "type": "int"
++        },
++        {
++          "name": "flush_total_time_ns",
++          "type": "int"
++        },
++        {
++          "name": "wr_total_time_ns",
++          "type": "int"
++        },
++        {
++          "name": "rd_total_time_ns",
++          "type": "int"
++        },
++        {
++          "name": "wr_highest_offset",
++          "type": "int"
++        },
++        {
++          "name": "rd_merged",
++          "type": "int"
++        },
++        {
++          "name": "wr_merged",
++          "type": "int"
++        },
++        {
++          "name": "idle_time_ns",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "failed_rd_operations",
++          "type": "int"
++        },
++        {
++          "name": "failed_wr_operations",
++          "type": "int"
++        },
++        {
++          "name": "failed_flush_operations",
++          "type": "int"
++        },
++        {
++          "name": "invalid_rd_operations",
++          "type": "int"
++        },
++        {
++          "name": "invalid_wr_operations",
++          "type": "int"
++        },
++        {
++          "name": "invalid_flush_operations",
++          "type": "int"
++        },
++        {
++          "name": "account_invalid",
++          "type": "bool"
++        },
++        {
++          "name": "account_failed",
++          "type": "bool"
++        },
++        {
++          "name": "timed_stats",
++          "type": "[332]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[241]",
++      "element-type": "241",
++      "meta-type": "array"
++    },
++    {
++      "name": "241",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "type",
++          "type": "333"
++        },
++        {
++          "name": "help",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "default",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[str]",
++      "element-type": "str",
++      "meta-type": "array"
++    },
++    {
++      "name": "242",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "props",
++          "default": null,
++          "type": "any"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "243",
++      "meta-type": "enum",
++      "values": [
++        "incompatible",
++        "identical",
++        "superset",
++        "subset"
++      ]
++    },
++    {
++      "name": "244",
++      "meta-type": "enum",
++      "values": [
++        "static",
++        "full"
++      ]
++    },
++    {
++      "name": "245",
++      "members": [
++        {
++          "name": "node-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "socket-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "core-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "thread-id",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "246",
++      "meta-type": "enum",
++      "values": [
++        "x86",
++        "sparc",
++        "ppc",
++        "mips",
++        "tricore",
++        "other"
++      ]
++    },
++    {
++      "name": "247",
++      "members": [
++        {
++          "name": "pc",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "248",
++      "members": [
++        {
++          "name": "pc",
++          "type": "int"
++        },
++        {
++          "name": "npc",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "249",
++      "members": [
++        {
++          "name": "nip",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "250",
++      "members": [
++        {
++          "name": "PC",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "251",
++      "members": [
++        {
++          "name": "PC",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "252",
++      "members": [
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "253",
++      "meta-type": "enum",
++      "values": [
++        "none",
++        "active",
++        "completed",
++        "failed"
++      ]
++    },
++    {
++      "name": "[233]",
++      "element-type": "233",
++      "meta-type": "array"
++    },
++    {
++      "name": "[254]",
++      "element-type": "254",
++      "meta-type": "array"
++    },
++    {
++      "name": "254",
++      "members": [
++        {
++          "name": "fd",
++          "type": "int"
++        },
++        {
++          "name": "opaque",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[int]",
++      "element-type": "int",
++      "meta-type": "array"
++    },
++    {
++      "name": "255",
++      "meta-type": "enum",
++      "values": [
++        "default",
++        "preferred",
++        "bind",
++        "interleave"
++      ]
++    },
++    {
++      "name": "256",
++      "meta-type": "enum",
++      "values": [
++        "dimm"
++      ]
++    },
++    {
++      "name": "257",
++      "members": [
++        {
++          "name": "data",
++          "type": "334"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "258",
++      "members": [
++        {
++          "name": "transferred",
++          "type": "int"
++        },
++        {
++          "name": "remaining",
++          "type": "int"
++        },
++        {
++          "name": "total",
++          "type": "int"
++        },
++        {
++          "name": "duplicate",
++          "type": "int"
++        },
++        {
++          "name": "skipped",
++          "type": "int"
++        },
++        {
++          "name": "normal",
++          "type": "int"
++        },
++        {
++          "name": "normal-bytes",
++          "type": "int"
++        },
++        {
++          "name": "dirty-pages-rate",
++          "type": "int"
++        },
++        {
++          "name": "mbps",
++          "type": "number"
++        },
++        {
++          "name": "dirty-sync-count",
++          "type": "int"
++        },
++        {
++          "name": "postcopy-requests",
++          "type": "int"
++        },
++        {
++          "name": "page-size",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "259",
++      "members": [
++        {
++          "name": "cache-size",
++          "type": "int"
++        },
++        {
++          "name": "bytes",
++          "type": "int"
++        },
++        {
++          "name": "pages",
++          "type": "int"
++        },
++        {
++          "name": "cache-miss",
++          "type": "int"
++        },
++        {
++          "name": "cache-miss-rate",
++          "type": "number"
++        },
++        {
++          "name": "overflow",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "260",
++      "meta-type": "enum",
++      "values": [
++        "xbzrle",
++        "rdma-pin-all",
++        "auto-converge",
++        "zero-blocks",
++        "compress",
++        "events",
++        "postcopy-ram",
++        "x-colo",
++        "release-ram",
++        "block",
++        "return-path"
++      ]
++    },
++    {
++      "name": "261",
++      "members": [
++        {
++          "name": "filename",
++          "type": "str"
++        },
++        {
++          "name": "format",
++          "type": "str"
++        },
++        {
++          "name": "dirty-flag",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "actual-size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "virtual-size",
++          "type": "int"
++        },
++        {
++          "name": "cluster-size",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "encrypted",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "compressed",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "backing-filename",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "full-backing-filename",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "backing-filename-format",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "snapshots",
++          "default": null,
++          "type": "[57]"
++        },
++        {
++          "name": "backing-image",
++          "default": null,
++          "type": "261"
++        },
++        {
++          "name": "format-specific",
++          "default": null,
++          "type": "335"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "262",
++      "members": [
++        {
++          "name": "writeback",
++          "type": "bool"
++        },
++        {
++          "name": "direct",
++          "type": "bool"
++        },
++        {
++          "name": "no-flush",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[263]",
++      "element-type": "263",
++      "meta-type": "array"
++    },
++    {
++      "name": "263",
++      "members": [
++        {
++          "name": "bus",
++          "type": "int"
++        },
++        {
++          "name": "slot",
++          "type": "int"
++        },
++        {
++          "name": "function",
++          "type": "int"
++        },
++        {
++          "name": "class_info",
++          "type": "336"
++        },
++        {
++          "name": "id",
++          "type": "337"
++        },
++        {
++          "name": "irq",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "qdev_id",
++          "type": "str"
++        },
++        {
++          "name": "pci_bridge",
++          "default": null,
++          "type": "338"
++        },
++        {
++          "name": "regions",
++          "type": "[339]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "264",
++      "meta-type": "enum",
++      "values": [
++        "builtin",
++        "enum",
++        "array",
++        "object",
++        "alternate",
++        "command",
++        "event"
++      ]
++    },
++    {
++      "name": "265",
++      "members": [
++        {
++          "name": "json-type",
++          "type": "340"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "266",
++      "members": [
++        {
++          "name": "values",
++          "type": "[str]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "267",
++      "members": [
++        {
++          "name": "element-type",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "268",
++      "members": [
++        {
++          "name": "members",
++          "type": "[341]"
++        },
++        {
++          "name": "tag",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "variants",
++          "default": null,
++          "type": "[342]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "269",
++      "members": [
++        {
++          "name": "members",
++          "type": "[343]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "270",
++      "members": [
++        {
++          "name": "arg-type",
++          "type": "str"
++        },
++        {
++          "name": "ret-type",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "271",
++      "members": [
++        {
++          "name": "arg-type",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "272",
++      "members": [
++        {
++          "name": "priority",
++          "type": "int"
++        },
++        {
++          "name": "tbl-id",
++          "type": "int"
++        },
++        {
++          "name": "in-pport",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "tunnel-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "vlan-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "eth-type",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "eth-src",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "eth-dst",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "ip-proto",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "ip-tos",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "ip-dst",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "273",
++      "members": [
++        {
++          "name": "in-pport",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "tunnel-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "vlan-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "eth-src",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "eth-dst",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "ip-proto",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "ip-tos",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "274",
++      "members": [
++        {
++          "name": "goto-tbl",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "group-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "tunnel-lport",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "vlan-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "new-vlan-id",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "out-pport",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "275",
++      "meta-type": "enum",
++      "values": [
++        "half",
++        "full"
++      ]
++    },
++    {
++      "name": "276",
++      "meta-type": "enum",
++      "values": [
++        "off",
++        "on"
++      ]
++    },
++    {
++      "name": "277",
++      "meta-type": "enum",
++      "values": [
++        "normal",
++        "none",
++        "all"
++      ]
++    },
++    {
++      "name": "278",
++      "meta-type": "enum",
++      "values": [
++        "client",
++        "server",
++        "unknown"
++      ]
++    },
++    {
++      "name": "[194]",
++      "element-type": "194",
++      "meta-type": "array"
++    },
++    {
++      "name": "279",
++      "meta-type": "enum",
++      "values": [
++        "debug",
++        "inmigrate",
++        "internal-error",
++        "io-error",
++        "paused",
++        "postmigrate",
++        "prelaunch",
++        "finish-migrate",
++        "restore-vm",
++        "running",
++        "save-vm",
++        "shutdown",
++        "suspended",
++        "watchdog",
++        "guest-panicked",
++        "colo"
++      ]
++    },
++    {
++      "name": "280",
++      "tag": "type",
++      "variants": [
++        {
++          "case": "passthrough",
++          "type": "345"
++        }
++      ],
++      "members": [
++        {
++          "name": "type",
++          "type": "344"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "281",
++      "members": [
++        {
++          "name": "major",
++          "type": "int"
++        },
++        {
++          "name": "minor",
++          "type": "int"
++        },
++        {
++          "name": "micro",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "282",
++      "meta-type": "enum",
++      "values": [
++        "ipv4",
++        "ipv6",
++        "unix",
++        "vsock",
++        "unknown"
++      ]
++    },
++    {
++      "name": "[197]",
++      "element-type": "197",
++      "meta-type": "array"
++    },
++    {
++      "name": "[283]",
++      "element-type": "283",
++      "meta-type": "array"
++    },
++    {
++      "name": "283",
++      "members": [
++        {
++          "name": "host",
++          "type": "str"
++        },
++        {
++          "name": "service",
++          "type": "str"
++        },
++        {
++          "name": "family",
++          "type": "282"
++        },
++        {
++          "name": "websocket",
++          "type": "bool"
++        },
++        {
++          "name": "auth",
++          "type": "284"
++        },
++        {
++          "name": "vencrypt",
++          "default": null,
++          "type": "285"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "284",
++      "meta-type": "enum",
++      "values": [
++        "none",
++        "vnc",
++        "ra2",
++        "ra2ne",
++        "tight",
++        "ultra",
++        "tls",
++        "vencrypt",
++        "sasl"
++      ]
++    },
++    {
++      "name": "285",
++      "meta-type": "enum",
++      "values": [
++        "plain",
++        "tls-none",
++        "x509-none",
++        "tls-vnc",
++        "x509-vnc",
++        "tls-plain",
++        "x509-plain",
++        "tls-sasl",
++        "x509-sasl"
++      ]
++    },
++    {
++      "name": "286",
++      "meta-type": "enum",
++      "values": [
++        "utf8",
++        "base64"
++      ]
++    },
++    {
++      "name": "[287]",
++      "element-type": "287",
++      "meta-type": "array"
++    },
++    {
++      "name": "287",
++      "tag": "type",
++      "variants": [
++        {
++          "case": "number",
++          "type": "347"
++        },
++        {
++          "case": "qcode",
++          "type": "348"
++        }
++      ],
++      "members": [
++        {
++          "name": "type",
++          "type": "346"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "288",
++      "meta-type": "enum",
++      "values": [
++        "unavailable",
++        "disabled",
++        "enabled"
++      ]
++    },
++    {
++      "name": "[289]",
++      "element-type": "289",
++      "meta-type": "array"
++    },
++    {
++      "name": "289",
++      "tag": "type",
++      "variants": [
++        {
++          "case": "abort",
++          "type": "350"
++        },
++        {
++          "case": "block-dirty-bitmap-add",
++          "type": "351"
++        },
++        {
++          "case": "block-dirty-bitmap-clear",
++          "type": "352"
++        },
++        {
++          "case": "blockdev-backup",
++          "type": "353"
++        },
++        {
++          "case": "blockdev-snapshot",
++          "type": "354"
++        },
++        {
++          "case": "blockdev-snapshot-internal-sync",
++          "type": "355"
++        },
++        {
++          "case": "blockdev-snapshot-sync",
++          "type": "356"
++        },
++        {
++          "case": "drive-backup",
++          "type": "357"
++        }
++      ],
++      "members": [
++        {
++          "name": "type",
++          "type": "349"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "290",
++      "members": [
++        {
++          "name": "completion-mode",
++          "default": null,
++          "type": "358"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "291",
++      "meta-type": "enum",
++      "values": [
++        "hyper-v"
++      ]
++    },
++    {
++      "name": "292",
++      "members": [
++        {
++          "name": "arg1",
++          "type": "int"
++        },
++        {
++          "name": "arg2",
++          "type": "int"
++        },
++        {
++          "name": "arg3",
++          "type": "int"
++        },
++        {
++          "name": "arg4",
++          "type": "int"
++        },
++        {
++          "name": "arg5",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "293",
++      "members": [
++        {
++          "type": "48"
++        },
++        {
++          "type": "str"
++        }
++      ],
++      "meta-type": "alternate"
++    },
++    {
++      "name": "[294]",
++      "element-type": "294",
++      "meta-type": "array"
++    },
++    {
++      "name": "294",
++      "members": [
++        {
++          "name": "event",
++          "type": "359"
++        },
++        {
++          "name": "state",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "errno",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "sector",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "once",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "immediately",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[295]",
++      "element-type": "295",
++      "meta-type": "array"
++    },
++    {
++      "name": "295",
++      "members": [
++        {
++          "name": "event",
++          "type": "359"
++        },
++        {
++          "name": "state",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "new_state",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "296",
++      "meta-type": "enum",
++      "values": [
++        "auto",
++        "on",
++        "off"
++      ]
++    },
++    {
++      "name": "297",
++      "meta-type": "enum",
++      "values": [
++        "threads",
++        "native"
++      ]
++    },
++    {
++      "name": "[298]",
++      "element-type": "298",
++      "meta-type": "array"
++    },
++    {
++      "name": "298",
++      "tag": "type",
++      "variants": [
++        {
++          "case": "inet",
++          "type": "309"
++        },
++        {
++          "case": "unix",
++          "type": "361"
++        },
++        {
++          "case": "vsock",
++          "type": "362"
++        },
++        {
++          "case": "fd",
++          "type": "363"
++        }
++      ],
++      "members": [
++        {
++          "name": "type",
++          "type": "360"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "299",
++      "meta-type": "enum",
++      "values": [
++        "tcp",
++        "iser"
++      ]
++    },
++    {
++      "name": "300",
++      "meta-type": "enum",
++      "values": [
++        "crc32c",
++        "none",
++        "crc32c-none",
++        "none-crc32c"
++      ]
++    },
++    {
++      "name": "301",
++      "members": [
++        {
++          "name": "type",
++          "type": "364"
++        },
++        {
++          "name": "host",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "302",
++      "members": [
++        {
++          "type": "48"
++        },
++        {
++          "type": "str"
++        },
++        {
++          "type": "null"
++        }
++      ],
++      "meta-type": "alternate"
++    },
++    {
++      "name": "303",
++      "members": [
++        {
++          "type": "365"
++        },
++        {
++          "type": "366"
++        }
++      ],
++      "meta-type": "alternate"
++    },
++    {
++      "name": "304",
++      "tag": "format",
++      "variants": [
++        {
++          "case": "aes",
++          "type": "368"
++        },
++        {
++          "case": "luks",
++          "type": "369"
++        }
++      ],
++      "members": [
++        {
++          "name": "format",
++          "type": "367"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "305",
++      "tag": "format",
++      "variants": [
++        {
++          "case": "aes",
++          "type": "368"
++        }
++      ],
++      "members": [
++        {
++          "name": "format",
++          "type": "370"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[293]",
++      "element-type": "293",
++      "meta-type": "array"
++    },
++    {
++      "name": "306",
++      "meta-type": "enum",
++      "values": [
++        "quorum",
++        "fifo"
++      ]
++    },
++    {
++      "name": "[307]",
++      "element-type": "307",
++      "meta-type": "array"
++    },
++    {
++      "name": "307",
++      "members": [
++        {
++          "name": "host",
++          "type": "str"
++        },
++        {
++          "name": "port",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "308",
++      "meta-type": "enum",
++      "values": [
++        "primary",
++        "secondary"
++      ]
++    },
++    {
++      "name": "309",
++      "members": [
++        {
++          "name": "host",
++          "type": "str"
++        },
++        {
++          "name": "port",
++          "type": "str"
++        },
++        {
++          "name": "numeric",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "to",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "ipv4",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "ipv6",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "310",
++      "meta-type": "enum",
++      "values": [
++        "file",
++        "serial",
++        "parallel",
++        "pipe",
++        "socket",
++        "udp",
++        "pty",
++        "null",
++        "mux",
++        "msmouse",
++        "wctablet",
++        "braille",
++        "testdev",
++        "stdio",
++        "console",
++        "spicevmc",
++        "spiceport",
++        "vc",
++        "ringbuf",
++        "memory"
++      ]
++    },
++    {
++      "name": "311",
++      "members": [
++        {
++          "name": "data",
++          "type": "371"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "312",
++      "members": [
++        {
++          "name": "data",
++          "type": "372"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "313",
++      "members": [
++        {
++          "name": "data",
++          "type": "373"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "314",
++      "members": [
++        {
++          "name": "data",
++          "type": "374"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "315",
++      "members": [
++        {
++          "name": "data",
++          "type": "375"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "316",
++      "members": [
++        {
++          "name": "data",
++          "type": "376"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "317",
++      "members": [
++        {
++          "name": "data",
++          "type": "377"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "318",
++      "members": [
++        {
++          "name": "data",
++          "type": "378"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "319",
++      "members": [
++        {
++          "name": "data",
++          "type": "379"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "320",
++      "members": [
++        {
++          "name": "data",
++          "type": "380"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "321",
++      "members": [
++        {
++          "name": "data",
++          "type": "381"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "322",
++      "meta-type": "enum",
++      "values": [
++        "key",
++        "btn",
++        "rel",
++        "abs"
++      ]
++    },
++    {
++      "name": "323",
++      "members": [
++        {
++          "name": "data",
++          "type": "382"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "324",
++      "members": [
++        {
++          "name": "data",
++          "type": "383"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "325",
++      "members": [
++        {
++          "name": "data",
++          "type": "384"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "null",
++      "json-type": "null",
++      "meta-type": "builtin"
++    },
++    {
++      "name": "326",
++      "meta-type": "enum",
++      "values": [
++        "inet",
++        "unix",
++        "vsock",
++        "fd"
++      ]
++    },
++    {
++      "name": "327",
++      "members": [
++        {
++          "name": "data",
++          "type": "309"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "328",
++      "members": [
++        {
++          "name": "data",
++          "type": "361"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "329",
++      "members": [
++        {
++          "name": "data",
++          "type": "362"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "330",
++      "members": [
++        {
++          "name": "data",
++          "type": "363"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "331",
++      "meta-type": "enum",
++      "values": [
++        "active",
++        "disabled",
++        "frozen"
++      ]
++    },
++    {
++      "name": "[332]",
++      "element-type": "332",
++      "meta-type": "array"
++    },
++    {
++      "name": "332",
++      "members": [
++        {
++          "name": "interval_length",
++          "type": "int"
++        },
++        {
++          "name": "min_rd_latency_ns",
++          "type": "int"
++        },
++        {
++          "name": "max_rd_latency_ns",
++          "type": "int"
++        },
++        {
++          "name": "avg_rd_latency_ns",
++          "type": "int"
++        },
++        {
++          "name": "min_wr_latency_ns",
++          "type": "int"
++        },
++        {
++          "name": "max_wr_latency_ns",
++          "type": "int"
++        },
++        {
++          "name": "avg_wr_latency_ns",
++          "type": "int"
++        },
++        {
++          "name": "min_flush_latency_ns",
++          "type": "int"
++        },
++        {
++          "name": "max_flush_latency_ns",
++          "type": "int"
++        },
++        {
++          "name": "avg_flush_latency_ns",
++          "type": "int"
++        },
++        {
++          "name": "avg_rd_queue_depth",
++          "type": "number"
++        },
++        {
++          "name": "avg_wr_queue_depth",
++          "type": "number"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "333",
++      "meta-type": "enum",
++      "values": [
++        "string",
++        "boolean",
++        "number",
++        "size"
++      ]
++    },
++    {
++      "name": "334",
++      "members": [
++        {
++          "name": "id",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "addr",
++          "type": "int"
++        },
++        {
++          "name": "size",
++          "type": "int"
++        },
++        {
++          "name": "slot",
++          "type": "int"
++        },
++        {
++          "name": "node",
++          "type": "int"
++        },
++        {
++          "name": "memdev",
++          "type": "str"
++        },
++        {
++          "name": "hotplugged",
++          "type": "bool"
++        },
++        {
++          "name": "hotpluggable",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[57]",
++      "element-type": "57",
++      "meta-type": "array"
++    },
++    {
++      "name": "335",
++      "tag": "type",
++      "variants": [
++        {
++          "case": "qcow2",
++          "type": "386"
++        },
++        {
++          "case": "vmdk",
++          "type": "387"
++        },
++        {
++          "case": "luks",
++          "type": "388"
++        }
++      ],
++      "members": [
++        {
++          "name": "type",
++          "type": "385"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "336",
++      "members": [
++        {
++          "name": "desc",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "class",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "337",
++      "members": [
++        {
++          "name": "device",
++          "type": "int"
++        },
++        {
++          "name": "vendor",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "338",
++      "members": [
++        {
++          "name": "bus",
++          "type": "389"
++        },
++        {
++          "name": "devices",
++          "default": null,
++          "type": "[263]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[339]",
++      "element-type": "339",
++      "meta-type": "array"
++    },
++    {
++      "name": "339",
++      "members": [
++        {
++          "name": "bar",
++          "type": "int"
++        },
++        {
++          "name": "type",
++          "type": "str"
++        },
++        {
++          "name": "address",
++          "type": "int"
++        },
++        {
++          "name": "size",
++          "type": "int"
++        },
++        {
++          "name": "prefetch",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "mem_type_64",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "340",
++      "meta-type": "enum",
++      "values": [
++        "string",
++        "number",
++        "int",
++        "boolean",
++        "null",
++        "object",
++        "array",
++        "value"
++      ]
++    },
++    {
++      "name": "[341]",
++      "element-type": "341",
++      "meta-type": "array"
++    },
++    {
++      "name": "341",
++      "members": [
++        {
++          "name": "name",
++          "type": "str"
++        },
++        {
++          "name": "type",
++          "type": "str"
++        },
++        {
++          "name": "default",
++          "default": null,
++          "type": "any"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[342]",
++      "element-type": "342",
++      "meta-type": "array"
++    },
++    {
++      "name": "342",
++      "members": [
++        {
++          "name": "case",
++          "type": "str"
++        },
++        {
++          "name": "type",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[343]",
++      "element-type": "343",
++      "meta-type": "array"
++    },
++    {
++      "name": "343",
++      "members": [
++        {
++          "name": "type",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "344",
++      "meta-type": "enum",
++      "values": [
++        "passthrough"
++      ]
++    },
++    {
++      "name": "345",
++      "members": [
++        {
++          "name": "data",
++          "type": "390"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "346",
++      "meta-type": "enum",
++      "values": [
++        "number",
++        "qcode"
++      ]
++    },
++    {
++      "name": "347",
++      "members": [
++        {
++          "name": "data",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "348",
++      "members": [
++        {
++          "name": "data",
++          "type": "391"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "349",
++      "meta-type": "enum",
++      "values": [
++        "abort",
++        "block-dirty-bitmap-add",
++        "block-dirty-bitmap-clear",
++        "blockdev-backup",
++        "blockdev-snapshot",
++        "blockdev-snapshot-internal-sync",
++        "blockdev-snapshot-sync",
++        "drive-backup"
++      ]
++    },
++    {
++      "name": "350",
++      "members": [
++        {
++          "name": "data",
++          "type": "392"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "351",
++      "members": [
++        {
++          "name": "data",
++          "type": "36"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "352",
++      "members": [
++        {
++          "name": "data",
++          "type": "37"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "353",
++      "members": [
++        {
++          "name": "data",
++          "type": "49"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "354",
++      "members": [
++        {
++          "name": "data",
++          "type": "55"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "355",
++      "members": [
++        {
++          "name": "data",
++          "type": "58"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "356",
++      "members": [
++        {
++          "name": "data",
++          "type": "59"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "357",
++      "members": [
++        {
++          "name": "data",
++          "type": "76"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "358",
++      "meta-type": "enum",
++      "values": [
++        "individual",
++        "grouped"
++      ]
++    },
++    {
++      "name": "359",
++      "meta-type": "enum",
++      "values": [
++        "l1_update",
++        "l1_grow_alloc_table",
++        "l1_grow_write_table",
++        "l1_grow_activate_table",
++        "l2_load",
++        "l2_update",
++        "l2_update_compressed",
++        "l2_alloc_cow_read",
++        "l2_alloc_write",
++        "read_aio",
++        "read_backing_aio",
++        "read_compressed",
++        "write_aio",
++        "write_compressed",
++        "vmstate_load",
++        "vmstate_save",
++        "cow_read",
++        "cow_write",
++        "reftable_load",
++        "reftable_grow",
++        "reftable_update",
++        "refblock_load",
++        "refblock_update",
++        "refblock_update_part",
++        "refblock_alloc",
++        "refblock_alloc_hookup",
++        "refblock_alloc_write",
++        "refblock_alloc_write_blocks",
++        "refblock_alloc_write_table",
++        "refblock_alloc_switch_table",
++        "cluster_alloc",
++        "cluster_alloc_bytes",
++        "cluster_free",
++        "flush_to_os",
++        "flush_to_disk",
++        "pwritev_rmw_head",
++        "pwritev_rmw_after_head",
++        "pwritev_rmw_tail",
++        "pwritev_rmw_after_tail",
++        "pwritev",
++        "pwritev_zero",
++        "pwritev_done",
++        "empty_image_prepare"
++      ]
++    },
++    {
++      "name": "360",
++      "meta-type": "enum",
++      "values": [
++        "inet",
++        "unix",
++        "vsock",
++        "fd"
++      ]
++    },
++    {
++      "name": "361",
++      "members": [
++        {
++          "name": "path",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "362",
++      "members": [
++        {
++          "name": "cid",
++          "type": "str"
++        },
++        {
++          "name": "port",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "363",
++      "members": [
++        {
++          "name": "str",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "364",
++      "meta-type": "enum",
++      "values": [
++        "inet"
++      ]
++    },
++    {
++      "name": "365",
++      "members": [
++        {
++          "name": "template",
++          "default": null,
++          "type": "366"
++        },
++        {
++          "name": "main-header",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "active-l1",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "active-l2",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "refcount-table",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "refcount-block",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "snapshot-table",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "inactive-l1",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "inactive-l2",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "366",
++      "meta-type": "enum",
++      "values": [
++        "none",
++        "constant",
++        "cached",
++        "all"
++      ]
++    },
++    {
++      "name": "367",
++      "meta-type": "enum",
++      "values": [
++        "aes",
++        "luks"
++      ]
++    },
++    {
++      "name": "368",
++      "members": [
++        {
++          "name": "key-secret",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "369",
++      "members": [
++        {
++          "name": "key-secret",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "370",
++      "meta-type": "enum",
++      "values": [
++        "aes"
++      ]
++    },
++    {
++      "name": "371",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "in",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "out",
++          "type": "str"
++        },
++        {
++          "name": "append",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "372",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "device",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "373",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "addr",
++          "type": "236"
++        },
++        {
++          "name": "tls-creds",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "server",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "wait",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "nodelay",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "telnet",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "tn3270",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "reconnect",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "374",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "remote",
++          "type": "236"
++        },
++        {
++          "name": "local",
++          "default": null,
++          "type": "236"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "375",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "376",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "chardev",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "377",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "signal",
++          "default": null,
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "378",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "type",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "379",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "fqdn",
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "380",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "width",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "height",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "cols",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "rows",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "381",
++      "members": [
++        {
++          "name": "logfile",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "logappend",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "size",
++          "default": null,
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "382",
++      "members": [
++        {
++          "name": "key",
++          "type": "287"
++        },
++        {
++          "name": "down",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "383",
++      "members": [
++        {
++          "name": "button",
++          "type": "393"
++        },
++        {
++          "name": "down",
++          "type": "bool"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "384",
++      "members": [
++        {
++          "name": "axis",
++          "type": "394"
++        },
++        {
++          "name": "value",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "385",
++      "meta-type": "enum",
++      "values": [
++        "qcow2",
++        "vmdk",
++        "luks"
++      ]
++    },
++    {
++      "name": "386",
++      "members": [
++        {
++          "name": "data",
++          "type": "395"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "387",
++      "members": [
++        {
++          "name": "data",
++          "type": "396"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "388",
++      "members": [
++        {
++          "name": "data",
++          "type": "397"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "389",
++      "members": [
++        {
++          "name": "number",
++          "type": "int"
++        },
++        {
++          "name": "secondary",
++          "type": "int"
++        },
++        {
++          "name": "subordinate",
++          "type": "int"
++        },
++        {
++          "name": "io_range",
++          "type": "398"
++        },
++        {
++          "name": "memory_range",
++          "type": "398"
++        },
++        {
++          "name": "prefetchable_range",
++          "type": "398"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "390",
++      "members": [
++        {
++          "name": "path",
++          "default": null,
++          "type": "str"
++        },
++        {
++          "name": "cancel-path",
++          "default": null,
++          "type": "str"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "391",
++      "meta-type": "enum",
++      "values": [
++        "unmapped",
++        "shift",
++        "shift_r",
++        "alt",
++        "alt_r",
++        "ctrl",
++        "ctrl_r",
++        "menu",
++        "esc",
++        "1",
++        "2",
++        "3",
++        "4",
++        "5",
++        "6",
++        "7",
++        "8",
++        "9",
++        "0",
++        "minus",
++        "equal",
++        "backspace",
++        "tab",
++        "q",
++        "w",
++        "e",
++        "r",
++        "t",
++        "y",
++        "u",
++        "i",
++        "o",
++        "p",
++        "bracket_left",
++        "bracket_right",
++        "ret",
++        "a",
++        "s",
++        "d",
++        "f",
++        "g",
++        "h",
++        "j",
++        "k",
++        "l",
++        "semicolon",
++        "apostrophe",
++        "grave_accent",
++        "backslash",
++        "z",
++        "x",
++        "c",
++        "v",
++        "b",
++        "n",
++        "m",
++        "comma",
++        "dot",
++        "slash",
++        "asterisk",
++        "spc",
++        "caps_lock",
++        "f1",
++        "f2",
++        "f3",
++        "f4",
++        "f5",
++        "f6",
++        "f7",
++        "f8",
++        "f9",
++        "f10",
++        "num_lock",
++        "scroll_lock",
++        "kp_divide",
++        "kp_multiply",
++        "kp_subtract",
++        "kp_add",
++        "kp_enter",
++        "kp_decimal",
++        "sysrq",
++        "kp_0",
++        "kp_1",
++        "kp_2",
++        "kp_3",
++        "kp_4",
++        "kp_5",
++        "kp_6",
++        "kp_7",
++        "kp_8",
++        "kp_9",
++        "less",
++        "f11",
++        "f12",
++        "print",
++        "home",
++        "pgup",
++        "pgdn",
++        "end",
++        "left",
++        "up",
++        "down",
++        "right",
++        "insert",
++        "delete",
++        "stop",
++        "again",
++        "props",
++        "undo",
++        "front",
++        "copy",
++        "open",
++        "paste",
++        "find",
++        "cut",
++        "lf",
++        "help",
++        "meta_l",
++        "meta_r",
++        "compose",
++        "pause",
++        "ro",
++        "hiragana",
++        "henkan",
++        "yen",
++        "kp_comma",
++        "kp_equals",
++        "power",
++        "sleep",
++        "wake",
++        "audionext",
++        "audioprev",
++        "audiostop",
++        "audioplay",
++        "audiomute",
++        "volumeup",
++        "volumedown",
++        "mediaselect",
++        "mail",
++        "calculator",
++        "computer",
++        "ac_home",
++        "ac_back",
++        "ac_forward",
++        "ac_refresh",
++        "ac_bookmarks"
++      ]
++    },
++    {
++      "name": "392",
++      "members": [
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "393",
++      "meta-type": "enum",
++      "values": [
++        "left",
++        "middle",
++        "right",
++        "wheel-up",
++        "wheel-down",
++        "side",
++        "extra"
++      ]
++    },
++    {
++      "name": "394",
++      "meta-type": "enum",
++      "values": [
++        "x",
++        "y"
++      ]
++    },
++    {
++      "name": "395",
++      "members": [
++        {
++          "name": "compat",
++          "type": "str"
++        },
++        {
++          "name": "lazy-refcounts",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "corrupt",
++          "default": null,
++          "type": "bool"
++        },
++        {
++          "name": "refcount-bits",
++          "type": "int"
++        },
++        {
++          "name": "encrypt",
++          "default": null,
++          "type": "399"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "396",
++      "members": [
++        {
++          "name": "create-type",
++          "type": "str"
++        },
++        {
++          "name": "cid",
++          "type": "int"
++        },
++        {
++          "name": "parent-cid",
++          "type": "int"
++        },
++        {
++          "name": "extents",
++          "type": "[261]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "397",
++      "members": [
++        {
++          "name": "cipher-alg",
++          "type": "400"
++        },
++        {
++          "name": "cipher-mode",
++          "type": "401"
++        },
++        {
++          "name": "ivgen-alg",
++          "type": "402"
++        },
++        {
++          "name": "ivgen-hash-alg",
++          "default": null,
++          "type": "403"
++        },
++        {
++          "name": "hash-alg",
++          "type": "403"
++        },
++        {
++          "name": "payload-offset",
++          "type": "int"
++        },
++        {
++          "name": "master-key-iters",
++          "type": "int"
++        },
++        {
++          "name": "uuid",
++          "type": "str"
++        },
++        {
++          "name": "slots",
++          "type": "[404]"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "398",
++      "members": [
++        {
++          "name": "base",
++          "type": "int"
++        },
++        {
++          "name": "limit",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "399",
++      "tag": "format",
++      "variants": [
++        {
++          "case": "aes",
++          "type": "405"
++        },
++        {
++          "case": "luks",
++          "type": "397"
++        }
++      ],
++      "members": [
++        {
++          "name": "format",
++          "type": "367"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "[261]",
++      "element-type": "261",
++      "meta-type": "array"
++    },
++    {
++      "name": "400",
++      "meta-type": "enum",
++      "values": [
++        "aes-128",
++        "aes-192",
++        "aes-256",
++        "des-rfb",
++        "3des",
++        "cast5-128",
++        "serpent-128",
++        "serpent-192",
++        "serpent-256",
++        "twofish-128",
++        "twofish-192",
++        "twofish-256"
++      ]
++    },
++    {
++      "name": "401",
++      "meta-type": "enum",
++      "values": [
++        "ecb",
++        "cbc",
++        "xts",
++        "ctr"
++      ]
++    },
++    {
++      "name": "402",
++      "meta-type": "enum",
++      "values": [
++        "plain",
++        "plain64",
++        "essiv"
++      ]
++    },
++    {
++      "name": "403",
++      "meta-type": "enum",
++      "values": [
++        "md5",
++        "sha1",
++        "sha224",
++        "sha256",
++        "sha384",
++        "sha512",
++        "ripemd160"
++      ]
++    },
++    {
++      "name": "[404]",
++      "element-type": "404",
++      "meta-type": "array"
++    },
++    {
++      "name": "404",
++      "members": [
++        {
++          "name": "active",
++          "type": "bool"
++        },
++        {
++          "name": "iters",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "stripes",
++          "default": null,
++          "type": "int"
++        },
++        {
++          "name": "key-offset",
++          "type": "int"
++        }
++      ],
++      "meta-type": "object"
++    },
++    {
++      "name": "405",
++      "members": [
++      ],
++      "meta-type": "object"
++    }
++  ],
++  "id": "libvirt-48"
++}
++
++{
++  "return": {
++  },
++  "id": "libvirt-1"
++}
++
++{
++  "return": [
++    {
++      "name": "default",
++      "typename": "604-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "ppc",
++      "typename": "604-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "ppc32",
++      "typename": "604-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "ppc64",
++      "typename": "970fx_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "970mp",
++      "typename": "970mp_v1.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "970fx",
++      "typename": "970fx_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "970",
++      "typename": "970_v2.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER9",
++      "typename": "POWER9_v1.0-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER8NVL",
++      "typename": "POWER8NVL_v1.0-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER8",
++      "typename": "POWER8_v2.0-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER8E",
++      "typename": "POWER8E_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER7+",
++      "typename": "POWER7+_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER7",
++      "typename": "POWER7_v2.3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER5gs",
++      "typename": "POWER5+_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "POWER5+",
++      "typename": "POWER5+_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Apollo7PM",
++      "typename": "7457A_v1.0-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7457A",
++      "typename": "7457A_v1.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7447A",
++      "typename": "7447A_v1.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Apollo7",
++      "typename": "7457_v1.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7457",
++      "typename": "7457_v1.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7447",
++      "typename": "7447_v1.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Apollo6",
++      "typename": "7455_v3.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7455",
++      "typename": "7455_v3.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7445",
++      "typename": "7445_v3.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7451",
++      "typename": "7451_v2.3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7441",
++      "typename": "7441_v2.3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Vger",
++      "typename": "7450_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7450",
++      "typename": "7450_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7448",
++      "typename": "7448_v2.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Nitro",
++      "typename": "7410_v1.4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7410",
++      "typename": "7410_v1.4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "G4",
++      "typename": "7400_v2.9-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Max",
++      "typename": "7400_v2.9-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7400",
++      "typename": "7400_v2.9-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Goldfinger",
++      "typename": "755_v2.8-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "755",
++      "typename": "755_v2.8-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "745",
++      "typename": "745_v2.8-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "LoneStar",
++      "typename": "750l_v3.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750l",
++      "typename": "750l_v3.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750gx",
++      "typename": "750gx_v1.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750fx",
++      "typename": "750fx_v2.3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750cxe",
++      "typename": "750cxe_v3.1b-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750cx",
++      "typename": "750cx_v2.2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750cl",
++      "typename": "750cl_v2.0-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Conan/Doyle",
++      "typename": "750p-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "G3",
++      "typename": "750_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Typhoon",
++      "typename": "750_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "750",
++      "typename": "750_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Arthur",
++      "typename": "740_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "740",
++      "typename": "740_v3.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Mach5",
++      "typename": "604r-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Sirocco",
++      "typename": "604e_v2.4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "604e",
++      "typename": "604e_v2.4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Goldeneye",
++      "typename": "603e7t-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "603r",
++      "typename": "603e7t-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Vaillant",
++      "typename": "603e7v-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Stretch",
++      "typename": "603e_v4.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "603e",
++      "typename": "603e_v4.1-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "Vanilla",
++      "typename": "603-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "601v",
++      "typename": "601_v2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "601",
++      "typename": "601_v2-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8560",
++      "typename": "MPC8560_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8555E",
++      "typename": "MPC8555E_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8555",
++      "typename": "MPC8555_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8548E",
++      "typename": "MPC8548E_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8548",
++      "typename": "MPC8548_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8547E",
++      "typename": "MPC8547E_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8545E",
++      "typename": "MPC8545E_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8545",
++      "typename": "MPC8545_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8544E",
++      "typename": "MPC8544E_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8544",
++      "typename": "MPC8544_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8543E",
++      "typename": "MPC8543E_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8543",
++      "typename": "MPC8543_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8541E",
++      "typename": "MPC8541E_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8541",
++      "typename": "MPC8541_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8540",
++      "typename": "MPC8540_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8533E",
++      "typename": "MPC8533E_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8533",
++      "typename": "MPC8533_v11-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "e500v2",
++      "typename": "e500v2_v22-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "e500v1",
++      "typename": "e500_v20-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "e500",
++      "typename": "e500v2_v22-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8347EA",
++      "typename": "MPC8347EAT-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8347E",
++      "typename": "MPC8347ET-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8347A",
++      "typename": "MPC8347AT-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8347",
++      "typename": "MPC8347T-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "e300",
++      "typename": "e300c3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "e200",
++      "typename": "e200z6-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8280",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8275",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8272",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8271",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8270",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8266_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8266_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8266",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8265_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8265_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8265",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8264_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8264_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8264",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8260_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8260_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8260",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8255_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8255_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8255",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8250_HiP4",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8250_HiP3",
++      "typename": "G2HiP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8250",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8248",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8247",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8245",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8241",
++      "typename": "G2HiP4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "PowerQUICC-II",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC82xx",
++      "typename": "G2leGP3-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC5200B",
++      "typename": "MPC5200B_v21-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC5200",
++      "typename": "MPC5200_v12-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC52xx",
++      "typename": "MPC5200_v12-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "MPC8240",
++      "typename": "603-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "440EP",
++      "typename": "440EPb-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "x2vp50",
++      "typename": "x2vp20-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "x2vp7",
++      "typename": "x2vp4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "405GPe",
++      "typename": "405CRc-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "405GP",
++      "typename": "405GPd-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "405CR",
++      "typename": "405CRc-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "405",
++      "typename": "405D4-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "403",
++      "typename": "403GC-powerpc64-cpu",
++      "static": false
++    },
++    {
++      "name": "7457A_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cl_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.7",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347ET",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8545E_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7455_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8547E_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "STB25",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER8_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401G2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8349A",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750e",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8545_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970fx_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fx_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER8E_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "Cobra",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.7",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603p",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8378E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500v2_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500mc",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e7v1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970mp_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8555E_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "440-Xilinx-w-dfpu",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740e",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405CRc",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7447A_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8533E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8540_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500v2_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e300c1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970fx_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750gx_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fx_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8641",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8544E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405D4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7457_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970fx_v3.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "604e_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.6",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "Npe4GS3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7410_v1.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7445_v3.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750l_v3.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8540_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "STB03",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8343A",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8378",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2HiP3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v3.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8567",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8545_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "Npe405H",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e7v",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v3.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "Npe405H2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.6",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405GPa",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8541E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750l_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8555E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7457A_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e200z6",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8379E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500v2_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347AP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401B2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8349E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.8",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8547E_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7455_v3.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7448_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8567E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7441_v2.10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v1.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2leGP1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7451_v2.10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8343E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cx_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "Npe405L",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e7",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401A1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8377",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7448_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7441_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405CRb",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7447A_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8540_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7445_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750gx_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "604",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v2.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543E_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347AT",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750l_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER8NVL_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7457A_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7457_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7450_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8572",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.5",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7410_v1.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405GPR",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8541_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401C2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500v2_v30",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7455_v3.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405EZ",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8568E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v1.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8560_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8560_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2H4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8533_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v3.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e200z5",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8349",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405CRa",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543E_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.7",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "403GC",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e5500",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7448_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC5200_v12",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7410_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "x2vp4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8555_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8541_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405LP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fx_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405EP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "601_v2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8544_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401D2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8572E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "604e_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cx_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC5200B_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750l_v3.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e300c4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7448_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7450_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2leGP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v3.1b",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.9",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2GP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405GPd",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548E_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e7t",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "IOP480",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750gx_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8560_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405D2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fl",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750l_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "x2vp20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e600",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7450_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7445_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2LS",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8543E_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7447_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7455_v3.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347P",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "440EPb",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC603",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fx_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER9_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8544_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "601_v1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER7+_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cx_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347EAP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401E2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8641D",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e300c3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8533_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7441_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740_v3.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER5+_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "602",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548E_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2leLS",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8343",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cx_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "604e_v2.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.8",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.6",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548E_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2le",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "403GB",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8545E_v21",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "POWER7_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7450_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC5200_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "755_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347EP",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7410_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750gl",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "403GCX",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750p",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8555_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7445_v3.4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347T",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970_v2.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "440-Xilinx",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "740p",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC5200B_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "440EPX",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7451_v2.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7450_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7400_v2.8",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7455_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405GPc",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8347EAT",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970mp_v1.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e7v2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "604r",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7447A_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8533E_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e500v2_v22",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401F2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8343EA",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7457_v1.2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7447_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970fx_v3.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v2.5",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8548E_v20",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8610",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v2.4b",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC5200_v10",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "403GA",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7410_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2leGP3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "7445_v3.3",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "603e_v4.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "440EPa",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "970fx_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8377E",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750fx_v2.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "601_v0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "STB04",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "745_v1.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "G2HiP4",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cl_v2.0",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxr",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8349EA",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750cxe_v3.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8379",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "401",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8568",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "e300c2",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "750_v3.1",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8544E_v11",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "405GPb",
++      "typename": "",
++      "static": false
++    },
++    {
++      "name": "MPC8541E_v11",
++      "typename": "",
++      "static": false
++    }
++  ],
++  "id": "libvirt-2"
++}
+diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+new file mode 100644
+index 0000000000..0dfa20726c
+--- /dev/null
++++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+@@ -0,0 +1,1072 @@
++<qemuCaps>
++  <qemuctime>0</qemuctime>
++  <selfctime>0</selfctime>
++  <selfvers>0</selfvers>
++  <usedQMP/>
++  <flag name='kvm'/>
++  <flag name='mem-path'/>
++  <flag name='drive-serial'/>
++  <flag name='monitor-json'/>
++  <flag name='sdl'/>
++  <flag name='netdev'/>
++  <flag name='rtc'/>
++  <flag name='vhost-net'/>
++  <flag name='nodefconfig'/>
++  <flag name='boot-menu'/>
++  <flag name='fsdev'/>
++  <flag name='name-process'/>
++  <flag name='smbios-type'/>
++  <flag name='vga-none'/>
++  <flag name='boot-index'/>
++  <flag name='hda-duplex'/>
++  <flag name='drive-aio'/>
++  <flag name='chardev-spicevmc'/>
++  <flag name='virtio-tx-alg'/>
++  <flag name='pci-multifunction'/>
++  <flag name='virtio-blk-pci.ioeventfd'/>
++  <flag name='virtio-blk-pci.event_idx'/>
++  <flag name='virtio-net-pci.event_idx'/>
++  <flag name='cache-directsync'/>
++  <flag name='piix3-usb-uhci'/>
++  <flag name='piix4-usb-uhci'/>
++  <flag name='usb-ehci'/>
++  <flag name='ich9-usb-ehci1'/>
++  <flag name='vt82c686b-usb-uhci'/>
++  <flag name='pci-ohci'/>
++  <flag name='usb-hub'/>
++  <flag name='no-shutdown'/>
++  <flag name='cache-unsafe'/>
++  <flag name='ich9-ahci'/>
++  <flag name='fsdev-readonly'/>
++  <flag name='virtio-blk-pci.scsi'/>
++  <flag name='drive-copy-on-read'/>
++  <flag name='fsdev-writeout'/>
++  <flag name='drive-iotune'/>
++  <flag name='system_wakeup'/>
++  <flag name='scsi-disk.channel'/>
++  <flag name='scsi-block'/>
++  <flag name='transaction'/>
++  <flag name='block-job-async'/>
++  <flag name='scsi-cd'/>
++  <flag name='ide-cd'/>
++  <flag name='no-user-config'/>
++  <flag name='hda-micro'/>
++  <flag name='dump-guest-memory'/>
++  <flag name='nec-usb-xhci'/>
++  <flag name='balloon-event'/>
++  <flag name='bridge'/>
++  <flag name='lsi'/>
++  <flag name='virtio-scsi-pci'/>
++  <flag name='blockio'/>
++  <flag name='ide-drive.wwn'/>
++  <flag name='scsi-disk.wwn'/>
++  <flag name='seccomp-sandbox'/>
++  <flag name='reboot-timeout'/>
++  <flag name='dump-guest-core'/>
++  <flag name='seamless-migration'/>
++  <flag name='block-commit'/>
++  <flag name='vnc'/>
++  <flag name='drive-mirror'/>
++  <flag name='usb-host.bootindex'/>
++  <flag name='blockdev-snapshot-sync'/>
++  <flag name='VGA'/>
++  <flag name='device-video-primary'/>
++  <flag name='usb-serial'/>
++  <flag name='usb-net'/>
++  <flag name='add-fd'/>
++  <flag name='nbd-server'/>
++  <flag name='virtio-rng'/>
++  <flag name='rng-random'/>
++  <flag name='rng-egd'/>
++  <flag name='dtb'/>
++  <flag name='megasas'/>
++  <flag name='ipv6-migration'/>
++  <flag name='machine-opt'/>
++  <flag name='machine-usb-opt'/>
++  <flag name='nvram'/>
++  <flag name='pci-bridge'/>
++  <flag name='vfio-pci'/>
++  <flag name='vfio-pci.bootindex'/>
++  <flag name='scsi-generic'/>
++  <flag name='scsi-generic.bootindex'/>
++  <flag name='mem-merge'/>
++  <flag name='vnc-websocket'/>
++  <flag name='drive-discard'/>
++  <flag name='mlock'/>
++  <flag name='vnc-share-policy'/>
++  <flag name='device-del-event'/>
++  <flag name='usb-storage'/>
++  <flag name='usb-storage.removable'/>
++  <flag name='virtio-mmio'/>
++  <flag name='ich9-intel-hda'/>
++  <flag name='boot-strict'/>
++  <flag name='spiceport'/>
++  <flag name='usb-kbd'/>
++  <flag name='host-pci-multidomain'/>
++  <flag name='msg-timestamp'/>
++  <flag name='active-commit'/>
++  <flag name='change-backing-file'/>
++  <flag name='memory-backend-ram'/>
++  <flag name='numa'/>
++  <flag name='memory-backend-file'/>
++  <flag name='usb-audio'/>
++  <flag name='splash-timeout'/>
++  <flag name='iothread'/>
++  <flag name='migrate-rdma'/>
++  <flag name='ivshmem'/>
++  <flag name='drive-iotune-max'/>
++  <flag name='VGA.vgamem_mb'/>
++  <flag name='pc-dimm'/>
++  <flag name='machine-vmport-opt'/>
++  <flag name='aes-key-wrap'/>
++  <flag name='dea-key-wrap'/>
++  <flag name='pci-serial'/>
++  <flag name='vhost-user-multiqueue'/>
++  <flag name='migration-event'/>
++  <flag name='rtl8139'/>
++  <flag name='e1000'/>
++  <flag name='virtio-net'/>
++  <flag name='gic-version'/>
++  <flag name='incoming-defer'/>
++  <flag name='virtio-gpu'/>
++  <flag name='virtio-keyboard'/>
++  <flag name='virtio-mouse'/>
++  <flag name='virtio-tablet'/>
++  <flag name='virtio-input-host'/>
++  <flag name='chardev-file-append'/>
++  <flag name='vserport-change-event'/>
++  <flag name='virtio-balloon-pci.deflate-on-oom'/>
++  <flag name='mptsas1068'/>
++  <flag name='chardev-logfile'/>
++  <flag name='debug-threads'/>
++  <flag name='secret'/>
++  <flag name='device-tray-moved-event'/>
++  <flag name='nec-usb-xhci-ports'/>
++  <flag name='virtio-scsi-pci.iothread'/>
++  <flag name='name-guest'/>
++  <flag name='drive-detect-zeroes'/>
++  <flag name='tls-creds-x509'/>
++  <flag name='display'/>
++  <flag name='smm'/>
++  <flag name='virtio-pci-disable-legacy'/>
++  <flag name='query-hotpluggable-cpus'/>
++  <flag name='virtio-net.rx_queue_size'/>
++  <flag name='virtio-vga'/>
++  <flag name='drive-iotune-max-length'/>
++  <flag name='ivshmem-plain'/>
++  <flag name='ivshmem-doorbell'/>
++  <flag name='query-qmp-schema'/>
++  <flag name='gluster.debug_level'/>
++  <flag name='vhost-scsi'/>
++  <flag name='drive-iotune-group'/>
++  <flag name='virtio-net.host_mtu'/>
++  <flag name='query-cpu-definitions'/>
++  <flag name='block-write-threshold'/>
++  <flag name='query-named-block-nodes'/>
++  <flag name='qemu-xhci'/>
++  <flag name='kernel-irqchip'/>
++  <flag name='kernel-irqchip.split'/>
++  <flag name='virtio.iommu_platform'/>
++  <flag name='virtio.ats'/>
++  <flag name='loadparm'/>
++  <flag name='spapr-pci-host-bridge'/>
++  <flag name='spapr-pci-host-bridge.numa_node'/>
++  <flag name='vnc-multi-servers'/>
++  <flag name='virtio-net.tx_queue_size'/>
++  <flag name='chardev-reconnect'/>
++  <flag name='virtio-gpu.max_outputs'/>
++  <flag name='vxhs'/>
++  <flag name='virtio-blk.num-queues'/>
++  <version>2010000</version>
++  <kvmVersion>0</kvmVersion>
++  <package> (v2.10.0)</package>
++  <arch>ppc64</arch>
++  <cpu type='kvm' name='default'/>
++  <cpu type='kvm' name='ppc'/>
++  <cpu type='kvm' name='ppc32'/>
++  <cpu type='kvm' name='ppc64'/>
++  <cpu type='kvm' name='970mp'/>
++  <cpu type='kvm' name='970fx'/>
++  <cpu type='kvm' name='970'/>
++  <cpu type='kvm' name='POWER9'/>
++  <cpu type='kvm' name='POWER8NVL'/>
++  <cpu type='kvm' name='POWER8'/>
++  <cpu type='kvm' name='POWER8E'/>
++  <cpu type='kvm' name='POWER7+'/>
++  <cpu type='kvm' name='POWER7'/>
++  <cpu type='kvm' name='POWER5gs'/>
++  <cpu type='kvm' name='POWER5+'/>
++  <cpu type='kvm' name='Apollo7PM'/>
++  <cpu type='kvm' name='7457A'/>
++  <cpu type='kvm' name='7447A'/>
++  <cpu type='kvm' name='Apollo7'/>
++  <cpu type='kvm' name='7457'/>
++  <cpu type='kvm' name='7447'/>
++  <cpu type='kvm' name='Apollo6'/>
++  <cpu type='kvm' name='7455'/>
++  <cpu type='kvm' name='7445'/>
++  <cpu type='kvm' name='7451'/>
++  <cpu type='kvm' name='7441'/>
++  <cpu type='kvm' name='Vger'/>
++  <cpu type='kvm' name='7450'/>
++  <cpu type='kvm' name='7448'/>
++  <cpu type='kvm' name='Nitro'/>
++  <cpu type='kvm' name='7410'/>
++  <cpu type='kvm' name='G4'/>
++  <cpu type='kvm' name='Max'/>
++  <cpu type='kvm' name='7400'/>
++  <cpu type='kvm' name='Goldfinger'/>
++  <cpu type='kvm' name='755'/>
++  <cpu type='kvm' name='745'/>
++  <cpu type='kvm' name='LoneStar'/>
++  <cpu type='kvm' name='750l'/>
++  <cpu type='kvm' name='750gx'/>
++  <cpu type='kvm' name='750fx'/>
++  <cpu type='kvm' name='750cxe'/>
++  <cpu type='kvm' name='750cx'/>
++  <cpu type='kvm' name='750cl'/>
++  <cpu type='kvm' name='Conan/Doyle'/>
++  <cpu type='kvm' name='G3'/>
++  <cpu type='kvm' name='Typhoon'/>
++  <cpu type='kvm' name='750'/>
++  <cpu type='kvm' name='Arthur'/>
++  <cpu type='kvm' name='740'/>
++  <cpu type='kvm' name='Mach5'/>
++  <cpu type='kvm' name='Sirocco'/>
++  <cpu type='kvm' name='604e'/>
++  <cpu type='kvm' name='Goldeneye'/>
++  <cpu type='kvm' name='603r'/>
++  <cpu type='kvm' name='Vaillant'/>
++  <cpu type='kvm' name='Stretch'/>
++  <cpu type='kvm' name='603e'/>
++  <cpu type='kvm' name='Vanilla'/>
++  <cpu type='kvm' name='601v'/>
++  <cpu type='kvm' name='601'/>
++  <cpu type='kvm' name='MPC8560'/>
++  <cpu type='kvm' name='MPC8555E'/>
++  <cpu type='kvm' name='MPC8555'/>
++  <cpu type='kvm' name='MPC8548E'/>
++  <cpu type='kvm' name='MPC8548'/>
++  <cpu type='kvm' name='MPC8547E'/>
++  <cpu type='kvm' name='MPC8545E'/>
++  <cpu type='kvm' name='MPC8545'/>
++  <cpu type='kvm' name='MPC8544E'/>
++  <cpu type='kvm' name='MPC8544'/>
++  <cpu type='kvm' name='MPC8543E'/>
++  <cpu type='kvm' name='MPC8543'/>
++  <cpu type='kvm' name='MPC8541E'/>
++  <cpu type='kvm' name='MPC8541'/>
++  <cpu type='kvm' name='MPC8540'/>
++  <cpu type='kvm' name='MPC8533E'/>
++  <cpu type='kvm' name='MPC8533'/>
++  <cpu type='kvm' name='e500v2'/>
++  <cpu type='kvm' name='e500v1'/>
++  <cpu type='kvm' name='e500'/>
++  <cpu type='kvm' name='MPC8347EA'/>
++  <cpu type='kvm' name='MPC8347E'/>
++  <cpu type='kvm' name='MPC8347A'/>
++  <cpu type='kvm' name='MPC8347'/>
++  <cpu type='kvm' name='e300'/>
++  <cpu type='kvm' name='e200'/>
++  <cpu type='kvm' name='MPC8280'/>
++  <cpu type='kvm' name='MPC8275'/>
++  <cpu type='kvm' name='MPC8272'/>
++  <cpu type='kvm' name='MPC8271'/>
++  <cpu type='kvm' name='MPC8270'/>
++  <cpu type='kvm' name='MPC8266_HiP4'/>
++  <cpu type='kvm' name='MPC8266_HiP3'/>
++  <cpu type='kvm' name='MPC8266'/>
++  <cpu type='kvm' name='MPC8265_HiP4'/>
++  <cpu type='kvm' name='MPC8265_HiP3'/>
++  <cpu type='kvm' name='MPC8265'/>
++  <cpu type='kvm' name='MPC8264_HiP4'/>
++  <cpu type='kvm' name='MPC8264_HiP3'/>
++  <cpu type='kvm' name='MPC8264'/>
++  <cpu type='kvm' name='MPC8260_HiP4'/>
++  <cpu type='kvm' name='MPC8260_HiP3'/>
++  <cpu type='kvm' name='MPC8260'/>
++  <cpu type='kvm' name='MPC8255_HiP4'/>
++  <cpu type='kvm' name='MPC8255_HiP3'/>
++  <cpu type='kvm' name='MPC8255'/>
++  <cpu type='kvm' name='MPC8250_HiP4'/>
++  <cpu type='kvm' name='MPC8250_HiP3'/>
++  <cpu type='kvm' name='MPC8250'/>
++  <cpu type='kvm' name='MPC8248'/>
++  <cpu type='kvm' name='MPC8247'/>
++  <cpu type='kvm' name='MPC8245'/>
++  <cpu type='kvm' name='MPC8241'/>
++  <cpu type='kvm' name='PowerQUICC-II'/>
++  <cpu type='kvm' name='MPC82xx'/>
++  <cpu type='kvm' name='MPC5200B'/>
++  <cpu type='kvm' name='MPC5200'/>
++  <cpu type='kvm' name='MPC52xx'/>
++  <cpu type='kvm' name='MPC8240'/>
++  <cpu type='kvm' name='440EP'/>
++  <cpu type='kvm' name='x2vp50'/>
++  <cpu type='kvm' name='x2vp7'/>
++  <cpu type='kvm' name='405GPe'/>
++  <cpu type='kvm' name='405GP'/>
++  <cpu type='kvm' name='405CR'/>
++  <cpu type='kvm' name='405'/>
++  <cpu type='kvm' name='403'/>
++  <cpu type='kvm' name='7457A_v1.2'/>
++  <cpu type='kvm' name='750cl_v1.0'/>
++  <cpu type='kvm' name='750cxe_v2.1'/>
++  <cpu type='kvm' name='755_v2.7'/>
++  <cpu type='kvm' name='MPC8347ET'/>
++  <cpu type='kvm' name='MPC8545E_v20'/>
++  <cpu type='kvm' name='750_v2.1'/>
++  <cpu type='kvm' name='755_v2.2'/>
++  <cpu type='kvm' name='745_v2.0'/>
++  <cpu type='kvm' name='7455_v1.0'/>
++  <cpu type='kvm' name='MPC8547E_v21'/>
++  <cpu type='kvm' name='STB25'/>
++  <cpu type='kvm' name='POWER8_v2.0'/>
++  <cpu type='kvm' name='401G2'/>
++  <cpu type='kvm' name='MPC8349A'/>
++  <cpu type='kvm' name='750e'/>
++  <cpu type='kvm' name='MPC8545_v21'/>
++  <cpu type='kvm' name='MPC8548_v11'/>
++  <cpu type='kvm' name='970fx_v2.0'/>
++  <cpu type='kvm' name='750fx_v2.0'/>
++  <cpu type='kvm' name='POWER8E_v2.1'/>
++  <cpu type='kvm' name='Cobra'/>
++  <cpu type='kvm' name='7400_v2.7'/>
++  <cpu type='kvm' name='603p'/>
++  <cpu type='kvm' name='MPC8378E'/>
++  <cpu type='kvm' name='e500v2_v10'/>
++  <cpu type='kvm' name='e500mc'/>
++  <cpu type='kvm' name='603e7v1'/>
++  <cpu type='kvm' name='970mp_v1.0'/>
++  <cpu type='kvm' name='MPC8555E_v11'/>
++  <cpu type='kvm' name='440-Xilinx-w-dfpu'/>
++  <cpu type='kvm' name='740e'/>
++  <cpu type='kvm' name='405CRc'/>
++  <cpu type='kvm' name='7447A_v1.1'/>
++  <cpu type='kvm' name='MPC8533E_v10'/>
++  <cpu type='kvm' name='MPC8543_v11'/>
++  <cpu type='kvm' name='7400_v2.2'/>
++  <cpu type='kvm' name='MPC8540_v21'/>
++  <cpu type='kvm' name='e500v2_v21'/>
++  <cpu type='kvm' name='e300c1'/>
++  <cpu type='kvm' name='970fx_v1.0'/>
++  <cpu type='kvm' name='750gx_v1.2'/>
++  <cpu type='kvm' name='750fx_v1.0'/>
++  <cpu type='kvm' name='MPC8641'/>
++  <cpu type='kvm' name='MPC8544E_v10'/>
++  <cpu type='kvm' name='405D4'/>
++  <cpu type='kvm' name='7457_v1.1'/>
++  <cpu type='kvm' name='970fx_v3.0'/>
++  <cpu type='kvm' name='604e_v2.2'/>
++  <cpu type='kvm' name='755_v2.6'/>
++  <cpu type='kvm' name='Npe4GS3'/>
++  <cpu type='kvm' name='7410_v1.4'/>
++  <cpu type='kvm' name='750_v2.0'/>
++  <cpu type='kvm' name='7445_v3.2'/>
++  <cpu type='kvm' name='745_v2.4'/>
++  <cpu type='kvm' name='750l_v3.2'/>
++  <cpu type='kvm' name='MPC8540_v10'/>
++  <cpu type='kvm' name='750_v1.0'/>
++  <cpu type='kvm' name='STB03'/>
++  <cpu type='kvm' name='MPC8343A'/>
++  <cpu type='kvm' name='MPC8378'/>
++  <cpu type='kvm' name='G2HiP3'/>
++  <cpu type='kvm' name='750cxe_v3.0'/>
++  <cpu type='kvm' name='e500_v10'/>
++  <cpu type='kvm' name='755_v1.1'/>
++  <cpu type='kvm' name='MPC8567'/>
++  <cpu type='kvm' name='MPC8545_v20'/>
++  <cpu type='kvm' name='MPC8548_v10'/>
++  <cpu type='kvm' name='Npe405H'/>
++  <cpu type='kvm' name='603e7v'/>
++  <cpu type='kvm' name='750_v3.0'/>
++  <cpu type='kvm' name='Npe405H2'/>
++  <cpu type='kvm' name='7400_v2.6'/>
++  <cpu type='kvm' name='405GPa'/>
++  <cpu type='kvm' name='MPC8548_v21'/>
++  <cpu type='kvm' name='MPC8541E_v10'/>
++  <cpu type='kvm' name='750l_v2.2'/>
++  <cpu type='kvm' name='MPC8555E_v10'/>
++  <cpu type='kvm' name='7457A_v1.1'/>
++  <cpu type='kvm' name='e200z6'/>
++  <cpu type='kvm' name='MPC8379E'/>
++  <cpu type='kvm' name='e500v2_v20'/>
++  <cpu type='kvm' name='MPC8347AP'/>
++  <cpu type='kvm' name='401B2'/>
++  <cpu type='kvm' name='MPC8349E'/>
++  <cpu type='kvm' name='755_v2.1'/>
++  <cpu type='kvm' name='MPC8543_v21'/>
++  <cpu type='kvm' name='745_v2.8'/>
++  <cpu type='kvm' name='MPC8547E_v20'/>
++  <cpu type='kvm' name='7455_v3.4'/>
++  <cpu type='kvm' name='7448_v1.1'/>
++  <cpu type='kvm' name='740_v2.2'/>
++  <cpu type='kvm' name='7400_v1.1'/>
++  <cpu type='kvm' name='MPC8567E'/>
++  <cpu type='kvm' name='7441_v2.10'/>
++  <cpu type='kvm' name='603e_v1.4'/>
++  <cpu type='kvm' name='G2leGP1'/>
++  <cpu type='kvm' name='7451_v2.10'/>
++  <cpu type='kvm' name='MPC8343E'/>
++  <cpu type='kvm' name='750cx_v2.2'/>
++  <cpu type='kvm' name='Npe405L'/>
++  <cpu type='kvm' name='603e7'/>
++  <cpu type='kvm' name='401A1'/>
++  <cpu type='kvm' name='MPC8377'/>
++  <cpu type='kvm' name='7448_v2.1'/>
++  <cpu type='kvm' name='7441_v2.3'/>
++  <cpu type='kvm' name='7400_v2.1'/>
++  <cpu type='kvm' name='405CRb'/>
++  <cpu type='kvm' name='7447A_v1.0'/>
++  <cpu type='kvm' name='MPC8540_v20'/>
++  <cpu type='kvm' name='MPC8543_v10'/>
++  <cpu type='kvm' name='7445_v2.1'/>
++  <cpu type='kvm' name='e500_v20'/>
++  <cpu type='kvm' name='750gx_v1.1'/>
++  <cpu type='kvm' name='604'/>
++  <cpu type='kvm' name='750cxe_v2.4'/>
++  <cpu type='kvm' name='MPC8548_v20'/>
++  <cpu type='kvm' name='MPC8543E_v11'/>
++  <cpu type='kvm' name='MPC8347AT'/>
++  <cpu type='kvm' name='750l_v2.1'/>
++  <cpu type='kvm' name='POWER8NVL_v1.0'/>
++  <cpu type='kvm' name='7457A_v1.0'/>
++  <cpu type='kvm' name='7457_v1.0'/>
++  <cpu type='kvm' name='7450_v1.2'/>
++  <cpu type='kvm' name='MPC8572'/>
++  <cpu type='kvm' name='755_v2.5'/>
++  <cpu type='kvm' name='7410_v1.3'/>
++  <cpu type='kvm' name='745_v2.3'/>
++  <cpu type='kvm' name='405GPR'/>
++  <cpu type='kvm' name='755_v2.0'/>
++  <cpu type='kvm' name='MPC8541_v11'/>
++  <cpu type='kvm' name='401C2'/>
++  <cpu type='kvm' name='e500v2_v30'/>
++  <cpu type='kvm' name='7455_v3.3'/>
++  <cpu type='kvm' name='405EZ'/>
++  <cpu type='kvm' name='MPC8568E'/>
++  <cpu type='kvm' name='755_v1.0'/>
++  <cpu type='kvm' name='603e_v1.3'/>
++  <cpu type='kvm' name='MPC8560_v10'/>
++  <cpu type='kvm' name='host'/>
++  <cpu type='kvm' name='MPC8560_v21'/>
++  <cpu type='kvm' name='G2H4'/>
++  <cpu type='kvm' name='MPC8533_v11'/>
++  <cpu type='kvm' name='740_v3.1'/>
++  <cpu type='kvm' name='e200z5'/>
++  <cpu type='kvm' name='MPC8349'/>
++  <cpu type='kvm' name='7400_v2.0'/>
++  <cpu type='kvm' name='405CRa'/>
++  <cpu type='kvm' name='MPC8543E_v10'/>
++  <cpu type='kvm' name='MPC8543E_v21'/>
++  <cpu type='kvm' name='750cxe_v2.3'/>
++  <cpu type='kvm' name='MPC8543_v20'/>
++  <cpu type='kvm' name='745_v2.7'/>
++  <cpu type='kvm' name='403GC'/>
++  <cpu type='kvm' name='e5500'/>
++  <cpu type='kvm' name='7448_v1.0'/>
++  <cpu type='kvm' name='MPC5200_v12'/>
++  <cpu type='kvm' name='740_v2.1'/>
++  <cpu type='kvm' name='745_v2.2'/>
++  <cpu type='kvm' name='7400_v1.0'/>
++  <cpu type='kvm' name='7410_v1.2'/>
++  <cpu type='kvm' name='x2vp4'/>
++  <cpu type='kvm' name='MPC8555_v11'/>
++  <cpu type='kvm' name='MPC8541_v10'/>
++  <cpu type='kvm' name='405LP'/>
++  <cpu type='kvm' name='750fx_v2.3'/>
++  <cpu type='kvm' name='405EP'/>
++  <cpu type='kvm' name='601_v2'/>
++  <cpu type='kvm' name='MPC8544_v11'/>
++  <cpu type='kvm' name='401D2'/>
++  <cpu type='kvm' name='MPC8572E'/>
++  <cpu type='kvm' name='604e_v1.0'/>
++  <cpu type='kvm' name='750cx_v2.1'/>
++  <cpu type='kvm' name='MPC5200B_v21'/>
++  <cpu type='kvm' name='750l_v3.0'/>
++  <cpu type='kvm' name='e300c4'/>
++  <cpu type='kvm' name='7448_v2.0'/>
++  <cpu type='kvm' name='7450_v2.1'/>
++  <cpu type='kvm' name='G2leGP'/>
++  <cpu type='kvm' name='750cxe_v3.1b'/>
++  <cpu type='kvm' name='7400_v2.9'/>
++  <cpu type='kvm' name='G2GP'/>
++  <cpu type='kvm' name='603'/>
++  <cpu type='kvm' name='405GPd'/>
++  <cpu type='kvm' name='MPC8548E_v11'/>
++  <cpu type='kvm' name='603e7t'/>
++  <cpu type='kvm' name='IOP480'/>
++  <cpu type='kvm' name='750gx_v1.0'/>
++  <cpu type='kvm' name='MPC8560_v20'/>
++  <cpu type='kvm' name='405D2'/>
++  <cpu type='kvm' name='750fl'/>
++  <cpu type='kvm' name='750l_v2.0'/>
++  <cpu type='kvm' name='x2vp20'/>
++  <cpu type='kvm' name='e600'/>
++  <cpu type='kvm' name='7450_v1.1'/>
++  <cpu type='kvm' name='755_v2.4'/>
++  <cpu type='kvm' name='7445_v1.0'/>
++  <cpu type='kvm' name='G2LS'/>
++  <cpu type='kvm' name='MPC8543E_v20'/>
++  <cpu type='kvm' name='603e_v2.2'/>
++  <cpu type='kvm' name='7447_v1.1'/>
++  <cpu type='kvm' name='603e_v4'/>
++  <cpu type='kvm' name='7455_v3.2'/>
++  <cpu type='kvm' name='740_v2.0'/>
++  <cpu type='kvm' name='MPC8347P'/>
++  <cpu type='kvm' name='440EPb'/>
++  <cpu type='kvm' name='MPC603'/>
++  <cpu type='kvm' name='603e_v1.2'/>
++  <cpu type='kvm' name='750fx_v2.2'/>
++  <cpu type='kvm' name='POWER9_v1.0'/>
++  <cpu type='kvm' name='740_v1.0'/>
++  <cpu type='kvm' name='MPC8544_v10'/>
++  <cpu type='kvm' name='601_v1'/>
++  <cpu type='kvm' name='745_v1.1'/>
++  <cpu type='kvm' name='POWER7+_v2.1'/>
++  <cpu type='kvm' name='750cx_v2.0'/>
++  <cpu type='kvm' name='MPC8347EAP'/>
++  <cpu type='kvm' name='401E2'/>
++  <cpu type='kvm' name='MPC8641D'/>
++  <cpu type='kvm' name='e300c3'/>
++  <cpu type='kvm' name='MPC8533_v10'/>
++  <cpu type='kvm' name='7441_v2.1'/>
++  <cpu type='kvm' name='740_v3.0'/>
++  <cpu type='kvm' name='POWER5+_v2.1'/>
++  <cpu type='kvm' name='602'/>
++  <cpu type='kvm' name='MPC8548E_v10'/>
++  <cpu type='kvm' name='G2leLS'/>
++  <cpu type='kvm' name='MPC8343'/>
++  <cpu type='kvm' name='750cx_v1.0'/>
++  <cpu type='kvm' name='750cxe_v2.2'/>
++  <cpu type='kvm' name='604e_v2.4'/>
++  <cpu type='kvm' name='755_v2.8'/>
++  <cpu type='kvm' name='745_v2.6'/>
++  <cpu type='kvm' name='MPC8548E_v21'/>
++  <cpu type='kvm' name='G2le'/>
++  <cpu type='kvm' name='403GB'/>
++  <cpu type='kvm' name='MPC8545E_v21'/>
++  <cpu type='kvm' name='POWER7_v2.3'/>
++  <cpu type='kvm' name='750_v2.2'/>
++  <cpu type='kvm' name='7450_v1.0'/>
++  <cpu type='kvm' name='MPC5200_v11'/>
++  <cpu type='kvm' name='755_v2.3'/>
++  <cpu type='kvm' name='MPC8347EP'/>
++  <cpu type='kvm' name='7410_v1.1'/>
++  <cpu type='kvm' name='750gl'/>
++  <cpu type='kvm' name='403GCX'/>
++  <cpu type='kvm' name='745_v2.1'/>
++  <cpu type='kvm' name='750p'/>
++  <cpu type='kvm' name='G2'/>
++  <cpu type='kvm' name='MPC8555_v10'/>
++  <cpu type='kvm' name='7445_v3.4'/>
++  <cpu type='kvm' name='MPC8347T'/>
++  <cpu type='kvm' name='603e_v3'/>
++  <cpu type='kvm' name='970_v2.2'/>
++  <cpu type='kvm' name='440-Xilinx'/>
++  <cpu type='kvm' name='740p'/>
++  <cpu type='kvm' name='MPC5200B_v20'/>
++  <cpu type='kvm' name='440EPX'/>
++  <cpu type='kvm' name='603e_v1.1'/>
++  <cpu type='kvm' name='7451_v2.3'/>
++  <cpu type='kvm' name='7450_v2.0'/>
++  <cpu type='kvm' name='7400_v2.8'/>
++  <cpu type='kvm' name='7455_v2.1'/>
++  <cpu type='kvm' name='405GPc'/>
++  <cpu type='kvm' name='MPC8347EAT'/>
++  <cpu type='kvm' name='970mp_v1.1'/>
++  <cpu type='kvm' name='603e7v2'/>
++  <cpu type='kvm' name='604r'/>
++  <cpu type='kvm' name='7447A_v1.2'/>
++  <cpu type='kvm' name='MPC8533E_v11'/>
++  <cpu type='kvm' name='e500v2_v22'/>
++  <cpu type='kvm' name='401F2'/>
++  <cpu type='kvm' name='MPC8343EA'/>
++  <cpu type='kvm' name='7457_v1.2'/>
++  <cpu type='kvm' name='7447_v1.0'/>
++  <cpu type='kvm' name='970fx_v3.1'/>
++  <cpu type='kvm' name='745_v2.5'/>
++  <cpu type='kvm' name='MPC8548E_v20'/>
++  <cpu type='kvm' name='MPC8610'/>
++  <cpu type='kvm' name='750cxe_v2.4b'/>
++  <cpu type='kvm' name='MPC5200_v10'/>
++  <cpu type='kvm' name='403GA'/>
++  <cpu type='kvm' name='7410_v1.0'/>
++  <cpu type='kvm' name='G2leGP3'/>
++  <cpu type='kvm' name='7445_v3.3'/>
++  <cpu type='kvm' name='603e_v4.1'/>
++  <cpu type='kvm' name='440EPa'/>
++  <cpu type='kvm' name='970fx_v2.1'/>
++  <cpu type='kvm' name='MPC8377E'/>
++  <cpu type='kvm' name='750fx_v2.1'/>
++  <cpu type='kvm' name='601_v0'/>
++  <cpu type='kvm' name='STB04'/>
++  <cpu type='kvm' name='745_v1.0'/>
++  <cpu type='kvm' name='G2HiP4'/>
++  <cpu type='kvm' name='750cl_v2.0'/>
++  <cpu type='kvm' name='750cxr'/>
++  <cpu type='kvm' name='MPC8349EA'/>
++  <cpu type='kvm' name='750cxe_v3.1'/>
++  <cpu type='kvm' name='MPC8379'/>
++  <cpu type='kvm' name='401'/>
++  <cpu type='kvm' name='MPC8568'/>
++  <cpu type='kvm' name='e300c2'/>
++  <cpu type='kvm' name='750_v3.1'/>
++  <cpu type='kvm' name='MPC8544E_v11'/>
++  <cpu type='kvm' name='405GPb'/>
++  <cpu type='kvm' name='MPC8541E_v11'/>
++  <cpu type='tcg' name='default'/>
++  <cpu type='tcg' name='ppc'/>
++  <cpu type='tcg' name='ppc32'/>
++  <cpu type='tcg' name='ppc64'/>
++  <cpu type='tcg' name='970mp'/>
++  <cpu type='tcg' name='970fx'/>
++  <cpu type='tcg' name='970'/>
++  <cpu type='tcg' name='POWER9'/>
++  <cpu type='tcg' name='POWER8NVL'/>
++  <cpu type='tcg' name='POWER8'/>
++  <cpu type='tcg' name='POWER8E'/>
++  <cpu type='tcg' name='POWER7+'/>
++  <cpu type='tcg' name='POWER7'/>
++  <cpu type='tcg' name='POWER5gs'/>
++  <cpu type='tcg' name='POWER5+'/>
++  <cpu type='tcg' name='Apollo7PM'/>
++  <cpu type='tcg' name='7457A'/>
++  <cpu type='tcg' name='7447A'/>
++  <cpu type='tcg' name='Apollo7'/>
++  <cpu type='tcg' name='7457'/>
++  <cpu type='tcg' name='7447'/>
++  <cpu type='tcg' name='Apollo6'/>
++  <cpu type='tcg' name='7455'/>
++  <cpu type='tcg' name='7445'/>
++  <cpu type='tcg' name='7451'/>
++  <cpu type='tcg' name='7441'/>
++  <cpu type='tcg' name='Vger'/>
++  <cpu type='tcg' name='7450'/>
++  <cpu type='tcg' name='7448'/>
++  <cpu type='tcg' name='Nitro'/>
++  <cpu type='tcg' name='7410'/>
++  <cpu type='tcg' name='G4'/>
++  <cpu type='tcg' name='Max'/>
++  <cpu type='tcg' name='7400'/>
++  <cpu type='tcg' name='Goldfinger'/>
++  <cpu type='tcg' name='755'/>
++  <cpu type='tcg' name='745'/>
++  <cpu type='tcg' name='LoneStar'/>
++  <cpu type='tcg' name='750l'/>
++  <cpu type='tcg' name='750gx'/>
++  <cpu type='tcg' name='750fx'/>
++  <cpu type='tcg' name='750cxe'/>
++  <cpu type='tcg' name='750cx'/>
++  <cpu type='tcg' name='750cl'/>
++  <cpu type='tcg' name='Conan/Doyle'/>
++  <cpu type='tcg' name='G3'/>
++  <cpu type='tcg' name='Typhoon'/>
++  <cpu type='tcg' name='750'/>
++  <cpu type='tcg' name='Arthur'/>
++  <cpu type='tcg' name='740'/>
++  <cpu type='tcg' name='Mach5'/>
++  <cpu type='tcg' name='Sirocco'/>
++  <cpu type='tcg' name='604e'/>
++  <cpu type='tcg' name='Goldeneye'/>
++  <cpu type='tcg' name='603r'/>
++  <cpu type='tcg' name='Vaillant'/>
++  <cpu type='tcg' name='Stretch'/>
++  <cpu type='tcg' name='603e'/>
++  <cpu type='tcg' name='Vanilla'/>
++  <cpu type='tcg' name='601v'/>
++  <cpu type='tcg' name='601'/>
++  <cpu type='tcg' name='MPC8560'/>
++  <cpu type='tcg' name='MPC8555E'/>
++  <cpu type='tcg' name='MPC8555'/>
++  <cpu type='tcg' name='MPC8548E'/>
++  <cpu type='tcg' name='MPC8548'/>
++  <cpu type='tcg' name='MPC8547E'/>
++  <cpu type='tcg' name='MPC8545E'/>
++  <cpu type='tcg' name='MPC8545'/>
++  <cpu type='tcg' name='MPC8544E'/>
++  <cpu type='tcg' name='MPC8544'/>
++  <cpu type='tcg' name='MPC8543E'/>
++  <cpu type='tcg' name='MPC8543'/>
++  <cpu type='tcg' name='MPC8541E'/>
++  <cpu type='tcg' name='MPC8541'/>
++  <cpu type='tcg' name='MPC8540'/>
++  <cpu type='tcg' name='MPC8533E'/>
++  <cpu type='tcg' name='MPC8533'/>
++  <cpu type='tcg' name='e500v2'/>
++  <cpu type='tcg' name='e500v1'/>
++  <cpu type='tcg' name='e500'/>
++  <cpu type='tcg' name='MPC8347EA'/>
++  <cpu type='tcg' name='MPC8347E'/>
++  <cpu type='tcg' name='MPC8347A'/>
++  <cpu type='tcg' name='MPC8347'/>
++  <cpu type='tcg' name='e300'/>
++  <cpu type='tcg' name='e200'/>
++  <cpu type='tcg' name='MPC8280'/>
++  <cpu type='tcg' name='MPC8275'/>
++  <cpu type='tcg' name='MPC8272'/>
++  <cpu type='tcg' name='MPC8271'/>
++  <cpu type='tcg' name='MPC8270'/>
++  <cpu type='tcg' name='MPC8266_HiP4'/>
++  <cpu type='tcg' name='MPC8266_HiP3'/>
++  <cpu type='tcg' name='MPC8266'/>
++  <cpu type='tcg' name='MPC8265_HiP4'/>
++  <cpu type='tcg' name='MPC8265_HiP3'/>
++  <cpu type='tcg' name='MPC8265'/>
++  <cpu type='tcg' name='MPC8264_HiP4'/>
++  <cpu type='tcg' name='MPC8264_HiP3'/>
++  <cpu type='tcg' name='MPC8264'/>
++  <cpu type='tcg' name='MPC8260_HiP4'/>
++  <cpu type='tcg' name='MPC8260_HiP3'/>
++  <cpu type='tcg' name='MPC8260'/>
++  <cpu type='tcg' name='MPC8255_HiP4'/>
++  <cpu type='tcg' name='MPC8255_HiP3'/>
++  <cpu type='tcg' name='MPC8255'/>
++  <cpu type='tcg' name='MPC8250_HiP4'/>
++  <cpu type='tcg' name='MPC8250_HiP3'/>
++  <cpu type='tcg' name='MPC8250'/>
++  <cpu type='tcg' name='MPC8248'/>
++  <cpu type='tcg' name='MPC8247'/>
++  <cpu type='tcg' name='MPC8245'/>
++  <cpu type='tcg' name='MPC8241'/>
++  <cpu type='tcg' name='PowerQUICC-II'/>
++  <cpu type='tcg' name='MPC82xx'/>
++  <cpu type='tcg' name='MPC5200B'/>
++  <cpu type='tcg' name='MPC5200'/>
++  <cpu type='tcg' name='MPC52xx'/>
++  <cpu type='tcg' name='MPC8240'/>
++  <cpu type='tcg' name='440EP'/>
++  <cpu type='tcg' name='x2vp50'/>
++  <cpu type='tcg' name='x2vp7'/>
++  <cpu type='tcg' name='405GPe'/>
++  <cpu type='tcg' name='405GP'/>
++  <cpu type='tcg' name='405CR'/>
++  <cpu type='tcg' name='405'/>
++  <cpu type='tcg' name='403'/>
++  <cpu type='tcg' name='7457A_v1.2'/>
++  <cpu type='tcg' name='750cl_v1.0'/>
++  <cpu type='tcg' name='750cxe_v2.1'/>
++  <cpu type='tcg' name='755_v2.7'/>
++  <cpu type='tcg' name='MPC8347ET'/>
++  <cpu type='tcg' name='MPC8545E_v20'/>
++  <cpu type='tcg' name='750_v2.1'/>
++  <cpu type='tcg' name='755_v2.2'/>
++  <cpu type='tcg' name='745_v2.0'/>
++  <cpu type='tcg' name='7455_v1.0'/>
++  <cpu type='tcg' name='MPC8547E_v21'/>
++  <cpu type='tcg' name='STB25'/>
++  <cpu type='tcg' name='POWER8_v2.0'/>
++  <cpu type='tcg' name='401G2'/>
++  <cpu type='tcg' name='MPC8349A'/>
++  <cpu type='tcg' name='750e'/>
++  <cpu type='tcg' name='MPC8545_v21'/>
++  <cpu type='tcg' name='MPC8548_v11'/>
++  <cpu type='tcg' name='970fx_v2.0'/>
++  <cpu type='tcg' name='750fx_v2.0'/>
++  <cpu type='tcg' name='POWER8E_v2.1'/>
++  <cpu type='tcg' name='Cobra'/>
++  <cpu type='tcg' name='7400_v2.7'/>
++  <cpu type='tcg' name='603p'/>
++  <cpu type='tcg' name='MPC8378E'/>
++  <cpu type='tcg' name='e500v2_v10'/>
++  <cpu type='tcg' name='e500mc'/>
++  <cpu type='tcg' name='603e7v1'/>
++  <cpu type='tcg' name='970mp_v1.0'/>
++  <cpu type='tcg' name='MPC8555E_v11'/>
++  <cpu type='tcg' name='440-Xilinx-w-dfpu'/>
++  <cpu type='tcg' name='740e'/>
++  <cpu type='tcg' name='405CRc'/>
++  <cpu type='tcg' name='7447A_v1.1'/>
++  <cpu type='tcg' name='MPC8533E_v10'/>
++  <cpu type='tcg' name='MPC8543_v11'/>
++  <cpu type='tcg' name='7400_v2.2'/>
++  <cpu type='tcg' name='MPC8540_v21'/>
++  <cpu type='tcg' name='e500v2_v21'/>
++  <cpu type='tcg' name='e300c1'/>
++  <cpu type='tcg' name='970fx_v1.0'/>
++  <cpu type='tcg' name='750gx_v1.2'/>
++  <cpu type='tcg' name='750fx_v1.0'/>
++  <cpu type='tcg' name='MPC8641'/>
++  <cpu type='tcg' name='MPC8544E_v10'/>
++  <cpu type='tcg' name='405D4'/>
++  <cpu type='tcg' name='7457_v1.1'/>
++  <cpu type='tcg' name='970fx_v3.0'/>
++  <cpu type='tcg' name='604e_v2.2'/>
++  <cpu type='tcg' name='755_v2.6'/>
++  <cpu type='tcg' name='Npe4GS3'/>
++  <cpu type='tcg' name='7410_v1.4'/>
++  <cpu type='tcg' name='750_v2.0'/>
++  <cpu type='tcg' name='7445_v3.2'/>
++  <cpu type='tcg' name='745_v2.4'/>
++  <cpu type='tcg' name='750l_v3.2'/>
++  <cpu type='tcg' name='MPC8540_v10'/>
++  <cpu type='tcg' name='750_v1.0'/>
++  <cpu type='tcg' name='STB03'/>
++  <cpu type='tcg' name='MPC8343A'/>
++  <cpu type='tcg' name='MPC8378'/>
++  <cpu type='tcg' name='G2HiP3'/>
++  <cpu type='tcg' name='750cxe_v3.0'/>
++  <cpu type='tcg' name='e500_v10'/>
++  <cpu type='tcg' name='755_v1.1'/>
++  <cpu type='tcg' name='MPC8567'/>
++  <cpu type='tcg' name='MPC8545_v20'/>
++  <cpu type='tcg' name='MPC8548_v10'/>
++  <cpu type='tcg' name='Npe405H'/>
++  <cpu type='tcg' name='603e7v'/>
++  <cpu type='tcg' name='750_v3.0'/>
++  <cpu type='tcg' name='Npe405H2'/>
++  <cpu type='tcg' name='7400_v2.6'/>
++  <cpu type='tcg' name='405GPa'/>
++  <cpu type='tcg' name='MPC8548_v21'/>
++  <cpu type='tcg' name='MPC8541E_v10'/>
++  <cpu type='tcg' name='750l_v2.2'/>
++  <cpu type='tcg' name='MPC8555E_v10'/>
++  <cpu type='tcg' name='7457A_v1.1'/>
++  <cpu type='tcg' name='e200z6'/>
++  <cpu type='tcg' name='MPC8379E'/>
++  <cpu type='tcg' name='e500v2_v20'/>
++  <cpu type='tcg' name='MPC8347AP'/>
++  <cpu type='tcg' name='401B2'/>
++  <cpu type='tcg' name='MPC8349E'/>
++  <cpu type='tcg' name='755_v2.1'/>
++  <cpu type='tcg' name='MPC8543_v21'/>
++  <cpu type='tcg' name='745_v2.8'/>
++  <cpu type='tcg' name='MPC8547E_v20'/>
++  <cpu type='tcg' name='7455_v3.4'/>
++  <cpu type='tcg' name='7448_v1.1'/>
++  <cpu type='tcg' name='740_v2.2'/>
++  <cpu type='tcg' name='7400_v1.1'/>
++  <cpu type='tcg' name='MPC8567E'/>
++  <cpu type='tcg' name='7441_v2.10'/>
++  <cpu type='tcg' name='603e_v1.4'/>
++  <cpu type='tcg' name='G2leGP1'/>
++  <cpu type='tcg' name='7451_v2.10'/>
++  <cpu type='tcg' name='MPC8343E'/>
++  <cpu type='tcg' name='750cx_v2.2'/>
++  <cpu type='tcg' name='Npe405L'/>
++  <cpu type='tcg' name='603e7'/>
++  <cpu type='tcg' name='401A1'/>
++  <cpu type='tcg' name='MPC8377'/>
++  <cpu type='tcg' name='7448_v2.1'/>
++  <cpu type='tcg' name='7441_v2.3'/>
++  <cpu type='tcg' name='7400_v2.1'/>
++  <cpu type='tcg' name='405CRb'/>
++  <cpu type='tcg' name='7447A_v1.0'/>
++  <cpu type='tcg' name='MPC8540_v20'/>
++  <cpu type='tcg' name='MPC8543_v10'/>
++  <cpu type='tcg' name='7445_v2.1'/>
++  <cpu type='tcg' name='e500_v20'/>
++  <cpu type='tcg' name='750gx_v1.1'/>
++  <cpu type='tcg' name='604'/>
++  <cpu type='tcg' name='750cxe_v2.4'/>
++  <cpu type='tcg' name='MPC8548_v20'/>
++  <cpu type='tcg' name='MPC8543E_v11'/>
++  <cpu type='tcg' name='MPC8347AT'/>
++  <cpu type='tcg' name='750l_v2.1'/>
++  <cpu type='tcg' name='POWER8NVL_v1.0'/>
++  <cpu type='tcg' name='7457A_v1.0'/>
++  <cpu type='tcg' name='7457_v1.0'/>
++  <cpu type='tcg' name='7450_v1.2'/>
++  <cpu type='tcg' name='MPC8572'/>
++  <cpu type='tcg' name='755_v2.5'/>
++  <cpu type='tcg' name='7410_v1.3'/>
++  <cpu type='tcg' name='745_v2.3'/>
++  <cpu type='tcg' name='405GPR'/>
++  <cpu type='tcg' name='755_v2.0'/>
++  <cpu type='tcg' name='MPC8541_v11'/>
++  <cpu type='tcg' name='401C2'/>
++  <cpu type='tcg' name='e500v2_v30'/>
++  <cpu type='tcg' name='7455_v3.3'/>
++  <cpu type='tcg' name='405EZ'/>
++  <cpu type='tcg' name='MPC8568E'/>
++  <cpu type='tcg' name='755_v1.0'/>
++  <cpu type='tcg' name='603e_v1.3'/>
++  <cpu type='tcg' name='MPC8560_v10'/>
++  <cpu type='tcg' name='MPC8560_v21'/>
++  <cpu type='tcg' name='G2H4'/>
++  <cpu type='tcg' name='MPC8533_v11'/>
++  <cpu type='tcg' name='740_v3.1'/>
++  <cpu type='tcg' name='e200z5'/>
++  <cpu type='tcg' name='MPC8349'/>
++  <cpu type='tcg' name='7400_v2.0'/>
++  <cpu type='tcg' name='405CRa'/>
++  <cpu type='tcg' name='MPC8543E_v10'/>
++  <cpu type='tcg' name='MPC8543E_v21'/>
++  <cpu type='tcg' name='750cxe_v2.3'/>
++  <cpu type='tcg' name='MPC8543_v20'/>
++  <cpu type='tcg' name='745_v2.7'/>
++  <cpu type='tcg' name='403GC'/>
++  <cpu type='tcg' name='e5500'/>
++  <cpu type='tcg' name='7448_v1.0'/>
++  <cpu type='tcg' name='MPC5200_v12'/>
++  <cpu type='tcg' name='740_v2.1'/>
++  <cpu type='tcg' name='745_v2.2'/>
++  <cpu type='tcg' name='7400_v1.0'/>
++  <cpu type='tcg' name='7410_v1.2'/>
++  <cpu type='tcg' name='x2vp4'/>
++  <cpu type='tcg' name='MPC8555_v11'/>
++  <cpu type='tcg' name='MPC8541_v10'/>
++  <cpu type='tcg' name='405LP'/>
++  <cpu type='tcg' name='750fx_v2.3'/>
++  <cpu type='tcg' name='405EP'/>
++  <cpu type='tcg' name='601_v2'/>
++  <cpu type='tcg' name='MPC8544_v11'/>
++  <cpu type='tcg' name='401D2'/>
++  <cpu type='tcg' name='MPC8572E'/>
++  <cpu type='tcg' name='604e_v1.0'/>
++  <cpu type='tcg' name='750cx_v2.1'/>
++  <cpu type='tcg' name='MPC5200B_v21'/>
++  <cpu type='tcg' name='750l_v3.0'/>
++  <cpu type='tcg' name='e300c4'/>
++  <cpu type='tcg' name='7448_v2.0'/>
++  <cpu type='tcg' name='7450_v2.1'/>
++  <cpu type='tcg' name='G2leGP'/>
++  <cpu type='tcg' name='750cxe_v3.1b'/>
++  <cpu type='tcg' name='7400_v2.9'/>
++  <cpu type='tcg' name='G2GP'/>
++  <cpu type='tcg' name='603'/>
++  <cpu type='tcg' name='405GPd'/>
++  <cpu type='tcg' name='MPC8548E_v11'/>
++  <cpu type='tcg' name='603e7t'/>
++  <cpu type='tcg' name='IOP480'/>
++  <cpu type='tcg' name='750gx_v1.0'/>
++  <cpu type='tcg' name='MPC8560_v20'/>
++  <cpu type='tcg' name='405D2'/>
++  <cpu type='tcg' name='750fl'/>
++  <cpu type='tcg' name='750l_v2.0'/>
++  <cpu type='tcg' name='x2vp20'/>
++  <cpu type='tcg' name='e600'/>
++  <cpu type='tcg' name='7450_v1.1'/>
++  <cpu type='tcg' name='755_v2.4'/>
++  <cpu type='tcg' name='7445_v1.0'/>
++  <cpu type='tcg' name='G2LS'/>
++  <cpu type='tcg' name='MPC8543E_v20'/>
++  <cpu type='tcg' name='603e_v2.2'/>
++  <cpu type='tcg' name='7447_v1.1'/>
++  <cpu type='tcg' name='603e_v4'/>
++  <cpu type='tcg' name='7455_v3.2'/>
++  <cpu type='tcg' name='740_v2.0'/>
++  <cpu type='tcg' name='MPC8347P'/>
++  <cpu type='tcg' name='440EPb'/>
++  <cpu type='tcg' name='MPC603'/>
++  <cpu type='tcg' name='603e_v1.2'/>
++  <cpu type='tcg' name='750fx_v2.2'/>
++  <cpu type='tcg' name='POWER9_v1.0'/>
++  <cpu type='tcg' name='740_v1.0'/>
++  <cpu type='tcg' name='MPC8544_v10'/>
++  <cpu type='tcg' name='601_v1'/>
++  <cpu type='tcg' name='745_v1.1'/>
++  <cpu type='tcg' name='POWER7+_v2.1'/>
++  <cpu type='tcg' name='750cx_v2.0'/>
++  <cpu type='tcg' name='MPC8347EAP'/>
++  <cpu type='tcg' name='401E2'/>
++  <cpu type='tcg' name='MPC8641D'/>
++  <cpu type='tcg' name='e300c3'/>
++  <cpu type='tcg' name='MPC8533_v10'/>
++  <cpu type='tcg' name='7441_v2.1'/>
++  <cpu type='tcg' name='740_v3.0'/>
++  <cpu type='tcg' name='POWER5+_v2.1'/>
++  <cpu type='tcg' name='602'/>
++  <cpu type='tcg' name='MPC8548E_v10'/>
++  <cpu type='tcg' name='G2leLS'/>
++  <cpu type='tcg' name='MPC8343'/>
++  <cpu type='tcg' name='750cx_v1.0'/>
++  <cpu type='tcg' name='750cxe_v2.2'/>
++  <cpu type='tcg' name='604e_v2.4'/>
++  <cpu type='tcg' name='755_v2.8'/>
++  <cpu type='tcg' name='745_v2.6'/>
++  <cpu type='tcg' name='MPC8548E_v21'/>
++  <cpu type='tcg' name='G2le'/>
++  <cpu type='tcg' name='403GB'/>
++  <cpu type='tcg' name='MPC8545E_v21'/>
++  <cpu type='tcg' name='POWER7_v2.3'/>
++  <cpu type='tcg' name='750_v2.2'/>
++  <cpu type='tcg' name='7450_v1.0'/>
++  <cpu type='tcg' name='MPC5200_v11'/>
++  <cpu type='tcg' name='755_v2.3'/>
++  <cpu type='tcg' name='MPC8347EP'/>
++  <cpu type='tcg' name='7410_v1.1'/>
++  <cpu type='tcg' name='750gl'/>
++  <cpu type='tcg' name='403GCX'/>
++  <cpu type='tcg' name='745_v2.1'/>
++  <cpu type='tcg' name='750p'/>
++  <cpu type='tcg' name='G2'/>
++  <cpu type='tcg' name='MPC8555_v10'/>
++  <cpu type='tcg' name='7445_v3.4'/>
++  <cpu type='tcg' name='MPC8347T'/>
++  <cpu type='tcg' name='603e_v3'/>
++  <cpu type='tcg' name='970_v2.2'/>
++  <cpu type='tcg' name='440-Xilinx'/>
++  <cpu type='tcg' name='740p'/>
++  <cpu type='tcg' name='MPC5200B_v20'/>
++  <cpu type='tcg' name='440EPX'/>
++  <cpu type='tcg' name='603e_v1.1'/>
++  <cpu type='tcg' name='7451_v2.3'/>
++  <cpu type='tcg' name='7450_v2.0'/>
++  <cpu type='tcg' name='7400_v2.8'/>
++  <cpu type='tcg' name='7455_v2.1'/>
++  <cpu type='tcg' name='405GPc'/>
++  <cpu type='tcg' name='MPC8347EAT'/>
++  <cpu type='tcg' name='970mp_v1.1'/>
++  <cpu type='tcg' name='603e7v2'/>
++  <cpu type='tcg' name='604r'/>
++  <cpu type='tcg' name='7447A_v1.2'/>
++  <cpu type='tcg' name='MPC8533E_v11'/>
++  <cpu type='tcg' name='e500v2_v22'/>
++  <cpu type='tcg' name='401F2'/>
++  <cpu type='tcg' name='MPC8343EA'/>
++  <cpu type='tcg' name='7457_v1.2'/>
++  <cpu type='tcg' name='7447_v1.0'/>
++  <cpu type='tcg' name='970fx_v3.1'/>
++  <cpu type='tcg' name='745_v2.5'/>
++  <cpu type='tcg' name='MPC8548E_v20'/>
++  <cpu type='tcg' name='MPC8610'/>
++  <cpu type='tcg' name='750cxe_v2.4b'/>
++  <cpu type='tcg' name='MPC5200_v10'/>
++  <cpu type='tcg' name='403GA'/>
++  <cpu type='tcg' name='7410_v1.0'/>
++  <cpu type='tcg' name='G2leGP3'/>
++  <cpu type='tcg' name='7445_v3.3'/>
++  <cpu type='tcg' name='603e_v4.1'/>
++  <cpu type='tcg' name='440EPa'/>
++  <cpu type='tcg' name='970fx_v2.1'/>
++  <cpu type='tcg' name='MPC8377E'/>
++  <cpu type='tcg' name='750fx_v2.1'/>
++  <cpu type='tcg' name='601_v0'/>
++  <cpu type='tcg' name='STB04'/>
++  <cpu type='tcg' name='745_v1.0'/>
++  <cpu type='tcg' name='G2HiP4'/>
++  <cpu type='tcg' name='750cl_v2.0'/>
++  <cpu type='tcg' name='750cxr'/>
++  <cpu type='tcg' name='MPC8349EA'/>
++  <cpu type='tcg' name='750cxe_v3.1'/>
++  <cpu type='tcg' name='MPC8379'/>
++  <cpu type='tcg' name='401'/>
++  <cpu type='tcg' name='MPC8568'/>
++  <cpu type='tcg' name='e300c2'/>
++  <cpu type='tcg' name='750_v3.1'/>
++  <cpu type='tcg' name='MPC8544E_v11'/>
++  <cpu type='tcg' name='405GPb'/>
++  <cpu type='tcg' name='MPC8541E_v11'/>
++  <machine name='pseries-2.10' alias='pseries' hotplugCpus='yes' maxCpus='1024'/>
++  <machine name='ref405ep' maxCpus='1'/>
++  <machine name='virtex-ml507' maxCpus='1'/>
++  <machine name='powernv' maxCpus='2048'/>
++  <machine name='ppce500' maxCpus='32'/>
++  <machine name='mpc8544ds' maxCpus='15'/>
++  <machine name='bamboo' maxCpus='1'/>
++  <machine name='g3beige' maxCpus='1'/>
++  <machine name='prep' maxCpus='1'/>
++  <machine name='pseries-2.9' hotplugCpus='yes' maxCpus='1024'/>
++  <machine name='mac99' maxCpus='1'/>
++  <machine name='pseries-2.6' maxCpus='1024'/>
++  <machine name='pseries-2.7' hotplugCpus='yes' maxCpus='1024'/>
++  <machine name='pseries-2.8' hotplugCpus='yes' maxCpus='1024'/>
++  <machine name='pseries-2.4' maxCpus='1024'/>
++  <machine name='pseries-2.5' maxCpus='1024'/>
++  <machine name='pseries-2.2' maxCpus='1024'/>
++  <machine name='taihu' maxCpus='1'/>
++  <machine name='pseries-2.3' maxCpus='1024'/>
++  <machine name='pseries-2.1' maxCpus='1024'/>
++  <machine name='40p' maxCpus='1'/>
++</qemuCaps>
+diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
+index 9bb1ffca6a..6e39866ebe 100644
+--- a/tests/qemucapabilitiestest.c
++++ b/tests/qemucapabilitiestest.c
+@@ -175,6 +175,7 @@ mymain(void)
+     DO_TEST("aarch64", "caps_2.6.0-gicv3");
+     DO_TEST("ppc64", "caps_2.6.0");
+     DO_TEST("ppc64", "caps_2.9.0");
++    DO_TEST("ppc64", "caps_2.10.0");
+     DO_TEST("s390x", "caps_2.7.0");
+     DO_TEST("s390x", "caps_2.8.0");
+     DO_TEST("s390x", "caps_2.9.0");
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-tests-Add-resctrl-skx-twocaches-test-case-to-vircaps2xmltest.patch b/SOURCES/libvirt-tests-Add-resctrl-skx-twocaches-test-case-to-vircaps2xmltest.patch
new file mode 100644
index 0000000..5b122c9
--- /dev/null
+++ b/SOURCES/libvirt-tests-Add-resctrl-skx-twocaches-test-case-to-vircaps2xmltest.patch
@@ -0,0 +1,359 @@
+From b4c36bdf3ed28042338716cc1add921bd4f54e2d Mon Sep 17 00:00:00 2001
+Message-Id: <b4c36bdf3ed28042338716cc1add921bd4f54e2d@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:21 +0100
+Subject: [PATCH] tests: Add resctrl-skx-twocaches test case to vircaps2xmltest
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+This doesn't add very much value for now, but future test for virresctrl will
+take information from vircaps2xmldata (since it is dependent on the same info
+then why duplicate it) and this particular use case helps us cover bit more of
+the code regarding proper formatting and handling errors.  And one more test for
+vircaps2xmltest doesn't hurt either.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit d807014563bb25b466d5dbf718f023c18e762a4b)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ .../resctrl/info/L3/cbm_mask                       |  1 +
+ .../resctrl/info/L3/min_cbm_bits                   |  1 +
+ .../resctrl/info/L3/num_closids                    |  1 +
+ .../linux-resctrl-skx-twocaches/resctrl/schemata   |  1 +
+ .../resctrl/some_reservation/schemata              |  1 +
+ .../system/cpu/cpu0/cache/index0/id                |  1 +
+ .../system/cpu/cpu0/cache/index0/level             |  1 +
+ .../system/cpu/cpu0/cache/index0/shared_cpu_list   |  1 +
+ .../system/cpu/cpu0/cache/index0/shared_cpu_map    |  1 +
+ .../system/cpu/cpu0/cache/index0/size              |  1 +
+ .../system/cpu/cpu0/cache/index0/type              |  1 +
+ .../system/cpu/cpu0/cache/index1/id                |  1 +
+ .../system/cpu/cpu0/cache/index1/level             |  1 +
+ .../system/cpu/cpu0/cache/index1/shared_cpu_list   |  1 +
+ .../system/cpu/cpu0/cache/index1/shared_cpu_map    |  1 +
+ .../system/cpu/cpu0/cache/index1/size              |  1 +
+ .../system/cpu/cpu0/cache/index1/type              |  1 +
+ .../system/cpu/cpu0/online                         |  1 +
+ .../system/cpu/cpu0/topology/core_id               |  1 +
+ .../system/cpu/cpu0/topology/core_siblings         |  1 +
+ .../system/cpu/cpu0/topology/core_siblings_list    |  1 +
+ .../system/cpu/cpu0/topology/physical_package_id   |  1 +
+ .../system/cpu/cpu0/topology/thread_siblings       |  1 +
+ .../system/cpu/cpu0/topology/thread_siblings_list  |  1 +
+ .../linux-resctrl-skx-twocaches/system/cpu/online  |  1 +
+ .../linux-resctrl-skx-twocaches/system/cpu/present |  1 +
+ .../system/node/node0/cpu0                         |  1 +
+ .../system/node/node0/cpulist                      |  1 +
+ .../system/node/node0/cpumap                       |  1 +
+ .../system/node/node0/distance                     |  1 +
+ .../linux-resctrl-skx-twocaches/system/node/online |  1 +
+ .../vircaps-x86_64-resctrl-skx-twocaches.xml       | 34 ++++++++++++++++++++++
+ tests/vircaps2xmltest.c                            |  1 +
+ 33 files changed, 66 insertions(+)
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/cbm_mask
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/min_cbm_bits
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/num_closids
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/schemata
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/some_reservation/schemata
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/id
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/level
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/shared_cpu_list
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/shared_cpu_map
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/size
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/type
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/id
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/level
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/shared_cpu_list
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/shared_cpu_map
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/size
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/type
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/online
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_id
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_siblings
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_siblings_list
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/physical_package_id
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/thread_siblings
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/thread_siblings_list
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/online
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/present
+ create mode 120000 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpu0
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpulist
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpumap
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/distance
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/online
+ create mode 100644 tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx-twocaches.xml
+
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/cbm_mask b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/cbm_mask
+new file mode 100644
+index 0000000000..d482bbb269
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/cbm_mask
+@@ -0,0 +1 @@
++7ff
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/min_cbm_bits
+new file mode 100644
+index 0000000000..d00491fd7e
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/min_cbm_bits
+@@ -0,0 +1 @@
++1
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/num_closids b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/num_closids
+new file mode 100644
+index 0000000000..b6a7d89c68
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/info/L3/num_closids
+@@ -0,0 +1 @@
++16
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/schemata
+new file mode 100644
+index 0000000000..691fbaf887
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/schemata
+@@ -0,0 +1 @@
++L3:0=0f0;1=000
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/some_reservation/schemata b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/some_reservation/schemata
+new file mode 100644
+index 0000000000..e76adc896c
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/some_reservation/schemata
+@@ -0,0 +1 @@
++L3:0=70e;1=3ff
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/id b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/id
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/id
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/level b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/level
+new file mode 100644
+index 0000000000..00750edc07
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/level
+@@ -0,0 +1 @@
++3
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/shared_cpu_list
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/shared_cpu_list
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/shared_cpu_map
+new file mode 100644
+index 0000000000..5325a8dff7
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/shared_cpu_map
+@@ -0,0 +1 @@
++001
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/size b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/size
+new file mode 100644
+index 0000000000..d23da60c12
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/size
+@@ -0,0 +1 @@
++33M
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/type b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/type
+new file mode 100644
+index 0000000000..e4fd9dccda
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index0/type
+@@ -0,0 +1 @@
++Unified
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/id b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/id
+new file mode 100644
+index 0000000000..d00491fd7e
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/id
+@@ -0,0 +1 @@
++1
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/level b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/level
+new file mode 100644
+index 0000000000..00750edc07
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/level
+@@ -0,0 +1 @@
++3
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/shared_cpu_list b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/shared_cpu_list
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/shared_cpu_list
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/shared_cpu_map b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/shared_cpu_map
+new file mode 100644
+index 0000000000..5325a8dff7
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/shared_cpu_map
+@@ -0,0 +1 @@
++001
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/size b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/size
+new file mode 100644
+index 0000000000..d23da60c12
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/size
+@@ -0,0 +1 @@
++33M
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/type b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/type
+new file mode 100644
+index 0000000000..e4fd9dccda
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/cache/index1/type
+@@ -0,0 +1 @@
++Unified
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/online b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/online
+new file mode 100644
+index 0000000000..d00491fd7e
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/online
+@@ -0,0 +1 @@
++1
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_id b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_id
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_id
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_siblings b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_siblings
+new file mode 100644
+index 0000000000..5325a8dff7
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_siblings
+@@ -0,0 +1 @@
++001
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_siblings_list b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_siblings_list
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/core_siblings_list
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/physical_package_id b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/physical_package_id
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/physical_package_id
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/thread_siblings b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/thread_siblings
+new file mode 100644
+index 0000000000..5325a8dff7
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/thread_siblings
+@@ -0,0 +1 @@
++001
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/thread_siblings_list b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/thread_siblings_list
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/topology/thread_siblings_list
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/online b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/online
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/online
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/present b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/present
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/present
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpu0 b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpu0
+new file mode 120000
+index 0000000000..c841bea28b
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpu0
+@@ -0,0 +1 @@
++../../cpu/cpu0
+\ No newline at end of file
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpulist b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpulist
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpulist
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpumap b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpumap
+new file mode 100644
+index 0000000000..5325a8dff7
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/cpumap
+@@ -0,0 +1 @@
++001
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/distance b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/distance
+new file mode 100644
+index 0000000000..f599e28b8a
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/node0/distance
+@@ -0,0 +1 @@
++10
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/online b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/online
+new file mode 100644
+index 0000000000..573541ac97
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/node/online
+@@ -0,0 +1 @@
++0
+diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx-twocaches.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx-twocaches.xml
+new file mode 100644
+index 0000000000..d18665b24f
+--- /dev/null
++++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx-twocaches.xml
+@@ -0,0 +1,34 @@
++<capabilities>
++
++  <host>
++    <cpu>
++      <arch>x86_64</arch>
++    </cpu>
++    <power_management/>
++    <migration_features>
++      <live/>
++    </migration_features>
++    <topology>
++      <cells num='1'>
++        <cell id='0'>
++          <memory unit='KiB'>1048576</memory>
++          <pages unit='KiB' size='4'>2048</pages>
++          <pages unit='KiB' size='2048'>4096</pages>
++          <pages unit='KiB' size='1048576'>6144</pages>
++          <cpus num='1'>
++            <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
++          </cpus>
++        </cell>
++      </cells>
++    </topology>
++    <cache>
++      <bank id='0' level='3' type='both' size='33' unit='MiB' cpus='0'>
++        <control granularity='3' unit='MiB' type='both' maxAllocs='16'/>
++      </bank>
++      <bank id='1' level='3' type='both' size='33' unit='MiB' cpus='0'>
++        <control granularity='3' unit='MiB' type='both' maxAllocs='16'/>
++      </bank>
++    </cache>
++  </host>
++
++</capabilities>
+diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c
+index c0a67858fe..9ee9bf9f95 100644
+--- a/tests/vircaps2xmltest.c
++++ b/tests/vircaps2xmltest.c
+@@ -121,6 +121,7 @@ mymain(void)
+     DO_TEST_FULL("resctrl", VIR_ARCH_X86_64, true, true, true);
+     DO_TEST_FULL("resctrl-cdp", VIR_ARCH_X86_64, true, true, true);
+     DO_TEST_FULL("resctrl-skx", VIR_ARCH_X86_64, true, true, true);
++    DO_TEST_FULL("resctrl-skx-twocaches", VIR_ARCH_X86_64, true, true, true);
+ 
+     return ret;
+ }
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-tests-Add-test-for-properly-removing-cachetune-entries.patch b/SOURCES/libvirt-tests-Add-test-for-properly-removing-cachetune-entries.patch
new file mode 100644
index 0000000..18b9079
--- /dev/null
+++ b/SOURCES/libvirt-tests-Add-test-for-properly-removing-cachetune-entries.patch
@@ -0,0 +1,113 @@
+From d41c109a5c9a6224201acdd0efde034776cfa49e Mon Sep 17 00:00:00 2001
+Message-Id: <d41c109a5c9a6224201acdd0efde034776cfa49e@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Fri, 2 Feb 2018 15:21:28 +0100
+Subject: [PATCH] tests: Add test for properly removing cachetune entries
+
+Cachetune for unavailable vCPUs should be cleared the same way vcpupin and other
+things do, so let's add tests for it.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 958e0431a93b5d330dcc3fa5984a85e5c789eead)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1540817
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ .../generic-cachetune-extra-tunes.xml              | 33 ++++++++++++++++++++++
+ .../generic-cachetune-extra-tunes.xml              | 30 ++++++++++++++++++++
+ tests/genericxml2xmltest.c                         |  1 +
+ 3 files changed, 64 insertions(+)
+ create mode 100644 tests/genericxml2xmlindata/generic-cachetune-extra-tunes.xml
+ create mode 100644 tests/genericxml2xmloutdata/generic-cachetune-extra-tunes.xml
+
+diff --git a/tests/genericxml2xmlindata/generic-cachetune-extra-tunes.xml b/tests/genericxml2xmlindata/generic-cachetune-extra-tunes.xml
+new file mode 100644
+index 0000000000..d3b01a8ecd
+--- /dev/null
++++ b/tests/genericxml2xmlindata/generic-cachetune-extra-tunes.xml
+@@ -0,0 +1,33 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219136</memory>
++  <currentMemory unit='KiB'>219136</currentMemory>
++  <vcpu placement='static'>2</vcpu>
++  <cputune>
++    <cachetune vcpus='0-3'>
++      <cache id='0' level='3' type='code' size='7680' unit='KiB'/>
++      <cache id='1' level='3' type='data' size='3840' unit='KiB'/>
++    </cachetune>
++    <cachetune vcpus='100'>
++      <cache id='1' level='3' type='code' size='6' unit='MiB'/>
++    </cachetune>
++  </cputune>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <controller type='usb' index='0'/>
++    <controller type='ide' index='0'/>
++    <controller type='pci' index='0' model='pci-root'/>
++    <input type='mouse' bus='ps2'/>
++    <input type='keyboard' bus='ps2'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/genericxml2xmloutdata/generic-cachetune-extra-tunes.xml b/tests/genericxml2xmloutdata/generic-cachetune-extra-tunes.xml
+new file mode 100644
+index 0000000000..db85af08da
+--- /dev/null
++++ b/tests/genericxml2xmloutdata/generic-cachetune-extra-tunes.xml
+@@ -0,0 +1,30 @@
++<domain type='qemu'>
++  <name>QEMUGuest1</name>
++  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
++  <memory unit='KiB'>219136</memory>
++  <currentMemory unit='KiB'>219136</currentMemory>
++  <vcpu placement='static'>2</vcpu>
++  <cputune>
++    <cachetune vcpus='0-1'>
++      <cache id='0' level='3' type='code' size='7680' unit='KiB'/>
++      <cache id='1' level='3' type='data' size='3840' unit='KiB'/>
++    </cachetune>
++  </cputune>
++  <os>
++    <type arch='i686' machine='pc'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-i686</emulator>
++    <controller type='usb' index='0'/>
++    <controller type='ide' index='0'/>
++    <controller type='pci' index='0' model='pci-root'/>
++    <input type='mouse' bus='ps2'/>
++    <input type='keyboard' bus='ps2'/>
++    <memballoon model='virtio'/>
++  </devices>
++</domain>
+diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
+index 4ced5c349c..4c3f32a816 100644
+--- a/tests/genericxml2xmltest.c
++++ b/tests/genericxml2xmltest.c
+@@ -133,6 +133,7 @@ mymain(void)
+     DO_TEST("cachetune");
+     DO_TEST("cachetune-small");
+     DO_TEST("cachetune-cdp");
++    DO_TEST_DIFFERENT("cachetune-extra-tunes");
+     DO_TEST_FULL("cachetune-colliding-allocs", false, true,
+                  TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
+     DO_TEST_FULL("cachetune-colliding-tunes", false, true,
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-tests-Add-tests-for-configuration-of-HPT-resizing.patch b/SOURCES/libvirt-tests-Add-tests-for-configuration-of-HPT-resizing.patch
new file mode 100644
index 0000000..52b2dbd
--- /dev/null
+++ b/SOURCES/libvirt-tests-Add-tests-for-configuration-of-HPT-resizing.patch
@@ -0,0 +1,178 @@
+From 4b4ddd95952a455426ec82c45c8309e346bb29c7 Mon Sep 17 00:00:00 2001
+Message-Id: <4b4ddd95952a455426ec82c45c8309e346bb29c7@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 15 Nov 2017 10:28:55 +0100
+Subject: [PATCH] tests: Add tests for configuration of HPT resizing
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 5e192a36201ed165c79bf66336747c220a7d63a2)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1308743
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ ...l2argv-pseries-hpt-resizing-invalid-machine.xml | 18 ++++++++++++++
+ .../qemuxml2argv-pseries-hpt-resizing.args         | 20 ++++++++++++++++
+ .../qemuxml2argv-pseries-hpt-resizing.xml          | 19 +++++++++++++++
+ tests/qemuxml2argvtest.c                           | 12 ++++++++++
+ .../qemuxml2xmlout-pseries-hpt-resizing.xml        | 28 ++++++++++++++++++++++
+ tests/qemuxml2xmltest.c                            |  5 ++++
+ 6 files changed, 102 insertions(+)
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing-invalid-machine.xml
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing.args
+ create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing.xml
+ create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hpt-resizing.xml
+
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing-invalid-machine.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing-invalid-machine.xml
+new file mode 100644
+index 0000000000..757fcc70e1
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing-invalid-machine.xml
+@@ -0,0 +1,18 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='x86_64' machine='pc'>hvm</type>
++  </os>
++  <features>
++    <!-- HPT resizing can't be enabled for non-pSeries guests -->
++    <hpt resizing='enabled'/>
++  </features>
++  <devices>
++    <emulator>/usr/bin/qemu-system-x86_64</emulator>
++    <controller type='usb' model='none'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing.args
+new file mode 100644
+index 0000000000..994789a5e0
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing.args
+@@ -0,0 +1,20 @@
++LC_ALL=C \
++PATH=/bin \
++HOME=/home/test \
++USER=test \
++LOGNAME=test \
++QEMU_AUDIO_DRV=none \
++/usr/bin/qemu-system-ppc64 \
++-name guest \
++-S \
++-machine pseries,accel=tcg,resize-hpt=required \
++-m 512 \
++-smp 1,sockets=1,cores=1,threads=1 \
++-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
++-nographic \
++-nodefconfig \
++-nodefaults \
++-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
++server,nowait \
++-mon chardev=charmonitor,id=monitor,mode=readline \
++-boot c
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing.xml
+new file mode 100644
+index 0000000000..f9dc9cac94
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-hpt-resizing.xml
+@@ -0,0 +1,19 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++  </os>
++  <features>
++    <!-- Explicitly enable HPT resizing. The guest will not start
++         at all unless HPT resizing can be arranged -->
++    <hpt resizing='required'/>
++  </features>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' model='none'/>
++    <memballoon model='none'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 03b1bcbcf7..ecc86d045c 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -1848,6 +1848,18 @@ mymain(void)
+             QEMU_CAPS_VIRTIO_SCSI,
+             QEMU_CAPS_DEVICE_VFIO_PCI);
+ 
++    DO_TEST("pseries-hpt-resizing",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_MACHINE_OPT,
++            QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
++    DO_TEST_FAILURE("pseries-hpt-resizing",
++                    QEMU_CAPS_NODEFCONFIG,
++                    QEMU_CAPS_MACHINE_OPT);
++    DO_TEST_PARSE_ERROR("pseries-hpt-resizing-invalid-machine",
++                        QEMU_CAPS_NODEFCONFIG,
++                        QEMU_CAPS_MACHINE_OPT,
++                        QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
++
+     DO_TEST("disk-ide-drive-split",
+             QEMU_CAPS_NODEFCONFIG,
+             QEMU_CAPS_IDE_CD);
+diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hpt-resizing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hpt-resizing.xml
+new file mode 100644
+index 0000000000..5dd0dbd0be
+--- /dev/null
++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hpt-resizing.xml
+@@ -0,0 +1,28 @@
++<domain type='qemu'>
++  <name>guest</name>
++  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
++  <memory unit='KiB'>524288</memory>
++  <currentMemory unit='KiB'>524288</currentMemory>
++  <vcpu placement='static'>1</vcpu>
++  <os>
++    <type arch='ppc64' machine='pseries'>hvm</type>
++    <boot dev='hd'/>
++  </os>
++  <features>
++    <hpt resizing='required'/>
++  </features>
++  <clock offset='utc'/>
++  <on_poweroff>destroy</on_poweroff>
++  <on_reboot>restart</on_reboot>
++  <on_crash>destroy</on_crash>
++  <devices>
++    <emulator>/usr/bin/qemu-system-ppc64</emulator>
++    <controller type='usb' index='0' model='none'/>
++    <controller type='pci' index='0' model='pci-root'>
++      <model name='spapr-pci-host-bridge'/>
++      <target index='0'/>
++    </controller>
++    <memballoon model='none'/>
++    <panic model='pseries'/>
++  </devices>
++</domain>
+diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
+index fdba2adb98..6687997900 100644
+--- a/tests/qemuxml2xmltest.c
++++ b/tests/qemuxml2xmltest.c
+@@ -761,6 +761,11 @@ mymain(void)
+             QEMU_CAPS_VIRTIO_SCSI,
+             QEMU_CAPS_DEVICE_VFIO_PCI);
+ 
++    DO_TEST("pseries-hpt-resizing",
++            QEMU_CAPS_NODEFCONFIG,
++            QEMU_CAPS_MACHINE_OPT,
++            QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
++
+     DO_TEST("balloon-device-auto", NONE);
+     DO_TEST("balloon-device-period", NONE);
+     DO_TEST("channel-virtio-auto", NONE);
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-tests-Add-virresctrltest.patch b/SOURCES/libvirt-tests-Add-virresctrltest.patch
new file mode 100644
index 0000000..acf5592
--- /dev/null
+++ b/SOURCES/libvirt-tests-Add-virresctrltest.patch
@@ -0,0 +1,207 @@
+From 15e49265411702cd518af91e04a78ef911559d06 Mon Sep 17 00:00:00 2001
+Message-Id: <15e49265411702cd518af91e04a78ef911559d06@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:31 +0100
+Subject: [PATCH] tests: Add virresctrltest
+
+This test initializes capabilities from vircaps2xmldata (since it exists there
+already) and then requests list of free bitmaps (all unallocated space) from
+virresctrl.c
+
+Desirable outputs are saved in virresctrldata.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit ae885bb52089b1d367e7ac1ed5d8d683e0bfefbd)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ tests/Makefile.am                                  |   9 +-
+ tests/virresctrldata/resctrl-cdp.schemata          |   2 +
+ .../virresctrldata/resctrl-skx-twocaches.schemata  |   1 +
+ tests/virresctrldata/resctrl-skx.schemata          |   1 +
+ tests/virresctrldata/resctrl.schemata              |   1 +
+ tests/virresctrltest.c                             | 102 +++++++++++++++++++++
+ 6 files changed, 115 insertions(+), 1 deletion(-)
+ create mode 100644 tests/virresctrldata/resctrl-cdp.schemata
+ create mode 100644 tests/virresctrldata/resctrl-skx-twocaches.schemata
+ create mode 100644 tests/virresctrldata/resctrl-skx.schemata
+ create mode 100644 tests/virresctrldata/resctrl.schemata
+ create mode 100644 tests/virresctrltest.c
+
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 0b2305d70b..f845b44102 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -164,6 +164,7 @@ EXTRA_DIST =		\
+ 	xml2vmxdata \
+ 	virstorageutildata \
+ 	virfilecachedata \
++	virresctrldata \
+ 	$(NULL)
+ 
+ test_helpers = commandhelper ssh
+@@ -231,6 +232,7 @@ if WITH_LINUX
+ test_programs += fchosttest
+ test_programs += scsihosttest
+ test_programs += vircaps2xmltest
++test_programs += virresctrltest
+ test_libraries += virusbmock.la \
+ 	virnetdevbandwidthmock.la \
+ 	virnumamock.la \
+@@ -1172,8 +1174,13 @@ virnumamock_la_CFLAGS = $(AM_CFLAGS)
+ virnumamock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
+ virnumamock_la_LIBADD = $(MOCKLIBS_LIBS)
+ 
++virresctrltest_SOURCES = \
++	virresctrltest.c testutils.h testutils.c virfilewrapper.h virfilewrapper.c
++virresctrltest_LDADD = $(LDADDS)
++
+ else ! WITH_LINUX
+-EXTRA_DIST += vircaps2xmltest.c virnumamock.c virfilewrapper.c virfilewrapper.h
++EXTRA_DIST += vircaps2xmltest.c virnumamock.c virfilewrapper.c \
++			  virfilewrapper.h virresctrltest.c
+ endif ! WITH_LINUX
+ 
+ if WITH_NSS
+diff --git a/tests/virresctrldata/resctrl-cdp.schemata b/tests/virresctrldata/resctrl-cdp.schemata
+new file mode 100644
+index 0000000000..2897e2afa6
+--- /dev/null
++++ b/tests/virresctrldata/resctrl-cdp.schemata
+@@ -0,0 +1,2 @@
++L3CODE:0=00ffc;1=0ff00
++L3DATA:0=00000;1=03fff
+diff --git a/tests/virresctrldata/resctrl-skx-twocaches.schemata b/tests/virresctrldata/resctrl-skx-twocaches.schemata
+new file mode 100644
+index 0000000000..86b3801a04
+--- /dev/null
++++ b/tests/virresctrldata/resctrl-skx-twocaches.schemata
+@@ -0,0 +1 @@
++L3:0=001;1=400
+diff --git a/tests/virresctrldata/resctrl-skx.schemata b/tests/virresctrldata/resctrl-skx.schemata
+new file mode 100644
+index 0000000000..5e8b0d6362
+--- /dev/null
++++ b/tests/virresctrldata/resctrl-skx.schemata
+@@ -0,0 +1 @@
++L3:0=70f
+diff --git a/tests/virresctrldata/resctrl.schemata b/tests/virresctrldata/resctrl.schemata
+new file mode 100644
+index 0000000000..fa980e58c9
+--- /dev/null
++++ b/tests/virresctrldata/resctrl.schemata
+@@ -0,0 +1 @@
++L3:0=000ff;1=000f0
+diff --git a/tests/virresctrltest.c b/tests/virresctrltest.c
+new file mode 100644
+index 0000000000..99e20d5dec
+--- /dev/null
++++ b/tests/virresctrltest.c
+@@ -0,0 +1,102 @@
++#include <config.h>
++#include <stdlib.h>
++
++#include "testutils.h"
++#include "virfilewrapper.h"
++#include "virresctrlpriv.h"
++
++
++#define VIR_FROM_THIS VIR_FROM_NONE
++
++struct virResctrlData {
++    const char *filename;
++    bool fail;
++};
++
++
++static int
++test_virResctrlGetUnused(const void *opaque)
++{
++    struct virResctrlData *data = (struct virResctrlData *) opaque;
++    char *system_dir = NULL;
++    char *resctrl_dir = NULL;
++    int ret = -1;
++    virResctrlAllocPtr alloc = NULL;
++    char *schemata_str = NULL;
++    char *schemata_file;
++    virCapsPtr caps = NULL;
++
++    if (virAsprintf(&system_dir, "%s/vircaps2xmldata/linux-%s/system",
++                    abs_srcdir, data->filename) < 0)
++        goto cleanup;
++
++    if (virAsprintf(&resctrl_dir, "%s/vircaps2xmldata/linux-%s/resctrl",
++                    abs_srcdir, data->filename) < 0)
++        goto cleanup;
++
++    if (virAsprintf(&schemata_file, "%s/virresctrldata/%s.schemata",
++                    abs_srcdir, data->filename) < 0)
++        goto cleanup;
++
++    virFileWrapperAddPrefix("/sys/devices/system", system_dir);
++    virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl_dir);
++
++    caps = virCapabilitiesNew(VIR_ARCH_X86_64, false, false);
++    if (!caps || virCapabilitiesInitCaches(caps) < 0) {
++        fprintf(stderr, "Could not initialize capabilities");
++        goto cleanup;
++    }
++
++    alloc = virResctrlAllocGetUnused(caps->host.resctrl);
++
++    virFileWrapperClearPrefixes();
++
++    if (!alloc) {
++        if (data->fail)
++            ret = 0;
++        goto cleanup;
++    } else if (data->fail) {
++        VIR_TEST_DEBUG("Error expected but there wasn't any.\n");
++        ret = -1;
++        goto cleanup;
++    }
++
++    schemata_str = virResctrlAllocFormat(alloc);
++
++    if (virTestCompareToFile(schemata_str, schemata_file) < 0)
++        goto cleanup;
++
++    ret = 0;
++ cleanup:
++    virObjectUnref(caps);
++    virObjectUnref(alloc);
++    VIR_FREE(system_dir);
++    VIR_FREE(resctrl_dir);
++    VIR_FREE(schemata_str);
++    VIR_FREE(schemata_file);
++    return ret;
++}
++
++
++static int
++mymain(void)
++{
++    struct virResctrlData data = {0};
++    int ret = 0;
++
++#define DO_TEST_UNUSED(_filename) \
++    do { \
++        data = (struct virResctrlData) { .filename = _filename }; \
++        if (virTestRun("Free: " _filename, test_virResctrlGetUnused, &data) < 0) \
++            ret = -1; \
++    } while (0)
++
++    DO_TEST_UNUSED("resctrl");
++    DO_TEST_UNUSED("resctrl-cdp");
++    DO_TEST_UNUSED("resctrl-skx");
++    DO_TEST_UNUSED("resctrl-skx-twocaches");
++
++    return ret;
++}
++
++VIR_TEST_MAIN(mymain)
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-tests-Clean-up-and-modify-some-vircaps2xmldata.patch b/SOURCES/libvirt-tests-Clean-up-and-modify-some-vircaps2xmldata.patch
new file mode 100644
index 0000000..8ce3fc7
--- /dev/null
+++ b/SOURCES/libvirt-tests-Clean-up-and-modify-some-vircaps2xmldata.patch
@@ -0,0 +1,76 @@
+From f0b982a8f6e736bcf5070c6d3ed166159792dda1 Mon Sep 17 00:00:00 2001
+Message-Id: <f0b982a8f6e736bcf5070c6d3ed166159792dda1@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:33 +0100
+Subject: [PATCH] tests: Clean up and modify some vircaps2xmldata
+
+Basically the `cpus` and `tasks` files are not needed, and I've witnessed on a
+real system that the schemata file may have spaces prepended to a line, so let's
+adjust at least one test so that it reflects what can happen.  Also `000`
+allocation is invalid and a full mask means it's all free.  So adjust for that
+too.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 47bb586c7533fc9f8366d078b3db26e791aaadf2)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus               | 1 -
+ tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/tasks              | 0
+ tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/schemata | 2 +-
+ tests/vircaps2xmldata/linux-resctrl/resctrl/cpus                   | 1 -
+ tests/vircaps2xmldata/linux-resctrl/resctrl/schemata               | 2 +-
+ tests/vircaps2xmldata/linux-resctrl/resctrl/tasks                  | 0
+ tests/virresctrldata/resctrl-skx-twocaches.schemata                | 2 +-
+ 7 files changed, 3 insertions(+), 5 deletions(-)
+ delete mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus
+ delete mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/tasks
+ delete mode 100644 tests/vircaps2xmldata/linux-resctrl/resctrl/cpus
+ delete mode 100644 tests/vircaps2xmldata/linux-resctrl/resctrl/tasks
+
+diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus
+deleted file mode 100644
+index b3a79aa953..0000000000
+--- a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus
++++ /dev/null
+@@ -1 +0,0 @@
+-ffffff,ffffffff,ffffffff
+diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/tasks b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/tasks
+deleted file mode 100644
+index e69de29bb2..0000000000
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/schemata
+index 691fbaf887..23af473be4 100644
+--- a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/schemata
++++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/resctrl/schemata
+@@ -1 +1 @@
+-L3:0=0f0;1=000
++L3:0=0f0;1=7ff
+diff --git a/tests/vircaps2xmldata/linux-resctrl/resctrl/cpus b/tests/vircaps2xmldata/linux-resctrl/resctrl/cpus
+deleted file mode 100644
+index 98d03acc98..0000000000
+--- a/tests/vircaps2xmldata/linux-resctrl/resctrl/cpus
++++ /dev/null
+@@ -1 +0,0 @@
+-fff
+diff --git a/tests/vircaps2xmldata/linux-resctrl/resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl/resctrl/schemata
+index c1a765f1e0..78d2d8a9b8 100644
+--- a/tests/vircaps2xmldata/linux-resctrl/resctrl/schemata
++++ b/tests/vircaps2xmldata/linux-resctrl/resctrl/schemata
+@@ -1 +1 @@
+-L3:0=1ff00;1=1ff0f
++    L3:0=1ff00;1=1ff0f
+diff --git a/tests/vircaps2xmldata/linux-resctrl/resctrl/tasks b/tests/vircaps2xmldata/linux-resctrl/resctrl/tasks
+deleted file mode 100644
+index e69de29bb2..0000000000
+diff --git a/tests/virresctrldata/resctrl-skx-twocaches.schemata b/tests/virresctrldata/resctrl-skx-twocaches.schemata
+index 86b3801a04..890d003bf2 100644
+--- a/tests/virresctrldata/resctrl-skx-twocaches.schemata
++++ b/tests/virresctrldata/resctrl-skx-twocaches.schemata
+@@ -1 +1 @@
+-L3:0=001;1=400
++L3:0=001;1=000
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-tests-Initialize-basic-capabilities-properly.patch b/SOURCES/libvirt-tests-Initialize-basic-capabilities-properly.patch
deleted file mode 100644
index 0af0431..0000000
--- a/SOURCES/libvirt-tests-Initialize-basic-capabilities-properly.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-From dbc0e98b62ca2961cd83ddf9fb2ad4ec80f941fe Mon Sep 17 00:00:00 2001
-Message-Id: <dbc0e98b62ca2961cd83ddf9fb2ad4ec80f941fe@dist-git>
-From: Andrea Bolognani <abologna@redhat.com>
-Date: Tue, 4 Apr 2017 14:59:28 +0200
-Subject: [PATCH] tests: Initialize basic capabilities properly
-
-The capabilities used in test cases should match those used
-during normal operation for the tests to make any sense.
-
-This results in the generated command line for a few test
-cases (most notably non-x86 test cases that were wrongly
-assuming they could use -no-acpi) changing.
-
-(cherry picked from commit 1cf3e52abb0ffbfe525a67d0d6379c45b51cd643)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
-
-Signed-off-by: Andrea Bolognani <abologna@redhat.com>
----
- src/qemu/qemu_capabilities.c                                          | 2 +-
- src/qemu/qemu_capabilities.h                                          | 2 ++
- tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args             | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args               | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args               | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.args          | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args                 | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-console-virtio-ccw.args           | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args          | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args            | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-zEC12.args               | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw-many.args         | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw.args              | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args             | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ccw.args         | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args                     | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi-ccw.args  | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args               | 1 +
- tests/qemuxml2argvdata/qemuxml2argv-iothreads-disk-virtio-ccw.args    | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.args    | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-off-cap.args   | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-off-caps.args  | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-on-cap.args    | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-on-caps.args   | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-off-cap.args   | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-off-caps.args  | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-on-cap.args    | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-on-caps.args   | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-machine-keywrap-none-caps.args    | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-machine-keywrap-none.args         | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-ppc64-nonuma.args  | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-net-virtio-ccw.args               | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args              | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args                      | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-ppce500-serial.args               | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args                | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args           | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args            | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args               | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.args                | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args        | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args     | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args          | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args              | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args            | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args    | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args                  | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args       | 1 +
- .../qemuxml2argv-s390-allow-bogus-usb-controller.args                 | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-s390-allow-bogus-usb-none.args    | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-s390-panic-missing.args           | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-s390-panic-no-address.args        | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-ccw.args               | 1 -
- tests/qemuxml2argvdata/qemuxml2argv-watchdog-diag288.args             | 1 -
- tests/qemuxml2argvtest.c                                              | 4 ++--
- 55 files changed, 7 insertions(+), 53 deletions(-)
-
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index b568a0f5e..9d0a29732 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -4302,7 +4302,7 @@ virQEMUCapsInitQMPArch(virQEMUCapsPtr qemuCaps,
-  *
-  * Initialize @qemuCaps with basic architecture-dependent capabilities.
-  */
--static void
-+void
- virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps)
- {
-     /* ACPI/HPET/KVM PIT are x86 specific */
-diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
-index d44682f2a..24e2f38ee 100644
---- a/src/qemu/qemu_capabilities.h
-+++ b/src/qemu/qemu_capabilities.h
-@@ -510,6 +510,8 @@ int virQEMUCapsParseHelpStr(const char *qemu,
-                             const char *qmperr);
- /* Only for use by test suite */
- int virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps, const char *str);
-+/* Only for use by test suite */
-+void virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps);
- 
- VIR_ENUM_DECL(virQEMUCaps);
- 
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args
-index 23276ad71..5fdaa08ef 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args
-@@ -15,5 +15,4 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
---no-acpi \
- -boot c
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args
-index f79c1c60e..2caf1b92c 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args
-@@ -15,5 +15,4 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
---no-acpi \
- -boot c
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args
-index fce9308b0..3ae8e5f86 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args
-@@ -15,5 +15,4 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
---no-acpi \
- -boot c
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.args b/tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.args
-index 85650717e..c8bb7260f 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-ccw-deflate.args
-@@ -15,6 +15,5 @@ QEMU_AUDIO_DRV=none \
- -nodefconfig \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -device virtio-balloon-ccw,id=balloon0,devno=fe.0.000a,deflate-on-oom=on
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args b/tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args
-index dc9f7afeb..17f60550c 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-ccw.args
-index 4fe0d6d39..73868d436 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-ccw.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-ccw.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -device virtio-serial-ccw,id=virtio-serial0,devno=fe.0.0001 \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args
-index 6e0e11e8a..06ef1b76c 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -device virtio-serial-s390,id=virtio-serial0 \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args
-index 07abc93b0..0b4ce4c68 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args
-@@ -15,5 +15,4 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-guest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-zEC12.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-zEC12.args
-index 4c95d6ac6..48850b8ca 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-zEC12.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-zEC12.args
-@@ -15,5 +15,4 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-guest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw-many.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw-many.args
-index 5f6b08733..8290cd652 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw-many.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw-many.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=0.0.0007,drive=drive-virtio-disk0,id=virtio-disk0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw.args
-index 45f51a8d1..2f77a2955 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args
-index 30aa47a1d..45c465912 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ccw.args
-index 3b352bf56..522fd9954 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ccw.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ccw.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001 \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args
-index d4bf19caa..6d4f65e0c 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args
-@@ -15,7 +15,6 @@ QEMU_AUDIO_DRV=none \
- -nodefconfig \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi-ccw.args
-index 199adfa5d..03de632ec 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi-ccw.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi-ccw.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest2/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -device virtio-scsi-ccw,id=scsi0,devno=fe.0.0001 \
- -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-virtio-disk0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args
-index 26e9496cf..1b2a52bcc 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args
-@@ -22,6 +22,7 @@ host-nodes=1-3,policy=bind \
- -monitor unix:/tmp/lib/domain--1-fedora/monitor.sock,server,nowait \
- -rtc base=utc,driftfix=slew \
- -no-kvm-pit-reinjection \
-+-no-hpet \
- -global PIIX4_PM.disable_s3=1 \
- -global PIIX4_PM.disable_s4=1 \
- -boot c \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-disk-virtio-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-disk-virtio-ccw.args
-index 5e001de06..ba4e699ee 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-disk-virtio-ccw.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-disk-virtio-ccw.args
-@@ -16,7 +16,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,iothread=iothread1,devno=fe.0.0000,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.args
-index 1ebb6d4a8..e87912b96 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.args
-@@ -16,7 +16,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -device virtio-scsi-ccw,iothread=iothread2,id=scsi0,devno=fe.0.0001 \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-off-cap.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-off-cap.args
-index 33a53a0fa..c718084db 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-off-cap.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-off-cap.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-off-caps.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-off-caps.args
-index 33a53a0fa..c718084db 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-off-caps.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-off-caps.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-on-cap.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-on-cap.args
-index 9536cce61..c6eaa244b 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-on-cap.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-on-cap.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-on-caps.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-on-caps.args
-index 9536cce61..c6eaa244b 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-on-caps.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aeskeywrap-on-caps.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-off-cap.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-off-cap.args
-index 9afa7c212..434f5061e 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-off-cap.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-off-cap.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-off-caps.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-off-caps.args
-index 9afa7c212..434f5061e 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-off-caps.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-off-caps.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-on-cap.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-on-cap.args
-index e73ed675f..24e2035a3 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-on-cap.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-on-cap.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-on-caps.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-on-caps.args
-index e73ed675f..24e2035a3 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-on-caps.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-deakeywrap-on-caps.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-keywrap-none-caps.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-keywrap-none-caps.args
-index 19d2c3520..acde08a4b 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-machine-keywrap-none-caps.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-keywrap-none-caps.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-keywrap-none.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-keywrap-none.args
-index 19d2c3520..acde08a4b 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-machine-keywrap-none.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-keywrap-none.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-ppc64-nonuma.args b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-ppc64-nonuma.args
-index 781f30db0..88ed6b615 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-ppc64-nonuma.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-ppc64-nonuma.args
-@@ -18,7 +18,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -kernel /media/ram/uImage \
- -initrd /media/ram/ramdisk \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-ccw.args
-index 86b6adde0..8a0598a9a 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-ccw.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-ccw.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -device virtio-net-ccw,vlan=0,id=net0,mac=00:11:22:33:44:55,devno=fe.0.0001 \
- -net user,vlan=0,name=hostnet0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args
-index 46ccbc90b..ef31b791a 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -device virtio-net-s390,vlan=0,id=net0,mac=00:11:22:33:44:55 \
- -net user,vlan=0,name=hostnet0
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args
-index 58c1526cd..10ddca0dc 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -kernel /media/ram/uImage \
- -initrd /media/ram/ramdisk \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppce500-serial.args b/tests/qemuxml2argvdata/qemuxml2argv-ppce500-serial.args
-index d62383602..87f4ee5e4 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-ppce500-serial.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-ppce500-serial.args
-@@ -16,7 +16,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -kernel /media/ram/uImage \
- -initrd /media/ram/ramdisk \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args
-index 2839dea62..97a7057ba 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -usb \
- -chardev pty,id=charserial0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
-index 06595a2aa..7740e2f5a 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
-@@ -18,7 +18,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -usb \
- -chardev pty,id=charserial0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args
-index 803c1aa2b..d2c99a7fa 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args
-@@ -18,7 +18,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -usb \
- -chardev pty,id=charserial0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args
-index 2839dea62..97a7057ba 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -usb \
- -chardev pty,id=charserial0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.args
-index 89e0e56a2..904b9518e 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.args
-@@ -14,7 +14,6 @@ QEMU_AUDIO_DRV=none \
- -nographic \
- -nodefaults \
- -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
---no-acpi \
- -boot c \
- -usb \
- -global spapr-nvram.reg=0x4000
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
-index 2839dea62..97a7057ba 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -usb \
- -chardev pty,id=charserial0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args
-index 2839dea62..97a7057ba 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -usb \
- -chardev pty,id=charserial0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
-index 56e3552a8..a92b1e01b 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \
- -chardev pty,id=charserial0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
-index 1a672c62a..caaccdbb8 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \
- -chardev pty,id=charserial0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
-index 727389102..b9bd905a5 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1 \
- -device pci-ohci,id=usb1,bus=pci.0,addr=0x2 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args
-index 5754d3c9a..63cf3c183 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -device spapr-vscsi,id=scsi0,reg=0x2000 \
- -device spapr-vscsi,id=scsi1,reg=0x30000000 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args
-index 43381dd2e..0294067bc 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -device spapr-vscsi,id=scsi0,reg=0x2000 \
- -device spapr-vscsi,id=scsi1,reg=0x3000 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args
-index e139e5237..91598e9d8 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args
-@@ -15,6 +15,7 @@ QEMU_AUDIO_DRV=spice \
- -monitor unix:/tmp/lib/domain--1-virt-manager-basic/monitor.sock,server,nowait \
- -rtc base=utc,driftfix=slew \
- -no-kvm-pit-reinjection \
-+-no-hpet \
- -global ICH9-LPC.disable_s3=1 \
- -global ICH9-LPC.disable_s4=1 \
- -boot c \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-allow-bogus-usb-controller.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-allow-bogus-usb-controller.args
-index a1c1c85af..8abe0df98 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-s390-allow-bogus-usb-controller.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-allow-bogus-usb-controller.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-test/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -device virtio-serial-s390,id=virtio-serial0 \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-allow-bogus-usb-none.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-allow-bogus-usb-none.args
-index a1c1c85af..8abe0df98 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-s390-allow-bogus-usb-none.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-allow-bogus-usb-none.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-test/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -device virtio-serial-s390,id=virtio-serial0 \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-panic-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-panic-missing.args
-index a18b5a5a7..32678145a 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-s390-panic-missing.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-panic-missing.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -device virtio-serial-ccw,id=virtio-serial0,devno=fe.0.0000 \
- -chardev pty,id=charconsole0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-panic-no-address.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-panic-no-address.args
-index e49c8df83..fa8fbbc4a 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-s390-panic-no-address.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-panic-no-address.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -boot c \
- -device virtio-serial-ccw,id=virtio-serial0,devno=fe.0.0000 \
- -chardev pty,id=charconsole0 \
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-ccw.args
-index dec49e1eb..a73bce85d 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-ccw.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-ccw.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -device virtio-serial-ccw,id=virtio-serial0,devno=fe.0.0001 \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-watchdog-diag288.args b/tests/qemuxml2argvdata/qemuxml2argv-watchdog-diag288.args
-index 2997c1241..95f915c2b 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-watchdog-diag288.args
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-watchdog-diag288.args
-@@ -17,7 +17,6 @@ QEMU_AUDIO_DRV=none \
- -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
- server,nowait \
- -mon chardev=charmonitor,id=monitor,mode=readline \
---no-acpi \
- -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
- -device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
- -device diag288,id=watchdog0 \
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 41461eadc..731b793c4 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -360,8 +360,6 @@ testInitQEMUCaps(struct testInfo *info,
-     if (!(info->qemuCaps = virQEMUCapsNew()))
-         goto cleanup;
- 
--    virQEMUCapsSet(info->qemuCaps, QEMU_CAPS_NO_ACPI);
--
-     if (testQemuCapsSetGIC(info->qemuCaps, gic) < 0)
-         goto cleanup;
- 
-@@ -381,6 +379,8 @@ testUpdateQEMUCaps(const struct testInfo *info,
- 
-     virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);
- 
-+    virQEMUCapsInitQMPBasicArch(info->qemuCaps);
-+
-     /* We need to pretend QEMU 2.0.0 is in use so that pSeries guests
-      * will get the correct alias assigned to their buses.
-      * See virQEMUCapsHasPCIMultiBus() */
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-tests-Minor-adjustments-for-test-data.patch b/SOURCES/libvirt-tests-Minor-adjustments-for-test-data.patch
new file mode 100644
index 0000000..51962a5
--- /dev/null
+++ b/SOURCES/libvirt-tests-Minor-adjustments-for-test-data.patch
@@ -0,0 +1,92 @@
+From 1bf25232a148ae013a327e1096fb221182a9ed7d Mon Sep 17 00:00:00 2001
+Message-Id: <1bf25232a148ae013a327e1096fb221182a9ed7d@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:20 +0100
+Subject: [PATCH] tests: Minor adjustments for test data
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+This patch modifies some not yet used test data so that the adding a test using
+this data is a clean patch and not an addition of huge file with some
+adjustments in small files that will be hidden in the middle of that commit.
+These changes include:
+
+- Add system dir in vircaps2xmldata/linux-caches
+
+  Back when data for systems with resctrl support were added they had the
+  /sys/fs/system directory put into a system/ subdir of the test and
+  /sys/fs/resctrl in a resctrl/ subdir of that test.  However, if we also want a
+  negative test for the resctrl (requesting allocation on a system that does not
+  support resctrl), we need one a test case with any sensible (with cache info)
+  system/ subdir and no resctrl/ one.  Easiest way is to add a
+  system -> . symlink into existing test case.
+
+- Change default group schemata for linux-resctrl and linux-resctrl-cdp
+
+  That way we can fit some allocation in.
+
+- Remove one cache from resctrl-skx's schemata and make some room for
+  allocations
+
+  That system already has only one cache, so that file was wrong anyway.  We
+  have a version with 2 caches already (linux-resctrl-skx-twocaches), so this
+  will also add variety to future tests.
+
+- Add some empty allocation for resctrl-skx
+
+  Just to have slightly more coverage and variety.  We can be sure nothing bad
+  happens if such allocation exists in case we have that in the tests.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 993c7f003012d1f249f1cdecc6ac56abaffe1e9b)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ tests/vircaps2xmldata/linux-caches/system                      | 1 +
+ tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata       | 4 ++--
+ tests/vircaps2xmldata/linux-resctrl-skx/resctrl/empty/schemata | 0
+ tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata       | 2 +-
+ tests/vircaps2xmldata/linux-resctrl/resctrl/schemata           | 2 +-
+ 5 files changed, 5 insertions(+), 4 deletions(-)
+ create mode 120000 tests/vircaps2xmldata/linux-caches/system
+ create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/resctrl/empty/schemata
+
+diff --git a/tests/vircaps2xmldata/linux-caches/system b/tests/vircaps2xmldata/linux-caches/system
+new file mode 120000
+index 0000000000..945c9b46d6
+--- /dev/null
++++ b/tests/vircaps2xmldata/linux-caches/system
+@@ -0,0 +1 @@
++.
+\ No newline at end of file
+diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata
+index 89dc76b864..5de8fb0261 100644
+--- a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata
++++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata
+@@ -1,2 +1,2 @@
+-L3DATA:0=fffff;1=fffff
+-L3CODE:0=fffff;1=fffff
++L3DATA:0=fffff;1=fc000
++L3CODE:0=ff003;1=f00ff
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/empty/schemata b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/empty/schemata
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata
+index 4a49137353..191081f1db 100644
+--- a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata
++++ b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata
+@@ -1 +1 @@
+-L3:0=7ff;1=7ff
++L3:0=0f0
+diff --git a/tests/vircaps2xmldata/linux-resctrl/resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl/resctrl/schemata
+index 9b47d25fc7..c1a765f1e0 100644
+--- a/tests/vircaps2xmldata/linux-resctrl/resctrl/schemata
++++ b/tests/vircaps2xmldata/linux-resctrl/resctrl/schemata
+@@ -1 +1 @@
+-L3:0=1ffff;1=1ffff
++L3:0=1ff00;1=1ff0f
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-tests-Remove-executable-bits-on-plain-data-files.patch b/SOURCES/libvirt-tests-Remove-executable-bits-on-plain-data-files.patch
new file mode 100644
index 0000000..671e493
--- /dev/null
+++ b/SOURCES/libvirt-tests-Remove-executable-bits-on-plain-data-files.patch
@@ -0,0 +1,48 @@
+From f40e3d33b65bcdba7f0199082c4de8d8109a5e0d Mon Sep 17 00:00:00 2001
+Message-Id: <f40e3d33b65bcdba7f0199082c4de8d8109a5e0d@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:19 +0100
+Subject: [PATCH] tests: Remove executable bits on plain data files
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 02e822e0414eb2c01984c03dbfd79f1e2da528b3)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask     | 0
+ tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits | 0
+ tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids  | 0
+ tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask     | 0
+ tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits | 0
+ tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids  | 0
+ 6 files changed, 0 insertions(+), 0 deletions(-)
+ mode change 100755 => 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask
+ mode change 100755 => 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits
+ mode change 100755 => 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids
+ mode change 100755 => 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask
+ mode change 100755 => 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits
+ mode change 100755 => 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids
+
+diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask
+old mode 100755
+new mode 100644
+diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits
+old mode 100755
+new mode 100644
+diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids
+old mode 100755
+new mode 100644
+diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask
+old mode 100755
+new mode 100644
+diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits
+old mode 100755
+new mode 100644
+diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids
+old mode 100755
+new mode 100644
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-tests-Rename-ppc64le-caps-to-ppc64.patch b/SOURCES/libvirt-tests-Rename-ppc64le-caps-to-ppc64.patch
new file mode 100644
index 0000000..3df1ffc
--- /dev/null
+++ b/SOURCES/libvirt-tests-Rename-ppc64le-caps-to-ppc64.patch
@@ -0,0 +1,102 @@
+From 22398ee5b022b7831477d79959d4990a849b7e55 Mon Sep 17 00:00:00 2001
+Message-Id: <22398ee5b022b7831477d79959d4990a849b7e55@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Wed, 15 Nov 2017 10:28:52 +0100
+Subject: [PATCH] tests: Rename ppc64le caps to ppc64
+
+The architecture itself is called ppc64, and it can run both in big
+endian and little endian mode - the latter is known as ppc64le.
+
+>From the (virtual) hardware point of view, ppc64 is a more accurate
+name so it should be used here.
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 61ea70341a668738a4fb524a65fa1a80705b2bab)
+
+Conflicts:
+  * tests/qemucapabilitiestest.c:
+    caused by missing capabilities for QEMU 2.10.0 on aarch64
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1308743
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ .../{qemu_2.6.0.ppc64le.xml => qemu_2.6.0.ppc64.xml}                  | 2 +-
+ tests/domaincapstest.c                                                | 2 +-
+ .../{caps_2.6.0.ppc64le.replies => caps_2.6.0.ppc64.replies}          | 0
+ .../{caps_2.6.0.ppc64le.xml => caps_2.6.0.ppc64.xml}                  | 0
+ .../{caps_2.9.0.ppc64le.replies => caps_2.9.0.ppc64.replies}          | 0
+ .../{caps_2.9.0.ppc64le.xml => caps_2.9.0.ppc64.xml}                  | 0
+ tests/qemucapabilitiestest.c                                          | 4 ++--
+ 7 files changed, 4 insertions(+), 4 deletions(-)
+ rename tests/domaincapsschemadata/{qemu_2.6.0.ppc64le.xml => qemu_2.6.0.ppc64.xml} (98%)
+ rename tests/qemucapabilitiesdata/{caps_2.6.0.ppc64le.replies => caps_2.6.0.ppc64.replies} (100%)
+ rename tests/qemucapabilitiesdata/{caps_2.6.0.ppc64le.xml => caps_2.6.0.ppc64.xml} (100%)
+ rename tests/qemucapabilitiesdata/{caps_2.9.0.ppc64le.replies => caps_2.9.0.ppc64.replies} (100%)
+ rename tests/qemucapabilitiesdata/{caps_2.9.0.ppc64le.xml => caps_2.9.0.ppc64.xml} (100%)
+
+diff --git a/tests/domaincapsschemadata/qemu_2.6.0.ppc64le.xml b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
+similarity index 98%
+rename from tests/domaincapsschemadata/qemu_2.6.0.ppc64le.xml
+rename to tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
+index 5b986e52f7..98c72d36de 100644
+--- a/tests/domaincapsschemadata/qemu_2.6.0.ppc64le.xml
++++ b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
+@@ -2,7 +2,7 @@
+   <path>/usr/bin/qemu-system-ppc64</path>
+   <domain>kvm</domain>
+   <machine>pseries-2.6</machine>
+-  <arch>ppc64le</arch>
++  <arch>ppc64</arch>
+   <vcpu max='255'/>
+   <os supported='yes'>
+     <loader supported='yes'>
+diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
+index 7aeac4507f..f3f623bb3d 100644
+--- a/tests/domaincapstest.c
++++ b/tests/domaincapstest.c
+@@ -460,7 +460,7 @@ mymain(void)
+ 
+     DO_TEST_QEMU("2.6.0", "caps_2.6.0",
+                  "/usr/bin/qemu-system-ppc64", NULL,
+-                 "ppc64le", VIR_DOMAIN_VIRT_KVM);
++                 "ppc64", VIR_DOMAIN_VIRT_KVM);
+ 
+     DO_TEST_QEMU("2.8.0", "caps_2.8.0",
+                  "/usr/bin/qemu-system-x86_64", NULL,
+diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.replies b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.replies
+similarity index 100%
+rename from tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.replies
+rename to tests/qemucapabilitiesdata/caps_2.6.0.ppc64.replies
+diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
+similarity index 100%
+rename from tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
+rename to tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64le.replies b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.replies
+similarity index 100%
+rename from tests/qemucapabilitiesdata/caps_2.9.0.ppc64le.replies
+rename to tests/qemucapabilitiesdata/caps_2.9.0.ppc64.replies
+diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64le.xml b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+similarity index 100%
+rename from tests/qemucapabilitiesdata/caps_2.9.0.ppc64le.xml
+rename to tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
+diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
+index df3a9de516..9bb1ffca6a 100644
+--- a/tests/qemucapabilitiestest.c
++++ b/tests/qemucapabilitiestest.c
+@@ -173,8 +173,8 @@ mymain(void)
+     DO_TEST("x86_64", "caps_2.10.0");
+     DO_TEST("aarch64", "caps_2.6.0-gicv2");
+     DO_TEST("aarch64", "caps_2.6.0-gicv3");
+-    DO_TEST("ppc64le", "caps_2.6.0");
+-    DO_TEST("ppc64le", "caps_2.9.0");
++    DO_TEST("ppc64", "caps_2.6.0");
++    DO_TEST("ppc64", "caps_2.9.0");
+     DO_TEST("s390x", "caps_2.7.0");
+     DO_TEST("s390x", "caps_2.8.0");
+     DO_TEST("s390x", "caps_2.9.0");
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-tests-Test-ACPI-UEFI-requirements.patch b/SOURCES/libvirt-tests-Test-ACPI-UEFI-requirements.patch
deleted file mode 100644
index 6438ac3..0000000
--- a/SOURCES/libvirt-tests-Test-ACPI-UEFI-requirements.patch
+++ /dev/null
@@ -1,496 +0,0 @@
-From 2281fa3a645d077431375a77eacf53ba878101b7 Mon Sep 17 00:00:00 2001
-Message-Id: <2281fa3a645d077431375a77eacf53ba878101b7@dist-git>
-From: Andrea Bolognani <abologna@redhat.com>
-Date: Tue, 4 Apr 2017 14:59:32 +0200
-Subject: [PATCH] tests: Test ACPI, UEFI requirements
-
-Make sure every combination of ACPI and UEFI works, or fails to
-work, as expected.
-
-(cherry picked from commit deb38c4503597a8e0b3e74c6112ef28a15b072c8)
-
-Downstream changes:
-
- * tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args,
-   tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args,
-   tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args:
-
-   - add RTM and HLE flags to Haswell CPU so that the test
-     suite can pass.
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
-
-Signed-off-by: Andrea Bolognani <abologna@redhat.com>
----
- .../qemuxml2argv-aarch64-acpi-nouefi.args          | 22 +++++++++++++++++++++
- .../qemuxml2argv-aarch64-acpi-nouefi.xml           | 22 +++++++++++++++++++++
- .../qemuxml2argv-aarch64-acpi-uefi.args            | 22 +++++++++++++++++++++
- .../qemuxml2argv-aarch64-acpi-uefi.xml             | 21 ++++++++++++++++++++
- .../qemuxml2argv-aarch64-noacpi-nouefi.args        | 22 +++++++++++++++++++++
- .../qemuxml2argv-aarch64-noacpi-nouefi.xml         | 19 ++++++++++++++++++
- .../qemuxml2argv-aarch64-noacpi-uefi.args          | 23 ++++++++++++++++++++++
- .../qemuxml2argv-aarch64-noacpi-uefi.xml           | 18 +++++++++++++++++
- .../qemuxml2argv-q35-acpi-nouefi.args              | 21 ++++++++++++++++++++
- .../qemuxml2argv-q35-acpi-nouefi.xml               | 22 +++++++++++++++++++++
- .../qemuxml2argv-q35-acpi-uefi.args                | 22 +++++++++++++++++++++
- .../qemuxml2argv-q35-acpi-uefi.xml                 | 21 ++++++++++++++++++++
- .../qemuxml2argv-q35-noacpi-nouefi.args            | 22 +++++++++++++++++++++
- .../qemuxml2argv-q35-noacpi-nouefi.xml             | 19 ++++++++++++++++++
- .../qemuxml2argv-q35-noacpi-uefi.xml               | 18 +++++++++++++++++
- tests/qemuxml2argvtest.c                           | 14 +++++++++++++
- 16 files changed, 328 insertions(+)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-nouefi.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-nouefi.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-uefi.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-uefi.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-nouefi.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-nouefi.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-uefi.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-uefi.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.xml
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-uefi.xml
-
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-nouefi.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-nouefi.args
-new file mode 100644
-index 000000000..5d9e1fb7c
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-nouefi.args
-@@ -0,0 +1,22 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-aarch64 \
-+-name guest \
-+-S \
-+-M virt \
-+-cpu host \
-+-m 1024 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
-+-nographic \
-+-nodefconfig \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-guest/monitor.sock,server,nowait \
-+-boot c \
-+-kernel /var/lib/libvirt/images/guest.vmlinux \
-+-initrd /var/lib/libvirt/images/guest.initramfs \
-+-append 'console=ttyAMA0 rw root=/dev/vda rootwait'
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-nouefi.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-nouefi.xml
-new file mode 100644
-index 000000000..cda1b1bdc
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-nouefi.xml
-@@ -0,0 +1,22 @@
-+<domain type='qemu'>
-+  <name>guest</name>
-+  <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
-+  <memory unit='KiB'>1048576</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='aarch64' machine='virt'>hvm</type>
-+    <kernel>/var/lib/libvirt/images/guest.vmlinuz</kernel>
-+    <initrd>/var/lib/libvirt/images/guest.initramfs</initrd>
-+    <cmdline>console=ttyAMA0 rw root=/dev/vda rootwait</cmdline>
-+  </os>
-+  <features>
-+    <acpi/>
-+  </features>
-+  <cpu mode='custom'>
-+    <model>cortex-a57</model>
-+  </cpu>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-aarch64</emulator>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-uefi.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-uefi.args
-new file mode 100644
-index 000000000..36371ba02
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-uefi.args
-@@ -0,0 +1,22 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-aarch64 \
-+-name guest \
-+-S \
-+-M virt \
-+-cpu cortex-a57 \
-+-drive file=/usr/share/AAVMF/AAVMF_CODE.fd,if=pflash,format=raw,unit=0,\
-+readonly=on \
-+-drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,\
-+unit=1 \
-+-m 1024 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-guest/monitor.sock,server,nowait \
-+-boot c
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-uefi.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-uefi.xml
-new file mode 100644
-index 000000000..5de2eb5d3
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-acpi-uefi.xml
-@@ -0,0 +1,21 @@
-+<domain type='qemu'>
-+  <name>guest</name>
-+  <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
-+  <memory unit='KiB'>1048576</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='aarch64' machine='virt'>hvm</type>
-+    <loader readonly='yes' type='pflash'>/usr/share/AAVMF/AAVMF_CODE.fd</loader>
-+    <nvram>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
-+  </os>
-+  <features>
-+    <acpi/>
-+  </features>
-+  <cpu mode='custom'>
-+    <model>cortex-a57</model>
-+  </cpu>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-aarch64</emulator>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-nouefi.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-nouefi.args
-new file mode 100644
-index 000000000..301eda89e
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-nouefi.args
-@@ -0,0 +1,22 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-aarch64 \
-+-name guest \
-+-S \
-+-M virt \
-+-cpu cortex-a57 \
-+-m 1024 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-guest/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-kernel /var/lib/libvirt/images/guest.vmlinuz \
-+-initrd /var/lib/libvirt/images/guest.initramfs \
-+-append 'console=ttyAMA0 rw root=/dev/vda rootwait'
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-nouefi.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-nouefi.xml
-new file mode 100644
-index 000000000..e8551ed2d
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-nouefi.xml
-@@ -0,0 +1,19 @@
-+<domain type='qemu'>
-+  <name>guest</name>
-+  <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
-+  <memory unit='KiB'>1048576</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='aarch64' machine='virt'>hvm</type>
-+    <kernel>/var/lib/libvirt/images/guest.vmlinuz</kernel>
-+    <initrd>/var/lib/libvirt/images/guest.initramfs</initrd>
-+    <cmdline>console=ttyAMA0 rw root=/dev/vda rootwait</cmdline>
-+  </os>
-+  <cpu mode='custom'>
-+    <model>cortex-a57</model>
-+  </cpu>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-aarch64</emulator>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-uefi.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-uefi.args
-new file mode 100644
-index 000000000..c62de750f
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-uefi.args
-@@ -0,0 +1,23 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-aarch64 \
-+-name guest \
-+-S \
-+-M virt \
-+-cpu cortex-a57 \
-+-drive file=/usr/share/AAVMF/AAVMF_CODE.fd,if=pflash,format=raw,unit=0,\
-+readonly=on \
-+-drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,\
-+unit=1 \
-+-m 1024 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-guest/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-uefi.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-uefi.xml
-new file mode 100644
-index 000000000..e66b805da
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-noacpi-uefi.xml
-@@ -0,0 +1,18 @@
-+<domain type='qemu'>
-+  <name>guest</name>
-+  <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
-+  <memory unit='KiB'>1048576</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='aarch64' machine='virt'>hvm</type>
-+    <loader readonly='yes' type='pflash'>/usr/share/AAVMF/AAVMF_CODE.fd</loader>
-+    <nvram>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
-+  </os>
-+  <cpu mode='custom'>
-+    <model>cortex-a57</model>
-+  </cpu>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-aarch64</emulator>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args
-new file mode 100644
-index 000000000..531520b0a
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args
-@@ -0,0 +1,21 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-x86_64 \
-+-name guest \
-+-S \
-+-M q35 \
-+-cpu Haswell,+rtm,+hle \
-+-m 1024 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-guest/monitor.sock,server,nowait \
-+-boot c \
-+-kernel /var/lib/libvirt/images/guest.vmlinuz \
-+-initrd /var/lib/libvirt/images/guest.initramfs \
-+-append 'rw root=/dev/vda rootwait'
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.xml b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.xml
-new file mode 100644
-index 000000000..7d735f99c
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.xml
-@@ -0,0 +1,22 @@
-+<domain type='qemu'>
-+  <name>guest</name>
-+  <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
-+  <memory unit='KiB'>1048576</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='q35'>hvm</type>
-+    <kernel>/var/lib/libvirt/images/guest.vmlinuz</kernel>
-+    <initrd>/var/lib/libvirt/images/guest.initramfs</initrd>
-+    <cmdline>rw root=/dev/vda rootwait</cmdline>
-+  </os>
-+  <features>
-+    <acpi/>
-+  </features>
-+  <cpu mode='custom'>
-+    <model>Haswell</model>
-+  </cpu>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args
-new file mode 100644
-index 000000000..4dd99676e
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args
-@@ -0,0 +1,22 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-x86_64 \
-+-name guest \
-+-S \
-+-M q35 \
-+-cpu Haswell,+rtm,+hle \
-+-drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,\
-+readonly=on \
-+-drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,\
-+unit=1 \
-+-m 1024 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-guest/monitor.sock,server,nowait \
-+-boot c
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.xml b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.xml
-new file mode 100644
-index 000000000..4eb5a466e
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.xml
-@@ -0,0 +1,21 @@
-+<domain type='qemu'>
-+  <name>guest</name>
-+  <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
-+  <memory unit='KiB'>1048576</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='q35'>hvm</type>
-+    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
-+    <nvram>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
-+  </os>
-+  <features>
-+    <acpi/>
-+  </features>
-+  <cpu mode='custom'>
-+    <model>Haswell</model>
-+  </cpu>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args
-new file mode 100644
-index 000000000..4d7cdfbe3
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args
-@@ -0,0 +1,22 @@
-+LC_ALL=C \
-+PATH=/bin \
-+HOME=/home/test \
-+USER=test \
-+LOGNAME=test \
-+QEMU_AUDIO_DRV=none \
-+/usr/bin/qemu-system-x86_64 \
-+-name guest \
-+-S \
-+-M q35 \
-+-cpu Haswell,+rtm,+hle \
-+-m 1024 \
-+-smp 1,sockets=1,cores=1,threads=1 \
-+-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
-+-nographic \
-+-nodefaults \
-+-monitor unix:/tmp/lib/domain--1-guest/monitor.sock,server,nowait \
-+-no-acpi \
-+-boot c \
-+-kernel /var/lib/libvirt/images/guest.vmlinuz \
-+-initrd /var/lib/libvirt/images/guest.initramfs \
-+-append 'rw root=/dev/vda rootwait'
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.xml b/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.xml
-new file mode 100644
-index 000000000..163b424ea
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.xml
-@@ -0,0 +1,19 @@
-+<domain type='qemu'>
-+  <name>guest</name>
-+  <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
-+  <memory unit='KiB'>1048576</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='q35'>hvm</type>
-+    <kernel>/var/lib/libvirt/images/guest.vmlinuz</kernel>
-+    <initrd>/var/lib/libvirt/images/guest.initramfs</initrd>
-+    <cmdline>rw root=/dev/vda rootwait</cmdline>
-+  </os>
-+  <cpu mode='custom'>
-+    <model>Haswell</model>
-+  </cpu>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-uefi.xml b/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-uefi.xml
-new file mode 100644
-index 000000000..91c83c808
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-uefi.xml
-@@ -0,0 +1,18 @@
-+<domain type='qemu'>
-+  <name>guest</name>
-+  <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
-+  <memory unit='KiB'>1048576</memory>
-+  <vcpu placement='static'>1</vcpu>
-+  <os>
-+    <type arch='x86_64' machine='q35'>hvm</type>
-+    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
-+    <nvram>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
-+  </os>
-+  <cpu mode='custom'>
-+    <model>Haswell</model>
-+  </cpu>
-+  <devices>
-+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
-+    <memballoon model='none'/>
-+  </devices>
-+</domain>
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 5c0e1e8ab..cfd6dcd55 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -757,6 +757,13 @@ mymain(void)
-             QEMU_CAPS_MACHINE_OPT,
-             QEMU_CAPS_MACHINE_SMM_OPT,
-             QEMU_CAPS_VIRTIO_SCSI);
-+
-+    /* Make sure all combinations of ACPI and UEFI behave as expected */
-+    DO_TEST("q35-acpi-uefi", NONE);
-+    DO_TEST_PARSE_ERROR("q35-noacpi-uefi", NONE);
-+    DO_TEST("q35-noacpi-nouefi", NONE);
-+    DO_TEST("q35-acpi-nouefi", NONE);
-+
-     DO_TEST("clock-utc", QEMU_CAPS_NODEFCONFIG);
-     DO_TEST("clock-localtime", NONE);
-     DO_TEST("clock-localtime-basis-localtime", QEMU_CAPS_RTC);
-@@ -2316,6 +2323,13 @@ mymain(void)
-     DO_TEST_FAILURE("aarch64-kvm-32-on-64",
-             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
-             QEMU_CAPS_KVM);
-+
-+    /* Make sure all combinations of ACPI and UEFI behave as expected */
-+    DO_TEST("aarch64-acpi-uefi", NONE);
-+    DO_TEST("aarch64-noacpi-uefi", NONE);
-+    DO_TEST("aarch64-noacpi-nouefi", NONE);
-+    DO_TEST_PARSE_ERROR("aarch64-acpi-nouefi", NONE);
-+
-     qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
- 
-     DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY);
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-util-Add-helpers-for-getting-resctrl-group-allocs.patch b/SOURCES/libvirt-util-Add-helpers-for-getting-resctrl-group-allocs.patch
new file mode 100644
index 0000000..d7905cd
--- /dev/null
+++ b/SOURCES/libvirt-util-Add-helpers-for-getting-resctrl-group-allocs.patch
@@ -0,0 +1,151 @@
+From 12745d1c8180273ad1028da0da7440cb959819eb Mon Sep 17 00:00:00 2001
+Message-Id: <12745d1c8180273ad1028da0da7440cb959819eb@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:40 +0100
+Subject: [PATCH] util: Add helpers for getting resctrl group allocs
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit f6199295a9656a79e29cab9ed5694f040c266998)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 81 ++++++++++++++++++++++++++++++++++-----------------
+ 1 file changed, 54 insertions(+), 27 deletions(-)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index 42876c6e2b..df6461a046 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -1041,6 +1041,55 @@ virResctrlAllocParse(virResctrlInfoPtr resctrl,
+ }
+ 
+ 
++static int
++virResctrlAllocGetGroup(virResctrlInfoPtr resctrl,
++                        const char *groupname,
++                        virResctrlAllocPtr *alloc)
++{
++    char *schemata = NULL;
++    int rv = virFileReadValueString(&schemata,
++                                     SYSFS_RESCTRL_PATH
++                                     "/%s/schemata",
++                                     groupname);
++
++    *alloc = NULL;
++
++    if (rv < 0)
++        return rv;
++
++    *alloc = virResctrlAllocNew();
++    if (!*alloc)
++        goto error;
++
++    if (virResctrlAllocParse(resctrl, *alloc, schemata) < 0)
++        goto error;
++
++    VIR_FREE(schemata);
++    return 0;
++
++ error:
++    VIR_FREE(schemata);
++    virObjectUnref(*alloc);
++    *alloc = NULL;
++    return -1;
++}
++
++
++static virResctrlAllocPtr
++virResctrlAllocGetDefault(virResctrlInfoPtr resctrl)
++{
++    virResctrlAllocPtr ret = NULL;
++    int rv = virResctrlAllocGetGroup(resctrl, ".", &ret);
++
++    if (rv == -2) {
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("Could not read schemata file for the default group"));
++    }
++
++    return ret;
++}
++
++
+ static void
+ virResctrlAllocSubtractPerType(virResctrlAllocPerTypePtr dst,
+                                virResctrlAllocPerTypePtr src)
+@@ -1141,7 +1190,6 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
+     virResctrlAllocPtr alloc = NULL;
+     struct dirent *ent = NULL;
+     DIR *dirp = NULL;
+-    char *schemata = NULL;
+     int rv = -1;
+ 
+     if (virResctrlInfoIsEmpty(resctrl)) {
+@@ -1154,22 +1202,12 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
+     if (!ret)
+         return NULL;
+ 
+-    if (virFileReadValueString(&schemata,
+-                               SYSFS_RESCTRL_PATH
+-                               "/schemata") < 0) {
+-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+-                       _("Could not read schemata file for the default group"));
+-        goto error;
+-    }
+-
+-    alloc = virResctrlAllocNew();
++    alloc = virResctrlAllocGetDefault(resctrl);
+     if (!alloc)
+         goto error;
+ 
+-    if (virResctrlAllocParse(resctrl, alloc, schemata) < 0)
+-        goto error;
+-
+     virResctrlAllocSubtract(ret, alloc);
++    virObjectUnref(alloc);
+ 
+     if (virDirOpen(&dirp, SYSFS_RESCTRL_PATH) < 0)
+         goto error;
+@@ -1178,11 +1216,7 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
+         if (STREQ(ent->d_name, "info"))
+             continue;
+ 
+-        VIR_FREE(schemata);
+-        rv = virFileReadValueString(&schemata,
+-                                    SYSFS_RESCTRL_PATH
+-                                    "/%s/schemata",
+-                                    ent->d_name);
++        rv = virResctrlAllocGetGroup(resctrl, ent->d_name, &alloc);
+         if (rv == -2)
+             continue;
+ 
+@@ -1193,15 +1227,9 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
+             goto error;
+         }
+ 
+-        virObjectUnref(alloc);
+-        alloc = virResctrlAllocNew();
+-        if (!alloc)
+-            goto error;
+-
+-        if (virResctrlAllocParse(resctrl, alloc, schemata) < 0)
+-            goto error;
+-
+         virResctrlAllocSubtract(ret, alloc);
++        virObjectUnref(alloc);
++        alloc = NULL;
+     }
+     if (rv < 0)
+         goto error;
+@@ -1209,7 +1237,6 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
+  cleanup:
+     virObjectUnref(alloc);
+     VIR_DIR_CLOSE(dirp);
+-    VIR_FREE(schemata);
+     return ret;
+ 
+  error:
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Add-virNetDevSetCoalesce-function.patch b/SOURCES/libvirt-util-Add-virNetDevSetCoalesce-function.patch
deleted file mode 100644
index f5fca5c..0000000
--- a/SOURCES/libvirt-util-Add-virNetDevSetCoalesce-function.patch
+++ /dev/null
@@ -1,201 +0,0 @@
-From 40bd6c3ac6e183b504b38192938d0178438d3966 Mon Sep 17 00:00:00 2001
-Message-Id: <40bd6c3ac6e183b504b38192938d0178438d3966@dist-git>
-From: Martin Kletzander <mkletzan@redhat.com>
-Date: Tue, 25 Apr 2017 13:41:15 +0200
-Subject: [PATCH] util: Add virNetDevSetCoalesce function
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1414627
-
-That function is able to configure coalesce settings for an interface,
-similarly to 'ethtool -C'.  This function also updates back the
-structure so that it contains actual data on the device (if the device
-doesn't support some settings kernel might just return 0 and not set
-whatever is not supported), so this way we'll have up-to-date
-information in the live domain XML.
-
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-(cherry picked from commit 652ef9bc8c72a7118436a8c95c5742ec6a6d12a3)
-Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- configure.ac             |  3 +-
- src/libvirt_private.syms |  1 +
- src/util/virnetdev.c     | 83 ++++++++++++++++++++++++++++++++++++++++++++++++
- src/util/virnetdev.h     | 34 ++++++++++++++++++++
- 4 files changed, 120 insertions(+), 1 deletion(-)
-
-diff --git a/configure.ac b/configure.ac
-index 08051d53a..d9dc21aa9 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -347,7 +347,8 @@ AC_CHECK_TYPE([struct sockpeercred],
-   ]])
- 
- AC_CHECK_DECLS([ETH_FLAG_TXVLAN, ETH_FLAG_NTUPLE, ETH_FLAG_RXHASH, ETH_FLAG_LRO,
--                ETHTOOL_GGSO, ETHTOOL_GGRO, ETHTOOL_GFLAGS, ETHTOOL_GFEATURES],
-+                ETHTOOL_GGSO, ETHTOOL_GGRO, ETHTOOL_GFLAGS, ETHTOOL_GFEATURES,
-+                ETHTOOL_SCOALESCE, ETHTOOL_GCOALESCE],
-   [], [], [[#include <linux/ethtool.h>
-   ]])
- 
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index d802e7598..134d4a832 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -2064,6 +2064,7 @@ virNetDevRxFilterModeTypeFromString;
- virNetDevRxFilterModeTypeToString;
- virNetDevRxFilterNew;
- virNetDevSaveNetConfig;
-+virNetDevSetCoalesce;
- virNetDevSetMAC;
- virNetDevSetMTU;
- virNetDevSetMTUFromDevice;
-diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
-index 9aa9c9f88..f14286f62 100644
---- a/src/util/virnetdev.c
-+++ b/src/util/virnetdev.c
-@@ -3082,6 +3082,89 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap ATTRIBUTE_UNUSED,
- # endif
- 
- 
-+# if HAVE_DECL_ETHTOOL_SCOALESCE && HAVE_DECL_ETHTOOL_GCOALESCE
-+/**
-+ * virNetDevSetCoalesce:
-+ * @ifname: interface name to modify
-+ * @coalesce: Coalesce settings to set and update
-+ *
-+ * This function sets the various coalesce settings for a given interface
-+ * @ifname and updates them back into @coalesce.
-+ *
-+ * Returns 0 in case of success or -1 on failure
-+ */
-+int virNetDevSetCoalesce(const char *ifname,
-+                         virNetDevCoalescePtr coalesce)
-+{
-+    int fd = -1;
-+    int ret = -1;
-+    struct ifreq ifr;
-+    struct ethtool_coalesce coal = {0};
-+
-+    if (!coalesce)
-+        return 0;
-+
-+    coal = (struct ethtool_coalesce) {
-+        .cmd = ETHTOOL_SCOALESCE,
-+        .rx_max_coalesced_frames = coalesce->rx_max_coalesced_frames,
-+        .rx_coalesce_usecs_irq = coalesce->rx_coalesce_usecs_irq,
-+        .rx_max_coalesced_frames_irq = coalesce->rx_max_coalesced_frames_irq,
-+        .tx_coalesce_usecs = coalesce->tx_coalesce_usecs,
-+        .tx_max_coalesced_frames = coalesce->tx_max_coalesced_frames,
-+        .tx_coalesce_usecs_irq = coalesce->tx_coalesce_usecs_irq,
-+        .tx_max_coalesced_frames_irq = coalesce->tx_max_coalesced_frames_irq,
-+        .stats_block_coalesce_usecs = coalesce->stats_block_coalesce_usecs,
-+        .use_adaptive_rx_coalesce = coalesce->use_adaptive_rx_coalesce,
-+        .use_adaptive_tx_coalesce = coalesce->use_adaptive_tx_coalesce,
-+        .pkt_rate_low = coalesce->pkt_rate_low,
-+        .rx_coalesce_usecs_low = coalesce->rx_coalesce_usecs_low,
-+        .rx_max_coalesced_frames_low = coalesce->rx_max_coalesced_frames_low,
-+        .tx_coalesce_usecs_low = coalesce->tx_coalesce_usecs_low,
-+        .tx_max_coalesced_frames_low = coalesce->tx_max_coalesced_frames_low,
-+        .pkt_rate_high = coalesce->pkt_rate_high,
-+        .rx_coalesce_usecs_high = coalesce->rx_coalesce_usecs_high,
-+        .rx_max_coalesced_frames_high = coalesce->rx_max_coalesced_frames_high,
-+        .tx_coalesce_usecs_high = coalesce->tx_coalesce_usecs_high,
-+        .tx_max_coalesced_frames_high = coalesce->tx_max_coalesced_frames_high,
-+        .rate_sample_interval = coalesce->rate_sample_interval,
-+    };
-+
-+    if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
-+        return -1;
-+
-+    ifr.ifr_data = (void *) &coal;
-+
-+    if (virNetDevSendEthtoolIoctl(fd, &ifr) < 0) {
-+        virReportSystemError(errno,
-+                             _("Cannot set coalesce info on '%s'"),
-+                             ifname);
-+        goto cleanup;
-+    }
-+
-+    coal = (struct ethtool_coalesce) {
-+        .cmd = ETHTOOL_GCOALESCE,
-+    };
-+
-+    /* Don't fail if the update itself fails */
-+    virNetDevSendEthtoolIoctl(fd, &ifr);
-+
-+    ret = 0;
-+ cleanup:
-+    VIR_FORCE_CLOSE(fd);
-+    return ret;
-+}
-+# else
-+int virNetDevSetCoalesce(const char *ifname,
-+                         virNetDevCoalescePtr coalesce ATTRIBUTE_UNUSED)
-+{
-+    virReportSystemError(ENOSYS,
-+                         _("Cannot set coalesce info on interface '%s'"),
-+                         ifname);
-+    return -1;
-+}
-+# endif
-+
-+
- /**
-  * virNetDevGetFeatures:
-  * This function gets the nic offloads features available for ifname
-diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
-index 437a77625..cff8cb51c 100644
---- a/src/util/virnetdev.h
-+++ b/src/util/virnetdev.h
-@@ -112,6 +112,36 @@ typedef enum {
- 
- VIR_ENUM_DECL(virNetDevFeature)
- 
-+/* Modeled after struct ethtool_coalesce, see linux/ethtool.h for explanations
-+ * of particular fields */
-+typedef struct _virNetDevCoalesce virNetDevCoalesce;
-+typedef virNetDevCoalesce *virNetDevCoalescePtr;
-+struct _virNetDevCoalesce {
-+    uint32_t rx_coalesce_usecs;
-+    uint32_t rx_max_coalesced_frames;
-+    uint32_t rx_coalesce_usecs_irq;
-+    uint32_t rx_max_coalesced_frames_irq;
-+    uint32_t tx_coalesce_usecs;
-+    uint32_t tx_max_coalesced_frames;
-+    uint32_t tx_coalesce_usecs_irq;
-+    uint32_t tx_max_coalesced_frames_irq;
-+    uint32_t stats_block_coalesce_usecs;
-+    uint32_t use_adaptive_rx_coalesce;
-+    uint32_t use_adaptive_tx_coalesce;
-+    uint32_t pkt_rate_low;
-+    uint32_t rx_coalesce_usecs_low;
-+    uint32_t rx_max_coalesced_frames_low;
-+    uint32_t tx_coalesce_usecs_low;
-+    uint32_t tx_max_coalesced_frames_low;
-+    uint32_t pkt_rate_high;
-+    uint32_t rx_coalesce_usecs_high;
-+    uint32_t rx_max_coalesced_frames_high;
-+    uint32_t tx_coalesce_usecs_high;
-+    uint32_t tx_max_coalesced_frames_high;
-+    uint32_t rate_sample_interval;
-+};
-+
-+
- int virNetDevSetupControl(const char *ifname,
-                           virIfreq *ifr)
-     ATTRIBUTE_RETURN_CHECK;
-@@ -144,6 +174,10 @@ int virNetDevRestoreMacAddress(const char *linkdev,
-                                const char *stateDir)
-     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
- 
-+int virNetDevSetCoalesce(const char *ifname,
-+                         virNetDevCoalescePtr coalesce)
-+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
-+
- int virNetDevSetMTU(const char *ifname,
-                     int mtu)
-     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-util-Add-virResctrlInfo.patch b/SOURCES/libvirt-util-Add-virResctrlInfo.patch
new file mode 100644
index 0000000..1232688
--- /dev/null
+++ b/SOURCES/libvirt-util-Add-virResctrlInfo.patch
@@ -0,0 +1,407 @@
+From 6c23daa9238671767dec5c43387be996a066196f Mon Sep 17 00:00:00 2001
+Message-Id: <6c23daa9238671767dec5c43387be996a066196f@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:25 +0100
+Subject: [PATCH] util: Add virResctrlInfo
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+This will make the current functions obsolete and it will provide more
+information to the virresctrl module so that it can be used later.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit cd572df89bc43405a970ad207b32f23c73bdaa75)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ po/POTFILES.in           |   1 +
+ src/libvirt_private.syms |   3 +
+ src/util/virresctrl.c    | 305 +++++++++++++++++++++++++++++++++++++++++++++++
+ src/util/virresctrl.h    |  16 +++
+ 4 files changed, 325 insertions(+)
+
+diff --git a/po/POTFILES.in b/po/POTFILES.in
+index c1fa23427e..8382ee6336 100644
+--- a/po/POTFILES.in
++++ b/po/POTFILES.in
+@@ -252,6 +252,7 @@ src/util/virportallocator.c
+ src/util/virprocess.c
+ src/util/virqemu.c
+ src/util/virrandom.c
++src/util/virresctrl.c
+ src/util/virrotatingfile.c
+ src/util/virscsi.c
+ src/util/virscsihost.c
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 7dd4621b70..e0e0046522 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -2549,6 +2549,9 @@ virCacheTypeFromString;
+ virCacheTypeToString;
+ virResctrlGetCacheControlType;
+ virResctrlGetCacheInfo;
++virResctrlGetInfo;
++virResctrlInfoGetCache;
++virResctrlInfoNew;
+ 
+ 
+ # util/virrotatingfile.h
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index 050a08178e..7ab68c6f74 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -25,12 +25,15 @@
+ #include "viralloc.h"
+ #include "virfile.h"
+ #include "virlog.h"
++#include "virobject.h"
+ #include "virstring.h"
+ 
+ #define VIR_FROM_THIS VIR_FROM_RESCTRL
+ 
+ VIR_LOG_INIT("util.virresctrl")
+ 
++
++/* Common definitions */
+ #define SYSFS_RESCTRL_PATH "/sys/fs/resctrl"
+ 
+ /* Resctrl is short for Resource Control.  It might be implemented for various
+@@ -55,6 +58,308 @@ VIR_ENUM_IMPL(virResctrl, VIR_CACHE_TYPE_LAST,
+               "CODE",
+               "DATA")
+ 
++
++/* Info-related definitions and InfoClass-related functions */
++typedef struct _virResctrlInfoPerType virResctrlInfoPerType;
++typedef virResctrlInfoPerType *virResctrlInfoPerTypePtr;
++struct _virResctrlInfoPerType {
++    /* Kernel-provided information */
++    char *cbm_mask;
++    unsigned int min_cbm_bits;
++
++    /* Our computed information from the above */
++    unsigned int bits;
++    unsigned int max_cache_id;
++
++    /* In order to be self-sufficient we need size information per cache.
++     * Funnily enough, one of the outcomes of the resctrlfs design is that it
++     * does not account for different sizes per cache on the same level.  So
++     * for the sake of easiness, let's copy that, for now. */
++    unsigned long long size;
++
++    /* Information that we will return upon request (this is public struct) as
++     * until now all the above is internal to this module */
++    virResctrlInfoPerCache control;
++};
++
++typedef struct _virResctrlInfoPerLevel virResctrlInfoPerLevel;
++typedef virResctrlInfoPerLevel *virResctrlInfoPerLevelPtr;
++struct _virResctrlInfoPerLevel {
++    virResctrlInfoPerTypePtr *types;
++};
++
++struct _virResctrlInfo {
++    virObject parent;
++
++    virResctrlInfoPerLevelPtr *levels;
++    size_t nlevels;
++};
++
++static virClassPtr virResctrlInfoClass;
++
++static void
++virResctrlInfoDispose(void *obj)
++{
++    size_t i = 0;
++    size_t j = 0;
++
++    virResctrlInfoPtr resctrl = obj;
++
++    for (i = 0; i < resctrl->nlevels; i++) {
++        virResctrlInfoPerLevelPtr level = resctrl->levels[i];
++
++        if (!level)
++            continue;
++
++        if (level->types) {
++            for (j = 0; j < VIR_CACHE_TYPE_LAST; j++) {
++                if (level->types[j])
++                    VIR_FREE(level->types[j]->cbm_mask);
++                VIR_FREE(level->types[j]);
++            }
++        }
++        VIR_FREE(level->types);
++        VIR_FREE(level);
++    }
++
++    VIR_FREE(resctrl->levels);
++}
++
++
++static int
++virResctrlInfoOnceInit(void)
++{
++    if (!(virResctrlInfoClass = virClassNew(virClassForObject(),
++                                            "virResctrlInfo",
++                                            sizeof(virResctrlInfo),
++                                            virResctrlInfoDispose)))
++        return -1;
++
++    return 0;
++}
++
++
++VIR_ONCE_GLOBAL_INIT(virResctrlInfo)
++
++
++virResctrlInfoPtr
++virResctrlInfoNew(void)
++{
++    if (virResctrlInfoInitialize() < 0)
++        return NULL;
++
++    return virObjectNew(virResctrlInfoClass);
++}
++
++
++/* Info-related functions */
++static bool
++virResctrlInfoIsEmpty(virResctrlInfoPtr resctrl)
++{
++    size_t i = 0;
++    size_t j = 0;
++
++    if (!resctrl)
++        return true;
++
++    for (i = 0; i < resctrl->nlevels; i++) {
++        virResctrlInfoPerLevelPtr i_level = resctrl->levels[i];
++
++        if (!i_level)
++            continue;
++
++        for (j = 0; j < VIR_CACHE_TYPE_LAST; j++) {
++            if (i_level->types[j])
++                return false;
++        }
++    }
++
++    return true;
++}
++
++
++int
++virResctrlGetInfo(virResctrlInfoPtr resctrl)
++{
++    DIR *dirp = NULL;
++    char *info_path = NULL;
++    char *endptr = NULL;
++    char *tmp_str = NULL;
++    int ret = -1;
++    int rv = -1;
++    int type = 0;
++    struct dirent *ent = NULL;
++    unsigned int level = 0;
++    virResctrlInfoPerLevelPtr i_level = NULL;
++    virResctrlInfoPerTypePtr i_type = NULL;
++
++    rv = virDirOpenIfExists(&dirp, SYSFS_RESCTRL_PATH "/info");
++    if (rv <= 0) {
++        ret = rv;
++        goto cleanup;
++    }
++
++    while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0) {
++        if (ent->d_type != DT_DIR)
++            continue;
++
++        if (ent->d_name[0] != 'L')
++            continue;
++
++        if (virStrToLong_uip(ent->d_name + 1, &endptr, 10, &level) < 0) {
++            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                           _("Cannot parse resctrl cache info level"));
++            goto cleanup;
++        }
++
++        type = virResctrlTypeFromString(endptr);
++        if (type < 0) {
++            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                           _("Cannot parse resctrl cache info type"));
++            goto cleanup;
++        }
++
++        if (VIR_ALLOC(i_type) < 0)
++            goto cleanup;
++
++        i_type->control.scope = type;
++
++        rv = virFileReadValueUint(&i_type->control.max_allocation,
++                                  SYSFS_RESCTRL_PATH "/info/%s/num_closids",
++                                  ent->d_name);
++        if (rv == -2)
++            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                           _("Cannot get num_closids from resctrl cache info"));
++        if (rv < 0)
++            goto cleanup;
++
++        rv = virFileReadValueString(&i_type->cbm_mask,
++                                    SYSFS_RESCTRL_PATH
++                                    "/info/%s/cbm_mask",
++                                    ent->d_name);
++        if (rv == -2)
++            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                           _("Cannot get cbm_mask from resctrl cache info"));
++        if (rv < 0)
++            goto cleanup;
++
++        virStringTrimOptionalNewline(i_type->cbm_mask);
++
++        rv = virFileReadValueUint(&i_type->min_cbm_bits,
++                                  SYSFS_RESCTRL_PATH "/info/%s/min_cbm_bits",
++                                  ent->d_name);
++        if (rv == -2)
++            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                           _("Cannot get min_cbm_bits from resctrl cache info"));
++        if (rv < 0)
++            goto cleanup;
++
++        if (resctrl->nlevels <= level &&
++            VIR_EXPAND_N(resctrl->levels, resctrl->nlevels,
++                         level - resctrl->nlevels + 1) < 0)
++            goto cleanup;
++
++        if (!resctrl->levels[level] &&
++            (VIR_ALLOC(resctrl->levels[level]) < 0 ||
++             VIR_ALLOC_N(resctrl->levels[level]->types, VIR_CACHE_TYPE_LAST) < 0))
++            goto cleanup;
++        i_level = resctrl->levels[level];
++
++        if (i_level->types[type]) {
++            virReportError(VIR_ERR_INTERNAL_ERROR,
++                           _("Duplicate cache type in resctrlfs for level %u"),
++                           level);
++            goto cleanup;
++        }
++
++        for (tmp_str = i_type->cbm_mask; *tmp_str != '\0'; tmp_str++) {
++            if (!c_isxdigit(*tmp_str)) {
++                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                               _("Cannot parse cbm_mask from resctrl cache info"));
++                goto cleanup;
++            }
++
++            i_type->bits += count_one_bits(virHexToBin(*tmp_str));
++        }
++
++        VIR_STEAL_PTR(i_level->types[type], i_type);
++    }
++
++    ret = 0;
++ cleanup:
++    VIR_DIR_CLOSE(dirp);
++    VIR_FREE(info_path);
++    if (i_type)
++        VIR_FREE(i_type->cbm_mask);
++    VIR_FREE(i_type);
++    return ret;
++}
++
++
++int
++virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
++                       unsigned int level,
++                       unsigned long long size,
++                       size_t *ncontrols,
++                       virResctrlInfoPerCachePtr **controls)
++{
++    virResctrlInfoPerLevelPtr i_level = NULL;
++    virResctrlInfoPerTypePtr i_type = NULL;
++    size_t i = 0;
++    int ret = -1;
++
++    if (virResctrlInfoIsEmpty(resctrl))
++        return 0;
++
++    if (level >= resctrl->nlevels)
++        return 0;
++
++    i_level = resctrl->levels[level];
++    if (!i_level)
++        return 0;
++
++    for (i = 0; i < VIR_CACHE_TYPE_LAST; i++) {
++        i_type = i_level->types[i];
++        if (!i_type)
++            continue;
++
++        /* Let's take the opportunity to update our internal information about
++         * the cache size */
++        if (!i_type->size) {
++            i_type->size = size;
++            i_type->control.granularity = size / i_type->bits;
++            if (i_type->min_cbm_bits != 1)
++                i_type->control.min = i_type->min_cbm_bits * i_type->control.granularity;
++        } else {
++            if (i_type->size != size) {
++                virReportError(VIR_ERR_INTERNAL_ERROR,
++                               _("level %u cache size %llu does not match "
++                                 "expected size %llu"),
++                                 level, i_type->size, size);
++                goto error;
++            }
++            i_type->max_cache_id++;
++        }
++
++        if (VIR_EXPAND_N(*controls, *ncontrols, 1) < 0)
++            goto error;
++        if (VIR_ALLOC((*controls)[*ncontrols - 1]) < 0)
++            goto error;
++
++        memcpy((*controls)[*ncontrols - 1], &i_type->control, sizeof(i_type->control));
++    }
++
++    ret = 0;
++ cleanup:
++    return ret;
++ error:
++    while (*ncontrols)
++        VIR_FREE((*controls)[--*ncontrols]);
++    VIR_FREE(*controls);
++    goto cleanup;
++}
++
++
+ int
+ virResctrlGetCacheInfo(unsigned int level,
+                        unsigned long long size,
+diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
+index 42e8527803..c7f25c76e1 100644
+--- a/src/util/virresctrl.h
++++ b/src/util/virresctrl.h
+@@ -49,7 +49,23 @@ struct _virResctrlInfoPerCache {
+     unsigned int max_allocation;
+ };
+ 
++typedef struct _virResctrlInfo virResctrlInfo;
++typedef virResctrlInfo *virResctrlInfoPtr;
+ 
++virResctrlInfoPtr
++virResctrlInfoNew(void);
++
++int
++virResctrlGetInfo(virResctrlInfoPtr resctrl);
++
++int
++virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
++                       unsigned int level,
++                       unsigned long long size,
++                       size_t *ncontrols,
++                       virResctrlInfoPerCachePtr **controls);
++
++/* To be removed */
+ int
+ virResctrlGetCacheInfo(unsigned int level,
+                        unsigned long long size,
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Check-for-empty-allocation-instead-of-just-NULL-pointer.patch b/SOURCES/libvirt-util-Check-for-empty-allocation-instead-of-just-NULL-pointer.patch
new file mode 100644
index 0000000..8518730
--- /dev/null
+++ b/SOURCES/libvirt-util-Check-for-empty-allocation-instead-of-just-NULL-pointer.patch
@@ -0,0 +1,38 @@
+From 230fcf5bfaf2b17313fe255a09bfa79c8ea9ae8a Mon Sep 17 00:00:00 2001
+Message-Id: <230fcf5bfaf2b17313fe255a09bfa79c8ea9ae8a@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:35 +0100
+Subject: [PATCH] util: Check for empty allocation instead of just NULL pointer
+
+When working on the CAT series one of the changes was that the pointer got
+allocated in another part of the code, even when resctrl was not available on
+the host system.  However this one particular place neglected that so it needs
+to be fixed in order to get the proper error message when requesting
+<cachetune/> on HW with no support for it.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit bd5d07425de504c571d6d47ace8602fa86c1a1c8)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index 754820ee46..03218a481d 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -1472,7 +1472,7 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl,
+     if (!alloc)
+         return 0;
+ 
+-    if (!resctrl) {
++    if (virResctrlInfoIsEmpty(resctrl)) {
+         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                        _("Resource control is not supported on this host"));
+         return -1;
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Check-if-kernel-provided-info-is-consistent-with-itself.patch b/SOURCES/libvirt-util-Check-if-kernel-provided-info-is-consistent-with-itself.patch
new file mode 100644
index 0000000..89c2e24
--- /dev/null
+++ b/SOURCES/libvirt-util-Check-if-kernel-provided-info-is-consistent-with-itself.patch
@@ -0,0 +1,43 @@
+From e3521dc836329e941d3d7bea0bcac1b0731162a5 Mon Sep 17 00:00:00 2001
+Message-Id: <e3521dc836329e941d3d7bea0bcac1b0731162a5@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Mon, 5 Feb 2018 13:39:19 +0100
+Subject: [PATCH] util: Check if kernel-provided info is consistent with itself
+
+Just in case someone re-mounted /sys/fs/resctrl with different mount
+options (cdp), add a check here.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1540780
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit d300b5448721970962efc18c3b3b0a358f2359ab)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index ef388757a7..6860e86e64 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -941,6 +941,17 @@ virResctrlAllocParseProcessCache(virResctrlInfoPtr resctrl,
+     if (!mask)
+         return -1;
+ 
++    if (!resctrl ||
++        level >= resctrl->nlevels ||
++        !resctrl->levels[level] ||
++        !resctrl->levels[level]->types[type]) {
++        virReportError(VIR_ERR_INTERNAL_ERROR,
++                       _("Missing or inconsistent resctrl info for "
++                         "level '%ud' type '%s'"),
++                       level, virCacheTypeToString(type));
++        goto cleanup;
++    }
++
+     if (virBitmapShrink(mask, resctrl->levels[level]->types[type]->bits) < 0)
+         goto cleanup;
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Clear-unused-part-of-the-map-in-virBitmapShrink.patch b/SOURCES/libvirt-util-Clear-unused-part-of-the-map-in-virBitmapShrink.patch
new file mode 100644
index 0000000..aa6d5af
--- /dev/null
+++ b/SOURCES/libvirt-util-Clear-unused-part-of-the-map-in-virBitmapShrink.patch
@@ -0,0 +1,135 @@
+From fbecdf5ed4345a15d1ffc30922d44272a3d60368 Mon Sep 17 00:00:00 2001
+Message-Id: <fbecdf5ed4345a15d1ffc30922d44272a3d60368@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Fri, 2 Feb 2018 15:21:27 +0100
+Subject: [PATCH] util: Clear unused part of the map in virBitmapShrink
+
+Some of the other functions depend on the fact that unused bits and longs are
+always zero and it's less error-prone to clear it than fix the other functions.
+It's enough to zero out one piece of the map since we're calling realloc() to
+get rid of the rest (and updating map_len).
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1540817
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit d6e582da80d07a90f154dc27aca239d44fc2b7b7)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/conf/domain_conf.c |  4 +++-
+ src/util/virbitmap.c   | 30 ++++++++++++++++++++++--------
+ src/util/virbitmap.h   |  2 +-
+ src/util/virresctrl.c  |  3 ++-
+ tests/virbitmaptest.c  |  8 ++++++++
+ 5 files changed, 36 insertions(+), 11 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 181b035647..0af3dd5ab6 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -18365,7 +18365,9 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
+ 
+     /* We need to limit the bitmap to number of vCPUs.  If there's nothing left,
+      * then we can just clean up and return 0 immediately */
+-    virBitmapShrink(vcpus, def->maxvcpus);
++    if (virBitmapShrink(vcpus, def->maxvcpus) < 0)
++        goto cleanup;
++
+     if (virBitmapIsAllClear(vcpus)) {
+         ret = 0;
+         goto cleanup;
+diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
+index b2c5c7a6a5..33cae2f305 100644
+--- a/src/util/virbitmap.c
++++ b/src/util/virbitmap.c
+@@ -1201,21 +1201,35 @@ virBitmapSubtract(virBitmapPtr a,
+ /**
+  * virBitmapShrink:
+  * @map: Pointer to bitmap
+- * @b: last bit position to be excluded from bitmap
++ * @b: Size to reduce the bitmap to
+  *
+- * Resizes the bitmap so that no more than @b bits will fit into it.  Nothing
+- * will change if the size is already smaller than @b.
+- *
+- * NB: Does not adjust the map->map_len so that a subsequent virBitmapExpand
+- * doesn't necessarily need to reallocate.
++ * Reduces the bitmap to size @b.  Nothing will change if the size is already
++ * smaller than or equal to @b.
+  */
+-void
++int
+ virBitmapShrink(virBitmapPtr map,
+                 size_t b)
+ {
++    size_t nl = 0;
++    size_t nb = 0;
++
+     if (!map)
+-        return;
++        return 0;
+ 
+     if (map->max_bit >= b)
+         map->max_bit = b;
++
++    nl = map->max_bit / VIR_BITMAP_BITS_PER_UNIT;
++    nb = map->max_bit % VIR_BITMAP_BITS_PER_UNIT;
++    map->map[nl] &= ((1UL << nb) - 1);
++
++    nl++;
++    if (nl == map->map_len)
++        return 0;
++
++    if (VIR_REALLOC_N(map->map, nl) < 0)
++        return -1;
++
++    map->map_len = nl;
++    return 0;
+ }
+diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
+index 2464814055..5a3362a19f 100644
+--- a/src/util/virbitmap.h
++++ b/src/util/virbitmap.h
+@@ -153,6 +153,6 @@ void virBitmapIntersect(virBitmapPtr a, virBitmapPtr b)
+ void virBitmapSubtract(virBitmapPtr a, virBitmapPtr b)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+ 
+-void virBitmapShrink(virBitmapPtr map, size_t b);
++int virBitmapShrink(virBitmapPtr map, size_t b);
+ 
+ #endif
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index 70426199ce..ef388757a7 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -941,7 +941,8 @@ virResctrlAllocParseProcessCache(virResctrlInfoPtr resctrl,
+     if (!mask)
+         return -1;
+ 
+-    virBitmapShrink(mask, resctrl->levels[level]->types[type]->bits);
++    if (virBitmapShrink(mask, resctrl->levels[level]->types[type]->bits) < 0)
++        goto cleanup;
+ 
+     if (virResctrlAllocUpdateMask(alloc, level, type, cache_id, mask) < 0)
+         goto cleanup;
+diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
+index 5bf30b2b1c..a78e4da723 100644
+--- a/tests/virbitmaptest.c
++++ b/tests/virbitmaptest.c
+@@ -656,6 +656,14 @@ test12(const void *opaque ATTRIBUTE_UNUSED)
+ 
+     TEST_MAP(1024, "34,1023");
+ 
++    if (virBitmapShrink(map, 35) < 0)
++        goto cleanup;
++    TEST_MAP(35, "34");
++
++    if (virBitmapShrink(map, 34) < 0)
++        goto cleanup;
++    TEST_MAP(34, "");
++
+     ret = 0;
+ 
+  cleanup:
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Don-t-check-if-entries-under-sys-fs-resctrl-info-are-directories.patch b/SOURCES/libvirt-util-Don-t-check-if-entries-under-sys-fs-resctrl-info-are-directories.patch
new file mode 100644
index 0000000..33da698
--- /dev/null
+++ b/SOURCES/libvirt-util-Don-t-check-if-entries-under-sys-fs-resctrl-info-are-directories.patch
@@ -0,0 +1,90 @@
+From eaeaf49524c3b7f26afb86bdeddba8d86bce4790 Mon Sep 17 00:00:00 2001
+Message-Id: <eaeaf49524c3b7f26afb86bdeddba8d86bce4790@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:39 +0100
+Subject: [PATCH] util: Don't check if entries under /sys/fs/resctrl/(info/)
+ are directories
+
+We are skipping non-directories under /sys/fs/resctrl/(info/) since those are not
+interesting for us.  However in tests it can sometimes happen that ent->d_type
+is 0 instead of 4 (DT_DIR) for directories.
+
+I've seen it fail on two machines.  Different machines, different systems, I
+cannot reproduce it even using the same setup.  So one of the ways how to work
+around this is call stat() on it.  The other one is not checking if it is a
+directory since we'll find out eventually when we want to read some files
+underneath it.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit f2e16994f7d660a54daba1059441dc0dcf4d9cbd)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 27 +++++++++++++++------------
+ 1 file changed, 15 insertions(+), 12 deletions(-)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index 684cb22fd8..42876c6e2b 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -410,10 +410,6 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
+ 
+     while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0) {
+         VIR_DEBUG("Parsing info type '%s'", ent->d_name);
+-
+-        if (ent->d_type != DT_DIR)
+-            continue;
+-
+         if (ent->d_name[0] != 'L')
+             continue;
+ 
+@@ -436,19 +432,29 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
+         rv = virFileReadValueUint(&i_type->control.max_allocation,
+                                   SYSFS_RESCTRL_PATH "/info/%s/num_closids",
+                                   ent->d_name);
+-        if (rv == -2)
+-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+-                           _("Cannot get num_closids from resctrl cache info"));
+-        if (rv < 0)
++        if (rv == -2) {
++            /* The file doesn't exist, so it's unusable for us,
++             *  but we can scan further */
++            VIR_WARN("The path '" SYSFS_RESCTRL_PATH "/info/%s/num_closids' "
++                     "does not exist",
++                     ent->d_name);
++        } else if (rv < 0) {
++            /* Other failures are fatal, so just quit */
+             goto cleanup;
++        }
+ 
+         rv = virFileReadValueString(&i_type->cbm_mask,
+                                     SYSFS_RESCTRL_PATH
+                                     "/info/%s/cbm_mask",
+                                     ent->d_name);
+-        if (rv == -2)
++        if (rv == -2) {
++            /* If the previous file exists, so should this one.  Hence -2 is
++             * fatal in this case as well (errors out in next condition) - the
++             * kernel interface might've changed too much or something else is
++             * wrong. */
+             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                            _("Cannot get cbm_mask from resctrl cache info"));
++        }
+         if (rv < 0)
+             goto cleanup;
+ 
+@@ -1169,9 +1175,6 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
+         goto error;
+ 
+     while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH)) > 0) {
+-        if (ent->d_type != DT_DIR)
+-            continue;
+-
+         if (STREQ(ent->d_name, "info"))
+             continue;
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Don-t-output-too-many-zeros-from-virBitmapToString.patch b/SOURCES/libvirt-util-Don-t-output-too-many-zeros-from-virBitmapToString.patch
new file mode 100644
index 0000000..f14fcc3
--- /dev/null
+++ b/SOURCES/libvirt-util-Don-t-output-too-many-zeros-from-virBitmapToString.patch
@@ -0,0 +1,118 @@
+From 86761c187660d73daed649c6be28502aa5e01a14 Mon Sep 17 00:00:00 2001
+Message-Id: <86761c187660d73daed649c6be28502aa5e01a14@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:13 +0100
+Subject: [PATCH] util: Don't output too many zeros from virBitmapToString
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Truncate the output so that it is only as big as is needed to fit all
+the bits, not all the units from the map.  This will be needed in the
+future in order to properly format bitmaps for kernel's sysfs files.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit fb106028752d8bd31f48a7c50357b7437b87d7c1)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/qemu/qemu_capabilities.c |  4 ++--
+ src/util/virbitmap.c         | 30 ++++++++++++++++++++++++++++--
+ src/util/virbitmap.h         |  2 +-
+ 3 files changed, 31 insertions(+), 5 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 5bf188f427..dc546ba702 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -1525,7 +1525,7 @@ int virQEMUCapsParseHelpStr(const char *qemu,
+                                    qemuCaps, check_yajl) < 0)
+         goto cleanup;
+ 
+-    strflags = virBitmapToString(qemuCaps->flags, true);
++    strflags = virBitmapToString(qemuCaps->flags, true, false);
+     VIR_DEBUG("Version %u.%u.%u, cooked version %u, flags %s",
+               major, minor, micro, *version, NULLSTR(strflags));
+     VIR_FREE(strflags);
+@@ -2407,7 +2407,7 @@ virQEMUCapsClear(virQEMUCapsPtr qemuCaps,
+ 
+ char *virQEMUCapsFlagsString(virQEMUCapsPtr qemuCaps)
+ {
+-    return virBitmapToString(qemuCaps->flags, true);
++    return virBitmapToString(qemuCaps->flags, true, false);
+ }
+ 
+ 
+diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
+index f5700a6424..b1c1236fd3 100644
+--- a/src/util/virbitmap.c
++++ b/src/util/virbitmap.c
+@@ -313,6 +313,7 @@ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
+  * virBitmapToString:
+  * @bitmap: Pointer to bitmap
+  * @prefix: Whether to prepend "0x"
++ * @trim: Whether to output only the minimum required characters
+  *
+  * Convert @bitmap to printable string.
+  *
+@@ -320,10 +321,14 @@ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
+  */
+ char *
+ virBitmapToString(virBitmapPtr bitmap,
+-                  bool prefix)
++                  bool prefix,
++                  bool trim)
+ {
+     virBuffer buf = VIR_BUFFER_INITIALIZER;
+     size_t sz;
++    size_t len;
++    size_t diff;
++    char *ret = NULL;
+ 
+     if (prefix)
+         virBufferAddLit(&buf, "0x");
+@@ -337,7 +342,28 @@ virBitmapToString(virBitmapPtr bitmap,
+     }
+ 
+     virBufferCheckError(&buf);
+-    return virBufferContentAndReset(&buf);
++    ret = virBufferContentAndReset(&buf);
++    if (!ret)
++        return NULL;
++
++    if (!trim)
++        return ret;
++
++    if (bitmap->max_bit != bitmap->map_len * VIR_BITMAP_BITS_PER_UNIT) {
++        char *tmp = ret;
++
++        if (prefix)
++            tmp += 2;
++
++        len = strlen(tmp);
++        sz = VIR_DIV_UP(bitmap->max_bit, 4);
++        diff = len - sz;
++
++        if (diff)
++            memmove(tmp, tmp + diff, sz + 1);
++    }
++
++    return ret;
+ }
+ 
+ /**
+diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
+index 720b389cfe..02acb7519d 100644
+--- a/src/util/virbitmap.h
++++ b/src/util/virbitmap.h
+@@ -80,7 +80,7 @@ bool virBitmapIsBitSet(virBitmapPtr bitmap, size_t b)
+ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
+ 
+-char *virBitmapToString(virBitmapPtr bitmap, bool prefix)
++char *virBitmapToString(virBitmapPtr bitmap, bool prefix, bool trim)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+ 
+ char *virBitmapFormat(virBitmapPtr bitmap);
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Don-t-overwrite-mask-in-virResctrlAllocFindUnused.patch b/SOURCES/libvirt-util-Don-t-overwrite-mask-in-virResctrlAllocFindUnused.patch
new file mode 100644
index 0000000..7dcff5d
--- /dev/null
+++ b/SOURCES/libvirt-util-Don-t-overwrite-mask-in-virResctrlAllocFindUnused.patch
@@ -0,0 +1,117 @@
+From a7cc1c068ba979a35bad3f4a21e1161379725c61 Mon Sep 17 00:00:00 2001
+Message-Id: <a7cc1c068ba979a35bad3f4a21e1161379725c61@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:42 +0100
+Subject: [PATCH] util: Don't overwrite mask in virResctrlAllocFindUnused
+
+Due to confusing naming the pointer to the mask got copied which must not
+happen, so use UpdateMask instead of SetMask.  That also means we can get
+completely rid of SetMask.
+
+Also don't clear the free bits since it is not used again (leftover from
+previous versions).
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 859186091cc6348e48cdad37c635fb3342e68189)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 41 ++++++++++++++---------------------------
+ 1 file changed, 14 insertions(+), 27 deletions(-)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index a0ea274871..fdd1ded6f7 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -1253,22 +1253,6 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl ATTRIBUTE_UNUSED)
+ 
+ #endif /* ! __linux__ */
+ 
+-static int
+-virResctrlAllocSetMask(virResctrlAllocPerTypePtr a_type,
+-                       unsigned int cache,
+-                       virBitmapPtr mask)
+-{
+-    if (a_type->nmasks <= cache &&
+-        VIR_EXPAND_N(a_type->masks, a_type->nmasks,
+-                     cache - a_type->nmasks + 1) < 0)
+-        return -1;
+-
+-    virBitmapFree(a_type->masks[cache]);
+-    a_type->masks[cache] = mask;
+-
+-    return 0;
+-}
+-
+ 
+ /*
+  * Given the information about requested allocation type `a_type`, the host
+@@ -1276,16 +1260,19 @@ virResctrlAllocSetMask(virResctrlAllocPerTypePtr a_type,
+  * this function tries to find the smallest free space in which the allocation
+  * for cache id `cache` would fit.  We're looking for the smallest place in
+  * order to minimize fragmentation and maximize the possibility of succeeding.
++ *
++ * Per-cache allocation for the @level, @type and @cache must already be
++ * allocated for @alloc (does not have to exist though).
+  */
+ static int
+-virResctrlAllocFindUnused(virResctrlAllocPerTypePtr a_type,
++virResctrlAllocFindUnused(virResctrlAllocPtr alloc,
+                           virResctrlInfoPerTypePtr i_type,
+                           virResctrlAllocPerTypePtr f_type,
+                           unsigned int level,
+                           unsigned int type,
+                           unsigned int cache)
+ {
+-    unsigned long long *size = a_type->sizes[cache];
++    unsigned long long *size = alloc->levels[level]->types[type]->sizes[cache];
+     virBitmapPtr a_mask = NULL;
+     virBitmapPtr f_mask = NULL;
+     unsigned long long need_bits;
+@@ -1293,6 +1280,7 @@ virResctrlAllocFindUnused(virResctrlAllocPerTypePtr a_type,
+     ssize_t pos = -1;
+     ssize_t last_bits = 0;
+     ssize_t last_pos = -1;
++    int ret = -1;
+ 
+     if (!size)
+         return 0;
+@@ -1384,17 +1372,16 @@ virResctrlAllocFindUnused(virResctrlAllocPerTypePtr a_type,
+     if (!a_mask)
+         return -1;
+ 
+-    for (i = last_pos; i < last_pos + need_bits; i++) {
++    for (i = last_pos; i < last_pos + need_bits; i++)
+         ignore_value(virBitmapSetBit(a_mask, i));
+-        ignore_value(virBitmapClearBit(f_mask, i));
+-    }
+ 
+-    if (virResctrlAllocSetMask(a_type, cache, a_mask) < 0) {
+-        virBitmapFree(a_mask);
+-        return -1;
+-    }
++    if (virResctrlAllocUpdateMask(alloc, level, type, cache, a_mask) < 0)
++        goto cleanup;
+ 
+-    return 0;
++    ret = 0;
++ cleanup:
++    virBitmapFree(a_mask);
++    return ret;
+ }
+ 
+ 
+@@ -1500,7 +1487,7 @@ virResctrlAllocMasksAssign(virResctrlInfoPtr resctrl,
+                 virResctrlInfoPerLevelPtr i_level = resctrl->levels[level];
+                 virResctrlInfoPerTypePtr i_type = i_level->types[type];
+ 
+-                if (virResctrlAllocFindUnused(a_type, i_type, f_type, level, type, cache) < 0)
++                if (virResctrlAllocFindUnused(alloc, i_type, f_type, level, type, cache) < 0)
+                     goto cleanup;
+             }
+         }
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Extract-path-formatting-into-virResctrlAllocDeterminePath.patch b/SOURCES/libvirt-util-Extract-path-formatting-into-virResctrlAllocDeterminePath.patch
new file mode 100644
index 0000000..daa5237
--- /dev/null
+++ b/SOURCES/libvirt-util-Extract-path-formatting-into-virResctrlAllocDeterminePath.patch
@@ -0,0 +1,98 @@
+From f2a6092c61d5ef0f2648529a8c141d5f85551da1 Mon Sep 17 00:00:00 2001
+Message-Id: <f2a6092c61d5ef0f2648529a8c141d5f85551da1@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:44 +0100
+Subject: [PATCH] util: Extract path formatting into
+ virResctrlAllocDeterminePath
+
+We can use this from more places later, so just a future code de-duplication.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit b9ceacba7cd32eac55f383495319807430627b4c)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/libvirt_private.syms |  1 +
+ src/util/virresctrl.c    | 29 ++++++++++++++++++++---------
+ src/util/virresctrl.h    |  4 ++++
+ 3 files changed, 25 insertions(+), 9 deletions(-)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index ee75e09767..9c64d0cb97 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -2549,6 +2549,7 @@ virCacheTypeFromString;
+ virCacheTypeToString;
+ virResctrlAllocAddPID;
+ virResctrlAllocCreate;
++virResctrlAllocDeterminePath;
+ virResctrlAllocForeachSize;
+ virResctrlAllocFormat;
+ virResctrlAllocGetID;
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index fdd1ded6f7..e1c4998f71 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -1501,6 +1501,25 @@ virResctrlAllocMasksAssign(virResctrlInfoPtr resctrl,
+ }
+ 
+ 
++int
++virResctrlAllocDeterminePath(virResctrlAllocPtr alloc,
++                             const char *machinename)
++{
++    if (!alloc->id) {
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("Resctrl Allocation ID must be set before creation"));
++        return -1;
++    }
++
++    if (!alloc->path &&
++        virAsprintf(&alloc->path, "%s/%s-%s",
++                    SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
++        return -1;
++
++    return 0;
++}
++
++
+ /* This checks if the directory for the alloc exists.  If not it tries to create
+  * it and apply appropriate alloc settings. */
+ int
+@@ -1522,15 +1541,7 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl,
+         return -1;
+     }
+ 
+-    if (!alloc->id) {
+-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+-                       _("Resctrl Allocation ID must be set before creation"));
+-        return -1;
+-    }
+-
+-    if (!alloc->path &&
+-        virAsprintf(&alloc->path, "%s/%s-%s",
+-                    SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
++    if (virResctrlAllocDeterminePath(alloc, machinename) < 0)
+         return -1;
+ 
+     if (virFileExists(alloc->path)) {
+diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
+index 63a954feaa..5368ba2119 100644
+--- a/src/util/virresctrl.h
++++ b/src/util/virresctrl.h
+@@ -102,6 +102,10 @@ virResctrlAllocGetID(virResctrlAllocPtr alloc);
+ char *
+ virResctrlAllocFormat(virResctrlAllocPtr alloc);
+ 
++int
++virResctrlAllocDeterminePath(virResctrlAllocPtr alloc,
++                             const char *machinename);
++
+ int
+ virResctrlAllocCreate(virResctrlInfoPtr r_info,
+                       virResctrlAllocPtr alloc,
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Fix-leak-in-virStringTrimOptionalNewline.patch b/SOURCES/libvirt-util-Fix-leak-in-virStringTrimOptionalNewline.patch
new file mode 100644
index 0000000..1f50cfc
--- /dev/null
+++ b/SOURCES/libvirt-util-Fix-leak-in-virStringTrimOptionalNewline.patch
@@ -0,0 +1,41 @@
+From 38a50c517836b12720b963c498e303d677ec434c Mon Sep 17 00:00:00 2001
+Message-Id: <38a50c517836b12720b963c498e303d677ec434c@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:23 +0100
+Subject: [PATCH] util: Fix leak in virStringTrimOptionalNewline
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Do not access any data if strlen() == 0.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit ea7b2a6d04f5c354b1cda941362ba8ac42e92278)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virstring.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/src/util/virstring.c b/src/util/virstring.c
+index eac4774b53..b2ebce27ff 100644
+--- a/src/util/virstring.c
++++ b/src/util/virstring.c
+@@ -1394,9 +1394,13 @@ virStringEncodeBase64(const uint8_t *buf, size_t buflen)
+  */
+ void virStringTrimOptionalNewline(char *str)
+ {
+-    char *tmp = str + strlen(str) - 1;
+-    if (*tmp == '\n')
+-        *tmp = '\0';
++    size_t len = strlen(str);
++
++    if (!len)
++        return;
++
++    if (str[len - 1] == '\n')
++        str[len - 1] = '\0';
+ }
+ 
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Fix-possible-leak-in-virResctrlAllocMasksAssign.patch b/SOURCES/libvirt-util-Fix-possible-leak-in-virResctrlAllocMasksAssign.patch
new file mode 100644
index 0000000..ca3f860
--- /dev/null
+++ b/SOURCES/libvirt-util-Fix-possible-leak-in-virResctrlAllocMasksAssign.patch
@@ -0,0 +1,38 @@
+From 7d3283c2747833de50eab930209c16896885761a Mon Sep 17 00:00:00 2001
+Message-Id: <7d3283c2747833de50eab930209c16896885761a@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Fri, 2 Feb 2018 15:21:26 +0100
+Subject: [PATCH] util: Fix possible leak in virResctrlAllocMasksAssign
+
+Found by coverity.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 679543449c0488f3b6f4c5671eee70a86cfa03ec)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1540817
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index e1c4998f71..70426199ce 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -1444,10 +1444,10 @@ virResctrlAllocMasksAssign(virResctrlInfoPtr resctrl,
+ 
+     alloc_default = virResctrlAllocGetDefault(resctrl);
+     if (!alloc_default)
+-        return -1;
++        goto cleanup;
+ 
+     if (virResctrlAllocCopyMasks(alloc, alloc_default) < 0)
+-        return -1;
++        goto cleanup;
+ 
+     for (level = 0; level < alloc->nlevels; level++) {
+         virResctrlAllocPerLevelPtr a_level = alloc->levels[level];
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Introduce-virBitmapNewString.patch b/SOURCES/libvirt-util-Introduce-virBitmapNewString.patch
new file mode 100644
index 0000000..36b9b7b
--- /dev/null
+++ b/SOURCES/libvirt-util-Introduce-virBitmapNewString.patch
@@ -0,0 +1,168 @@
+From 75d7a0195b91b16116e5ad37d2cdd2374c80ef1b Mon Sep 17 00:00:00 2001
+Message-Id: <75d7a0195b91b16116e5ad37d2cdd2374c80ef1b@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:14 +0100
+Subject: [PATCH] util: Introduce virBitmapNewString
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Our bitmaps can be represented as data (raw bytes for which we have
+virBitmapNewData() and virBitmapToData()), human representation (list
+of numbers in a string for which we have virBitmapParse() and
+virBitmapFormat()) and hexadecimal string (for which we have only
+virBitmapToString()).  So let's add the missing complement for the
+last one so that we can parse hexadecimal strings.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 2e5579a43b45e55d744cac9f62aaa901e2587fee)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/libvirt_private.syms |  1 +
+ src/util/virbitmap.c     | 38 ++++++++++++++++++++++++++++++++++++++
+ src/util/virbitmap.h     |  4 ++++
+ tests/virbitmaptest.c    | 38 ++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 81 insertions(+)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index f1c6786ecf..1d895a3bf6 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -1372,6 +1372,7 @@ virBitmapNewCopy;
+ virBitmapNewData;
+ virBitmapNewEmpty;
+ virBitmapNewQuiet;
++virBitmapNewString;
+ virBitmapNextClearBit;
+ virBitmapNextSetBit;
+ virBitmapOverlaps;
+diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
+index b1c1236fd3..47d16ee222 100644
+--- a/src/util/virbitmap.c
++++ b/src/util/virbitmap.c
+@@ -36,6 +36,7 @@
+ #include "c-ctype.h"
+ #include "count-one-bits.h"
+ #include "virstring.h"
++#include "virutil.h"
+ #include "virerror.h"
+ 
+ #define VIR_FROM_THIS VIR_FROM_NONE
+@@ -1071,6 +1072,43 @@ virBitmapCountBits(virBitmapPtr bitmap)
+     return ret;
+ }
+ 
++
++/**
++ * virBitmapNewString:
++ * @string: the string to be converted to a bitmap
++ *
++ * Allocate a bitmap from a string of hexadecimal data.
++ *
++ * Returns a pointer to the allocated bitmap or NULL if
++ * memory cannot be allocated.
++ */
++virBitmapPtr
++virBitmapNewString(const char *string)
++{
++    virBitmapPtr bitmap;
++    size_t i = 0;
++    size_t len = strlen(string);
++
++    if (strspn(string, "0123456789abcdefABCDEF") != len) {
++        virReportError(VIR_ERR_INVALID_ARG,
++                       _("Invalid hexadecimal string '%s'"), string);
++        return NULL;
++    }
++
++    bitmap = virBitmapNew(len * 4);
++    if (!bitmap)
++        return NULL;
++
++    for (i = 0; i < len; i++) {
++        unsigned long nibble = virHexToBin(string[len - i - 1]);
++        nibble <<= VIR_BITMAP_BIT_OFFSET(i * 4);
++        bitmap->map[VIR_BITMAP_UNIT_OFFSET(i * 4)] |= nibble;
++    }
++
++    return bitmap;
++}
++
++
+ /**
+  * virBitmapDataFormat:
+  * @data: the data
+diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
+index 02acb7519d..e964a3edc9 100644
+--- a/src/util/virbitmap.h
++++ b/src/util/virbitmap.h
+@@ -80,6 +80,10 @@ bool virBitmapIsBitSet(virBitmapPtr bitmap, size_t b)
+ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
+ 
++virBitmapPtr
++virBitmapNewString(const char *string)
++    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
++
+ char *virBitmapToString(virBitmapPtr bitmap, bool prefix, bool trim)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+ 
+diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
+index 75cdddf9a7..9daa8316f3 100644
+--- a/tests/virbitmaptest.c
++++ b/tests/virbitmaptest.c
+@@ -663,6 +663,42 @@ test12(const void *opaque ATTRIBUTE_UNUSED)
+     return ret;
+ }
+ 
++
++/* virBitmap(New/To)String */
++static int
++test13(const void *opaque ATTRIBUTE_UNUSED)
++{
++    virBitmapPtr map = NULL;
++    const char *strings[] = { "1234feebee", "000c0fefe" };
++    char *str = NULL;
++    size_t i = 0;
++    int ret = -1;
++
++    for (i = 0; i < ARRAY_CARDINALITY(strings); i++) {
++        map = virBitmapNewString(strings[i]);
++        str = virBitmapToString(map, false, true);
++
++        if (!map || !str)
++            goto cleanup;
++
++        if (STRNEQ(strings[i], str)) {
++            fprintf(stderr, "\n expected bitmap string '%s' actual string "
++                    "'%s'\n", strings[i], str);
++            goto cleanup;
++        }
++
++        VIR_FREE(str);
++        virBitmapFree(map);
++        map = NULL;
++    }
++
++    ret = 0;
++ cleanup:
++    VIR_FREE(str);
++    virBitmapFree(map);
++    return ret;
++}
++
+ #undef TEST_MAP
+ 
+ 
+@@ -711,6 +747,8 @@ mymain(void)
+ 
+     if (virTestRun("test12", test12, NULL) < 0)
+         ret = -1;
++    if (virTestRun("test13", test13, NULL) < 0)
++        ret = -1;
+ 
+     return ret;
+ }
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Introduce-virBitmapShrink.patch b/SOURCES/libvirt-util-Introduce-virBitmapShrink.patch
new file mode 100644
index 0000000..eabf3c6
--- /dev/null
+++ b/SOURCES/libvirt-util-Introduce-virBitmapShrink.patch
@@ -0,0 +1,82 @@
+From e743acc0093fdb790509f64014ad8858ecfe0839 Mon Sep 17 00:00:00 2001
+Message-Id: <e743acc0093fdb790509f64014ad8858ecfe0839@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:16 +0100
+Subject: [PATCH] util: Introduce virBitmapShrink
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Sometimes the size of the bitmap matters and it might not be guessed correctly
+when parsing from some type of input.  For example virBitmapNewData() has Byte
+granularity, virBitmapNewString() has nibble granularity and so on.
+virBitmapParseUnlimited() can be tricked into creating huge bitmap that's not
+needed (e.g.: "0-2,^99999999").  This function provides a way to shrink the
+bitmap.  It is not supposed to free any memory.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit baca005367cf60743f67df44440fc316e6d20c19)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/libvirt_private.syms |  1 +
+ src/util/virbitmap.c     | 23 +++++++++++++++++++++++
+ src/util/virbitmap.h     |  2 ++
+ 3 files changed, 26 insertions(+)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 8cc8cbcc90..7dd4621b70 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -1382,6 +1382,7 @@ virBitmapParseUnlimited;
+ virBitmapSetAll;
+ virBitmapSetBit;
+ virBitmapSetBitExpand;
++virBitmapShrink;
+ virBitmapSize;
+ virBitmapSubtract;
+ virBitmapToData;
+diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
+index 7338f0255a..b2c5c7a6a5 100644
+--- a/src/util/virbitmap.c
++++ b/src/util/virbitmap.c
+@@ -1196,3 +1196,26 @@ virBitmapSubtract(virBitmapPtr a,
+     for (i = 0; i < max; i++)
+         a->map[i] &= ~b->map[i];
+ }
++
++
++/**
++ * virBitmapShrink:
++ * @map: Pointer to bitmap
++ * @b: last bit position to be excluded from bitmap
++ *
++ * Resizes the bitmap so that no more than @b bits will fit into it.  Nothing
++ * will change if the size is already smaller than @b.
++ *
++ * NB: Does not adjust the map->map_len so that a subsequent virBitmapExpand
++ * doesn't necessarily need to reallocate.
++ */
++void
++virBitmapShrink(virBitmapPtr map,
++                size_t b)
++{
++    if (!map)
++        return;
++
++    if (map->max_bit >= b)
++        map->max_bit = b;
++}
+diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
+index 7b2bea8b53..2464814055 100644
+--- a/src/util/virbitmap.h
++++ b/src/util/virbitmap.h
+@@ -153,4 +153,6 @@ void virBitmapIntersect(virBitmapPtr a, virBitmapPtr b)
+ void virBitmapSubtract(virBitmapPtr a, virBitmapPtr b)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+ 
++void virBitmapShrink(virBitmapPtr map, size_t b);
++
+ #endif
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Introduce-virFormatIntPretty.patch b/SOURCES/libvirt-util-Introduce-virFormatIntPretty.patch
new file mode 100644
index 0000000..5208622
--- /dev/null
+++ b/SOURCES/libvirt-util-Introduce-virFormatIntPretty.patch
@@ -0,0 +1,114 @@
+From 155bc6e4428d2a01a1b63f0a4221211c2116e893 Mon Sep 17 00:00:00 2001
+Message-Id: <155bc6e4428d2a01a1b63f0a4221211c2116e893@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:09 +0100
+Subject: [PATCH] util: Introduce virFormatIntPretty
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+We can't output better memory sizes if we want to be compatible with libvirt
+older than the one which introduced /memory/unit, but for new things we can just
+output nicer capacity to the user if available.  And this function enables that.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 87a8a30d613dd2061377aa46fa6e9a05e12aa1b4)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/libvirt_private.syms |  1 +
+ src/util/virutil.c       | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
+ src/util/virutil.h       |  4 ++++
+ 3 files changed, 56 insertions(+)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 57999e77b0..5a87276a2e 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -2938,6 +2938,7 @@ virDoubleToStr;
+ virEnumFromString;
+ virEnumToString;
+ virFormatIntDecimal;
++virFormatIntPretty;
+ virGetDeviceID;
+ virGetDeviceUnprivSGIO;
+ virGetEnvAllowSUID;
+diff --git a/src/util/virutil.c b/src/util/virutil.c
+index 170e921920..2379cf019d 100644
+--- a/src/util/virutil.c
++++ b/src/util/virutil.c
+@@ -485,6 +485,57 @@ virFormatIntDecimal(char *buf, size_t buflen, int val)
+ }
+ 
+ 
++/**
++ * virFormatIntPretty
++ *
++ * @val: Value in bytes to be shortened
++ * @unit: unit to be used
++ *
++ * Similar to vshPrettyCapacity, but operates on integers and not doubles
++ *
++ * Returns shortened value that can be used with @unit.
++ */
++unsigned long long
++virFormatIntPretty(unsigned long long val,
++                   const char **unit)
++{
++    unsigned long long limit = 1024;
++
++    if (val % limit || val == 0) {
++        *unit = "B";
++        return val;
++    }
++    limit *= 1024;
++    if (val % limit) {
++        *unit = "KiB";
++        return val / (limit / 1024);
++    }
++    limit *= 1024;
++    if (val % limit) {
++        *unit = "MiB";
++        return val / (limit / 1024);
++    }
++    limit *= 1024;
++    if (val % limit) {
++        *unit = "GiB";
++        return val / (limit / 1024);
++    }
++    limit *= 1024;
++    if (val % limit) {
++        *unit = "TiB";
++        return val / (limit / 1024);
++    }
++    limit *= 1024;
++    if (val % limit) {
++        *unit = "PiB";
++        return val / (limit / 1024);
++    }
++    limit *= 1024;
++    *unit = "EiB";
++    return val / (limit / 1024);
++}
++
++
+ const char *virEnumToString(const char *const*types,
+                             unsigned int ntypes,
+                             int type)
+diff --git a/src/util/virutil.h b/src/util/virutil.h
+index a862a8a637..9ee728235f 100644
+--- a/src/util/virutil.h
++++ b/src/util/virutil.h
+@@ -66,6 +66,10 @@ int virParseVersionString(const char *str, unsigned long *version,
+ char *virFormatIntDecimal(char *buf, size_t buflen, int val)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+ 
++unsigned long long
++virFormatIntPretty(unsigned long long val,
++                   const char **unit);
++
+ int virDiskNameParse(const char *name, int *disk, int *partition);
+ int virDiskNameToIndex(const char* str);
+ char *virIndexToDiskName(int idx, const char *prefix);
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Make-it-possible-for-virResctrlAllocSetMask-to-replace-existing-mask.patch b/SOURCES/libvirt-util-Make-it-possible-for-virResctrlAllocSetMask-to-replace-existing-mask.patch
new file mode 100644
index 0000000..bd7507f
--- /dev/null
+++ b/SOURCES/libvirt-util-Make-it-possible-for-virResctrlAllocSetMask-to-replace-existing-mask.patch
@@ -0,0 +1,35 @@
+From a4c7051325a78ece1923633d734903f1596a80d6 Mon Sep 17 00:00:00 2001
+Message-Id: <a4c7051325a78ece1923633d734903f1596a80d6@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:37 +0100
+Subject: [PATCH] util: Make it possible for virResctrlAllocSetMask to replace
+ existing mask
+
+This wil be used in the future, but it makes sense for now as well.  It makes
+sure there is no mask leftover that would leak.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 6899118043ec4e6bd35f1641fe71dc67bfce3859)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index a1d09c547e..89b1382b68 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -1239,6 +1239,7 @@ virResctrlAllocSetMask(virResctrlAllocPerTypePtr a_type,
+                      cache - a_type->nmasks + 1) < 0)
+         return -1;
+ 
++    virBitmapFree(a_type->masks[cache]);
+     a_type->masks[cache] = mask;
+ 
+     return 0;
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Make-prefix-optional-in-virBitampString.patch b/SOURCES/libvirt-util-Make-prefix-optional-in-virBitampString.patch
new file mode 100644
index 0000000..ae2e12c
--- /dev/null
+++ b/SOURCES/libvirt-util-Make-prefix-optional-in-virBitampString.patch
@@ -0,0 +1,84 @@
+From c5355b3f4b45e1a0a432ba7ee420649ef5c4c4a5 Mon Sep 17 00:00:00 2001
+Message-Id: <c5355b3f4b45e1a0a432ba7ee420649ef5c4c4a5@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:10 +0100
+Subject: [PATCH] util: Make prefix optional in virBitampString
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit d127aced0a694b8158074e167c8c1db03bbc2df1)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/qemu/qemu_capabilities.c | 4 ++--
+ src/util/virbitmap.c         | 8 ++++++--
+ src/util/virbitmap.h         | 2 +-
+ 3 files changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index bd80edc978..d6bd28d072 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -1525,7 +1525,7 @@ int virQEMUCapsParseHelpStr(const char *qemu,
+                                    qemuCaps, check_yajl) < 0)
+         goto cleanup;
+ 
+-    strflags = virBitmapString(qemuCaps->flags);
++    strflags = virBitmapString(qemuCaps->flags, true);
+     VIR_DEBUG("Version %u.%u.%u, cooked version %u, flags %s",
+               major, minor, micro, *version, NULLSTR(strflags));
+     VIR_FREE(strflags);
+@@ -2407,7 +2407,7 @@ virQEMUCapsClear(virQEMUCapsPtr qemuCaps,
+ 
+ char *virQEMUCapsFlagsString(virQEMUCapsPtr qemuCaps)
+ {
+-    return virBitmapString(qemuCaps->flags);
++    return virBitmapString(qemuCaps->flags, true);
+ }
+ 
+ 
+diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
+index 57a8fbf82c..f08384ff1c 100644
+--- a/src/util/virbitmap.c
++++ b/src/util/virbitmap.c
+@@ -312,17 +312,21 @@ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
+ /**
+  * virBitmapString:
+  * @bitmap: Pointer to bitmap
++ * @prefix: Whether to prepend "0x"
+  *
+  * Convert @bitmap to printable string.
+  *
+  * Returns pointer to the string or NULL on error.
+  */
+-char *virBitmapString(virBitmapPtr bitmap)
++char *
++virBitmapString(virBitmapPtr bitmap,
++                bool prefix)
+ {
+     virBuffer buf = VIR_BUFFER_INITIALIZER;
+     size_t sz;
+ 
+-    virBufferAddLit(&buf, "0x");
++    if (prefix)
++        virBufferAddLit(&buf, "0x");
+ 
+     sz = bitmap->map_len;
+ 
+diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
+index ffa3c42d79..dc8fb71a07 100644
+--- a/src/util/virbitmap.h
++++ b/src/util/virbitmap.h
+@@ -80,7 +80,7 @@ bool virBitmapIsBitSet(virBitmapPtr bitmap, size_t b)
+ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
+ 
+-char *virBitmapString(virBitmapPtr bitmap)
++char *virBitmapString(virBitmapPtr bitmap, bool prefix)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+ 
+ char *virBitmapFormat(virBitmapPtr bitmap);
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Reintroduce-virBitmapSubtract.patch b/SOURCES/libvirt-util-Reintroduce-virBitmapSubtract.patch
new file mode 100644
index 0000000..b51e276
--- /dev/null
+++ b/SOURCES/libvirt-util-Reintroduce-virBitmapSubtract.patch
@@ -0,0 +1,139 @@
+From cfbc47467f2174875f63493458a2f350ec21b65d Mon Sep 17 00:00:00 2001
+Message-Id: <cfbc47467f2174875f63493458a2f350ec21b65d@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:15 +0100
+Subject: [PATCH] util: Reintroduce virBitmapSubtract
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Already introduced in the past with 9479642fd3c5, but then renamed to
+virBitmapIntersect by a908e9e45eb2.  This time we'll really use it.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 449442c34d20753ca57852d9d7957dd7ba868fae)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/libvirt_private.syms |  1 +
+ src/util/virbitmap.c     | 22 ++++++++++++++++++++++
+ src/util/virbitmap.h     |  3 +++
+ tests/virbitmaptest.c    | 42 ++++++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 68 insertions(+)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 1d895a3bf6..8cc8cbcc90 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -1383,6 +1383,7 @@ virBitmapSetAll;
+ virBitmapSetBit;
+ virBitmapSetBitExpand;
+ virBitmapSize;
++virBitmapSubtract;
+ virBitmapToData;
+ virBitmapToDataBuf;
+ virBitmapToString;
+diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
+index 47d16ee222..7338f0255a 100644
+--- a/src/util/virbitmap.c
++++ b/src/util/virbitmap.c
+@@ -1174,3 +1174,25 @@ virBitmapIntersect(virBitmapPtr a,
+     for (i = 0; i < max; i++)
+         a->map[i] &= b->map[i];
+ }
++
++
++/**
++ * virBitmapSubtract:
++ * @a: minuend/result
++ * @b: subtrahend
++ *
++ * Performs subtraction of two bitmaps: a = a - b
++ */
++void
++virBitmapSubtract(virBitmapPtr a,
++                  virBitmapPtr b)
++{
++    size_t i;
++    size_t max = a->map_len;
++
++    if (max > b->map_len)
++        max = b->map_len;
++
++    for (i = 0; i < max; i++)
++        a->map[i] &= ~b->map[i];
++}
+diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
+index e964a3edc9..7b2bea8b53 100644
+--- a/src/util/virbitmap.h
++++ b/src/util/virbitmap.h
+@@ -150,4 +150,7 @@ bool virBitmapOverlaps(virBitmapPtr b1,
+ void virBitmapIntersect(virBitmapPtr a, virBitmapPtr b)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+ 
++void virBitmapSubtract(virBitmapPtr a, virBitmapPtr b)
++    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
++
+ #endif
+diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
+index 9daa8316f3..5bf30b2b1c 100644
+--- a/tests/virbitmaptest.c
++++ b/tests/virbitmaptest.c
+@@ -701,6 +701,39 @@ test13(const void *opaque ATTRIBUTE_UNUSED)
+ 
+ #undef TEST_MAP
+ 
++static int
++test14(const void *opaque)
++{
++    const struct testBinaryOpData *data = opaque;
++    virBitmapPtr amap = NULL;
++    virBitmapPtr bmap = NULL;
++    virBitmapPtr resmap = NULL;
++    int ret = -1;
++
++    if (virBitmapParse(data->a, &amap, 256) < 0 ||
++        virBitmapParse(data->b, &bmap, 256) < 0 ||
++        virBitmapParse(data->res, &resmap, 256) < 0)
++        goto cleanup;
++
++    virBitmapSubtract(amap, bmap);
++
++    if (!virBitmapEqual(amap, resmap)) {
++        fprintf(stderr,
++                "\n bitmap subtraction failed: '%s' - '%s' != '%s'\n",
++                data->a, data->b, data->res);
++        goto cleanup;
++    }
++
++    ret = 0;
++
++ cleanup:
++    virBitmapFree(amap);
++    virBitmapFree(bmap);
++    virBitmapFree(resmap);
++
++    return ret;
++}
++
+ 
+ #define TESTBINARYOP(A, B, RES, FUNC)                                         \
+     testBinaryOpData.a = A;                                                   \
+@@ -750,6 +783,15 @@ mymain(void)
+     if (virTestRun("test13", test13, NULL) < 0)
+         ret = -1;
+ 
++    virTestCounterReset("test14-");
++    TESTBINARYOP("0", "0", "0,^0", test14);
++    TESTBINARYOP("0-3", "0", "1-3", test14);
++    TESTBINARYOP("0-3", "0,3", "1-2", test14);
++    TESTBINARYOP("0,^0", "0", "0,^0", test14);
++    TESTBINARYOP("0-3", "0-3", "0,^0", test14);
++    TESTBINARYOP("0-3", "0,^0", "0-3", test14);
++    TESTBINARYOP("0,2", "1,3", "0,2", test14);
++
+     return ret;
+ }
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Remove-now-unneeded-resctrl-functions.patch b/SOURCES/libvirt-util-Remove-now-unneeded-resctrl-functions.patch
new file mode 100644
index 0000000..c0c2ca4
--- /dev/null
+++ b/SOURCES/libvirt-util-Remove-now-unneeded-resctrl-functions.patch
@@ -0,0 +1,193 @@
+From 5965fa7d3b6a473b47457f9a21ce0229c3d7464b Mon Sep 17 00:00:00 2001
+Message-Id: <5965fa7d3b6a473b47457f9a21ce0229c3d7464b@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:27 +0100
+Subject: [PATCH] util: Remove now-unneeded resctrl functions
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit 6328e48713c0730797d82a03d154a00b62625c3a)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/libvirt_private.syms |   2 -
+ src/util/virresctrl.c    | 132 -----------------------------------------------
+ src/util/virresctrl.h    |  11 ----
+ 3 files changed, 145 deletions(-)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index e0e0046522..02bad6c0ce 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -2547,8 +2547,6 @@ virRandomInt;
+ # util/virresctrl.h
+ virCacheTypeFromString;
+ virCacheTypeToString;
+-virResctrlGetCacheControlType;
+-virResctrlGetCacheInfo;
+ virResctrlGetInfo;
+ virResctrlInfoGetCache;
+ virResctrlInfoNew;
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index 7ab68c6f74..f122af2050 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -358,135 +358,3 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
+     VIR_FREE(*controls);
+     goto cleanup;
+ }
+-
+-
+-int
+-virResctrlGetCacheInfo(unsigned int level,
+-                       unsigned long long size,
+-                       virCacheType scope,
+-                       virResctrlInfoPerCachePtr **controls,
+-                       size_t *ncontrols)
+-{
+-    int ret = -1;
+-    char *tmp = NULL;
+-    char *path = NULL;
+-    char *cbm_mask = NULL;
+-    char *type_upper = NULL;
+-    unsigned int bits = 0;
+-    unsigned int min_cbm_bits = 0;
+-    virResctrlInfoPerCachePtr control;
+-
+-    if (VIR_ALLOC(control) < 0)
+-        goto cleanup;
+-
+-    if (scope != VIR_CACHE_TYPE_BOTH &&
+-        virStringToUpper(&type_upper, virCacheTypeToString(scope)) < 0)
+-        goto cleanup;
+-
+-    if (virFileReadValueUint(&control->max_allocation,
+-                             SYSFS_RESCTRL_PATH "/info/L%u%s/num_closids",
+-                             level,
+-                             type_upper ? type_upper : "") < 0)
+-        goto cleanup;
+-
+-    if (virFileReadValueString(&cbm_mask,
+-                               SYSFS_RESCTRL_PATH
+-                               "/info/L%u%s/cbm_mask",
+-                               level,
+-                               type_upper ? type_upper: "") < 0)
+-        goto cleanup;
+-
+-    if (virFileReadValueUint(&min_cbm_bits,
+-                             SYSFS_RESCTRL_PATH "/info/L%u%s/min_cbm_bits",
+-                             level,
+-                             type_upper ? type_upper : "") < 0)
+-        goto cleanup;
+-
+-    virStringTrimOptionalNewline(cbm_mask);
+-
+-    for (tmp = cbm_mask; *tmp != '\0'; tmp++) {
+-        if (c_isxdigit(*tmp))
+-            bits += count_one_bits(virHexToBin(*tmp));
+-    }
+-
+-    control->granularity = size / bits;
+-    if (min_cbm_bits != 1)
+-        control->min = min_cbm_bits * control->granularity;
+-
+-    control->scope = scope;
+-
+-    if (VIR_APPEND_ELEMENT(*controls, *ncontrols, control) < 0)
+-        goto cleanup;
+-
+-    ret = 0;
+-
+- cleanup:
+-    VIR_FREE(path);
+-    VIR_FREE(cbm_mask);
+-    VIR_FREE(type_upper);
+-    VIR_FREE(control);
+-    return ret;
+-}
+-
+-
+-static inline int
+-virResctrlGetCacheDir(char **path,
+-                      const char *prefix,
+-                      unsigned int level,
+-                      virCacheType type)
+-{
+-    return virAsprintf(path,
+-                       SYSFS_RESCTRL_PATH "%s/L%u%s",
+-                       prefix ? prefix : "",
+-                       level,
+-                       virResctrlTypeToString(type));
+-}
+-
+-
+-/*
+- * This function tests whether TYPE of cache control is supported or not.
+- *
+- * Returns 0 if not, 1 if yes and negative value on error.
+- */
+-static int
+-virResctrlGetCacheSupport(unsigned int level, virCacheType type)
+-{
+-    int ret = -1;
+-    char *path = NULL;
+-
+-    if (virResctrlGetCacheDir(&path, "/info", level, type) < 0)
+-        return -1;
+-
+-    ret = virFileExists(path);
+-    VIR_FREE(path);
+-    return ret;
+-}
+-
+-
+-/*
+- * This function tests which TYPE of cache control is supported
+- * Return values are:
+- *  -1: error
+- *   0: none
+- *   1: CAT
+- *   2: CDP
+- */
+-int
+-virResctrlGetCacheControlType(unsigned int level)
+-{
+-    int rv = -1;
+-
+-    rv = virResctrlGetCacheSupport(level, VIR_CACHE_TYPE_BOTH);
+-    if (rv < 0)
+-        return -1;
+-    if (rv)
+-        return 1;
+-
+-    rv = virResctrlGetCacheSupport(level, VIR_CACHE_TYPE_CODE);
+-    if (rv < 0)
+-        return -1;
+-    if (rv)
+-        return 2;
+-
+-    return 0;
+-}
+diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
+index c7f25c76e1..a81ff687de 100644
+--- a/src/util/virresctrl.h
++++ b/src/util/virresctrl.h
+@@ -65,15 +65,4 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
+                        size_t *ncontrols,
+                        virResctrlInfoPerCachePtr **controls);
+ 
+-/* To be removed */
+-int
+-virResctrlGetCacheInfo(unsigned int level,
+-                       unsigned long long size,
+-                       virCacheType scope,
+-                       virResctrlInfoPerCachePtr **controls,
+-                       size_t *ncontrols);
+-
+-int
+-virResctrlGetCacheControlType(unsigned int level);
+-
+ #endif /*  __VIR_RESCTRL_H__ */
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Remove-unused-variable-in-virResctrlGetInfo.patch b/SOURCES/libvirt-util-Remove-unused-variable-in-virResctrlGetInfo.patch
new file mode 100644
index 0000000..8f36689
--- /dev/null
+++ b/SOURCES/libvirt-util-Remove-unused-variable-in-virResctrlGetInfo.patch
@@ -0,0 +1,39 @@
+From f022e7ba0c41592a8c117b29179cb3c8394210e6 Mon Sep 17 00:00:00 2001
+Message-Id: <f022e7ba0c41592a8c117b29179cb3c8394210e6@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:38 +0100
+Subject: [PATCH] util: Remove unused variable in virResctrlGetInfo
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit e28ccd2643b0c4cf35c4b53876fa46dc23007426)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index 89b1382b68..684cb22fd8 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -392,7 +392,6 @@ int
+ virResctrlGetInfo(virResctrlInfoPtr resctrl)
+ {
+     DIR *dirp = NULL;
+-    char *info_path = NULL;
+     char *endptr = NULL;
+     char *tmp_str = NULL;
+     int ret = -1;
+@@ -507,7 +506,6 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
+     ret = 0;
+  cleanup:
+     VIR_DIR_CLOSE(dirp);
+-    VIR_FREE(info_path);
+     if (i_type)
+         VIR_FREE(i_type->cbm_mask);
+     VIR_FREE(i_type);
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Rename-virBitmapDataToString-to-virBitmapDataFormat.patch b/SOURCES/libvirt-util-Rename-virBitmapDataToString-to-virBitmapDataFormat.patch
new file mode 100644
index 0000000..ce37e38
--- /dev/null
+++ b/SOURCES/libvirt-util-Rename-virBitmapDataToString-to-virBitmapDataFormat.patch
@@ -0,0 +1,144 @@
+From 41bc8c60fd726c0e7724f969796521bfc7a037f8 Mon Sep 17 00:00:00 2001
+Message-Id: <41bc8c60fd726c0e7724f969796521bfc7a037f8@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:12 +0100
+Subject: [PATCH] util: Rename virBitmapDataToString to virBitmapDataFormat
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+It is literally only a wrapper around virBitmapNewData() and
+virBitmapFormat(), only the naming was wrong since it was introduced.
+And because we have virBitmap*String functions where the meaning of
+the 'String' is constant, this might confuse someone.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 5d893ed6ad7f42fb9ae94c6150c9d8aedc5c512b)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/libvirt_private.syms | 2 +-
+ src/util/virbitmap.c     | 6 +++---
+ src/util/virbitmap.h     | 4 ++--
+ tests/virbitmaptest.c    | 6 +++---
+ tools/virsh-domain.c     | 4 ++--
+ tools/virsh-host.c       | 2 +-
+ 6 files changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index d0f2c027fc..f1c6786ecf 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -1357,7 +1357,7 @@ virBitmapClearBit;
+ virBitmapClearBitExpand;
+ virBitmapCopy;
+ virBitmapCountBits;
+-virBitmapDataToString;
++virBitmapDataFormat;
+ virBitmapEqual;
+ virBitmapFormat;
+ virBitmapFree;
+diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
+index e7d04e8c8b..f5700a6424 100644
+--- a/src/util/virbitmap.c
++++ b/src/util/virbitmap.c
+@@ -1046,7 +1046,7 @@ virBitmapCountBits(virBitmapPtr bitmap)
+ }
+ 
+ /**
+- * virBitmapDataToString:
++ * virBitmapDataFormat:
+  * @data: the data
+  * @len: length of @data in bytes
+  *
+@@ -1056,8 +1056,8 @@ virBitmapCountBits(virBitmapPtr bitmap)
+  * Returns: a string representation of the data, or NULL on error
+  */
+ char *
+-virBitmapDataToString(const void *data,
+-                      int len)
++virBitmapDataFormat(const void *data,
++                    int len)
+ {
+     virBitmapPtr map = NULL;
+     char *ret = NULL;
+diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
+index 99eb779d71..720b389cfe 100644
+--- a/src/util/virbitmap.h
++++ b/src/util/virbitmap.h
+@@ -136,8 +136,8 @@ ssize_t virBitmapNextClearBit(virBitmapPtr bitmap, ssize_t pos)
+ size_t virBitmapCountBits(virBitmapPtr bitmap)
+     ATTRIBUTE_NONNULL(1);
+ 
+-char *virBitmapDataToString(const void *data,
+-                            int len)
++char *virBitmapDataFormat(const void *data,
++                          int len)
+     ATTRIBUTE_NONNULL(1);
+ bool virBitmapOverlaps(virBitmapPtr b1,
+                        virBitmapPtr b2)
+diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
+index 76005117e7..75cdddf9a7 100644
+--- a/tests/virbitmaptest.c
++++ b/tests/virbitmaptest.c
+@@ -294,7 +294,7 @@ test4(const void *data ATTRIBUTE_UNUSED)
+     return -1;
+ }
+ 
+-/* test for virBitmapNewData/ToData/DataToString */
++/* test for virBitmapNewData/ToData/DataFormat */
+ static int
+ test5(const void *v ATTRIBUTE_UNUSED)
+ {
+@@ -336,12 +336,12 @@ test5(const void *v ATTRIBUTE_UNUSED)
+         data2[4] != 0x04)
+         goto error;
+ 
+-    if (!(str = virBitmapDataToString(data, sizeof(data))))
++    if (!(str = virBitmapDataFormat(data, sizeof(data))))
+         goto error;
+     if (STRNEQ(str, "0,9,34"))
+         goto error;
+     VIR_FREE(str);
+-    if (!(str = virBitmapDataToString(data2, len2)))
++    if (!(str = virBitmapDataFormat(data2, len2)))
+         goto error;
+     if (STRNEQ(str, "0,2,9,15,34"))
+         goto error;
+diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
+index 1e33e82959..7547cf134f 100644
+--- a/tools/virsh-domain.c
++++ b/tools/virsh-domain.c
+@@ -6527,7 +6527,7 @@ virshVcpuinfoPrintAffinity(vshControl *ctl,
+ 
+     vshPrint(ctl, "%-15s ", _("CPU Affinity:"));
+     if (pretty) {
+-        if (!(str = virBitmapDataToString(cpumap, VIR_CPU_MAPLEN(maxcpu))))
++        if (!(str = virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(maxcpu))))
+             goto cleanup;
+         vshPrint(ctl, _("%s (out of %d)"), str, maxcpu);
+     } else {
+@@ -6781,7 +6781,7 @@ virshPrintPinInfo(vshControl *ctl,
+ {
+     char *str = NULL;
+ 
+-    if (!(str = virBitmapDataToString(cpumap, cpumaplen)))
++    if (!(str = virBitmapDataFormat(cpumap, cpumaplen)))
+         return false;
+ 
+     vshPrint(ctl, "%s", str);
+diff --git a/tools/virsh-host.c b/tools/virsh-host.c
+index 5509065fd6..ecaf830e35 100644
+--- a/tools/virsh-host.c
++++ b/tools/virsh-host.c
+@@ -717,7 +717,7 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
+ 
+     vshPrint(ctl, "%-15s ", _("CPU map:"));
+     if (pretty) {
+-        char *str = virBitmapDataToString(cpumap, VIR_CPU_MAPLEN(cpunum));
++        char *str = virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(cpunum));
+ 
+         if (!str)
+             goto cleanup;
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Rename-virBitmapString-to-virBitmapToString.patch b/SOURCES/libvirt-util-Rename-virBitmapString-to-virBitmapToString.patch
new file mode 100644
index 0000000..4651e11
--- /dev/null
+++ b/SOURCES/libvirt-util-Rename-virBitmapString-to-virBitmapToString.patch
@@ -0,0 +1,100 @@
+From c78834f22a28c110183b885e024b40398a11a267 Mon Sep 17 00:00:00 2001
+Message-Id: <c78834f22a28c110183b885e024b40398a11a267@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:11 +0100
+Subject: [PATCH] util: Rename virBitmapString to virBitmapToString
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+This follows the virBitmapToData() function and, similarly to
+virBitmapNewData(), we'll be able to have virBitmapNewString() later
+on without name confusion.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 68d7cc649c652623e11e36286c9888495543dac4)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/libvirt_private.syms     | 2 +-
+ src/qemu/qemu_capabilities.c | 4 ++--
+ src/util/virbitmap.c         | 6 +++---
+ src/util/virbitmap.h         | 2 +-
+ 4 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 5a87276a2e..d0f2c027fc 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -1382,9 +1382,9 @@ virBitmapSetAll;
+ virBitmapSetBit;
+ virBitmapSetBitExpand;
+ virBitmapSize;
+-virBitmapString;
+ virBitmapToData;
+ virBitmapToDataBuf;
++virBitmapToString;
+ 
+ 
+ # util/virbuffer.h
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index d6bd28d072..5bf188f427 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -1525,7 +1525,7 @@ int virQEMUCapsParseHelpStr(const char *qemu,
+                                    qemuCaps, check_yajl) < 0)
+         goto cleanup;
+ 
+-    strflags = virBitmapString(qemuCaps->flags, true);
++    strflags = virBitmapToString(qemuCaps->flags, true);
+     VIR_DEBUG("Version %u.%u.%u, cooked version %u, flags %s",
+               major, minor, micro, *version, NULLSTR(strflags));
+     VIR_FREE(strflags);
+@@ -2407,7 +2407,7 @@ virQEMUCapsClear(virQEMUCapsPtr qemuCaps,
+ 
+ char *virQEMUCapsFlagsString(virQEMUCapsPtr qemuCaps)
+ {
+-    return virBitmapString(qemuCaps->flags, true);
++    return virBitmapToString(qemuCaps->flags, true);
+ }
+ 
+ 
+diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
+index f08384ff1c..e7d04e8c8b 100644
+--- a/src/util/virbitmap.c
++++ b/src/util/virbitmap.c
+@@ -310,7 +310,7 @@ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
+ }
+ 
+ /**
+- * virBitmapString:
++ * virBitmapToString:
+  * @bitmap: Pointer to bitmap
+  * @prefix: Whether to prepend "0x"
+  *
+@@ -319,8 +319,8 @@ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
+  * Returns pointer to the string or NULL on error.
+  */
+ char *
+-virBitmapString(virBitmapPtr bitmap,
+-                bool prefix)
++virBitmapToString(virBitmapPtr bitmap,
++                  bool prefix)
+ {
+     virBuffer buf = VIR_BUFFER_INITIALIZER;
+     size_t sz;
+diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
+index dc8fb71a07..99eb779d71 100644
+--- a/src/util/virbitmap.h
++++ b/src/util/virbitmap.h
+@@ -80,7 +80,7 @@ bool virBitmapIsBitSet(virBitmapPtr bitmap, size_t b)
+ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
+ 
+-char *virBitmapString(virBitmapPtr bitmap, bool prefix)
++char *virBitmapToString(virBitmapPtr bitmap, bool prefix)
+     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+ 
+ char *virBitmapFormat(virBitmapPtr bitmap);
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Use-default-group-s-mask-for-unspecified-resctrl-allocations.patch b/SOURCES/libvirt-util-Use-default-group-s-mask-for-unspecified-resctrl-allocations.patch
new file mode 100644
index 0000000..4d45206
--- /dev/null
+++ b/SOURCES/libvirt-util-Use-default-group-s-mask-for-unspecified-resctrl-allocations.patch
@@ -0,0 +1,166 @@
+From 4574632d3d8eb9be947f0dd052a5d5a72fc306b7 Mon Sep 17 00:00:00 2001
+Message-Id: <4574632d3d8eb9be947f0dd052a5d5a72fc306b7@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:41 +0100
+Subject: [PATCH] util: Use default group's mask for unspecified resctrl
+ allocations
+
+Introduce virResctrlAllocCopyMasks() and use that to initially copy the default
+group schemata to the allocation before reserving any parts of the cache.  The
+reason for this is that when new group is created the schemata will have unknown
+data in it.  If there was previously group with the same CLoS ID, it will have
+the previous valies, if not it will have all bits set.  And we need to set all
+unspecified (in the XML) allocations to the same one as the default group.
+
+Some non-Linux functions now need to be made public due to this change.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit c39ce914dd88c35a66d1088f0688da24fea8cfcd)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virresctrl.c | 72 +++++++++++++++++++++++++++++++++++----------------
+ 1 file changed, 50 insertions(+), 22 deletions(-)
+
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index df6461a046..a0ea274871 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -667,8 +667,6 @@ virResctrlAllocGetType(virResctrlAllocPtr resctrl,
+ }
+ 
+ 
+-#ifdef __linux__
+-
+ static int
+ virResctrlAllocUpdateMask(virResctrlAllocPtr resctrl,
+                           unsigned int level,
+@@ -696,8 +694,6 @@ virResctrlAllocUpdateMask(virResctrlAllocPtr resctrl,
+     return virBitmapCopy(a_type->masks[cache], mask);
+ }
+ 
+-#endif
+-
+ 
+ static int
+ virResctrlAllocUpdateSize(virResctrlAllocPtr resctrl,
+@@ -917,8 +913,6 @@ virResctrlAllocFormat(virResctrlAllocPtr resctrl)
+ }
+ 
+ 
+-#ifdef __linux__
+-
+ static int
+ virResctrlAllocParseProcessCache(virResctrlInfoPtr resctrl,
+                                  virResctrlAllocPtr alloc,
+@@ -1090,6 +1084,8 @@ virResctrlAllocGetDefault(virResctrlInfoPtr resctrl)
+ }
+ 
+ 
++#ifdef __linux__
++
+ static void
+ virResctrlAllocSubtractPerType(virResctrlAllocPerTypePtr dst,
+                                virResctrlAllocPerTypePtr src)
+@@ -1298,23 +1294,8 @@ virResctrlAllocFindUnused(virResctrlAllocPerTypePtr a_type,
+     ssize_t last_bits = 0;
+     ssize_t last_pos = -1;
+ 
+-    /* If there is no reservation requested we need to set all bits.  That's due
+-     * to weird interface of the resctrl sysfs.  It's also the reason why we
+-     * cannot reserve the whole cache in one allocation. */
+-    if (!size) {
+-        a_mask = virBitmapNew(i_type->bits);
+-        if (!a_mask)
+-            return -1;
+-
+-        virBitmapSetAll(a_mask);
+-
+-        if (virResctrlAllocSetMask(a_type, cache, a_mask) < 0) {
+-            virBitmapFree(a_mask);
+-            return -1;
+-        }
+-
++    if (!size)
+         return 0;
+-    }
+ 
+     if (cache >= f_type->nmasks) {
+         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+@@ -1417,6 +1398,44 @@ virResctrlAllocFindUnused(virResctrlAllocPerTypePtr a_type,
+ }
+ 
+ 
++static int
++virResctrlAllocCopyMasks(virResctrlAllocPtr dst,
++                         virResctrlAllocPtr src)
++{
++    unsigned int level = 0;
++
++    for (level = 0; level < src->nlevels; level++) {
++        virResctrlAllocPerLevelPtr s_level = src->levels[level];
++        unsigned int type = 0;
++
++        if (!s_level)
++            continue;
++
++        for (type = 0; type < VIR_CACHE_TYPE_LAST; type++) {
++            virResctrlAllocPerTypePtr s_type = s_level->types[type];
++            virResctrlAllocPerTypePtr d_type = NULL;
++            unsigned int cache = 0;
++
++            if (!s_type)
++                continue;
++
++            d_type = virResctrlAllocGetType(dst, level, type);
++            if (!d_type)
++                return -1;
++
++            for (cache = 0; cache < s_type->nmasks; cache++) {
++                virBitmapPtr mask = s_type->masks[cache];
++
++                if (mask && virResctrlAllocUpdateMask(dst, level, type, cache, mask) < 0)
++                    return -1;
++            }
++        }
++    }
++
++    return 0;
++}
++
++
+ /*
+  * This function is called when creating an allocation in the system.  What it
+  * does is that it gets all the unused bits using virResctrlAllocGetUnused() and
+@@ -1430,11 +1449,19 @@ virResctrlAllocMasksAssign(virResctrlInfoPtr resctrl,
+     int ret = -1;
+     unsigned int level = 0;
+     virResctrlAllocPtr alloc_free = NULL;
++    virResctrlAllocPtr alloc_default = NULL;
+ 
+     alloc_free = virResctrlAllocGetUnused(resctrl);
+     if (!alloc_free)
+         return -1;
+ 
++    alloc_default = virResctrlAllocGetDefault(resctrl);
++    if (!alloc_default)
++        return -1;
++
++    if (virResctrlAllocCopyMasks(alloc, alloc_default) < 0)
++        return -1;
++
+     for (level = 0; level < alloc->nlevels; level++) {
+         virResctrlAllocPerLevelPtr a_level = alloc->levels[level];
+         virResctrlAllocPerLevelPtr f_level = NULL;
+@@ -1482,6 +1509,7 @@ virResctrlAllocMasksAssign(virResctrlInfoPtr resctrl,
+     ret = 0;
+  cleanup:
+     virObjectUnref(alloc_free);
++    virObjectUnref(alloc_default);
+     return ret;
+ }
+ 
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-Use-resctrl-instead-of-resctrlfs-spelling.patch b/SOURCES/libvirt-util-Use-resctrl-instead-of-resctrlfs-spelling.patch
new file mode 100644
index 0000000..e7981f5
--- /dev/null
+++ b/SOURCES/libvirt-util-Use-resctrl-instead-of-resctrlfs-spelling.patch
@@ -0,0 +1,96 @@
+From db2302bc5e5fa8b67384ca6adc85483ce5e24358 Mon Sep 17 00:00:00 2001
+Message-Id: <db2302bc5e5fa8b67384ca6adc85483ce5e24358@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Wed, 31 Jan 2018 16:32:36 +0100
+Subject: [PATCH] util: Use "resctrl" instead of "resctrlfs" spelling
+
+Pointed out during review on one or two places, but it actually appears in lot
+more places.  So let's be consistent.
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+(cherry picked from commit ebafc603c1ace128927662460d55c1a713ae5225)
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1289368
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/qemu/qemu_process.c |  2 +-
+ src/util/virresctrl.c   | 14 +++++++-------
+ 2 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
+index 57faf9cd79..29a8d8ba53 100644
+--- a/src/qemu/qemu_process.c
++++ b/src/qemu/qemu_process.c
+@@ -5932,7 +5932,7 @@ qemuProcessLaunch(virConnectPtr conn,
+     if (qemuProcessSetupEmulator(vm) < 0)
+         goto cleanup;
+ 
+-    VIR_DEBUG("Setting up resctrlfs");
++    VIR_DEBUG("Setting up resctrl");
+     if (qemuProcessResctrlCreate(driver, vm) < 0)
+         goto cleanup;
+ 
+diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
+index 03218a481d..a1d09c547e 100644
+--- a/src/util/virresctrl.c
++++ b/src/util/virresctrl.c
+@@ -76,7 +76,7 @@ struct _virResctrlInfoPerType {
+     unsigned int max_cache_id;
+ 
+     /* In order to be self-sufficient we need size information per cache.
+-     * Funnily enough, one of the outcomes of the resctrlfs design is that it
++     * Funnily enough, one of the outcomes of the resctrl design is that it
+      * does not account for different sizes per cache on the same level.  So
+      * for the sake of easiness, let's copy that, for now. */
+     unsigned long long size;
+@@ -302,12 +302,12 @@ virResctrlLockInternal(int op)
+     int fd = open(SYSFS_RESCTRL_PATH, O_DIRECTORY | O_CLOEXEC);
+ 
+     if (fd < 0) {
+-        virReportSystemError(errno, "%s", _("Cannot open resctrlfs"));
++        virReportSystemError(errno, "%s", _("Cannot open resctrl"));
+         return -1;
+     }
+ 
+     if (flock(fd, op) < 0) {
+-        virReportSystemError(errno, "%s", _("Cannot lock resctrlfs"));
++        virReportSystemError(errno, "%s", _("Cannot lock resctrl"));
+         VIR_FORCE_CLOSE(fd);
+         return -1;
+     }
+@@ -328,7 +328,7 @@ static inline int
+ virResctrlLockWrite(void)
+ {
+     virReportSystemError(ENOSYS, "%s",
+-                         _("resctrlfs not supported on this platform"));
++                         _("resctrl not supported on this platform"));
+     return -1;
+ }
+ 
+@@ -347,11 +347,11 @@ virResctrlUnlock(int fd)
+     /* The lock gets unlocked by closing the fd, which we need to do anyway in
+      * order to clean up properly */
+     if (VIR_CLOSE(fd) < 0) {
+-        virReportSystemError(errno, "%s", _("Cannot close resctrlfs"));
++        virReportSystemError(errno, "%s", _("Cannot close resctrl"));
+ 
+         /* Trying to save the already broken */
+         if (flock(fd, LOCK_UN) < 0)
+-            virReportSystemError(errno, "%s", _("Cannot unlock resctrlfs"));
++            virReportSystemError(errno, "%s", _("Cannot unlock resctrl"));
+         return -1;
+     }
+ #endif /* ! __linux__ */
+@@ -486,7 +486,7 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
+ 
+         if (i_level->types[type]) {
+             virReportError(VIR_ERR_INTERNAL_ERROR,
+-                           _("Duplicate cache type in resctrlfs for level %u"),
++                           _("Duplicate cache type in resctrl for level %u"),
+                            level);
+             goto cleanup;
+         }
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-add-virFileReadHeaderQuiet-wrapper-around-virFileReadHeaderFD.patch b/SOURCES/libvirt-util-add-virFileReadHeaderQuiet-wrapper-around-virFileReadHeaderFD.patch
index 038c84a..0758f32 100644
--- a/SOURCES/libvirt-util-add-virFileReadHeaderQuiet-wrapper-around-virFileReadHeaderFD.patch
+++ b/SOURCES/libvirt-util-add-virFileReadHeaderQuiet-wrapper-around-virFileReadHeaderFD.patch
@@ -1,5 +1,5 @@
-From da15d67c5cf0b6c0c1974d8ca251dbeec3d6a964 Mon Sep 17 00:00:00 2001
-Message-Id: <da15d67c5cf0b6c0c1974d8ca251dbeec3d6a964@dist-git>
+From 706f4e3526b154c4b65c242eba039a53c9386ca8 Mon Sep 17 00:00:00 2001
+Message-Id: <706f4e3526b154c4b65c242eba039a53c9386ca8@dist-git>
 From: Paolo Bonzini <pbonzini@redhat.com>
 Date: Tue, 12 Dec 2017 16:23:40 +0100
 Subject: [PATCH] util: add virFileReadHeaderQuiet wrapper around
@@ -16,10 +16,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  3 files changed, 22 insertions(+)
 
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 62ebb8180e..0c972d1861 100644
+index 478b3b3a6f..85b15314a9 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
-@@ -1646,6 +1646,7 @@ virFileReadAll;
+@@ -1752,6 +1752,7 @@ virFileReadAll;
  virFileReadAllQuiet;
  virFileReadBufQuiet;
  virFileReadHeaderFD;
@@ -28,10 +28,10 @@ index 62ebb8180e..0c972d1861 100644
  virFileReadLink;
  virFileReadValueBitmap;
 diff --git a/src/util/virfile.c b/src/util/virfile.c
-index a91c2c3495..51d1f5ce66 100644
+index 82cb36dbca..5e9bd2007a 100644
 --- a/src/util/virfile.c
 +++ b/src/util/virfile.c
-@@ -1356,6 +1356,25 @@ virFileReadHeaderFD(int fd, int maxlen, char **buf)
+@@ -1367,6 +1367,25 @@ virFileReadHeaderFD(int fd, int maxlen, char **buf)
  }
  
  
@@ -58,10 +58,10 @@ index a91c2c3495..51d1f5ce66 100644
     exceeding the maximum size limitation to EOVERFLOW.  */
  int
 diff --git a/src/util/virfile.h b/src/util/virfile.h
-index ba1c57c06a..38cc23ecaa 100644
+index 91d3186223..ea1faed2e4 100644
 --- a/src/util/virfile.h
 +++ b/src/util/virfile.h
-@@ -129,6 +129,8 @@ int virFileDeleteTree(const char *dir);
+@@ -131,6 +131,8 @@ int virFileDeleteTree(const char *dir);
  
  int virFileReadHeaderFD(int fd, int maxlen, char **buf)
      ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(3);
diff --git a/SOURCES/libvirt-util-allow-ignoring-SIOCSIFHWADDR-when-errno-is-EPERM.patch b/SOURCES/libvirt-util-allow-ignoring-SIOCSIFHWADDR-when-errno-is-EPERM.patch
deleted file mode 100644
index 0446e83..0000000
--- a/SOURCES/libvirt-util-allow-ignoring-SIOCSIFHWADDR-when-errno-is-EPERM.patch
+++ /dev/null
@@ -1,80 +0,0 @@
-From e8dcdd23e5f77d0207203da165d6ba0c561a51e2 Mon Sep 17 00:00:00 2001
-Message-Id: <e8dcdd23e5f77d0207203da165d6ba0c561a51e2@dist-git>
-From: Laine Stump <laine@redhat.com>
-Date: Sun, 23 Apr 2017 21:32:05 -0400
-Subject: [PATCH] util: allow ignoring SIOCSIFHWADDR when errno is EPERM
-
-Commit f4ef3a71 made a variation of virNetDevSetMAC that would return
-without logging an error message if errno was set to
-EADDRNOTAVAIL. This errno is set by some SRIOV VF drivers (in
-particular igbvf) when they fail to set the device's MAC address due
-to the PF driver refusing the request. This is useful if we want to
-try a different method of setting the VF MAC address before giving up
-(Commit 86556e16 actually does this, setting the desired MAC address
-to the "admin MAC in the PF, then detaching and reattaching the VF
-netdev driver to force a reinit of the MAC address).
-
-During testing of Bug 1442040 it was discovered that the ixgbe driver
-returns EPERM in this situation, so this patch changes the exception
-case for silent+non-terminal failure to account for this difference.
-
-Completes resolution to: https://bugzilla.redhat.com/1415609 (RHEL 7.4)
-                         https://bugzilla.redhat.com/1442040 (RHEL 7.3.z)
-
-(cherry picked from commit 997134fb8b17eef6eba439303b382b239996208b)
----
- src/util/virnetdev.c | 14 +++++++++-----
- 1 file changed, 9 insertions(+), 5 deletions(-)
-
-diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
-index 170e34827..9aa9c9f88 100644
---- a/src/util/virnetdev.c
-+++ b/src/util/virnetdev.c
-@@ -226,7 +226,8 @@ int virNetDevExists(const char *ifname)
-  * virNetDevSetMACInternal:
-  * @ifname: interface name to set MTU for
-  * @macaddr: MAC address
-- * @quiet: true if a failure to set MAC address with errno == EADDRNOTAVAIL
-+ * @quiet: true if a failure to set MAC address with
-+ *         errno == EADDRNOTAVAIL || errno == EPERM
-  *         should be silent (still returns error, but without log)
-  *
-  * This function sets the @macaddr for a given interface @ifname.
-@@ -258,7 +259,8 @@ virNetDevSetMACInternal(const char *ifname,
- 
-     if (ioctl(fd, SIOCSIFHWADDR, &ifr) < 0) {
- 
--        if (quiet && errno == EADDRNOTAVAIL)
-+        if (quiet &&
-+            (errno == EADDRNOTAVAIL || errno == EPERM))
-             goto cleanup;
- 
-         virReportSystemError(errno,
-@@ -305,7 +307,8 @@ virNetDevSetMACInternal(const char *ifname,
-         ifr.ifr_addr.sa_len = VIR_MAC_BUFLEN;
- 
-         if (ioctl(s, SIOCSIFLLADDR, &ifr) < 0) {
--            if (quiet && errno == EADDRNOTAVAIL)
-+            if (quiet &&
-+                (errno == EADDRNOTAVAIL || errno == EPERM))
-                 goto cleanup;
- 
-             virReportSystemError(errno,
-@@ -2229,11 +2232,12 @@ virNetDevSetNetConfig(const char *linkdev, int vf,
-             int retries = 100;
- 
-             /* if pfDevOrig == NULL, this isn't a VF, so we've failed */
--            if (!pfDevOrig || errno != EADDRNOTAVAIL)
-+            if (!pfDevOrig ||
-+                (errno != EADDRNOTAVAIL && errno != EPERM))
-                 goto cleanup;
- 
-             /* Otherwise this is a VF, and virNetDevSetMAC failed with
--             * EADDRNOTAVAIL, which could be due to the
-+             * EADDRNOTAVAIL/EPERM, which could be due to the
-              * "administratively set" flag being set in the PF for
-              * this VF.  When this happens, we can attempt to use an
-              * alternate method to set the VF MAC: first set it into
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-util-bitmap-Fix-value-of-map_alloc-when-shrinking-bitmap.patch b/SOURCES/libvirt-util-bitmap-Fix-value-of-map_alloc-when-shrinking-bitmap.patch
new file mode 100644
index 0000000..fd1d92e
--- /dev/null
+++ b/SOURCES/libvirt-util-bitmap-Fix-value-of-map_alloc-when-shrinking-bitmap.patch
@@ -0,0 +1,37 @@
+From 95cade1ca8bbf611fe14a80bd4cdd821c246ff74 Mon Sep 17 00:00:00 2001
+Message-Id: <95cade1ca8bbf611fe14a80bd4cdd821c246ff74@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Mon, 5 Feb 2018 17:57:36 +0100
+Subject: [PATCH] util: bitmap: Fix value of 'map_alloc' when shrinking bitmap
+
+The virBitmap code uses VIR_RESIZE_N to do quadratic scaling, which
+means that along with the number of requested map elements we also need
+to keep the number of actually allocated elements for the scaling
+algorithm to work properly.
+
+The shrinking code did not fix 'map_alloc' thus virResizeN might
+actually not expand the bitmap properly after called on a previously
+shrunk bitmap.
+
+(cherry picked from commit bf924e8e1be03982b0006e05b4faa3a645a45578)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1540817
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+---
+ src/util/virbitmap.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
+index 33cae2f305..36ecc95deb 100644
+--- a/src/util/virbitmap.c
++++ b/src/util/virbitmap.c
+@@ -1231,5 +1231,6 @@ virBitmapShrink(virBitmapPtr map,
+         return -1;
+ 
+     map->map_len = nl;
++    map->map_alloc = nl;
+     return 0;
+ }
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-check-ifa_addr-pointer-before-accessing-its-elements.patch b/SOURCES/libvirt-util-check-ifa_addr-pointer-before-accessing-its-elements.patch
deleted file mode 100644
index a9fae65..0000000
--- a/SOURCES/libvirt-util-check-ifa_addr-pointer-before-accessing-its-elements.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-From 6c74f5fdf8f882d89fd6a1c30fe017f2ed270a96 Mon Sep 17 00:00:00 2001
-Message-Id: <6c74f5fdf8f882d89fd6a1c30fe017f2ed270a96@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Fri, 21 Apr 2017 13:12:16 +0200
-Subject: [PATCH] util: check ifa_addr pointer before accessing its elements
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Reported by Rafał Wojciechowski <it@rafalwojciechowski.pl>.
-
-Thread 1 (Thread 0x7f194b99d700 (LWP 5631)):
-0  virNetDevGetifaddrsAddress (addr=0x7f194b99c7c0, ifname=0x7f193400e2b0 "ovirtmgmt") at util/virnetdevip.c:738
-1  virNetDevIPAddrGet (ifname=0x7f193400e2b0 "ovirtmgmt", addr=addr@entry=0x7f194b99c7c0) at util/virnetdevip.c:795
-2  0x00007f19467800d6 in networkGetNetworkAddress (netname=<optimized out>, netaddr=netaddr@entry=0x7f1924013f18) at network/bridge_driver.c:4780
-3  0x00007f193e43a33c in qemuProcessGraphicsSetupNetworkAddress (listenAddr=0x7f19340f7650 "127.0.0.1", glisten=0x7f1924013f10) at qemu/qemu_process.c:4062
-4  qemuProcessGraphicsSetupListen (vm=<optimized out>, graphics=0x7f1924014f10, cfg=0x7f1934119f00) at qemu/qemu_process.c:4133
-5  qemuProcessSetupGraphics (flags=17, vm=0x7f19240155d0, driver=0x7f193411f1d0) at qemu/qemu_process.c:4196
-6  qemuProcessPrepareDomain (conn=conn@entry=0x7f192c00ab50, driver=driver@entry=0x7f193411f1d0, vm=vm@entry=0x7f19240155d0, flags=flags@entry=17) at qemu/qemu_process.c:4969
-7  0x00007f193e4417c0 in qemuProcessStart (conn=conn@entry=0x7f192c00ab50, driver=driver@entry=0x7f193411f1d0, vm=0x7f19240155d0,asyncJob=asyncJob@entry=QEMU_ASYNC_JOB_START, migrateFrom=migrateFrom@entry=0x0, migrateFd=migrateFd@entry=-1, migratePath=migratePath@entry=0x0,snapshot=snapshot@entry=0x0, vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=17, flags@entry=1) at qemu/qemu_process.c:5553
-
-Man page for getifaddrs also states that the "ifa_addr" may contain
-a null pointer which happens if there is an existing network interface
-on the host without IP address.
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 42000bf7e554b3732a569db633824302d5ec2867)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1444408
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virnetdevip.c  | 7 ++++++-
- src/util/virnetdevtap.c | 3 +++
- 2 files changed, 9 insertions(+), 1 deletion(-)
-
-diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
-index c9ac6baf7..7a4fb1c91 100644
---- a/src/util/virnetdevip.c
-+++ b/src/util/virnetdevip.c
-@@ -893,10 +893,15 @@ virNetDevGetifaddrsAddress(const char *ifname,
-     }
- 
-     for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
--        int family = ifa->ifa_addr->sa_family;
-+        int family;
- 
-         if (STRNEQ_NULLABLE(ifa->ifa_name, ifname))
-             continue;
-+
-+        if (!ifa->ifa_addr)
-+            continue;
-+        family = ifa->ifa_addr->sa_family;
-+
-         if (family != AF_INET6 && family != AF_INET)
-             continue;
- 
-diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
-index 02ef7fd24..93002b929 100644
---- a/src/util/virnetdevtap.c
-+++ b/src/util/virnetdevtap.c
-@@ -762,6 +762,9 @@ virNetDevTapInterfaceStats(const char *ifname,
-     }
- 
-     for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
-+        if (!ifa->ifa_addr)
-+            continue;
-+
-         if (ifa->ifa_addr->sa_family != AF_LINK)
-             continue;
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-util-hostcpu-Correctly-report-total-number-of-vcpus-in-virHostCPUGetMap.patch b/SOURCES/libvirt-util-hostcpu-Correctly-report-total-number-of-vcpus-in-virHostCPUGetMap.patch
deleted file mode 100644
index 64b19c3..0000000
--- a/SOURCES/libvirt-util-hostcpu-Correctly-report-total-number-of-vcpus-in-virHostCPUGetMap.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From 0a811ab61fdd075efa148e50f567c6a198b57148 Mon Sep 17 00:00:00 2001
-Message-Id: <0a811ab61fdd075efa148e50f567c6a198b57148@dist-git>
-From: Nitesh Konkar <niteshkonkar.libvirt@gmail.com>
-Date: Tue, 30 May 2017 13:48:17 +0200
-Subject: [PATCH] util: hostcpu: Correctly report total number of vcpus in
- virHostCPUGetMap
-
-Callers expect the return value to be the total number of vcpus in the
-host (including offline vcpus). The refactor in c67e04e25fa58104e0fae41
-broke this assumption by using virHostCPUGetOnlineBitmap which only
-creates a bitmap long enough to hold the last online vcpu.
-
-Report the full number of host vcpus by returning value from
-virHostCPUGetCount().
-
-Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
-Signed-off-by: Peter Krempa <pkrempa@redhat.com>
-(cherry picked from commit 4ae0f65669a6672a408e08698678ed2958a77fde)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1456793
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/util/virhostcpu.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
-index 20d3a004b..67daace89 100644
---- a/src/util/virhostcpu.c
-+++ b/src/util/virhostcpu.c
-@@ -1081,7 +1081,7 @@ virHostCPUGetMap(unsigned char **cpumap,
-     if (online)
-         *online = virBitmapCountBits(cpus);
- 
--    ret = virBitmapSize(cpus);
-+    ret = virHostCPUGetCount();
- 
-  cleanup:
-     if (ret < 0 && cpumap)
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-util-introduce-virBufferEscapeRegex.patch b/SOURCES/libvirt-util-introduce-virBufferEscapeRegex.patch
deleted file mode 100644
index a3c3e40..0000000
--- a/SOURCES/libvirt-util-introduce-virBufferEscapeRegex.patch
+++ /dev/null
@@ -1,140 +0,0 @@
-From e302b6b9505730e9f1d139027c87867c973d2a26 Mon Sep 17 00:00:00 2001
-Message-Id: <e302b6b9505730e9f1d139027c87867c973d2a26@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Tue, 16 May 2017 11:46:12 +0200
-Subject: [PATCH] util: introduce virBufferEscapeRegex
-
-Add a helper to escape all possible meta-characters used for
-POSIX extended regular expressions.
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit 0918b84968ab8aeb1dc17d5da839d68d947f478f)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1446980
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/libvirt_private.syms |  1 +
- src/util/virbuffer.c     | 19 +++++++++++++++++++
- src/util/virbuffer.h     |  3 +++
- tests/virbuftest.c       | 40 ++++++++++++++++++++++++++++++++++++++++
- 4 files changed, 63 insertions(+)
-
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 06c338384..7e1a06db3 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -1292,6 +1292,7 @@ virBufferCurrentContent;
- virBufferError;
- virBufferEscape;
- virBufferEscapeN;
-+virBufferEscapeRegex;
- virBufferEscapeSexpr;
- virBufferEscapeShell;
- virBufferEscapeString;
-diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c
-index 80c8e289d..f07b119c0 100644
---- a/src/util/virbuffer.c
-+++ b/src/util/virbuffer.c
-@@ -556,6 +556,25 @@ virBufferEscapeSexpr(virBufferPtr buf,
- }
- 
- /**
-+ * virBufferEscapeRegex:
-+ * @buf: the buffer to append to
-+ * @format: a printf like format string but with only one %s parameter
-+ * @str: the string argument which needs to be escaped
-+ *
-+ * Do a formatted print with a single string to a buffer.  The @str is
-+ * escaped to avoid using POSIX extended regular expression meta-characters.
-+ * Escaping is not applied to characters specified in @format. Auto
-+ * indentation may be applied.
-+ */
-+void
-+virBufferEscapeRegex(virBufferPtr buf,
-+                     const char *format,
-+                     const char *str)
-+{
-+    virBufferEscape(buf, '\\', "^$.|?*+()[]{}\\", format, str);
-+}
-+
-+/**
-  * virBufferEscape:
-  * @buf: the buffer to append to
-  * @escape: the escape character to inject
-diff --git a/src/util/virbuffer.h b/src/util/virbuffer.h
-index d1b64ca3a..7a7014aa7 100644
---- a/src/util/virbuffer.h
-+++ b/src/util/virbuffer.h
-@@ -88,6 +88,9 @@ void virBufferEscapeString(virBufferPtr buf, const char *format,
-                            const char *str);
- void virBufferEscapeSexpr(virBufferPtr buf, const char *format,
-                           const char *str);
-+void virBufferEscapeRegex(virBufferPtr buf,
-+                          const char *format,
-+                          const char *str);
- void virBufferEscapeShell(virBufferPtr buf, const char *str);
- void virBufferURIEncodeString(virBufferPtr buf, const char *str);
- 
-diff --git a/tests/virbuftest.c b/tests/virbuftest.c
-index 8ec6ce51e..6f8d4b72c 100644
---- a/tests/virbuftest.c
-+++ b/tests/virbuftest.c
-@@ -405,6 +405,35 @@ testBufEscapeN(const void *opaque)
- 
- 
- static int
-+testBufEscapeRegex(const void *opaque)
-+{
-+    const struct testBufAddStrData *data = opaque;
-+    virBuffer buf = VIR_BUFFER_INITIALIZER;
-+    char *actual;
-+    int ret = -1;
-+
-+    virBufferEscapeRegex(&buf, "%s", data->data);
-+
-+    if (!(actual = virBufferContentAndReset(&buf))) {
-+        VIR_TEST_DEBUG("testBufEscapeN: buf is empty");
-+        goto cleanup;
-+    }
-+
-+    if (STRNEQ_NULLABLE(actual, data->expect)) {
-+        VIR_TEST_DEBUG("testBufEscapeN: Strings don't match:\n");
-+        virTestDifference(stderr, data->expect, actual);
-+        goto cleanup;
-+    }
-+
-+    ret = 0;
-+
-+ cleanup:
-+    VIR_FREE(actual);
-+    return ret;
-+}
-+
-+
-+static int
- testBufSetIndent(const void *opaque ATTRIBUTE_UNUSED)
- {
-     virBuffer buf = VIR_BUFFER_INITIALIZER;
-@@ -492,6 +521,17 @@ mymain(void)
-     DO_TEST_ESCAPEN("equal=escape", "equal\\=escape");
-     DO_TEST_ESCAPEN("comma,equal=escape", "comma,,equal\\=escape");
- 
-+#define DO_TEST_ESCAPE_REGEX(data, expect)                                  \
-+    do {                                                                    \
-+        struct testBufAddStrData info = { data, expect };                   \
-+        if (virTestRun("Buf: EscapeRegex", testBufEscapeRegex, &info) < 0)  \
-+            ret = -1;                                                       \
-+    } while (0)
-+
-+    DO_TEST_ESCAPE_REGEX("noescape", "noescape");
-+    DO_TEST_ESCAPE_REGEX("^$.|?*+()[]{}\\",
-+                         "\\^\\$\\.\\|\\?\\*\\+\\(\\)\\[\\]\\{\\}\\\\");
-+
-     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
- }
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-util-introduce-virHostCPUGetMicrocodeVersion.patch b/SOURCES/libvirt-util-introduce-virHostCPUGetMicrocodeVersion.patch
index e20bc64..376aeab 100644
--- a/SOURCES/libvirt-util-introduce-virHostCPUGetMicrocodeVersion.patch
+++ b/SOURCES/libvirt-util-introduce-virHostCPUGetMicrocodeVersion.patch
@@ -1,5 +1,5 @@
-From 7de4d78e69462ddea11864732e5cd38290a94016 Mon Sep 17 00:00:00 2001
-Message-Id: <7de4d78e69462ddea11864732e5cd38290a94016@dist-git>
+From ac8540f237280b2e302949f15d229e13477245c7 Mon Sep 17 00:00:00 2001
+Message-Id: <ac8540f237280b2e302949f15d229e13477245c7@dist-git>
 From: Paolo Bonzini <pbonzini@redhat.com>
 Date: Tue, 12 Dec 2017 16:23:41 +0100
 Subject: [PATCH] util: introduce virHostCPUGetMicrocodeVersion
@@ -20,10 +20,10 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
  3 files changed, 46 insertions(+)
 
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 0c972d1861..c50b6c2f77 100644
+index 85b15314a9..57999e77b0 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
-@@ -1739,6 +1739,7 @@ virHostCPUGetCount;
+@@ -1861,6 +1861,7 @@ virHostCPUGetCount;
  virHostCPUGetInfo;
  virHostCPUGetKVMMaxVCPUs;
  virHostCPUGetMap;
@@ -32,10 +32,10 @@ index 0c972d1861..c50b6c2f77 100644
  virHostCPUGetOnlineBitmap;
  virHostCPUGetPresentBitmap;
 diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
-index 67daace890..8135365d08 100644
+index bd58aa43df..a7ae7cd4cb 100644
 --- a/src/util/virhostcpu.c
 +++ b/src/util/virhostcpu.c
-@@ -1199,3 +1199,46 @@ virHostCPUGetKVMMaxVCPUs(void)
+@@ -1211,3 +1211,46 @@ virHostCPUGetKVMMaxVCPUs(void)
      return -1;
  }
  #endif /* HAVE_LINUX_KVM_H */
@@ -83,7 +83,7 @@ index 67daace890..8135365d08 100644
 +
 +#endif
 diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h
-index e9c22eecc9..7d77392454 100644
+index 67033de842..f9f3359288 100644
 --- a/src/util/virhostcpu.h
 +++ b/src/util/virhostcpu.h
 @@ -66,4 +66,6 @@ virBitmapPtr virHostCPUGetSiblingsList(unsigned int cpu);
diff --git a/SOURCES/libvirt-util-introduce-virStringMatch.patch b/SOURCES/libvirt-util-introduce-virStringMatch.patch
deleted file mode 100644
index 5092cae..0000000
--- a/SOURCES/libvirt-util-introduce-virStringMatch.patch
+++ /dev/null
@@ -1,161 +0,0 @@
-From a05097ee436b03de9280a9ae25f85a150ddaa327 Mon Sep 17 00:00:00 2001
-Message-Id: <a05097ee436b03de9280a9ae25f85a150ddaa327@dist-git>
-From: Pavel Hrdina <phrdina@redhat.com>
-Date: Tue, 16 May 2017 11:46:11 +0200
-Subject: [PATCH] util: introduce virStringMatch
-
-Simply tries to match the provided regex on a string and returns
-the result.  Useful if caller don't care about the matched substring
-and want to just test if some pattern patches a string.
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-(cherry picked from commit f15f155403e36a66e3568676105fdca725ad2c52)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1446980
-
-Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/libvirt_private.syms |  1 +
- src/util/virstring.c     | 32 ++++++++++++++++++++++++++++++++
- src/util/virstring.h     |  3 +++
- tests/virstringtest.c    | 47 +++++++++++++++++++++++++++++++++++++++++++++++
- 4 files changed, 83 insertions(+)
-
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 134d4a832..06c338384 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -2599,6 +2599,7 @@ virStringListHasString;
- virStringListJoin;
- virStringListLength;
- virStringListRemove;
-+virStringMatch;
- virStringReplace;
- virStringSearch;
- virStringSortCompare;
-diff --git a/src/util/virstring.c b/src/util/virstring.c
-index 69abc267b..5b2be317b 100644
---- a/src/util/virstring.c
-+++ b/src/util/virstring.c
-@@ -979,6 +979,38 @@ virStringSearch(const char *str,
- }
- 
- /**
-+ * virStringMatch:
-+ * @str: string to match
-+ * @regexp: POSIX Extended regular expression pattern used for matching
-+ *
-+ * Performs a POSIX extended regex match against a string.
-+ * Returns true on match, false on error or no match.
-+ */
-+bool
-+virStringMatch(const char *str,
-+               const char *regexp)
-+{
-+    regex_t re;
-+    int rv;
-+
-+    VIR_DEBUG("match '%s' for '%s'", str, regexp);
-+
-+    if ((rv = regcomp(&re, regexp, REG_EXTENDED | REG_NOSUB)) != 0) {
-+        char error[100];
-+        regerror(rv, &re, error, sizeof(error));
-+        VIR_WARN("error while compiling regular expression '%s': %s",
-+                 regexp, error);
-+        return false;
-+    }
-+
-+    rv = regexec(&re, str, 0, NULL, 0);
-+
-+    regfree(&re);
-+
-+    return rv == 0;
-+}
-+
-+/**
-  * virStringReplace:
-  * @haystack: the source string to process
-  * @oldneedle: the substring to locate
-diff --git a/src/util/virstring.h b/src/util/virstring.h
-index a5550e30d..0df03473a 100644
---- a/src/util/virstring.h
-+++ b/src/util/virstring.h
-@@ -274,6 +274,9 @@ ssize_t virStringSearch(const char *str,
-                         char ***matches)
-     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
- 
-+bool virStringMatch(const char *str,
-+                    const char *regexp);
-+
- char *virStringReplace(const char *haystack,
-                        const char *oldneedle,
-                        const char *newneedle)
-diff --git a/tests/virstringtest.c b/tests/virstringtest.c
-index db1731f96..d27c8a5a8 100644
---- a/tests/virstringtest.c
-+++ b/tests/virstringtest.c
-@@ -480,6 +480,38 @@ testStringSearch(const void *opaque)
- }
- 
- 
-+struct stringMatchData {
-+    const char *str;
-+    const char *regexp;
-+    bool expectMatch;
-+};
-+
-+static int
-+testStringMatch(const void *opaque)
-+{
-+    const struct stringMatchData *data = opaque;
-+    bool match;
-+
-+    match = virStringMatch(data->str, data->regexp);
-+
-+    if (data->expectMatch) {
-+        if (!match) {
-+            fprintf(stderr, "expected match for '%s' on '%s' but got no match\n",
-+                    data->regexp, data->str);
-+            return -1;
-+        }
-+    } else {
-+        if (match) {
-+            fprintf(stderr, "expected no match for '%s' on '%s' but got match\n",
-+                    data->regexp, data->str);
-+            return -1;
-+        }
-+    }
-+
-+    return 0;
-+}
-+
-+
- struct stringReplaceData {
-     const char *haystack;
-     const char *oldneedle;
-@@ -803,6 +835,21 @@ mymain(void)
-     const char *matches3[] = { "foo", "bar" };
-     TEST_SEARCH("1foo2bar3eek", "([a-z]+)", 2, 2, matches3, false);
- 
-+#define TEST_MATCH(s, r, m)                                                 \
-+    do {                                                                    \
-+        struct stringMatchData data = {                                     \
-+            .str = s,                                                       \
-+            .regexp = r,                                                    \
-+            .expectMatch = m,                                               \
-+        };                                                                  \
-+        if (virTestRun("virStringMatch " s, testStringMatch, &data) < 0)    \
-+            ret = -1;                                                       \
-+    } while (0)
-+
-+    TEST_MATCH("foo", "foo", true);
-+    TEST_MATCH("foobar", "f[o]+", true);
-+    TEST_MATCH("foobar", "^f[o]+$", false);
-+
- #define TEST_REPLACE(h, o, n, r)                                             \
-     do {                                                                     \
-         struct stringReplaceData data = {                                    \
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-util-json-Add-helper-to-return-string-or-number-properties-as-string.patch b/SOURCES/libvirt-util-json-Add-helper-to-return-string-or-number-properties-as-string.patch
new file mode 100644
index 0000000..c10c428
--- /dev/null
+++ b/SOURCES/libvirt-util-json-Add-helper-to-return-string-or-number-properties-as-string.patch
@@ -0,0 +1,72 @@
+From c9083a7a541a2d7231633df10dba151853fd4bca Mon Sep 17 00:00:00 2001
+Message-Id: <c9083a7a541a2d7231633df10dba151853fd4bca@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Wed, 31 Jan 2018 12:50:59 +0100
+Subject: [PATCH] util: json: Add helper to return string or number properties
+ as string
+
+The helper is useful in cases when the JSON we have to parse may contain
+one of the two due to historical reasons and the number value itself
+would be stored as a string.
+
+(cherry picked from commit d3da8013cc11d6a10d4a4146bcbb0a7e34523fa5)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1540290
+---
+ src/util/virjson.c | 27 +++++++++++++++++++++++++++
+ src/util/virjson.h |  1 +
+ 2 files changed, 28 insertions(+)
+
+diff --git a/src/util/virjson.c b/src/util/virjson.c
+index 17b11f2b3d..14b68b8c93 100644
+--- a/src/util/virjson.c
++++ b/src/util/virjson.c
+@@ -1208,6 +1208,33 @@ virJSONValueObjectGetString(virJSONValuePtr object,
+ }
+ 
+ 
++/**
++ * virJSONValueObjectGetStringOrNumber:
++ * @object: JSON value object
++ * @key: name of the property in @object to get
++ *
++ * Gets a property named @key from the JSON object @object. The value may be
++ * a number or a string and is returned as a string. In cases when the property
++ * is not present or is not a string or number NULL is returned.
++ */
++const char *
++virJSONValueObjectGetStringOrNumber(virJSONValuePtr object,
++                                    const char *key)
++{
++    virJSONValuePtr val = virJSONValueObjectGet(object, key);
++
++    if (!val)
++        return NULL;
++
++    if (val->type == VIR_JSON_TYPE_STRING)
++        return val->data.string;
++    else if (val->type == VIR_JSON_TYPE_NUMBER)
++        return val->data.number;
++
++    return NULL;
++}
++
++
+ int
+ virJSONValueObjectGetNumberInt(virJSONValuePtr object,
+                                const char *key,
+diff --git a/src/util/virjson.h b/src/util/virjson.h
+index e89a776ab5..b76a3c3472 100644
+--- a/src/util/virjson.h
++++ b/src/util/virjson.h
+@@ -149,6 +149,7 @@ virJSONValuePtr virJSONValueObjectStealArray(virJSONValuePtr object,
+                                              const char *key);
+ 
+ const char *virJSONValueObjectGetString(virJSONValuePtr object, const char *key);
++const char *virJSONValueObjectGetStringOrNumber(virJSONValuePtr object, const char *key);
+ int virJSONValueObjectGetNumberInt(virJSONValuePtr object, const char *key, int *value);
+ int virJSONValueObjectGetNumberUint(virJSONValuePtr object, const char *key, unsigned int *value);
+ int virJSONValueObjectGetNumberLong(virJSONValuePtr object, const char *key, long long *value);
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-make-macvtap-macvlan-generated-name-defines-available-to-other-files.patch b/SOURCES/libvirt-util-make-macvtap-macvlan-generated-name-defines-available-to-other-files.patch
deleted file mode 100644
index 57d9d6a..0000000
--- a/SOURCES/libvirt-util-make-macvtap-macvlan-generated-name-defines-available-to-other-files.patch
+++ /dev/null
@@ -1,201 +0,0 @@
-From 30400fc580740ddca6edd751d1768f189cfd112a Mon Sep 17 00:00:00 2001
-Message-Id: <30400fc580740ddca6edd751d1768f189cfd112a@dist-git>
-From: Laine Stump <laine@laine.org>
-Date: Tue, 2 May 2017 12:33:10 -0400
-Subject: [PATCH] util: make macvtap/macvlan generated name #defines available
- to other files
-
-MACVTAP_NAME_PREFIX and MACVLAN_NAME_PREFIX could be useful to other
-files if they were defined in virnetdevmacvlan.h instead of
-virnetdevmacvlan.c, so do that (while slightly renaming them and also
-adding yet another #define that chooses between macvlan/macvtap based
-on flags).
-
-This is a prerequisite to fix: https://bugzilla.redhat.com/1335798
-
-(cherry picked from commit a05400ef55c7c67c6b211dfa5a33400870d470ca)
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/util/virnetdevmacvlan.c | 65 ++++++++++++++++++---------------------------
- src/util/virnetdevmacvlan.h |  6 +++++
- 2 files changed, 32 insertions(+), 39 deletions(-)
-
-diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
-index 7222b0f2c..97c87701c 100644
---- a/src/util/virnetdevmacvlan.c
-+++ b/src/util/virnetdevmacvlan.c
-@@ -68,11 +68,11 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST,
- 
- VIR_LOG_INIT("util.netdevmacvlan");
- 
--# define MACVTAP_NAME_PREFIX	"macvtap"
--# define MACVTAP_NAME_PATTERN	"macvtap%d"
--
--# define MACVLAN_NAME_PREFIX	"macvlan"
--# define MACVLAN_NAME_PATTERN	"macvlan%d"
-+# define VIR_NET_GENERATED_MACVTAP_PATTERN VIR_NET_GENERATED_MACVTAP_PREFIX "%d"
-+# define VIR_NET_GENERATED_MACVLAN_PATTERN VIR_NET_GENERATED_MACVLAN_PREFIX "%d"
-+# define VIR_NET_GENERATED_PREFIX \
-+    ((flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? \
-+     VIR_NET_GENERATED_MACVTAP_PREFIX : VIR_NET_GENERATED_MACVLAN_PREFIX)
- 
- # define MACVLAN_MAX_ID 8191
- 
-@@ -124,9 +124,7 @@ virNetDevMacVLanReserveID(int id, unsigned int flags,
-     if (id > MACVLAN_MAX_ID) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-                        _("can't use name %s%d - out of range 0-%d"),
--                       (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--                       MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX,
--                       id, MACVLAN_MAX_ID);
-+                       VIR_NET_GENERATED_PREFIX, id, MACVLAN_MAX_ID);
-         return -1;
-     }
- 
-@@ -134,21 +132,18 @@ virNetDevMacVLanReserveID(int id, unsigned int flags,
-         (id = virBitmapNextClearBit(bitmap, id)) < 0) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-                        _("no unused %s names available"),
--                       (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--                       MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX);
-+                       VIR_NET_GENERATED_PREFIX);
-         return -1;
-     }
- 
-     if (virBitmapIsBitSet(bitmap, id)) {
-         if (quietFail) {
-             VIR_INFO("couldn't reserve name %s%d - already in use",
--                     (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--                     MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id);
-+                     VIR_NET_GENERATED_PREFIX, id);
-         } else {
-             virReportError(VIR_ERR_INTERNAL_ERROR,
-                            _("couldn't reserve name %s%d - already in use"),
--                           (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--                           MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id);
-+                           VIR_NET_GENERATED_PREFIX, id);
-         }
-         return -1;
-     }
-@@ -156,14 +151,11 @@ virNetDevMacVLanReserveID(int id, unsigned int flags,
-     if (virBitmapSetBit(bitmap, id) < 0) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-                        _("couldn't mark %s%d as used"),
--                       (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--                       MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id);
-+                       VIR_NET_GENERATED_PREFIX, id);
-         return -1;
-     }
- 
--    VIR_INFO("reserving device %s%d",
--             (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--             MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id);
-+    VIR_INFO("reserving device %s%d", VIR_NET_GENERATED_PREFIX, id);
-     return id;
- }
- 
-@@ -188,9 +180,7 @@ virNetDevMacVLanReleaseID(int id, unsigned int flags)
-     if (id > MACVLAN_MAX_ID) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-                        _("can't free name %s%d - out of range 0-%d"),
--                       (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--                       MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX,
--                       id, MACVLAN_MAX_ID);
-+                       VIR_NET_GENERATED_PREFIX, id, MACVLAN_MAX_ID);
-         return -1;
-     }
- 
-@@ -199,14 +189,12 @@ virNetDevMacVLanReleaseID(int id, unsigned int flags)
- 
-     VIR_INFO("releasing %sdevice %s%d",
-              virBitmapIsBitSet(bitmap, id) ? "" : "unreserved",
--             (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--             MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id);
-+             VIR_NET_GENERATED_PREFIX, id);
- 
-     if (virBitmapClearBit(bitmap, id) < 0) {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-                        _("couldn't mark %s%d as unused"),
--                       (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--                       MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id);
-+                       VIR_NET_GENERATED_PREFIX, id);
-         return -1;
-     }
-     return 0;
-@@ -236,11 +224,11 @@ virNetDevMacVLanReserveName(const char *name, bool quietFail)
-     if (virNetDevMacVLanInitialize() < 0)
-        return -1;
- 
--    if (STRPREFIX(name, MACVTAP_NAME_PREFIX)) {
--        idstr = name + strlen(MACVTAP_NAME_PREFIX);
-+    if (STRPREFIX(name, VIR_NET_GENERATED_MACVTAP_PREFIX)) {
-+        idstr = name + strlen(VIR_NET_GENERATED_MACVTAP_PREFIX);
-         flags |= VIR_NETDEV_MACVLAN_CREATE_WITH_TAP;
--    } else if (STRPREFIX(name, MACVLAN_NAME_PREFIX)) {
--        idstr = name + strlen(MACVLAN_NAME_PREFIX);
-+    } else if (STRPREFIX(name, VIR_NET_GENERATED_MACVLAN_PREFIX)) {
-+        idstr = name + strlen(VIR_NET_GENERATED_MACVLAN_PREFIX);
-     } else {
-         return -2;
-     }
-@@ -276,11 +264,11 @@ virNetDevMacVLanReleaseName(const char *name)
-     if (virNetDevMacVLanInitialize() < 0)
-        return -1;
- 
--    if (STRPREFIX(name, MACVTAP_NAME_PREFIX)) {
--        idstr = name + strlen(MACVTAP_NAME_PREFIX);
-+    if (STRPREFIX(name, VIR_NET_GENERATED_MACVTAP_PREFIX)) {
-+        idstr = name + strlen(VIR_NET_GENERATED_MACVTAP_PREFIX);
-         flags |= VIR_NETDEV_MACVLAN_CREATE_WITH_TAP;
--    } else if (STRPREFIX(name, MACVLAN_NAME_PREFIX)) {
--        idstr = name + strlen(MACVLAN_NAME_PREFIX);
-+    } else if (STRPREFIX(name, VIR_NET_GENERATED_MACVLAN_PREFIX)) {
-+        idstr = name + strlen(VIR_NET_GENERATED_MACVLAN_PREFIX);
-     } else {
-         return 0;
-     }
-@@ -985,10 +973,9 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
-                                        size_t tapfdSize,
-                                        unsigned int flags)
- {
--    const char *type = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--        MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX;
-+    const char *type = VIR_NET_GENERATED_PREFIX;
-     const char *pattern = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
--        MACVTAP_NAME_PATTERN : MACVLAN_NAME_PATTERN;
-+        VIR_NET_GENERATED_MACVTAP_PATTERN : VIR_NET_GENERATED_MACVLAN_PATTERN;
-     int reservedID = -1;
-     char ifname[IFNAMSIZ];
-     int retries, do_retry = 0;
-@@ -1031,8 +1018,8 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
-     if (ifnameRequested) {
-         int rc;
-         bool isAutoName
--            = (STRPREFIX(ifnameRequested, MACVTAP_NAME_PREFIX) ||
--               STRPREFIX(ifnameRequested, MACVLAN_NAME_PREFIX));
-+            = (STRPREFIX(ifnameRequested, VIR_NET_GENERATED_MACVTAP_PREFIX) ||
-+               STRPREFIX(ifnameRequested, VIR_NET_GENERATED_MACVLAN_PREFIX));
- 
-         VIR_INFO("Requested macvtap device name: %s", ifnameRequested);
-         virMutexLock(&virNetDevMacVLanCreateMutex);
-diff --git a/src/util/virnetdevmacvlan.h b/src/util/virnetdevmacvlan.h
-index c40f23ed2..a7c4b6d9c 100644
---- a/src/util/virnetdevmacvlan.h
-+++ b/src/util/virnetdevmacvlan.h
-@@ -51,6 +51,12 @@ typedef enum {
-    VIR_NETDEV_MACVLAN_VNET_HDR          = 1 << 2,
- } virNetDevMacVLanCreateFlags;
- 
-+/* libvirt will start macvtap/macvlan interface names with one of
-+ * these prefixes when it auto-generates the name
-+ */
-+# define VIR_NET_GENERATED_MACVTAP_PREFIX "macvtap"
-+# define VIR_NET_GENERATED_MACVLAN_PREFIX "macvlan"
-+
- int virNetDevMacVLanReserveName(const char *name, bool quietfail);
- int virNetDevMacVLanReleaseName(const char *name);
- 
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-util-mdev-Use-a-local-variable-instead-of-a-direct-pointer-access.patch b/SOURCES/libvirt-util-mdev-Use-a-local-variable-instead-of-a-direct-pointer-access.patch
deleted file mode 100644
index 19dd8bb..0000000
--- a/SOURCES/libvirt-util-mdev-Use-a-local-variable-instead-of-a-direct-pointer-access.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From 422a658bac7ffade2ac2bffb44dbe0b99919c224 Mon Sep 17 00:00:00 2001
-Message-Id: <422a658bac7ffade2ac2bffb44dbe0b99919c224@dist-git>
-From: Erik Skultety <eskultet@redhat.com>
-Date: Thu, 4 May 2017 13:49:59 +0200
-Subject: [PATCH] util: mdev: Use a local variable instead of a direct pointer
- access
-
-Use a local variable to hold data, rather than accessing the pointer
-after calling virMediatedDeviceListAdd (therefore VIR_APPEND_ELEMENT).
-Although not causing an issue at the moment, this change is a necessary
-prerequisite for tweaking virMediatedDeviceListAdd in a separate patch,
-which will take a reference for the source pointer (instead of pointer
-value) and will clear it along the way.
-
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Reviewed-by: Laine Stump <laine@laine.org>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1446455
-(cherry picked from commit 2739a983f235f0d92d210800d61bd1a195f01850)
-Signed-off-by: Erik Skultety <eskultet@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/util/virmdev.c | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/src/util/virmdev.c b/src/util/virmdev.c
-index 2a1ade739..c1499d238 100644
---- a/src/util/virmdev.c
-+++ b/src/util/virmdev.c
-@@ -447,20 +447,21 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
-     virObjectLock(dst);
-     for (i = 0; i < count; i++) {
-         virMediatedDevicePtr mdev = virMediatedDeviceListGet(src, i);
-+        const char *mdev_path = mdev->path;
- 
-         if (virMediatedDeviceIsUsed(mdev, dst) ||
-             virMediatedDeviceSetUsedBy(mdev, drvname, domname) < 0)
-             goto cleanup;
- 
-         /* Copy mdev references to the driver list:
--         * - caller is responsible for NOT freeing devices in @list on success
-+         * - caller is responsible for NOT freeing devices in @src on success
-          * - we're responsible for performing a rollback on failure
-          */
-         if (virMediatedDeviceListAdd(dst, mdev) < 0)
-             goto rollback;
- 
-         VIR_DEBUG("'%s' added to list of active mediated devices used by '%s'",
--                  mdev->path, domname);
-+                  mdev_path, domname);
-     }
- 
-     ret = 0;
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-util-rename-move-VIR_NET_GENERATED_PREFIX-to-be-consistent.patch b/SOURCES/libvirt-util-rename-move-VIR_NET_GENERATED_PREFIX-to-be-consistent.patch
deleted file mode 100644
index 3c1b698..0000000
--- a/SOURCES/libvirt-util-rename-move-VIR_NET_GENERATED_PREFIX-to-be-consistent.patch
+++ /dev/null
@@ -1,160 +0,0 @@
-From 39de2f3c6d425c6444cf1aea43baf203aacf5df4 Mon Sep 17 00:00:00 2001
-Message-Id: <39de2f3c6d425c6444cf1aea43baf203aacf5df4@dist-git>
-From: Laine Stump <laine@laine.org>
-Date: Tue, 2 May 2017 12:33:12 -0400
-Subject: [PATCH] util: rename/move VIR_NET_GENERATED_PREFIX to be consistent
-
-... with VIR_NET_GENERATED_MACV???_PREFIX, which is defined in
-util/virnetdevmacvlan.h.
-
-Since VIR_NET_GENERATED_PREFIX is used for plain tap devices, it is
-renamed to VIR_NET_GENERATED_TAP_PREFIX and moved to virnetdev.h
-
-(cherry picked from commit 30e672301dd16e0433e23864e21dcc9d0c311e8c)
-
-https://bugzilla.redhat.com/1335798
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/bhyve/bhyve_command.c              | 4 ++--
- src/conf/domain_conf.c                 | 4 ++--
- src/conf/domain_conf.h                 | 4 ----
- src/interface/interface_backend_udev.c | 2 +-
- src/qemu/qemu_interface.c              | 8 ++++----
- src/uml/uml_conf.c                     | 4 ++--
- src/util/virnetdev.h                   | 5 +++++
- 7 files changed, 16 insertions(+), 15 deletions(-)
-
-diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
-index e9c072b9f..eae5cb3ca 100644
---- a/src/bhyve/bhyve_command.c
-+++ b/src/bhyve/bhyve_command.c
-@@ -88,10 +88,10 @@ bhyveBuildNetArgStr(virConnectPtr conn,
-     }
- 
-     if (!net->ifname ||
--        STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) ||
-+        STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
-         strchr(net->ifname, '%')) {
-         VIR_FREE(net->ifname);
--        if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_PREFIX "%d") < 0)
-+        if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0)
-             goto cleanup;
-     }
- 
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 84a8a94e5..1653aa61d 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -9733,7 +9733,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
-                 ifname = virXMLPropString(cur, "dev");
-                 if (ifname &&
-                     (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
--                    (STRPREFIX(ifname, VIR_NET_GENERATED_PREFIX) ||
-+                    (STRPREFIX(ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
-                      (prefix && STRPREFIX(ifname, prefix)))) {
-                     /* An auto-generated target name, blank it out */
-                     VIR_FREE(ifname);
-@@ -22139,7 +22139,7 @@ virDomainNetDefFormat(virBufferPtr buf,
- 
-     if (def->ifname &&
-         !((flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
--          (STRPREFIX(def->ifname, VIR_NET_GENERATED_PREFIX) ||
-+          (STRPREFIX(def->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
-            (prefix && STRPREFIX(def->ifname, prefix))))) {
-         /* Skip auto-generated target names for inactive config. */
-         virBufferEscapeString(buf, "<target dev='%s'/>\n", def->ifname);
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index c91791262..f1e9fc2ba 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -1041,10 +1041,6 @@ struct _virDomainNetDef {
-     virNetDevCoalescePtr coalesce;
- };
- 
--/* Used for prefix of ifname of any network name generated dynamically
-- * by libvirt, and cannot be used for a persistent network name.  */
--# define VIR_NET_GENERATED_PREFIX "vnet"
--
- typedef enum {
-     VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT = 0,
-     VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED,
-diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
-index 18a45fa85..1cd84060a 100644
---- a/src/interface/interface_backend_udev.c
-+++ b/src/interface/interface_backend_udev.c
-@@ -570,7 +570,7 @@ udevBridgeScanDirFilter(const struct dirent *entry)
-      * vnet%d. Improvements to this check are welcome.
-      */
-     if (strlen(entry->d_name) >= 5) {
--        if (STRPREFIX(entry->d_name, VIR_NET_GENERATED_PREFIX) &&
-+        if (STRPREFIX(entry->d_name, VIR_NET_GENERATED_TAP_PREFIX) &&
-             c_isdigit(entry->d_name[4]))
-             return 0;
-     }
-diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
-index 2057ac929..c643b76ec 100644
---- a/src/qemu/qemu_interface.c
-+++ b/src/qemu/qemu_interface.c
-@@ -428,10 +428,10 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
-     }
- 
-     if (!net->ifname ||
--        STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) ||
-+        STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
-         strchr(net->ifname, '%')) {
-         VIR_FREE(net->ifname);
--        if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_PREFIX "%d") < 0)
-+        if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0)
-             goto cleanup;
-         /* avoid exposing vnet%d in getXMLDesc or error outputs */
-         template_ifname = true;
-@@ -528,10 +528,10 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
-     }
- 
-     if (!net->ifname ||
--        STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) ||
-+        STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
-         strchr(net->ifname, '%')) {
-         VIR_FREE(net->ifname);
--        if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_PREFIX "%d") < 0)
-+        if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0)
-             goto cleanup;
-         /* avoid exposing vnet%d in getXMLDesc or error outputs */
-         template_ifname = true;
-diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
-index bdef78324..9bd4f1187 100644
---- a/src/uml/uml_conf.c
-+++ b/src/uml/uml_conf.c
-@@ -112,10 +112,10 @@ umlConnectTapDevice(virDomainDefPtr vm,
-     int tapfd = -1;
- 
-     if (!net->ifname ||
--        STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) ||
-+        STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
-         strchr(net->ifname, '%')) {
-         VIR_FREE(net->ifname);
--        if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_PREFIX "%d") < 0)
-+        if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0)
-             goto error;
-         /* avoid exposing vnet%d in getXMLDesc or error outputs */
-         template_ifname = true;
-diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
-index cff8cb51c..97236c170 100644
---- a/src/util/virnetdev.h
-+++ b/src/util/virnetdev.h
-@@ -37,6 +37,11 @@ typedef struct ifreq virIfreq;
- typedef void virIfreq;
- # endif
- 
-+/* Used for prefix of ifname of any tap device name generated
-+ * dynamically by libvirt, cannot be used for a persistent network name.
-+ */
-+# define VIR_NET_GENERATED_TAP_PREFIX "vnet"
-+
- typedef enum {
-    VIR_NETDEV_RX_FILTER_MODE_NONE = 0,
-    VIR_NETDEV_RX_FILTER_MODE_NORMAL,
--- 
-2.12.2
-
diff --git a/SOURCES/libvirt-util-storage-Add-JSON-parser-for-new-options-in-iSCSI-protocol.patch b/SOURCES/libvirt-util-storage-Add-JSON-parser-for-new-options-in-iSCSI-protocol.patch
deleted file mode 100644
index e660497..0000000
--- a/SOURCES/libvirt-util-storage-Add-JSON-parser-for-new-options-in-iSCSI-protocol.patch
+++ /dev/null
@@ -1,141 +0,0 @@
-From 0d64aa3d8573b36ae85b77138dc463ca05e7bae1 Mon Sep 17 00:00:00 2001
-Message-Id: <0d64aa3d8573b36ae85b77138dc463ca05e7bae1@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:41 +0200
-Subject: [PATCH] util: storage: Add JSON parser for new options in iSCSI
- protocol
-
-Starting from qemu 2.9, more granular options are supported. Add parser
-for the relevant bits.
-
-With this patch libvirt is able to parse the host and target IQN of from
-the JSON pseudo-protocol specification.
-
-This corresponds to BlockdevOptionsIscsi in qemu qapi.
-
-(cherry picked from commit b24bc54080b4bc444e60560c0db00c5867e74000)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 63 ++++++++++++++++++++++++++++++++++++++++++++---
- tests/virstoragetest.c    | 19 ++++++++++++++
- 2 files changed, 78 insertions(+), 4 deletions(-)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index 3f8bc43928..945c3e4198 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -2940,18 +2940,73 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src,
-                                       virJSONValuePtr json,
-                                       int opaque ATTRIBUTE_UNUSED)
- {
-+    const char *transport = virJSONValueObjectGetString(json, "transport");
-+    const char *portal = virJSONValueObjectGetString(json, "portal");
-+    const char *target = virJSONValueObjectGetString(json, "target");
-     const char *uri;
-+    char *port;
-+    unsigned int lun = 0;
-+    char *fulltarget = NULL;
-+    int ret = -1;
- 
-     /* legacy URI based syntax passed via 'filename' option */
-     if ((uri = virJSONValueObjectGetString(json, "filename")))
-         return virStorageSourceParseBackingJSONUriStr(src, uri,
-                                                       VIR_STORAGE_NET_PROTOCOL_ISCSI);
- 
--    /* iSCSI currently supports only URI syntax passed in as filename */
--    virReportError(VIR_ERR_INVALID_ARG, "%s",
--                   _("missing iSCSI URI in JSON backing volume definition"));
-+    src->type = VIR_STORAGE_TYPE_NETWORK;
-+    src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
- 
--    return -1;
-+    if (VIR_ALLOC(src->hosts) < 0)
-+        goto cleanup;
-+
-+    src->nhosts = 1;
-+
-+    if (STRNEQ_NULLABLE(transport, "tcp")) {
-+        virReportError(VIR_ERR_INVALID_ARG, "%s",
-+                       _("only TCP transport is supported for iSCSI volumes"));
-+        goto cleanup;
-+    }
-+
-+    src->hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
-+
-+    if (!portal) {
-+        virReportError(VIR_ERR_INVALID_ARG, "%s",
-+                       _("missing 'portal' address in iSCSI backing definition"));
-+        goto cleanup;
-+    }
-+
-+    if (!target) {
-+        virReportError(VIR_ERR_INVALID_ARG, "%s",
-+                       _("missing 'target' in iSCSI backing definition"));
-+        goto cleanup;
-+    }
-+
-+    if (VIR_STRDUP(src->hosts->name, portal) < 0)
-+        goto cleanup;
-+
-+    if ((port = strchr(src->hosts->name, ':'))) {
-+        if (VIR_STRDUP(src->hosts->port, port + 1) < 0)
-+            goto cleanup;
-+
-+        if (strlen(src->hosts->port) == 0)
-+            VIR_FREE(src->hosts->port);
-+
-+        *port = '\0';
-+    }
-+
-+    ignore_value(virJSONValueObjectGetNumberUint(json, "lun", &lun));
-+
-+    if (virAsprintf(&fulltarget, "%s/%u", target, lun) < 0)
-+        goto cleanup;
-+
-+    VIR_STEAL_PTR(src->path, fulltarget);
-+
-+    ret = 0;
-+
-+ cleanup:
-+    VIR_FREE(fulltarget);
-+    return ret;
- }
- 
- 
-diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
-index 4a1d4d0923..294e1f6ffb 100644
---- a/tests/virstoragetest.c
-+++ b/tests/virstoragetest.c
-@@ -1502,6 +1502,25 @@ mymain(void)
-                                     "\"driver\": \"file\","
-                                     "\"filename\": \"/path/to/file\" } } }",
-                        "<source file='/path/to/file'/>\n");
-+    TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\","
-+                                       "\"transport\":\"tcp\","
-+                                       "\"portal\":\"test.org\","
-+                                       "\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\""
-+                                      "}"
-+                            "}",
-+                       "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/0'>\n"
-+                       "  <host name='test.org'/>\n"
-+                       "</source>\n");
-+    TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\","
-+                                       "\"transport\":\"tcp\","
-+                                       "\"portal\":\"test.org:1234\","
-+                                       "\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\","
-+                                       "\"lun\":6"
-+                                      "}"
-+                            "}",
-+                       "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n"
-+                       "  <host name='test.org' port='1234'/>\n"
-+                       "</source>\n");
- 
-  cleanup:
-     /* Final cleanup */
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-Add-helpers-to-parse-and-format-relPath-into-privateData.patch b/SOURCES/libvirt-util-storage-Add-helpers-to-parse-and-format-relPath-into-privateData.patch
new file mode 100644
index 0000000..a70757f
--- /dev/null
+++ b/SOURCES/libvirt-util-storage-Add-helpers-to-parse-and-format-relPath-into-privateData.patch
@@ -0,0 +1,81 @@
+From a6aa51d7aa34a75355993d818a43bcb31094693e Mon Sep 17 00:00:00 2001
+Message-Id: <a6aa51d7aa34a75355993d818a43bcb31094693e@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 14 Dec 2017 14:31:52 +0100
+Subject: [PATCH] util: storage: Add helpers to parse and format relPath into
+ privateData
+
+This will be the first private piece of data that will need to be stored
+in the XML for some drivers. Add helpers which will do it.
+
+(cherry picked from commit cd31709351142a2770d2b9baa7755eaed672710a)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1523261
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/libvirt_private.syms  |  2 ++
+ src/util/virstoragefile.c | 20 ++++++++++++++++++++
+ src/util/virstoragefile.h |  8 ++++++++
+ 3 files changed, 30 insertions(+)
+
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index cb76bbac87..478b3b3a6f 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -2728,6 +2728,8 @@ virStorageSourceParseRBDColonString;
+ virStorageSourcePoolDefFree;
+ virStorageSourcePoolModeTypeFromString;
+ virStorageSourcePoolModeTypeToString;
++virStorageSourcePrivateDataFormatRelPath;
++virStorageSourcePrivateDataParseRelPath;
+ virStorageSourceUpdateBackingSizes;
+ virStorageSourceUpdateCapacity;
+ virStorageSourceUpdatePhysicalSize;
+diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
+index 3a2d2aa056..d1e356a121 100644
+--- a/src/util/virstoragefile.c
++++ b/src/util/virstoragefile.c
+@@ -4083,3 +4083,23 @@ virStorageSourceNetworkAssignDefaultPorts(virStorageSourcePtr src)
+             src->hosts[i].port = virStorageSourceNetworkDefaultPort(src->protocol);
+     }
+ }
++
++
++int
++virStorageSourcePrivateDataParseRelPath(xmlXPathContextPtr ctxt,
++                                        virStorageSourcePtr src)
++{
++    src->relPath = virXPathString("string(./relPath)", ctxt);
++    return 0;
++}
++
++
++int
++virStorageSourcePrivateDataFormatRelPath(virStorageSourcePtr src,
++                                         virBufferPtr buf)
++{
++    if (src->relPath)
++        virBufferEscapeString(buf, "<relPath>%s</relPath>\n", src->relPath);
++
++    return 0;
++}
+diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
+index af8f56c8a1..c909488024 100644
+--- a/src/util/virstoragefile.h
++++ b/src/util/virstoragefile.h
+@@ -438,4 +438,12 @@ bool
+ virStorageSourceHasBacking(const virStorageSource *src);
+ 
+ 
++int
++virStorageSourcePrivateDataParseRelPath(xmlXPathContextPtr ctxt,
++                                        virStorageSourcePtr src);
++int
++virStorageSourcePrivateDataFormatRelPath(virStorageSourcePtr src,
++                                         virBufferPtr buf);
++
++
+ #endif /* __VIR_STORAGE_FILE_H__ */
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-util-storage-Add-missing-return-to-virStorageSourceParseBackingJSONGluster.patch b/SOURCES/libvirt-util-storage-Add-missing-return-to-virStorageSourceParseBackingJSONGluster.patch
deleted file mode 100644
index 33eb7e2..0000000
--- a/SOURCES/libvirt-util-storage-Add-missing-return-to-virStorageSourceParseBackingJSONGluster.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From 90864415eb0d8e1942bdb879035941909dc0a191 Mon Sep 17 00:00:00 2001
-Message-Id: <90864415eb0d8e1942bdb879035941909dc0a191@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:36 +0200
-Subject: [PATCH] util: storage: Add missing return to
- virStorageSourceParseBackingJSONGluster
-
-If the number of servers is not expected the code would report an error
-but would not return failure.
-
-(cherry picked from commit 506b80c84e4556296ea7ac499c77b9f4ee87079f)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index 6427c2b24a..c86cd2fc0a 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -2893,6 +2893,8 @@ virStorageSourceParseBackingJSONGluster(virStorageSourcePtr src,
-         virReportError(VIR_ERR_INVALID_ARG, "%s",
-                        _("at least 1 server is necessary in "
-                          "JSON backing definition for gluster volume"));
-+
-+        return -1;
-     }
- 
-     if (VIR_ALLOC_N(src->hosts, nservers) < 0)
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-Add-support-for-type-inet-in-virStorageSourceParseBackingJSONSocketAddress.patch b/SOURCES/libvirt-util-storage-Add-support-for-type-inet-in-virStorageSourceParseBackingJSONSocketAddress.patch
deleted file mode 100644
index b54bcf7..0000000
--- a/SOURCES/libvirt-util-storage-Add-support-for-type-inet-in-virStorageSourceParseBackingJSONSocketAddress.patch
+++ /dev/null
@@ -1,96 +0,0 @@
-From bc2eb8e377c02190ee96a78ba0f1ede84ec65c72 Mon Sep 17 00:00:00 2001
-Message-Id: <bc2eb8e377c02190ee96a78ba0f1ede84ec65c72@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:38 +0200
-Subject: [PATCH] util: storage: Add support for type 'inet' in
- virStorageSourceParseBackingJSONSocketAddress
-
-'SocketAddress' structure was changed to contain 'inet' instead of
-'tcp' since qemu commit c5f1ae3ae7b. Existing entries have a backward
-compatibility layer.
-
-Libvirt will parse 'inet' and 'tcp' as equivalents.
-
-(cherry picked from commit 1f915d40a220c6bb05d8630507eed045cabfba34)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 23 +++++++++--------------
- tests/virstoragetest.c    |  2 +-
- 2 files changed, 10 insertions(+), 15 deletions(-)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index b8aced5055..3c06685d6b 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -2807,18 +2807,17 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
-     const char *hostname = virJSONValueObjectGetString(json, "host");
-     const char *port = virJSONValueObjectGetString(json, "port");
-     const char *socket = virJSONValueObjectGetString(json, "socket");
--    int transport;
- 
--    if ((transport = virStorageNetHostTransportTypeFromString(type)) < 0) {
--        virReportError(VIR_ERR_INTERNAL_ERROR,
--                       _("unknown backing store transport protocol '%s'"), type);
-+    if (!type) {
-+        virReportError(VIR_ERR_INVALID_ARG, "%s",
-+                       _("missing socket address type in "
-+                         "JSON backing volume definition"));
-         return -1;
-     }
- 
--    host->transport = transport;
-+    if (STREQ(type, "tcp") || STREQ(type, "inet")) {
-+        host->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
- 
--    switch ((virStorageNetHostTransport) transport) {
--    case VIR_STORAGE_NET_HOST_TRANS_TCP:
-         if (!hostname) {
-             virReportError(VIR_ERR_INVALID_ARG, "%s",
-                            _("missing hostname for tcp backing server in "
-@@ -2829,9 +2828,9 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
-         if (VIR_STRDUP(host->name, hostname) < 0 ||
-             VIR_STRDUP(host->port, port) < 0)
-             return -1;
--        break;
-+    } else if (STREQ(type, "unix")) {
-+        host->transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
- 
--    case VIR_STORAGE_NET_HOST_TRANS_UNIX:
-         if (!socket) {
-             virReportError(VIR_ERR_INVALID_ARG, "%s",
-                            _("missing socket path for udp backing server in "
-@@ -2839,13 +2838,9 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
-             return -1;
-         }
- 
--
-         if (VIR_STRDUP(host->socket, socket) < 0)
-             return -1;
--        break;
--
--    case VIR_STORAGE_NET_HOST_TRANS_RDMA:
--    case VIR_STORAGE_NET_HOST_TRANS_LAST:
-+    } else {
-         virReportError(VIR_ERR_INTERNAL_ERROR,
-                        _("backing store protocol '%s' is not yet supported"),
-                        type);
-diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
-index 984994d8e7..4a1d4d0923 100644
---- a/tests/virstoragetest.c
-+++ b/tests/virstoragetest.c
-@@ -1431,7 +1431,7 @@ mymain(void)
-                                                "{ \"type\":\"unix\","
-                                                  "\"socket\":\"/path/socket\""
-                                                "},"
--                                               "{ \"type\":\"tcp\","
-+                                               "{ \"type\":\"inet\","
-                                                  "\"host\":\"example.com\""
-                                                "}"
-                                              "]"
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-Export-virStorageIsRelative.patch b/SOURCES/libvirt-util-storage-Export-virStorageIsRelative.patch
deleted file mode 100644
index 4907c8e..0000000
--- a/SOURCES/libvirt-util-storage-Export-virStorageIsRelative.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From 1c328fa0094c7a1c913f57a7361f650657d1aae8 Mon Sep 17 00:00:00 2001
-Message-Id: <1c328fa0094c7a1c913f57a7361f650657d1aae8@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 14:45:36 +0200
-Subject: [PATCH] util: storage: Export virStorageIsRelative
-
-(cherry picked from commit e4c3eff70ed83694cc49820edcf7f5733e5bae27)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461303
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/libvirt_private.syms  | 1 +
- src/util/virstoragefile.c | 2 +-
- src/util/virstoragefile.h | 1 +
- 3 files changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 8c088316c4..9c596e3f1c 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -2561,6 +2561,7 @@ virStorageFileParseChainIndex;
- virStorageFileProbeFormat;
- virStorageFileResize;
- virStorageIsFile;
-+virStorageIsRelative;
- virStorageNetHostDefClear;
- virStorageNetHostDefCopy;
- virStorageNetHostDefFree;
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index c2ba3fba9f..3ed79fb2b5 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -801,7 +801,7 @@ virStorageIsFile(const char *backing)
- }
- 
- 
--static bool
-+bool
- virStorageIsRelative(const char *backing)
- {
-     if (backing[0] == '/')
-diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
-index 9ebfc11081..ce54a19cee 100644
---- a/src/util/virstoragefile.h
-+++ b/src/util/virstoragefile.h
-@@ -332,6 +332,7 @@ int virStorageFileResize(const char *path,
- 
- int virStorageFileIsClusterFS(const char *path);
- bool virStorageIsFile(const char *path);
-+bool virStorageIsRelative(const char *backing);
- 
- int virStorageFileGetLVMKey(const char *path,
-                             char **key);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-Make-backingFormat-optional-in-virStorageFileGetMetadataInternal.patch b/SOURCES/libvirt-util-storage-Make-backingFormat-optional-in-virStorageFileGetMetadataInternal.patch
deleted file mode 100644
index c348679..0000000
--- a/SOURCES/libvirt-util-storage-Make-backingFormat-optional-in-virStorageFileGetMetadataInternal.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From edc31db33c74dd86c1d49c4e561a8535ef5968a9 Mon Sep 17 00:00:00 2001
-Message-Id: <edc31db33c74dd86c1d49c4e561a8535ef5968a9@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 16:58:52 +0200
-Subject: [PATCH] util: storage: Make @backingFormat optional in
- virStorageFileGetMetadataInternal
-
-Some callers don't need to know the backing format. Make the argument
-optional by using a dummy int if NULL is passed.
-
-(cherry picked from commit 296a53313f447d2f251cbea2cb050d2f695a7991)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461303
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Andrea Bolognani <abologna@redhat.com>
----
- src/util/virstoragefile.c | 4 ++++
- src/util/virstoragefile.h | 2 +-
- 2 files changed, 5 insertions(+), 1 deletion(-)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index 3ed79fb2b5..437a13b90b 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -966,9 +966,13 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
-                                   size_t len,
-                                   int *backingFormat)
- {
-+    int dummy;
-     int ret = -1;
-     size_t i;
- 
-+    if (!backingFormat)
-+        backingFormat = &dummy;
-+
-     VIR_DEBUG("path=%s, buf=%p, len=%zu, meta->format=%d",
-               meta->path, buf, len, meta->format);
- 
-diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
-index ce54a19cee..0bff8671f7 100644
---- a/src/util/virstoragefile.h
-+++ b/src/util/virstoragefile.h
-@@ -293,7 +293,7 @@ int virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
-                                       char *buf,
-                                       size_t len,
-                                       int *backingFormat)
--    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
-+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
- 
- virStorageSourcePtr virStorageFileGetMetadataFromFD(const char *path,
-                                                     int fd,
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-Output-parsed-network-backing-store-string-to-debug-log.patch b/SOURCES/libvirt-util-storage-Output-parsed-network-backing-store-string-to-debug-log.patch
deleted file mode 100644
index e23f74d..0000000
--- a/SOURCES/libvirt-util-storage-Output-parsed-network-backing-store-string-to-debug-log.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 12fcf8798007a7a74b6aaa5e2bb632f21ada9a0a Mon Sep 17 00:00:00 2001
-Message-Id: <12fcf8798007a7a74b6aaa5e2bb632f21ada9a0a@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:35 +0200
-Subject: [PATCH] util: storage: Output parsed network backing store string to
- debug log
-
-(cherry picked from commit 236e1f7e8caf602f2c18525652b13f7b9ede4431)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index a51622affe..6427c2b24a 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -3234,6 +3234,8 @@ virStorageSourceNewFromBackingAbsolute(const char *path)
-     } else {
-         ret->type = VIR_STORAGE_TYPE_NETWORK;
- 
-+        VIR_DEBUG("parsing backing store string: '%s'", path);
-+
-         /* handle URI formatted backing stores */
-         if ((json = STRSKIP(path, "json:")))
-             rc = virStorageSourceParseBackingJSON(ret, json);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-Parse-lun-for-iSCSI-protocol-from-JSON-as-string-or-number.patch b/SOURCES/libvirt-util-storage-Parse-lun-for-iSCSI-protocol-from-JSON-as-string-or-number.patch
new file mode 100644
index 0000000..a40d86a
--- /dev/null
+++ b/SOURCES/libvirt-util-storage-Parse-lun-for-iSCSI-protocol-from-JSON-as-string-or-number.patch
@@ -0,0 +1,85 @@
+From 9356d615ccbbb556a11d70a01941964b1af7d503 Mon Sep 17 00:00:00 2001
+Message-Id: <9356d615ccbbb556a11d70a01941964b1af7d503@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Wed, 31 Jan 2018 12:51:00 +0100
+Subject: [PATCH] util: storage: Parse 'lun' for iSCSI protocol from JSON as
+ string or number
+
+While the QEMU QAPI schema describes 'lun' as a number, the code dealing
+with JSON strings does not strictly adhere to this schema and thus
+formats the number back as a string. Use the new helper to retrieve both
+possibilities.
+
+Note that the formatting code is okay and qemu will accept it as an int.
+
+Tweak also one of the test strings to verify that both formats work
+with libvirt.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1540290
+(cherry picked from commit f46d6e22f2dc352cd43480c1d148222f4e62b8e6)
+---
+ src/util/virstoragefile.c | 13 +++++--------
+ tests/virstoragetest.c    |  2 +-
+ 2 files changed, 6 insertions(+), 9 deletions(-)
+
+diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
+index d1e356a121..69deaea7c5 100644
+--- a/src/util/virstoragefile.c
++++ b/src/util/virstoragefile.c
+@@ -2966,10 +2966,9 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src,
+     const char *transport = virJSONValueObjectGetString(json, "transport");
+     const char *portal = virJSONValueObjectGetString(json, "portal");
+     const char *target = virJSONValueObjectGetString(json, "target");
++    const char *lun = virJSONValueObjectGetStringOrNumber(json, "lun");
+     const char *uri;
+     char *port;
+-    unsigned int lun = 0;
+-    char *fulltarget = NULL;
+     int ret = -1;
+ 
+     /* legacy URI based syntax passed via 'filename' option */
+@@ -2980,6 +2979,9 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src,
+     src->type = VIR_STORAGE_TYPE_NETWORK;
+     src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
+ 
++    if (!lun)
++        lun = "0";
++
+     if (VIR_ALLOC(src->hosts) < 0)
+         goto cleanup;
+ 
+@@ -3015,17 +3017,12 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src,
+         *port = '\0';
+     }
+ 
+-    ignore_value(virJSONValueObjectGetNumberUint(json, "lun", &lun));
+-
+-    if (virAsprintf(&fulltarget, "%s/%u", target, lun) < 0)
++    if (virAsprintf(&src->path, "%s/%s", target, lun) < 0)
+         goto cleanup;
+ 
+-    VIR_STEAL_PTR(src->path, fulltarget);
+-
+     ret = 0;
+ 
+  cleanup:
+-    VIR_FREE(fulltarget);
+     return ret;
+ }
+ 
+diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
+index bdd0829c21..b7f2eeb96d 100644
+--- a/tests/virstoragetest.c
++++ b/tests/virstoragetest.c
+@@ -1572,7 +1572,7 @@ mymain(void)
+                                        "\"transport\":\"tcp\","
+                                        "\"portal\":\"test.org:1234\","
+                                        "\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\","
+-                                       "\"lun\":6"
++                                       "\"lun\":\"6\""
+                                       "}"
+                             "}",
+                        "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n"
+-- 
+2.16.1
+
diff --git a/SOURCES/libvirt-util-storage-Report-errors-when-source-host-data-is-missing.patch b/SOURCES/libvirt-util-storage-Report-errors-when-source-host-data-is-missing.patch
deleted file mode 100644
index fcfa5fc..0000000
--- a/SOURCES/libvirt-util-storage-Report-errors-when-source-host-data-is-missing.patch
+++ /dev/null
@@ -1,77 +0,0 @@
-From 046e5f4d9cf163ec2f38ba201c7d4cbe7965d792 Mon Sep 17 00:00:00 2001
-Message-Id: <046e5f4d9cf163ec2f38ba201c7d4cbe7965d792@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:40 +0200
-Subject: [PATCH] util: storage: Report errors when source host data is missing
-
-Merge the reporting of the missing source host data into the parser
-functions so that callers don't have to do it separately.
-
-(cherry picked from commit 299aff7e0cd52c50da518eeed676144d373e9281)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 29 +++++++++++++++++++++++------
- 1 file changed, 23 insertions(+), 6 deletions(-)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index f67e714e3c..3f8bc43928 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -2803,8 +2803,18 @@ static int
- virStorageSourceParseBackingJSONInetSocketAddress(virStorageNetHostDefPtr host,
-                                                   virJSONValuePtr json)
- {
--    const char *hostname = virJSONValueObjectGetString(json, "host");
--    const char *port = virJSONValueObjectGetString(json, "port");
-+    const char *hostname;
-+    const char *port;
-+
-+    if (!json) {
-+        virReportError(VIR_ERR_INVALID_ARG, "%s",
-+                       _("missing remote server specification in JSON "
-+                         "backing volume definition"));
-+        return -1;
-+    }
-+
-+    hostname = virJSONValueObjectGetString(json, "host");
-+    port = virJSONValueObjectGetString(json, "port");
- 
-     if (!hostname) {
-         virReportError(VIR_ERR_INVALID_ARG, "%s",
-@@ -2827,10 +2837,17 @@ static int
- virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
-                                               virJSONValuePtr json)
- {
--    const char *type = virJSONValueObjectGetString(json, "type");
--    const char *socket = virJSONValueObjectGetString(json, "socket");
-+    const char *type;
-+    const char *socket;
- 
--    if (!type) {
-+    if (!json) {
-+        virReportError(VIR_ERR_INVALID_ARG, "%s",
-+                       _("missing remote server specification in JSON "
-+                         "backing volume definition"));
-+        return -1;
-+    }
-+
-+    if (!(type = virJSONValueObjectGetString(json, "type"))) {
-         virReportError(VIR_ERR_INVALID_ARG, "%s",
-                        _("missing socket address type in "
-                          "JSON backing volume definition"));
-@@ -2843,7 +2860,7 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
-     } else if (STREQ(type, "unix")) {
-         host->transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
- 
--        if (!socket) {
-+        if (!(socket = virJSONValueObjectGetString(json, "socket"))) {
-             virReportError(VIR_ERR_INVALID_ARG, "%s",
-                            _("missing socket path for udp backing server in "
-                              "JSON backing volume definition"));
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-Split-out-parsing-of-TCP-network-host-from-JSON-pseudoprotocol.patch b/SOURCES/libvirt-util-storage-Split-out-parsing-of-TCP-network-host-from-JSON-pseudoprotocol.patch
deleted file mode 100644
index b522c63..0000000
--- a/SOURCES/libvirt-util-storage-Split-out-parsing-of-TCP-network-host-from-JSON-pseudoprotocol.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-From 663456f9a380912ee4659616074c091cb973a330 Mon Sep 17 00:00:00 2001
-Message-Id: <663456f9a380912ee4659616074c091cb973a330@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:39 +0200
-Subject: [PATCH] util: storage: Split out parsing of TCP network host from
- JSON pseudoprotocol
-
-Few backing protocols support only TCP. Split out the function which
-will correspond to parsing qemu's InetSocketAddressBase.
-
-(cherry picked from commit 49ed98a4579744568b5c57f65ae08034d5c9568f)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 38 +++++++++++++++++++++++++-------------
- 1 file changed, 25 insertions(+), 13 deletions(-)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index 3c06685d6b..f67e714e3c 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -2800,12 +2800,34 @@ virStorageSourceParseBackingJSONUri(virStorageSourcePtr src,
- 
- 
- static int
-+virStorageSourceParseBackingJSONInetSocketAddress(virStorageNetHostDefPtr host,
-+                                                  virJSONValuePtr json)
-+{
-+    const char *hostname = virJSONValueObjectGetString(json, "host");
-+    const char *port = virJSONValueObjectGetString(json, "port");
-+
-+    if (!hostname) {
-+        virReportError(VIR_ERR_INVALID_ARG, "%s",
-+                       _("missing hostname for tcp backing server in "
-+                         "JSON backing volume definition"));
-+        return -1;
-+    }
-+
-+    host->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
-+
-+    if (VIR_STRDUP(host->name, hostname) < 0 ||
-+        VIR_STRDUP(host->port, port) < 0)
-+        return -1;
-+
-+    return 0;
-+}
-+
-+
-+static int
- virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
-                                               virJSONValuePtr json)
- {
-     const char *type = virJSONValueObjectGetString(json, "type");
--    const char *hostname = virJSONValueObjectGetString(json, "host");
--    const char *port = virJSONValueObjectGetString(json, "port");
-     const char *socket = virJSONValueObjectGetString(json, "socket");
- 
-     if (!type) {
-@@ -2816,18 +2838,8 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
-     }
- 
-     if (STREQ(type, "tcp") || STREQ(type, "inet")) {
--        host->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
-+        return virStorageSourceParseBackingJSONInetSocketAddress(host, json);
- 
--        if (!hostname) {
--            virReportError(VIR_ERR_INVALID_ARG, "%s",
--                           _("missing hostname for tcp backing server in "
--                             "JSON backing volume definition"));
--            return -1;
--        }
--
--        if (VIR_STRDUP(host->name, hostname) < 0 ||
--            VIR_STRDUP(host->port, port) < 0)
--            return -1;
-     } else if (STREQ(type, "unix")) {
-         host->transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-NBD.patch b/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-NBD.patch
deleted file mode 100644
index 1a8260b..0000000
--- a/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-NBD.patch
+++ /dev/null
@@ -1,97 +0,0 @@
-From 042cf4d53a2422d998e6715a6c914f61cb345bb9 Mon Sep 17 00:00:00 2001
-Message-Id: <042cf4d53a2422d998e6715a6c914f61cb345bb9@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:42 +0200
-Subject: [PATCH] util: storage: adapt to changes in JSON format for NBD
-
-Since 2.9 the host and port for NBD are no longer directly under the
-json pseudo-protocol object, but rather belong to a sub-object called
-'server'.
-
-(cherry picked from commit 35d23f90b2266adb93079755161515699a401932)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 28 +++++++++++++++++-----------
- tests/virstoragetest.c    | 11 +++++++++++
- 2 files changed, 28 insertions(+), 11 deletions(-)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index 945c3e4198..ef3050711b 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -3019,11 +3019,12 @@ virStorageSourceParseBackingJSONNbd(virStorageSourcePtr src,
-     const char *host = virJSONValueObjectGetString(json, "host");
-     const char *port = virJSONValueObjectGetString(json, "port");
-     const char *export = virJSONValueObjectGetString(json, "export");
-+    virJSONValuePtr server = virJSONValueObjectGetObject(json, "server");
- 
--    if (!path && !host) {
-+    if (!path && !host && !server) {
-         virReportError(VIR_ERR_INVALID_ARG, "%s",
--                       _("missing path or host of NBD server in JSON backing "
--                         "volume definition"));
-+                       _("missing host specification of NBD server in JSON "
-+                         "backing volume definition"));
-         return -1;
-     }
- 
-@@ -3037,17 +3038,22 @@ virStorageSourceParseBackingJSONNbd(virStorageSourcePtr src,
-         return -1;
-     src->nhosts = 1;
- 
--    if (path) {
--        src->hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
--        if (VIR_STRDUP(src->hosts[0].socket, path) < 0)
-+    if (server) {
-+        if (virStorageSourceParseBackingJSONSocketAddress(src->hosts, server) < 0)
-             return -1;
-     } else {
--        src->hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
--        if (VIR_STRDUP(src->hosts[0].name, host) < 0)
--            return -1;
-+        if (path) {
-+            src->hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
-+            if (VIR_STRDUP(src->hosts[0].socket, path) < 0)
-+                return -1;
-+        } else {
-+            src->hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
-+            if (VIR_STRDUP(src->hosts[0].name, host) < 0)
-+                return -1;
- 
--        if (VIR_STRDUP(src->hosts[0].port, port) < 0)
--            return -1;
-+            if (VIR_STRDUP(src->hosts[0].port, port) < 0)
-+                return -1;
-+        }
-     }
- 
-     return 0;
-diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
-index 294e1f6ffb..54f7c849c5 100644
---- a/tests/virstoragetest.c
-+++ b/tests/virstoragetest.c
-@@ -1471,6 +1471,17 @@ mymain(void)
-                        "<source protocol='nbd' name='blah'>\n"
-                        "  <host name='example.org' port='6000'/>\n"
-                        "</source>\n");
-+    TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\","
-+                                       "\"export\":\"blah\","
-+                                       "\"server\": { \"type\":\"inet\","
-+                                                     "\"host\":\"example.org\","
-+                                                     "\"port\":\"6000\""
-+                                                   "}"
-+                                      "}"
-+                            "}",
-+                       "<source protocol='nbd' name='blah'>\n"
-+                       "  <host name='example.org' port='6000'/>\n"
-+                       "</source>\n");
-     TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"ssh\","
-                                        "\"host\":\"example.org\","
-                                        "\"port\":\"6000\","
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-ceph-rbd.patch b/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-ceph-rbd.patch
deleted file mode 100644
index 172dac4..0000000
--- a/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-ceph-rbd.patch
+++ /dev/null
@@ -1,122 +0,0 @@
-From 825c7ad1ab9be3abcd1935491d11d0590e3b3462 Mon Sep 17 00:00:00 2001
-Message-Id: <825c7ad1ab9be3abcd1935491d11d0590e3b3462@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:43 +0200
-Subject: [PATCH] util: storage: adapt to changes in JSON format for ceph/rbd
-
-Since qemu 2.9 the options changed from a monolithic string into fine
-grained options for the json pseudo-protocol object.
-
-(cherry picked from commit 4fac5a1935041254964313ed722fa8d59f8fa2de)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 50 +++++++++++++++++++++++++++++++++++++++++++----
- tests/virstoragetest.c    | 19 ++++++++++++++++++
- 2 files changed, 65 insertions(+), 4 deletions(-)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index ef3050711b..68bfdcd0ca 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -3127,6 +3127,15 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
-                                     int opaque ATTRIBUTE_UNUSED)
- {
-     const char *filename;
-+    const char *pool = virJSONValueObjectGetString(json, "pool");
-+    const char *image = virJSONValueObjectGetString(json, "image");
-+    const char *conf = virJSONValueObjectGetString(json, "conf");
-+    const char *snapshot = virJSONValueObjectGetString(json, "snapshot");
-+    virJSONValuePtr servers = virJSONValueObjectGetArray(json, "server");
-+    char *fullname = NULL;
-+    size_t nservers;
-+    size_t i;
-+    int ret = -1;
- 
-     src->type = VIR_STORAGE_TYPE_NETWORK;
-     src->protocol = VIR_STORAGE_NET_PROTOCOL_RBD;
-@@ -3135,11 +3144,44 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
-     if ((filename = virJSONValueObjectGetString(json, "filename")))
-         return virStorageSourceParseRBDColonString(filename, src);
- 
--    /* RBD currently supports only URI syntax passed in as filename */
--    virReportError(VIR_ERR_INVALID_ARG, "%s",
--                   _("missing RBD filename in JSON backing volume definition"));
-+    if (!pool || !image) {
-+        virReportError(VIR_ERR_INVALID_ARG, "%s",
-+                       _("missing pool or image name in ceph backing volume "
-+                         "JSON specification"));
-+        return -1;
-+    }
- 
--    return -1;
-+    /* currently we need to store the pool name and image name together, since
-+     * the rest of the code is not prepared for it */
-+    if (virAsprintf(&fullname, "%s/%s", pool, image) < 0)
-+        return -1;
-+
-+    if (VIR_STRDUP(src->snapshot, snapshot) < 0 ||
-+        VIR_STRDUP(src->configFile, conf) < 0)
-+        goto cleanup;
-+
-+    VIR_STEAL_PTR(src->path, fullname);
-+
-+    if (servers) {
-+        nservers = virJSONValueArraySize(servers);
-+
-+        if (VIR_ALLOC_N(src->hosts, nservers) < 0)
-+            goto cleanup;
-+
-+        src->nhosts = nservers;
-+
-+        for (i = 0; i < nservers; i++) {
-+            if (virStorageSourceParseBackingJSONInetSocketAddress(src->hosts + i,
-+                                                                  virJSONValueArrayGet(servers, i)) < 0)
-+                goto cleanup;
-+        }
-+    }
-+
-+    ret = 0;
-+ cleanup:
-+    VIR_FREE(fullname);
-+
-+    return ret;
- }
- 
- static int
-diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
-index 54f7c849c5..97eaeab094 100644
---- a/tests/virstoragetest.c
-+++ b/tests/virstoragetest.c
-@@ -1507,6 +1507,25 @@ mymain(void)
-                        "<source protocol='rbd' name='testshare'>\n"
-                        "  <host name='example.com'/>\n"
-                        "</source>\n");
-+    TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"rbd\","
-+                                       "\"image\":\"test\","
-+                                       "\"pool\":\"libvirt\","
-+                                       "\"conf\":\"/path/to/conf\","
-+                                       "\"snapshot\":\"snapshotname\","
-+                                       "\"server\":[ {\"host\":\"example.com\","
-+                                                      "\"port\":\"1234\""
-+                                                    "},"
-+                                                    "{\"host\":\"example2.com\""
-+                                                    "}"
-+                                                  "]"
-+                                      "}"
-+                             "}",
-+                        "<source protocol='rbd' name='libvirt/test'>\n"
-+                        "  <host name='example.com' port='1234'/>\n"
-+                        "  <host name='example2.com'/>\n"
-+                        "  <snapshot name='snapshotname'/>\n"
-+                        "  <config file='/path/to/conf'/>\n"
-+                        "</source>\n");
-     TEST_BACKING_PARSE("json:{ \"file\": { "
-                                 "\"driver\": \"raw\","
-                                 "\"file\": {"
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-sheepdog.patch b/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-sheepdog.patch
deleted file mode 100644
index 94e1d9d..0000000
--- a/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-sheepdog.patch
+++ /dev/null
@@ -1,94 +0,0 @@
-From 5e1615fba181a37d805c17f517c0a925d171fff5 Mon Sep 17 00:00:00 2001
-Message-Id: <5e1615fba181a37d805c17f517c0a925d171fff5@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:45 +0200
-Subject: [PATCH] util: storage: adapt to changes in JSON format for sheepdog
-
-Since qemu 2.9 the options changed from a monolithic string into fine
-grained options for the json pseudo-protocol object.
-
-(cherry picked from commit b16133b114fd0d787de1cda6bf2ff0110c523a32)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 28 ++++++++++++++++++++++++----
- tests/virstoragetest.c    | 11 +++++++++++
- 2 files changed, 35 insertions(+), 4 deletions(-)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index 566c4c27c3..c2ba3fba9f 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -3066,6 +3066,8 @@ virStorageSourceParseBackingJSONSheepdog(virStorageSourcePtr src,
-                                          int opaque ATTRIBUTE_UNUSED)
- {
-     const char *filename;
-+    const char *vdi = virJSONValueObjectGetString(json, "vdi");
-+    virJSONValuePtr server = virJSONValueObjectGetObject(json, "server");
- 
-     /* legacy URI based syntax passed via 'filename' option */
-     if ((filename = virJSONValueObjectGetString(json, "filename"))) {
-@@ -3074,13 +3076,31 @@ virStorageSourceParseBackingJSONSheepdog(virStorageSourcePtr src,
-                                                           VIR_STORAGE_NET_PROTOCOL_SHEEPDOG);
- 
-         /* libvirt doesn't implement a parser for the legacy non-URI syntax */
-+        virReportError(VIR_ERR_INVALID_ARG, "%s",
-+                       _("missing sheepdog URI in JSON backing volume definition"));
-+        return -1;
-     }
- 
--    /* Sheepdog currently supports only URI and legacy syntax passed in as filename */
--    virReportError(VIR_ERR_INVALID_ARG, "%s",
--                   _("missing sheepdog URI in JSON backing volume definition"));
-+    src->type = VIR_STORAGE_TYPE_NETWORK;
-+    src->protocol = VIR_STORAGE_NET_PROTOCOL_SHEEPDOG;
- 
--    return -1;
-+    if (!vdi) {
-+        virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing sheepdog vdi name"));
-+        return -1;
-+    }
-+
-+    if (VIR_STRDUP(src->path, vdi) < 0)
-+        return -1;
-+
-+    if (VIR_ALLOC(src->hosts) < 0)
-+        return -1;
-+
-+    src->nhosts = 1;
-+
-+    if (virStorageSourceParseBackingJSONSocketAddress(src->hosts, server) < 0)
-+        return -1;
-+
-+    return 0;
- }
- 
- 
-diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
-index 9ca927b5e4..36b8265dff 100644
---- a/tests/virstoragetest.c
-+++ b/tests/virstoragetest.c
-@@ -1562,6 +1562,17 @@ mymain(void)
-                        "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n"
-                        "  <host name='test.org' port='1234'/>\n"
-                        "</source>\n");
-+    TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"sheepdog\","
-+                                       "\"vdi\":\"test\","
-+                                       "\"server\":{ \"type\":\"inet\","
-+                                                    "\"host\":\"example.com\","
-+                                                    "\"port\":\"321\""
-+                                                  "}"
-+                                      "}"
-+                            "}",
-+                       "<source protocol='sheepdog' name='test'>\n"
-+                       "  <host name='example.com' port='321'/>\n"
-+                       "</source>\n");
- 
-  cleanup:
-     /* Final cleanup */
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-ssh.patch b/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-ssh.patch
deleted file mode 100644
index d5cf233..0000000
--- a/SOURCES/libvirt-util-storage-adapt-to-changes-in-JSON-format-for-ssh.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-From 90ebcae8a87903065233bfc55a607fcfd103c476 Mon Sep 17 00:00:00 2001
-Message-Id: <90ebcae8a87903065233bfc55a607fcfd103c476@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:44 +0200
-Subject: [PATCH] util: storage: adapt to changes in JSON format for ssh
-
-Since qemu 2.9 the options changed from a monolithic string into fine
-grained options for the json pseudo-protocol object.
-
-(cherry picked from commit ea2c418ac30628d1db021f351f0ea5440ba5e4e4)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 21 +++++++++++++--------
- tests/virstoragetest.c    | 11 +++++++++++
- 2 files changed, 24 insertions(+), 8 deletions(-)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index 68bfdcd0ca..566c4c27c3 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -3092,10 +3092,11 @@ virStorageSourceParseBackingJSONSSH(virStorageSourcePtr src,
-     const char *path = virJSONValueObjectGetString(json, "path");
-     const char *host = virJSONValueObjectGetString(json, "host");
-     const char *port = virJSONValueObjectGetString(json, "port");
-+    virJSONValuePtr server = virJSONValueObjectGetObject(json, "server");
- 
--    if (!host || !path) {
-+    if (!(host || server) || !path) {
-         virReportError(VIR_ERR_INVALID_ARG, "%s",
--                       _("missing host or path of SSH JSON backing "
-+                       _("missing host/server or path of SSH JSON backing "
-                          "volume definition"));
-         return -1;
-     }
-@@ -3110,12 +3111,16 @@ virStorageSourceParseBackingJSONSSH(virStorageSourcePtr src,
-         return -1;
-     src->nhosts = 1;
- 
--    src->hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
--    if (VIR_STRDUP(src->hosts[0].name, host) < 0)
--        return -1;
--
--    if (VIR_STRDUP(src->hosts[0].port, port) < 0)
--        return -1;
-+    if (server) {
-+        if (virStorageSourceParseBackingJSONInetSocketAddress(src->hosts,
-+                                                              server) < 0)
-+            return -1;
-+    } else {
-+        src->hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
-+        if (VIR_STRDUP(src->hosts[0].name, host) < 0 ||
-+            VIR_STRDUP(src->hosts[0].port, port) < 0)
-+            return -1;
-+    }
- 
-     return 0;
- }
-diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
-index 97eaeab094..9ca927b5e4 100644
---- a/tests/virstoragetest.c
-+++ b/tests/virstoragetest.c
-@@ -1501,6 +1501,17 @@ mymain(void)
-                        "<source protocol='ssh' name='blah'>\n"
-                        "  <host name='example.org' port='6000'/>\n"
-                        "</source>\n");
-+    TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"ssh\","
-+                                       "\"path\":\"blah\","
-+                                       "\"server\":{ \"host\":\"example.org\","
-+                                                    "\"port\":\"6000\""
-+                                                  "},"
-+                                       "\"user\":\"user\""
-+                                      "}"
-+                            "}",
-+                       "<source protocol='ssh' name='blah'>\n"
-+                       "  <host name='example.org' port='6000'/>\n"
-+                       "</source>\n");
-     TEST_BACKING_PARSE("json:{\"file.driver\":\"rbd\","
-                              "\"file.filename\":\"rbd:testshare:id=asdf:mon_host=example.com\""
-                             "}",
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-util-storage-make-virStorageSourceParseBackingJSONGlusterHost-universal.patch b/SOURCES/libvirt-util-storage-make-virStorageSourceParseBackingJSONGlusterHost-universal.patch
deleted file mode 100644
index 24b980d..0000000
--- a/SOURCES/libvirt-util-storage-make-virStorageSourceParseBackingJSONGlusterHost-universal.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-From 963c75c28dcda3f5a01df2d13d0a42186adbc2de Mon Sep 17 00:00:00 2001
-Message-Id: <963c75c28dcda3f5a01df2d13d0a42186adbc2de@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Tue, 20 Jun 2017 10:22:37 +0200
-Subject: [PATCH] util: storage: make
- virStorageSourceParseBackingJSONGlusterHost universal
-
-The same json strucutre is used for NBD and sheepdog volumes for
-specifying of the host. Rename the function and fix up error messages to
-be more universal.
-
-(cherry picked from commit 6402f402d4577b5eacf00debe5e59c328bb58f75)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1461638
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
-Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
----
- src/util/virstoragefile.c | 12 ++++++------
- 1 file changed, 6 insertions(+), 6 deletions(-)
-
-diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
-index c86cd2fc0a..b8aced5055 100644
---- a/src/util/virstoragefile.c
-+++ b/src/util/virstoragefile.c
-@@ -2800,8 +2800,8 @@ virStorageSourceParseBackingJSONUri(virStorageSourcePtr src,
- 
- 
- static int
--virStorageSourceParseBackingJSONGlusterHost(virStorageNetHostDefPtr host,
--                                            virJSONValuePtr json)
-+virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
-+                                              virJSONValuePtr json)
- {
-     const char *type = virJSONValueObjectGetString(json, "type");
-     const char *hostname = virJSONValueObjectGetString(json, "host");
-@@ -2822,7 +2822,7 @@ virStorageSourceParseBackingJSONGlusterHost(virStorageNetHostDefPtr host,
-         if (!hostname) {
-             virReportError(VIR_ERR_INVALID_ARG, "%s",
-                            _("missing hostname for tcp backing server in "
--                             "JSON backing definition for gluster volume"));
-+                             "JSON backing volume definition"));
-             return -1;
-         }
- 
-@@ -2835,7 +2835,7 @@ virStorageSourceParseBackingJSONGlusterHost(virStorageNetHostDefPtr host,
-         if (!socket) {
-             virReportError(VIR_ERR_INVALID_ARG, "%s",
-                            _("missing socket path for udp backing server in "
--                             "JSON backing definition for gluster volume"));
-+                             "JSON backing volume definition"));
-             return -1;
-         }
- 
-@@ -2902,8 +2902,8 @@ virStorageSourceParseBackingJSONGluster(virStorageSourcePtr src,
-     src->nhosts = nservers;
- 
-     for (i = 0; i < nservers; i++) {
--        if (virStorageSourceParseBackingJSONGlusterHost(src->hosts + i,
--                                                        virJSONValueArrayGet(server, i)) < 0)
-+        if (virStorageSourceParseBackingJSONSocketAddress(src->hosts + i,
-+                                                          virJSONValueArrayGet(server, i)) < 0)
-             return -1;
-     }
- 
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-vierror-Define-VIR_ERROR_MAX_LENGTH-macro.patch b/SOURCES/libvirt-vierror-Define-VIR_ERROR_MAX_LENGTH-macro.patch
new file mode 100644
index 0000000..8bd88a3
--- /dev/null
+++ b/SOURCES/libvirt-vierror-Define-VIR_ERROR_MAX_LENGTH-macro.patch
@@ -0,0 +1,61 @@
+From e1925c70ae31799e0c829ffee5afe88546cd000d Mon Sep 17 00:00:00 2001
+Message-Id: <e1925c70ae31799e0c829ffee5afe88546cd000d@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Wed, 22 Nov 2017 10:28:35 +0100
+Subject: [PATCH] vierror: Define VIR_ERROR_MAX_LENGTH macro
+
+And use it instead of a magic 1024 constant.
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+(cherry picked from commit c88ce8ae740165ffcf3cb172c6950ffe0c3a7b3b)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1335534
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
+---
+ src/util/virerror.c | 6 +++---
+ src/util/virerror.h | 2 ++
+ 2 files changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/src/util/virerror.c b/src/util/virerror.c
+index 1f15c5dbbe..91022c3b63 100644
+--- a/src/util/virerror.c
++++ b/src/util/virerror.c
+@@ -1480,7 +1480,7 @@ void virReportErrorHelper(int domcode,
+ {
+     int save_errno = errno;
+     va_list args;
+-    char errorMessage[1024];
++    char errorMessage[VIR_ERROR_MAX_LENGTH];
+     const char *virerr;
+ 
+     if (fmt) {
+@@ -1541,8 +1541,8 @@ void virReportSystemErrorFull(int domcode,
+                               const char *fmt, ...)
+ {
+     int save_errno = errno;
+-    char strerror_buf[1024];
+-    char msgDetailBuf[1024];
++    char strerror_buf[VIR_ERROR_MAX_LENGTH];
++    char msgDetailBuf[VIR_ERROR_MAX_LENGTH];
+ 
+     const char *errnoDetail = virStrerror(theerrno, strerror_buf,
+                                           sizeof(strerror_buf));
+diff --git a/src/util/virerror.h b/src/util/virerror.h
+index 3201d5cec6..77f6340dc8 100644
+--- a/src/util/virerror.h
++++ b/src/util/virerror.h
+@@ -24,6 +24,8 @@
+ 
+ # include "internal.h"
+ 
++# define VIR_ERROR_MAX_LENGTH 1024
++
+ extern virErrorFunc virErrorHandler;
+ extern void *virUserData;
+ 
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-virDomainDiskBackingStoreParse-Don-t-leak-idx.patch b/SOURCES/libvirt-virDomainDiskBackingStoreParse-Don-t-leak-idx.patch
new file mode 100644
index 0000000..d431e2e
--- /dev/null
+++ b/SOURCES/libvirt-virDomainDiskBackingStoreParse-Don-t-leak-idx.patch
@@ -0,0 +1,44 @@
+From 0d914e2528519ec2130a01017b32c373964fb825 Mon Sep 17 00:00:00 2001
+Message-Id: <0d914e2528519ec2130a01017b32c373964fb825@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Fri, 1 Dec 2017 15:48:38 +0100
+Subject: [PATCH] virDomainDiskBackingStoreParse: Don't leak @idx
+
+==1277== 8 bytes in 4 blocks are definitely lost in loss record 39 of 131
+==1277==    at 0x4C2AEDF: malloc (vg_replace_malloc.c:299)
+==1277==    by 0x68BBBC8: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
+==1277==    by 0x53B1DC2: virXMLPropString (virxml.c:510)
+==1277==    by 0x53D696A: virDomainDiskBackingStoreParse (domain_conf.c:8639)
+==1277==    by 0x53DA684: virDomainDiskDefParseXML (domain_conf.c:9590)
+==1277==    by 0x53F619F: virDomainDefParseXML (domain_conf.c:19233)
+==1277==    by 0x53F96EE: virDomainDefParseNode (domain_conf.c:20083)
+==1277==    by 0x53F9540: virDomainDefParse (domain_conf.c:20027)
+==1277==    by 0x53F95E6: virDomainDefParseFile (domain_conf.c:20053)
+==1277==    by 0x44D1D4: testCompareDomXML2XMLFiles (testutils.c:1265)
+==1277==    by 0x42FC7C: testXML2XMLActive (qemuxml2xmltest.c:71)
+==1277==    by 0x44AD20: virTestRun (testutils.c:180)
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+(cherry picked from commit 0fd85b98aee9094bf61a2db86b795421119a41b5)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1519759
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 3bb66e4326..83392a42c0 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -8671,6 +8671,7 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
+     virStorageSourceFree(backingStore);
+     VIR_FREE(type);
+     VIR_FREE(format);
++    VIR_FREE(idx);
+     ctxt->node = save_ctxt;
+     return ret;
+ }
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-virDomainDiskSourceNetworkParse-Don-t-leak-tlsCfg-or-haveTLS.patch b/SOURCES/libvirt-virDomainDiskSourceNetworkParse-Don-t-leak-tlsCfg-or-haveTLS.patch
new file mode 100644
index 0000000..0c45790
--- /dev/null
+++ b/SOURCES/libvirt-virDomainDiskSourceNetworkParse-Don-t-leak-tlsCfg-or-haveTLS.patch
@@ -0,0 +1,46 @@
+From e795a37abe3dab75cfb48d9b514cd3d42a2b7722 Mon Sep 17 00:00:00 2001
+Message-Id: <e795a37abe3dab75cfb48d9b514cd3d42a2b7722@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Fri, 1 Dec 2017 15:48:37 +0100
+Subject: [PATCH] virDomainDiskSourceNetworkParse: Don't leak @tlsCfg or
+ @haveTLS
+
+==861== 3 bytes in 1 blocks are definitely lost in loss record 3 of 168
+==861==    at 0x4C2AEDF: malloc (vg_replace_malloc.c:299)
+==861==    by 0x8C7FBC8: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
+==861==    by 0x5DCCDC2: virXMLPropString (virxml.c:510)
+==861==    by 0x5DF1232: virDomainDiskSourceNetworkParse (domain_conf.c:8445)
+==861==    by 0x5DF1728: virDomainDiskSourceParse (domain_conf.c:8576)
+==861==    by 0x5DF41A5: virDomainDiskDefParseXML (domain_conf.c:9238)
+==861==    by 0x5E1119F: virDomainDefParseXML (domain_conf.c:19233)
+==861==    by 0x5E146EE: virDomainDefParseNode (domain_conf.c:20083)
+==861==    by 0x5E14540: virDomainDefParse (domain_conf.c:20027)
+==861==    by 0x5E145E6: virDomainDefParseFile (domain_conf.c:20053)
+==861==    by 0x4053CC: testCompareXMLToArgv (qemuxml2argvtest.c:455)
+==861==    by 0x41F135: virTestRun (testutils.c:180)
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+(cherry picked from commit 7d7c01b4580f471e1376e30d4092dcf45cfe0ccc)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1519759
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/domain_conf.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index ec138ea861..3bb66e4326 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -8489,6 +8489,8 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
+     ret = 0;
+ 
+  cleanup:
++    VIR_FREE(tlsCfg);
++    VIR_FREE(haveTLS);
+     VIR_FREE(protocol);
+     return ret;
+ }
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-virDomainNumaGetNodeDistance-Fix-input-arguments-validation.patch b/SOURCES/libvirt-virDomainNumaGetNodeDistance-Fix-input-arguments-validation.patch
new file mode 100644
index 0000000..7d3437a
--- /dev/null
+++ b/SOURCES/libvirt-virDomainNumaGetNodeDistance-Fix-input-arguments-validation.patch
@@ -0,0 +1,40 @@
+From 1033a81438d6eae6eea225d489f876749f966f4d Mon Sep 17 00:00:00 2001
+Message-Id: <1033a81438d6eae6eea225d489f876749f966f4d@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Mon, 4 Dec 2017 13:38:49 +0100
+Subject: [PATCH] virDomainNumaGetNodeDistance: Fix input arguments validation
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1454889
+
+There's no point in checking if numa->mem_nodes[node].ndistances
+is set if we check for numa->mem_nodes[node].distances. However,
+it makes sense to check if the sibling node (@cellid) caller
+passed falls within boundaries.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Reviewed-by: John Ferlan <jferlan@redhat.com>
+(cherry picked from commit 0ededbb84eb34539e326b4d4791772b699352302)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/numa_conf.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
+index 7bba4120bd..c2f0d1ca8c 100644
+--- a/src/conf/numa_conf.c
++++ b/src/conf/numa_conf.c
+@@ -1153,8 +1153,8 @@ virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
+      * defined default for local and remote nodes.
+      */
+     if (!distances ||
+-        !distances[cellid].value ||
+-        !numa->mem_nodes[node].ndistances)
++        cellid >= numa->nmem_nodes ||
++        !distances[cellid].value)
+         return (node == cellid) ? LOCAL_DISTANCE : REMOTE_DISTANCE;
+ 
+     return distances[cellid].value;
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-virDomainXMLOption-Introduce-virDomainABIStabilityDomain.patch b/SOURCES/libvirt-virDomainXMLOption-Introduce-virDomainABIStabilityDomain.patch
deleted file mode 100644
index f58e702..0000000
--- a/SOURCES/libvirt-virDomainXMLOption-Introduce-virDomainABIStabilityDomain.patch
+++ /dev/null
@@ -1,617 +0,0 @@
-From c6dcdb3a528ca4fb8f06118a28b53ab7d174d26a Mon Sep 17 00:00:00 2001
-Message-Id: <c6dcdb3a528ca4fb8f06118a28b53ab7d174d26a@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Mon, 5 Jun 2017 09:35:23 +0200
-Subject: [PATCH] virDomainXMLOption: Introduce virDomainABIStabilityDomain
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1450349
-
-While checking for ABI stability, drivers might pose additional
-checks that are not valid for general case. For instance, qemu
-driver might check some memory backing attributes because of how
-qemu works. But those attributes may work well in other drivers.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-(cherry picked from commit 4f0aeed8713b679dd024542f4823efcef1473f4f)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/bhyve/bhyve_domain.c      |  2 +-
- src/conf/domain_conf.c        | 19 ++++++++++++++++---
- src/conf/domain_conf.h        | 16 ++++++++++++++--
- src/conf/snapshot_conf.c      |  3 ++-
- src/conf/snapshot_conf.h      |  1 +
- src/libxl/libxl_conf.c        |  2 +-
- src/libxl/libxl_domain.c      |  4 +++-
- src/lxc/lxc_conf.c            |  3 ++-
- src/openvz/openvz_driver.c    |  2 +-
- src/phyp/phyp_driver.c        |  2 +-
- src/qemu/qemu_capabilities.c  |  2 +-
- src/qemu/qemu_conf.c          |  3 ++-
- src/qemu/qemu_domain.c        |  1 +
- src/qemu/qemu_driver.c        |  5 +++--
- src/security/virt-aa-helper.c |  2 +-
- src/test/test_driver.c        |  6 ++++--
- src/uml/uml_driver.c          |  2 +-
- src/vbox/vbox_common.c        |  2 +-
- src/vmware/vmware_driver.c    |  2 +-
- src/vmx/vmx.c                 |  2 +-
- src/vz/vz_driver.c            |  2 +-
- src/xen/xen_driver.c          |  2 +-
- src/xenapi/xenapi_driver.c    |  2 +-
- tests/bhyveargv2xmltest.c     |  3 ++-
- tests/qemuargv2xmltest.c      |  2 +-
- tests/qemuxml2argvtest.c      |  2 +-
- tests/sexpr2xmltest.c         |  2 +-
- tests/testutils.c             |  4 ++--
- tests/vmx2xmltest.c           |  2 +-
- tests/xlconfigtest.c          |  2 +-
- tests/xmconfigtest.c          |  2 +-
- tests/xml2sexprtest.c         |  2 +-
- tests/xml2vmxtest.c           |  2 +-
- 33 files changed, 73 insertions(+), 37 deletions(-)
-
-diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
-index 76b4fac2c4..0a99550afa 100644
---- a/src/bhyve/bhyve_domain.c
-+++ b/src/bhyve/bhyve_domain.c
-@@ -144,7 +144,7 @@ virBhyveDriverCreateXMLConf(bhyveConnPtr driver)
-     virBhyveDriverDomainDefParserConfig.priv = driver;
-     return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
-                                  &virBhyveDriverPrivateDataCallbacks,
--                                 NULL);
-+                                 NULL, NULL);
- }
- 
- virDomainDefParserConfig virBhyveDriverDomainDefParserConfig = {
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 4404b8f737..bab85c6362 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -76,6 +76,9 @@ struct _virDomainXMLOption {
- 
-     /* XML namespace callbacks */
-     virDomainXMLNamespace ns;
-+
-+    /* ABI stability callbacks */
-+    virDomainABIStability abi;
- };
- 
- #define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS             \
-@@ -1050,7 +1053,8 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt)
- virDomainXMLOptionPtr
- virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
-                       virDomainXMLPrivateDataCallbacksPtr priv,
--                      virDomainXMLNamespacePtr xmlns)
-+                      virDomainXMLNamespacePtr xmlns,
-+                      virDomainABIStabilityPtr abi)
- {
-     virDomainXMLOptionPtr xmlopt;
- 
-@@ -1069,6 +1073,9 @@ virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
-     if (xmlns)
-         xmlopt->ns = *xmlns;
- 
-+    if (abi)
-+        xmlopt->abi = *abi;
-+
-     /* Technically this forbids to use one of Xerox's MAC address prefixes in
-      * our hypervisor drivers. This shouldn't ever be a problem.
-      *
-@@ -19911,6 +19918,7 @@ virDomainDefVcpuCheckAbiStability(virDomainDefPtr src,
- bool
- virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
-                                    virDomainDefPtr dst,
-+                                   virDomainXMLOptionPtr xmlopt,
-                                    unsigned int flags)
- {
-     size_t i;
-@@ -20337,6 +20345,10 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
-         !virDomainIOMMUDefCheckABIStability(src->iommu, dst->iommu))
-         goto error;
- 
-+    if (xmlopt && xmlopt->abi.domain &&
-+        !xmlopt->abi.domain(src, dst))
-+        goto error;
-+
-     /* Coverity is not very happy with this - all dead_error_condition */
- #if !STATIC_ANALYSIS
-     /* This switch statement is here to trigger compiler warning when adding
-@@ -20396,9 +20408,10 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
- 
- bool
- virDomainDefCheckABIStability(virDomainDefPtr src,
--                              virDomainDefPtr dst)
-+                              virDomainDefPtr dst,
-+                              virDomainXMLOptionPtr xmlopt)
- {
--    return virDomainDefCheckABIStabilityFlags(src, dst, 0);
-+    return virDomainDefCheckABIStabilityFlags(src, dst, xmlopt, 0);
- }
- 
- 
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index 980aafa66a..d64ef1b6e9 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -2537,9 +2537,19 @@ struct _virDomainXMLPrivateDataCallbacks {
-     virDomainXMLPrivateDataParseFunc  parse;
- };
- 
-+typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src,
-+                                            const virDomainDef *dst);
-+
-+typedef struct _virDomainABIStability virDomainABIStability;
-+typedef virDomainABIStability *virDomainABIStabilityPtr;
-+struct _virDomainABIStability {
-+    virDomainABIStabilityDomain domain;
-+};
-+
- virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
-                                             virDomainXMLPrivateDataCallbacksPtr priv,
--                                            virDomainXMLNamespacePtr xmlns);
-+                                            virDomainXMLNamespacePtr xmlns,
-+                                            virDomainABIStabilityPtr abi);
- 
- void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);
- 
-@@ -2805,10 +2815,12 @@ virDomainObjPtr virDomainObjParseFile(const char *filename,
-                                       unsigned int flags);
- 
- bool virDomainDefCheckABIStability(virDomainDefPtr src,
--                                   virDomainDefPtr dst);
-+                                   virDomainDefPtr dst,
-+                                   virDomainXMLOptionPtr xmlopt);
- 
- bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
-                                         virDomainDefPtr dst,
-+                                        virDomainXMLOptionPtr xmlopt,
-                                         unsigned int flags);
- 
- int virDomainDefAddImplicitDevices(virDomainDefPtr def);
-diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
-index 5daa8d11a7..b6cba5ac38 100644
---- a/src/conf/snapshot_conf.c
-+++ b/src/conf/snapshot_conf.c
-@@ -1198,6 +1198,7 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
-                               virDomainObjPtr vm,
-                               virDomainSnapshotDefPtr *defptr,
-                               virDomainSnapshotObjPtr *snap,
-+                              virDomainXMLOptionPtr xmlopt,
-                               bool *update_current,
-                               unsigned int flags)
- {
-@@ -1286,7 +1287,7 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
-         if (other->def->dom) {
-             if (def->dom) {
-                 if (!virDomainDefCheckABIStability(other->def->dom,
--                                                   def->dom))
-+                                                   def->dom, xmlopt))
-                     goto cleanup;
-             } else {
-                 /* Transfer the domain def */
-diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
-index fcf7a1e824..da904f9460 100644
---- a/src/conf/snapshot_conf.h
-+++ b/src/conf/snapshot_conf.h
-@@ -181,6 +181,7 @@ int virDomainSnapshotRedefinePrep(virDomainPtr domain,
-                                   virDomainObjPtr vm,
-                                   virDomainSnapshotDefPtr *def,
-                                   virDomainSnapshotObjPtr *snap,
-+                                  virDomainXMLOptionPtr xmlopt,
-                                   bool *update_current,
-                                   unsigned int flags);
- 
-diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
-index 4bab651b33..dd345c22cf 100644
---- a/src/libxl/libxl_conf.c
-+++ b/src/libxl/libxl_conf.c
-@@ -2147,5 +2147,5 @@ libxlCreateXMLConf(void)
- {
-     return virDomainXMLOptionNew(&libxlDomainDefParserConfig,
-                                  &libxlDomainXMLPrivateDataCallbacks,
--                                 NULL);
-+                                 NULL, NULL);
- }
-diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
-index ea28c93345..2d8852d280 100644
---- a/src/libxl/libxl_domain.c
-+++ b/src/libxl/libxl_domain.c
-@@ -1452,7 +1452,9 @@ libxlDomainDefCheckABIStability(libxlDriverPrivatePtr driver,
-         !(migratableDefDst = virDomainDefCopy(dst, cfg->caps, driver->xmlopt, NULL, true)))
-         goto cleanup;
- 
--    ret = virDomainDefCheckABIStability(migratableDefSrc, migratableDefDst);
-+    ret = virDomainDefCheckABIStability(migratableDefSrc,
-+                                        migratableDefDst,
-+                                        driver->xmlopt);
- 
-  cleanup:
-     virDomainDefFree(migratableDefSrc);
-diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
-index e47b667f58..b46fbc58ff 100644
---- a/src/lxc/lxc_conf.c
-+++ b/src/lxc/lxc_conf.c
-@@ -212,7 +212,8 @@ lxcDomainXMLConfInit(void)
- {
-     return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
-                                  &virLXCDriverPrivateDataCallbacks,
--                                 &virLXCDriverDomainXMLNamespace);
-+                                 &virLXCDriverDomainXMLNamespace,
-+                                 NULL);
- }
- 
- 
-diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
-index 647c8522dd..44a6631a99 100644
---- a/src/openvz/openvz_driver.c
-+++ b/src/openvz/openvz_driver.c
-@@ -1493,7 +1493,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
-         goto cleanup;
- 
-     if (!(driver->xmlopt = virDomainXMLOptionNew(&openvzDomainDefParserConfig,
--                                                 NULL, NULL)))
-+                                                 NULL, NULL, NULL)))
-         goto cleanup;
- 
-     if (openvzLoadDomains(driver) < 0)
-diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
-index 1803aa53b7..e85f66ffab 100644
---- a/src/phyp/phyp_driver.c
-+++ b/src/phyp/phyp_driver.c
-@@ -1199,7 +1199,7 @@ phypConnectOpen(virConnectPtr conn,
-         goto failure;
- 
-     if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(&virPhypDriverDomainDefParserConfig,
--                                                      NULL, NULL)))
-+                                                      NULL, NULL, NULL)))
-         goto failure;
- 
-     conn->privateData = phyp_driver;
-diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
-index 80db60bc4b..72d3f25763 100644
---- a/src/qemu/qemu_capabilities.c
-+++ b/src/qemu/qemu_capabilities.c
-@@ -5027,7 +5027,7 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd,
-         goto ignore;
-     }
- 
--    if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)) ||
-+    if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL)) ||
-         !(cmd->vm = virDomainObjNew(xmlopt)))
-         goto cleanup;
- 
-diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
-index 7324c9c415..e73a7b3781 100644
---- a/src/qemu/qemu_conf.c
-+++ b/src/qemu/qemu_conf.c
-@@ -907,7 +907,8 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver)
-     virQEMUDriverDomainDefParserConfig.priv = driver;
-     return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig,
-                                  &virQEMUDriverPrivateDataCallbacks,
--                                 &virQEMUDriverDomainXMLNamespace);
-+                                 &virQEMUDriverDomainXMLNamespace,
-+                                 NULL);
- }
- 
- 
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 89698d4fcd..e5da82aacc 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -5811,6 +5811,7 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
- 
-     if (!virDomainDefCheckABIStabilityFlags(migratableDefSrc,
-                                             migratableDefDst,
-+                                            driver->xmlopt,
-                                             check_flags))
-         goto cleanup;
- 
-diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
-index fdfa4a50e1..a9ac06a63c 100644
---- a/src/qemu/qemu_driver.c
-+++ b/src/qemu/qemu_driver.c
-@@ -6136,7 +6136,7 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
-                                           VIR_DOMAIN_XML_MIGRATABLE)))
-         goto cleanup;
- 
--    if (!virDomainDefCheckABIStability(def, newdef_migr)) {
-+    if (!virDomainDefCheckABIStability(def, newdef_migr, driver->xmlopt)) {
-         virErrorPtr err = virSaveLastError();
- 
-         /* Due to a bug in older version of external snapshot creation
-@@ -6145,7 +6145,7 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
-          * saved XML type, we need to check the ABI compatibility against
-          * the user provided XML if the check against the migratable XML
-          * fails. Snapshots created prior to v1.1.3 have this issue. */
--        if (!virDomainDefCheckABIStability(def, newdef)) {
-+        if (!virDomainDefCheckABIStability(def, newdef, driver->xmlopt)) {
-             virSetError(err);
-             virFreeError(err);
-             goto cleanup;
-@@ -14589,6 +14589,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
- 
-     if (redefine) {
-         if (virDomainSnapshotRedefinePrep(domain, vm, &def, &snap,
-+                                          driver->xmlopt,
-                                           &update_current, flags) < 0)
-             goto endjob;
-     } else {
-diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
-index 5f5d1cd710..48201d5b8c 100644
---- a/src/security/virt-aa-helper.c
-+++ b/src/security/virt-aa-helper.c
-@@ -667,7 +667,7 @@ get_definition(vahControl * ctl, const char *xmlStr)
-         goto exit;
-     }
- 
--    if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) {
-+    if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL))) {
-         vah_error(ctl, 0, _("Failed to create XML config object"));
-         goto exit;
-     }
-diff --git a/src/test/test_driver.c b/src/test/test_driver.c
-index 866949558b..39df646260 100644
---- a/src/test/test_driver.c
-+++ b/src/test/test_driver.c
-@@ -414,7 +414,7 @@ testDriverNew(void)
-         goto error;
-     }
- 
--    if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns)) ||
-+    if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL)) ||
-         !(ret->eventState = virObjectEventStateNew()) ||
-         !(ret->domains = virDomainObjListNew()) ||
-         !(ret->networks = virNetworkObjListNew()))
-@@ -6486,6 +6486,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
- 
-     if (redefine) {
-         if (virDomainSnapshotRedefinePrep(domain, vm, &def, &snap,
-+                                          privconn->xmlopt,
-                                           &update_current, flags) < 0)
-             goto cleanup;
-     } else {
-@@ -6761,7 +6762,8 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
-         if (virDomainObjIsActive(vm)) {
-             /* Transitions 5, 6, 8, 9 */
-             /* Check for ABI compatibility.  */
--            if (!virDomainDefCheckABIStability(vm->def, config)) {
-+            if (!virDomainDefCheckABIStability(vm->def, config,
-+                                               privconn->xmlopt)) {
-                 virErrorPtr err = virGetLastError();
- 
-                 if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) {
-diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
-index 532ce3b1f3..ae75daa596 100644
---- a/src/uml/uml_driver.c
-+++ b/src/uml/uml_driver.c
-@@ -533,7 +533,7 @@ umlStateInitialize(bool privileged,
-         goto out_of_memory;
- 
-     if (!(uml_driver->xmlopt = virDomainXMLOptionNew(&umlDriverDomainDefParserConfig,
--                                                     &privcb, NULL)))
-+                                                     &privcb, NULL, NULL)))
-         goto error;
- 
-     if ((uml_driver->inotifyFD = inotify_init()) < 0) {
-diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
-index b71506ae5d..dcc64b579c 100644
---- a/src/vbox/vbox_common.c
-+++ b/src/vbox/vbox_common.c
-@@ -139,7 +139,7 @@ vboxDriverObjNew(void)
- 
-     if (!(driver->caps = vboxCapsInit()) ||
-         !(driver->xmlopt = virDomainXMLOptionNew(&vboxDomainDefParserConfig,
--                                                 NULL, NULL)))
-+                                                 NULL, NULL, NULL)))
-         goto cleanup;
- 
-     return driver;
-diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
-index d3497bd2d5..24e97a4969 100644
---- a/src/vmware/vmware_driver.c
-+++ b/src/vmware/vmware_driver.c
-@@ -114,7 +114,7 @@ vmwareDomainXMLConfigInit(void)
-     virDomainXMLPrivateDataCallbacks priv = { .alloc = vmwareDataAllocFunc,
-                                               .free = vmwareDataFreeFunc };
- 
--    return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv, NULL);
-+    return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv, NULL, NULL);
- }
- 
- static virDrvOpenStatus
-diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
-index 31af2e9df4..3289a20026 100644
---- a/src/vmx/vmx.c
-+++ b/src/vmx/vmx.c
-@@ -591,7 +591,7 @@ virDomainXMLOptionPtr
- virVMXDomainXMLConfInit(void)
- {
-     return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL,
--                                 &virVMXDomainXMLNamespace);
-+                                 &virVMXDomainXMLNamespace, NULL);
- }
- 
- char *
-diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
-index 88f1960eb1..26c4f48459 100644
---- a/src/vz/vz_driver.c
-+++ b/src/vz/vz_driver.c
-@@ -326,7 +326,7 @@ vzDriverObjNew(void)
-     if (!(driver->caps = vzBuildCapabilities()) ||
-         !(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
-                                                  &vzDomainXMLPrivateDataCallbacksPtr,
--                                                 NULL)) ||
-+                                                 NULL, NULL)) ||
-         !(driver->domains = virDomainObjListNew()) ||
-         !(driver->domainEventState = virObjectEventStateNew()) ||
-         (vzInitVersion(driver) < 0) ||
-diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
-index 7a2f4a1a60..0c160f8370 100644
---- a/src/xen/xen_driver.c
-+++ b/src/xen/xen_driver.c
-@@ -401,7 +401,7 @@ virDomainXMLOptionPtr
- xenDomainXMLConfInit(void)
- {
-     return virDomainXMLOptionNew(&xenDomainDefParserConfig,
--                                 NULL, NULL);
-+                                 NULL, NULL, NULL);
- }
- 
- 
-diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
-index a9ed407bc5..5623ddb507 100644
---- a/src/xenapi/xenapi_driver.c
-+++ b/src/xenapi/xenapi_driver.c
-@@ -200,7 +200,7 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
-     }
- 
-     if (!(privP->xmlopt = virDomainXMLOptionNew(&xenapiDomainDefParserConfig,
--                                                NULL, NULL))) {
-+                                                NULL, NULL, NULL))) {
-         xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
-                                   _("Failed to create XML conf object"));
-         goto error;
-diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c
-index e759e4fa30..5d7261a45b 100644
---- a/tests/bhyveargv2xmltest.c
-+++ b/tests/bhyveargv2xmltest.c
-@@ -130,7 +130,8 @@ mymain(void)
-     if ((driver.caps = virBhyveCapsBuild()) == NULL)
-         return EXIT_FAILURE;
- 
--    if ((driver.xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)) == NULL)
-+    if ((driver.xmlopt = virDomainXMLOptionNew(NULL, NULL,
-+                                               NULL, NULL)) == NULL)
-         return EXIT_FAILURE;
- 
- # define DO_TEST_FULL(name, flags)                            \
-diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
-index a709c72cf1..01d2426be5 100644
---- a/tests/qemuargv2xmltest.c
-+++ b/tests/qemuargv2xmltest.c
-@@ -95,7 +95,7 @@ static int testCompareXMLToArgvFiles(const char *xmlfile,
-     if (testSanitizeDef(vmdef) < 0)
-         goto fail;
- 
--    if (!virDomainDefCheckABIStability(vmdef, vmdef)) {
-+    if (!virDomainDefCheckABIStability(vmdef, vmdef, driver.xmlopt)) {
-         VIR_TEST_DEBUG("ABI stability check failed on %s", xmlfile);
-         goto fail;
-     }
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index ecdda2db93..9e0d4d7141 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -464,7 +464,7 @@ testCompareXMLToArgv(const void *data)
-     if (virBitmapParse("0-3", &priv->autoNodeset, 4) < 0)
-         goto cleanup;
- 
--    if (!virDomainDefCheckABIStability(vm->def, vm->def)) {
-+    if (!virDomainDefCheckABIStability(vm->def, vm->def, driver.xmlopt)) {
-         VIR_TEST_DEBUG("ABI stability check failed on %s", xml);
-         goto cleanup;
-     }
-diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c
-index 9982fad9f7..91f751d671 100644
---- a/tests/sexpr2xmltest.c
-+++ b/tests/sexpr2xmltest.c
-@@ -57,7 +57,7 @@ testCompareFiles(const char *xml, const char *sexpr)
-                                  tty, vncport, caps, xmlopt)))
-       goto fail;
- 
--  if (!virDomainDefCheckABIStability(def, def)) {
-+  if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
-       fprintf(stderr, "ABI stability check failed on %s", xml);
-       goto fail;
-   }
-diff --git a/tests/testutils.c b/tests/testutils.c
-index f3feb6d3f9..b7dc8d8408 100644
---- a/tests/testutils.c
-+++ b/tests/testutils.c
-@@ -1136,7 +1136,7 @@ virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void)
- {
-     return virDomainXMLOptionNew(&virTestGenericDomainDefParserConfig,
-                                  &virTestGenericPrivateDataCallbacks,
--                                 NULL);
-+                                 NULL, NULL);
- }
- 
- 
-@@ -1169,7 +1169,7 @@ testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt,
-         goto out;
-     }
- 
--    if (!virDomainDefCheckABIStability(def, def)) {
-+    if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
-         VIR_TEST_DEBUG("ABI stability check failed on %s", infile);
-         result = TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_STABILITY;
-         goto out;
-diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
-index 9b59fd5ea7..bcaf4bb175 100644
---- a/tests/vmx2xmltest.c
-+++ b/tests/vmx2xmltest.c
-@@ -81,7 +81,7 @@ testCompareFiles(const char *vmx, const char *xml)
-     if (!(def = virVMXParseConfig(&ctx, xmlopt, caps, vmxData)))
-         goto cleanup;
- 
--    if (!virDomainDefCheckABIStability(def, def)) {
-+    if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
-         fprintf(stderr, "ABI stability check failed on %s", vmx);
-         goto cleanup;
-     }
-diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c
-index e74e4d60db..4d801ecdda 100644
---- a/tests/xlconfigtest.c
-+++ b/tests/xlconfigtest.c
-@@ -97,7 +97,7 @@ testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars)
-             goto fail;
-     }
- 
--    if (!virDomainDefCheckABIStability(def, def)) {
-+    if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
-         fprintf(stderr, "ABI stability check failed on %s", xml);
-         goto fail;
-     }
-diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
-index 63997777cc..d7454415cd 100644
---- a/tests/xmconfigtest.c
-+++ b/tests/xmconfigtest.c
-@@ -67,7 +67,7 @@ testCompareParseXML(const char *xmcfg, const char *xml)
-                                       VIR_DOMAIN_DEF_PARSE_INACTIVE)))
-         goto fail;
- 
--    if (!virDomainDefCheckABIStability(def, def)) {
-+    if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
-         fprintf(stderr, "ABI stability check failed on %s", xml);
-         goto fail;
-     }
-diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c
-index 0b95113118..a6a7a9ed3d 100644
---- a/tests/xml2sexprtest.c
-+++ b/tests/xml2sexprtest.c
-@@ -31,7 +31,7 @@ testCompareFiles(const char *xml, const char *sexpr)
-                                     VIR_DOMAIN_DEF_PARSE_INACTIVE)))
-       goto fail;
- 
--  if (!virDomainDefCheckABIStability(def, def)) {
-+  if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
-       fprintf(stderr, "ABI stability check failed on %s", xml);
-       goto fail;
-   }
-diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
-index b77be893c6..6242d46a5f 100644
---- a/tests/xml2vmxtest.c
-+++ b/tests/xml2vmxtest.c
-@@ -82,7 +82,7 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
-     if (def == NULL)
-         goto failure;
- 
--    if (!virDomainDefCheckABIStability(def, def)) {
-+    if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
-         fprintf(stderr, "ABI stability check failed on %s", xml);
-         goto failure;
-     }
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-virQEMUCapsHasPCIMultiBus-Fix-def-type.patch b/SOURCES/libvirt-virQEMUCapsHasPCIMultiBus-Fix-def-type.patch
new file mode 100644
index 0000000..4d2f533
--- /dev/null
+++ b/SOURCES/libvirt-virQEMUCapsHasPCIMultiBus-Fix-def-type.patch
@@ -0,0 +1,49 @@
+From 2e7743888fda6297e07527370c1d4c4b45217962 Mon Sep 17 00:00:00 2001
+Message-Id: <2e7743888fda6297e07527370c1d4c4b45217962@dist-git>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Mon, 20 Nov 2017 11:08:52 +0100
+Subject: [PATCH] virQEMUCapsHasPCIMultiBus: Fix @def type
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1434451
+
+This function only queries domain @def. It doesn't change it.
+Therefore it should take const pointer.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+(cherry picked from commit 481f8fdca1528f1398ef458b7c37ba57ea55dc68)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c | 2 +-
+ src/qemu/qemu_capabilities.h | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 3793f16590..f30d2fa09e 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -2391,7 +2391,7 @@ virQEMUCapsGet(virQEMUCapsPtr qemuCaps,
+ 
+ 
+ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
+-                               virDomainDefPtr def)
++                               const virDomainDef *def)
+ {
+     /* x86_64 and i686 support PCI-multibus on all machine types
+      * since forever */
+diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
+index f0e2e9016f..e7d766f801 100644
+--- a/src/qemu/qemu_capabilities.h
++++ b/src/qemu/qemu_capabilities.h
+@@ -451,7 +451,7 @@ bool virQEMUCapsGet(virQEMUCapsPtr qemuCaps,
+                     virQEMUCapsFlags flag);
+ 
+ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
+-                               virDomainDefPtr def);
++                               const virDomainDef *def);
+ 
+ bool virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps,
+                                const virDomainDef *def);
+-- 
+2.15.0
+
diff --git a/SOURCES/libvirt-virQEMUCapsHasPCIMultiBus-assume-true-if-we-have-no-version-information.patch b/SOURCES/libvirt-virQEMUCapsHasPCIMultiBus-assume-true-if-we-have-no-version-information.patch
new file mode 100644
index 0000000..63b0b2e
--- /dev/null
+++ b/SOURCES/libvirt-virQEMUCapsHasPCIMultiBus-assume-true-if-we-have-no-version-information.patch
@@ -0,0 +1,104 @@
+From 7bac1e059259bee2f00d6e363dad32ca2c2decb6 Mon Sep 17 00:00:00 2001
+Message-Id: <7bac1e059259bee2f00d6e363dad32ca2c2decb6@dist-git>
+From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
+Date: Thu, 30 Nov 2017 17:46:00 +0100
+Subject: [PATCH] virQEMUCapsHasPCIMultiBus: assume true if we have no version
+ information
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+In status XML, we do not store the QEMU version information, we only
+format all the capabilities. We dropped QEMU_CAPS_PCI_MULTIBUS
+in commit 5b783379 which was released in libvirt 3.2.0.
+
+Therefore the only way of telling if the already running domain
+at the time of daemon restart has been started with a QEMU that does
+use 'pci.0' or not on PPC is to look at the pci-root controller's
+alias. This is not an option if the domain has a user-specified alias
+for the pci-root.
+
+Instead of reintroducing the capability, assume 'pci.0' when we have
+no version information. That way the only left broken use case would
+be the combination of user aliases and very old QEMU.
+
+Partially reverts commit 3a37af1e4.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1518148
+(cherry picked from commit 65108d94d093de082dc5a2d4a73844dd569506db)
+Signed-off-by: Ján Tomko <jtomko@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c | 16 ++++++++--------
+ src/qemu/qemu_capspriv.h     |  4 ----
+ tests/qemuxml2argvtest.c     |  5 -----
+ 3 files changed, 8 insertions(+), 17 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 81f7e4e440..13ff1286c4 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -2435,6 +2435,14 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
+          *     ppce500: 1.6.0
+          */
+ 
++        /* We do not store the qemu version in domain status XML.
++         * Hope the user is using a QEMU new enough to use 'pci.0',
++         * otherwise the results of this function will be wrong
++         * for domains already running at the time of daemon
++         * restart */
++        if (qemuCaps->version == 0)
++            return true;
++
+         if (qemuCaps->version >= 2000000)
+             return true;
+ 
+@@ -2486,14 +2494,6 @@ virArch virQEMUCapsGetArch(virQEMUCapsPtr qemuCaps)
+ }
+ 
+ 
+-void
+-virQEMUCapsSetVersion(virQEMUCapsPtr qemuCaps,
+-                      unsigned int version)
+-{
+-    qemuCaps->version = version;
+-}
+-
+-
+ unsigned int virQEMUCapsGetVersion(virQEMUCapsPtr qemuCaps)
+ {
+     return qemuCaps->version;
+diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
+index f23995ec6e..219daa3629 100644
+--- a/src/qemu/qemu_capspriv.h
++++ b/src/qemu/qemu_capspriv.h
+@@ -55,10 +55,6 @@ void
+ virQEMUCapsSetArch(virQEMUCapsPtr qemuCaps,
+                    virArch arch);
+ 
+-void
+-virQEMUCapsSetVersion(virQEMUCapsPtr qemuCaps,
+-                      unsigned int version);
+-
+ void
+ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
+                             virArch hostArch,
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 72cefe4906..686a63855c 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -384,11 +384,6 @@ testUpdateQEMUCaps(const struct testInfo *info,
+ 
+     virQEMUCapsInitQMPBasicArch(info->qemuCaps);
+ 
+-    /* We need to pretend QEMU 2.0.0 is in use so that pSeries guests
+-     * will get the correct alias assigned to their buses.
+-     * See virQEMUCapsHasPCIMultiBus() */
+-    virQEMUCapsSetVersion(info->qemuCaps, 2000000);
+-
+     if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
+         goto cleanup;
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-virQEMUCapsHasPCIMultiBus-use-def-os.arch.patch b/SOURCES/libvirt-virQEMUCapsHasPCIMultiBus-use-def-os.arch.patch
new file mode 100644
index 0000000..de3ba98
--- /dev/null
+++ b/SOURCES/libvirt-virQEMUCapsHasPCIMultiBus-use-def-os.arch.patch
@@ -0,0 +1,110 @@
+From a845df6a28ecc3479ad40e49d711e0c86cd27f85 Mon Sep 17 00:00:00 2001
+Message-Id: <a845df6a28ecc3479ad40e49d711e0c86cd27f85@dist-git>
+From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
+Date: Thu, 30 Nov 2017 17:45:59 +0100
+Subject: [PATCH] virQEMUCapsHasPCIMultiBus: use def->os.arch
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+We do not fill out qemuCaps->arch when parsing status XML.
+
+Use def->os.arch like we do for PPC.
+
+This fixes hotplug after daemon restart for domains that use
+a user alias for the implicit pci-root on x86.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1518148
+(cherry picked from commit fdf354fb51e7f00b582d0daa18961d432155df83)
+Signed-off-by: Ján Tomko <jtomko@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c                                        | 2 +-
+ tests/qemuhotplugtestcpus/ppc64-modern-bulk-result-live.xml         | 2 +-
+ tests/qemuhotplugtestcpus/ppc64-modern-individual-result-live.xml   | 2 +-
+ tests/qemuhotplugtestcpus/x86-modern-bulk-result-live.xml           | 2 +-
+ tests/qemuhotplugtestcpus/x86-modern-individual-add-result-live.xml | 2 +-
+ tests/qemuhotplugtestcpus/x86-old-bulk-result-live.xml              | 2 +-
+ 6 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index d1677144b7..81f7e4e440 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -2415,7 +2415,7 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
+ {
+     /* x86_64 and i686 support PCI-multibus on all machine types
+      * since forever */
+-    if (ARCH_IS_X86(qemuCaps->arch))
++    if (ARCH_IS_X86(def->os.arch))
+         return true;
+ 
+     if (def->os.arch == VIR_ARCH_PPC ||
+diff --git a/tests/qemuhotplugtestcpus/ppc64-modern-bulk-result-live.xml b/tests/qemuhotplugtestcpus/ppc64-modern-bulk-result-live.xml
+index 662ed67390..43e6267250 100644
+--- a/tests/qemuhotplugtestcpus/ppc64-modern-bulk-result-live.xml
++++ b/tests/qemuhotplugtestcpus/ppc64-modern-bulk-result-live.xml
+@@ -56,7 +56,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+     </controller>
+     <controller type='pci' index='0' model='pci-root'>
+-      <alias name='pci'/>
++      <alias name='pci.0'/>
+     </controller>
+     <input type='mouse' bus='ps2'>
+       <alias name='input0'/>
+diff --git a/tests/qemuhotplugtestcpus/ppc64-modern-individual-result-live.xml b/tests/qemuhotplugtestcpus/ppc64-modern-individual-result-live.xml
+index 866a81a2d7..0a8d372149 100644
+--- a/tests/qemuhotplugtestcpus/ppc64-modern-individual-result-live.xml
++++ b/tests/qemuhotplugtestcpus/ppc64-modern-individual-result-live.xml
+@@ -56,7 +56,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+     </controller>
+     <controller type='pci' index='0' model='pci-root'>
+-      <alias name='pci'/>
++      <alias name='pci.0'/>
+     </controller>
+     <input type='mouse' bus='ps2'>
+       <alias name='input0'/>
+diff --git a/tests/qemuhotplugtestcpus/x86-modern-bulk-result-live.xml b/tests/qemuhotplugtestcpus/x86-modern-bulk-result-live.xml
+index a025033e84..fe9a81a091 100644
+--- a/tests/qemuhotplugtestcpus/x86-modern-bulk-result-live.xml
++++ b/tests/qemuhotplugtestcpus/x86-modern-bulk-result-live.xml
+@@ -32,7 +32,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+     </controller>
+     <controller type='pci' index='0' model='pci-root'>
+-      <alias name='pci'/>
++      <alias name='pci.0'/>
+     </controller>
+     <input type='mouse' bus='ps2'>
+       <alias name='input0'/>
+diff --git a/tests/qemuhotplugtestcpus/x86-modern-individual-add-result-live.xml b/tests/qemuhotplugtestcpus/x86-modern-individual-add-result-live.xml
+index 8adcb71041..12b28be5fe 100644
+--- a/tests/qemuhotplugtestcpus/x86-modern-individual-add-result-live.xml
++++ b/tests/qemuhotplugtestcpus/x86-modern-individual-add-result-live.xml
+@@ -32,7 +32,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+     </controller>
+     <controller type='pci' index='0' model='pci-root'>
+-      <alias name='pci'/>
++      <alias name='pci.0'/>
+     </controller>
+     <input type='mouse' bus='ps2'>
+       <alias name='input0'/>
+diff --git a/tests/qemuhotplugtestcpus/x86-old-bulk-result-live.xml b/tests/qemuhotplugtestcpus/x86-old-bulk-result-live.xml
+index b52f049fb0..6f50bb5c12 100644
+--- a/tests/qemuhotplugtestcpus/x86-old-bulk-result-live.xml
++++ b/tests/qemuhotplugtestcpus/x86-old-bulk-result-live.xml
+@@ -22,7 +22,7 @@
+       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+     </controller>
+     <controller type='pci' index='0' model='pci-root'>
+-      <alias name='pci'/>
++      <alias name='pci.0'/>
+     </controller>
+     <input type='mouse' bus='ps2'>
+       <alias name='input0'/>
+-- 
+2.15.1
+
diff --git a/SOURCES/libvirt-virQEMUDriverDomainABIStability-Check-for-memoryBacking.patch b/SOURCES/libvirt-virQEMUDriverDomainABIStability-Check-for-memoryBacking.patch
deleted file mode 100644
index 323947a..0000000
--- a/SOURCES/libvirt-virQEMUDriverDomainABIStability-Check-for-memoryBacking.patch
+++ /dev/null
@@ -1,96 +0,0 @@
-From c2cf1aadf957daddd0f7f44aa11d9e2d3f5883c2 Mon Sep 17 00:00:00 2001
-Message-Id: <c2cf1aadf957daddd0f7f44aa11d9e2d3f5883c2@dist-git>
-From: Michal Privoznik <mprivozn@redhat.com>
-Date: Mon, 5 Jun 2017 09:35:24 +0200
-Subject: [PATCH] virQEMUDriverDomainABIStability: Check for memoryBacking
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1450349
-
-Problem is, qemu fails to load guest memory image if these
-attribute change on migration/restore from an image.
-
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-(cherry picked from commit 7b4e9b2c55a1105dd96a608d7ee111394da0befc)
-Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- src/libvirt_private.syms |  2 ++
- src/qemu/qemu_conf.c     |  2 +-
- src/qemu/qemu_domain.c   | 22 ++++++++++++++++++++++
- src/qemu/qemu_domain.h   |  1 +
- 4 files changed, 26 insertions(+), 1 deletion(-)
-
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 343966cd0e..a578dfba34 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -407,6 +407,8 @@ virDomainMemoryFindByDef;
- virDomainMemoryFindInactiveByDef;
- virDomainMemoryInsert;
- virDomainMemoryRemove;
-+virDomainMemorySourceTypeFromString;
-+virDomainMemorySourceTypeToString;
- virDomainNetAppendIPAddress;
- virDomainNetDefClear;
- virDomainNetDefFormat;
-diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
-index e73a7b3781..76eed25277 100644
---- a/src/qemu/qemu_conf.c
-+++ b/src/qemu/qemu_conf.c
-@@ -908,7 +908,7 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver)
-     return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig,
-                                  &virQEMUDriverPrivateDataCallbacks,
-                                  &virQEMUDriverDomainXMLNamespace,
--                                 NULL);
-+                                 &virQEMUDriverDomainABIStability);
- }
- 
- 
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index e5da82aacc..11be085801 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -5792,6 +5792,28 @@ qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
- }
- 
- 
-+static bool
-+qemuDomainABIStabilityCheck(const virDomainDef *src,
-+                            const virDomainDef *dst)
-+{
-+    if (src->mem.source != dst->mem.source) {
-+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-+                       _("Target memoryBacking source '%s' doesn't "
-+                         "match source memoryBacking source'%s'"),
-+                       virDomainMemorySourceTypeToString(dst->mem.source),
-+                       virDomainMemorySourceTypeToString(src->mem.source));
-+        return false;
-+    }
-+
-+    return true;
-+}
-+
-+
-+virDomainABIStability virQEMUDriverDomainABIStability = {
-+    .domain = qemuDomainABIStabilityCheck,
-+};
-+
-+
- bool
- qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
-                                virDomainDefPtr src,
-diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
-index f503304879..2994398a9e 100644
---- a/src/qemu/qemu_domain.h
-+++ b/src/qemu/qemu_domain.h
-@@ -638,6 +638,7 @@ void qemuDomainCleanupRun(virQEMUDriverPtr driver,
- extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
- extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
- extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
-+extern virDomainABIStability virQEMUDriverDomainABIStability;
- 
- int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
-                                virDomainObjPtr vm, int asyncJob);
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-virsh-Add-support-for-VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB.patch b/SOURCES/libvirt-virsh-Add-support-for-VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB.patch
deleted file mode 100644
index 1a49422..0000000
--- a/SOURCES/libvirt-virsh-Add-support-for-VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB.patch
+++ /dev/null
@@ -1,87 +0,0 @@
-From b6a3d1447dd99d7c766c27c56305e7b9c6e83972 Mon Sep 17 00:00:00 2001
-Message-Id: <b6a3d1447dd99d7c766c27c56305e7b9c6e83972@dist-git>
-From: Peter Krempa <pkrempa@redhat.com>
-Date: Wed, 7 Jun 2017 13:31:22 +0200
-Subject: [PATCH] virsh: Add support for VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB
-
-Allow using the new flag with virsh.
-
-(cherry picked from commit 880b1a2e25fc7b76581b1115a5ab538d74193159)
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1459113
-
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- tools/virsh-domain.c | 10 +++++++++-
- tools/virsh.pod      |  6 ++++++
- 2 files changed, 15 insertions(+), 1 deletion(-)
-
-diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
-index 3374f2c8b6..da9f7c16ed 100644
---- a/tools/virsh-domain.c
-+++ b/tools/virsh-domain.c
-@@ -2249,6 +2249,10 @@ static const vshCmdOptDef opts_block_copy[] = {
-      .type = VSH_OT_BOOL,
-      .help = N_("the bandwidth limit is in bytes/s rather than MiB/s")
-     },
-+    {.name = "transient-job",
-+     .type = VSH_OT_BOOL,
-+     .help = N_("the copy job is not persisted if VM is turned off")
-+    },
-     {.name = NULL}
- };
- 
-@@ -2270,6 +2274,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
-     bool blocking = vshCommandOptBool(cmd, "wait") || finish || pivot;
-     bool async = vshCommandOptBool(cmd, "async");
-     bool bytes = vshCommandOptBool(cmd, "bytes");
-+    bool transientjob = vshCommandOptBool(cmd, "transient-job");
-     int timeout = 0;
-     const char *path = NULL;
-     int abort_flags = 0;
-@@ -2299,6 +2304,8 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
-         flags |= VIR_DOMAIN_BLOCK_REBASE_SHALLOW;
-     if (vshCommandOptBool(cmd, "reuse-external"))
-         flags |= VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT;
-+    if (transientjob)
-+        flags |= VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB;
-     if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
-         return false;
- 
-@@ -2347,7 +2354,8 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
-         }
-     }
- 
--    if (granularity || buf_size || (format && STRNEQ(format, "raw")) || xml) {
-+    if (granularity || buf_size || (format && STRNEQ(format, "raw")) || xml ||
-+        transientjob) {
-         /* New API */
-         if (bandwidth || granularity || buf_size) {
-             params = vshCalloc(ctl, 3, sizeof(*params));
-diff --git a/tools/virsh.pod b/tools/virsh.pod
-index 11bacefa9a..0315f1f265 100644
---- a/tools/virsh.pod
-+++ b/tools/virsh.pod
-@@ -1077,6 +1077,7 @@ command.
- | I<--xml> B<file> } [I<--shallow>] [I<--reuse-external>] [I<bandwidth>]
- [I<--wait> [I<--async>] [I<--verbose>]] [{I<--pivot> | I<--finish>}]
- [I<--timeout> B<seconds>] [I<granularity>] [I<buf-size>] [I<--bytes>]
-+[I<--transient-job>]
- 
- Copy a disk backing image chain to a destination.  Either I<dest> as
- the destination file name, or I<--xml> with the name of an XML file containing
-@@ -1131,6 +1132,11 @@ within a certain range. Specifying I<buf-size> will control how much data can
- be simultaneously in-flight during the copy; larger values use more memory but
- may allow faster completion (the default value is usually correct).
- 
-+I<--transient-job> allows to specify that the user does not require the job to
-+be recovered if the VM crashes or is turned off before the job completes. This
-+flag removes the restriction of copy jobs to transient domains if that
-+restriction is applied by the hypervisor.
-+
- =item B<blockpull> I<domain> I<path> [I<bandwidth>] [I<--bytes>] [I<base>]
- [I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async>]]
- [I<--keep-relative>]
--- 
-2.13.1
-
diff --git a/SOURCES/libvirt-virsh-Add-tls-description-for-the-virsh-man-page.patch b/SOURCES/libvirt-virsh-Add-tls-description-for-the-virsh-man-page.patch
deleted file mode 100644
index ae191a7..0000000
--- a/SOURCES/libvirt-virsh-Add-tls-description-for-the-virsh-man-page.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From 0bdb76d8a6b8eb9de8c434a247700a87a2626e0d Mon Sep 17 00:00:00 2001
-Message-Id: <0bdb76d8a6b8eb9de8c434a247700a87a2626e0d@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Fri, 12 May 2017 09:34:02 -0400
-Subject: [PATCH] virsh: Add --tls description for the virsh man page
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1448806
-
-Commit id '6a8d898d' neglected to update the man page.
-
-(cherry picked from commit c390f55e4b8cbdd3262d367ca477f6489ae69239)
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- tools/virsh.pod | 7 ++++++-
- 1 file changed, 6 insertions(+), 1 deletion(-)
-
-diff --git a/tools/virsh.pod b/tools/virsh.pod
-index 9a52d6716..0dd1fc7b2 100644
---- a/tools/virsh.pod
-+++ b/tools/virsh.pod
-@@ -1671,7 +1671,7 @@ I<domain> I<desturi> [I<migrateuri>] [I<graphicsuri>] [I<listen-address>] [I<dna
- [I<--compressed>] [I<--comp-methods> B<method-list>]
- [I<--comp-mt-level>] [I<--comp-mt-threads>] [I<--comp-mt-dthreads>]
- [I<--comp-xbzrle-cache>] [I<--auto-converge>] [I<auto-converge-initial>]
--[I<auto-converge-increment>] [I<--persistent-xml> B<file>]
-+[I<auto-converge-increment>] [I<--persistent-xml> B<file>] [I<--tls>]
- 
- Migrate domain to another host.  Add I<--live> for live migration; <--p2p>
- for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled>
-@@ -1752,6 +1752,11 @@ compression. I<--comp-mt-threads> and I<--comp-mt-dthreads> set the number
- of compress threads on source and the number of decompress threads on target
- respectively. I<--comp-xbzrle-cache> sets size of page cache in bytes.
- 
-+Providing I<--tls> causes the migration to use the host configured TLS setup
-+(see migrate_tls_x509_cert_dir in /etc/libvirt/qemu.conf) in order to perform
-+the migration of the domain. Usage requires proper TLS setup for both source
-+and target.
-+
- Running migration can be canceled by interrupting virsh (usually using
- C<Ctrl-C>) or by B<domjobabort> command sent from another virsh instance.
- 
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-virsh-Track-when-create-pkttyagent.patch b/SOURCES/libvirt-virsh-Track-when-create-pkttyagent.patch
deleted file mode 100644
index fbf4c1b..0000000
--- a/SOURCES/libvirt-virsh-Track-when-create-pkttyagent.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-From 3ffd39767ed4dec1233f91744184c518396acc8c Mon Sep 17 00:00:00 2001
-Message-Id: <3ffd39767ed4dec1233f91744184c518396acc8c@dist-git>
-From: John Ferlan <jferlan@redhat.com>
-Date: Thu, 25 May 2017 12:59:12 -0400
-Subject: [PATCH] virsh: Track when create pkttyagent
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1374126
-
-Due to how the processing for authentication using polkit works, the
-virshConnect code must first "attempt" an virConnectOpenAuth and then
-check for a "special" return error code VIR_ERR_AUTH_UNAVAILABLE in
-order to attempt to "retry" the authentication after performing a creation
-of a pkttyagent to handle the challenge/response for the client.
-
-However, if pkttyagent creation is not possible for the authentication
-being attempted (such as perhaps a "qemu+ssh://someuser@localhost/system"),
-then the same failure pattern would be returned and another attempt to
-create a pkttyagent would be done. This would continue "forever" until
-someone forced quit (e.g. ctrl-c) from virsh as the 'authfail' was not
-incremented when creating the pkttyagent.
-
-So add a 'agentCreated' boolean to track if we've attempted to create the
-agent at least once and force a failure if that creation returned the same
-error pattern.
-
-This resolves a possible never ending loop and will generate an error:
-
-error: failed to connect to the hypervisor
-error: authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage'
-
-NB: If the authentication was for a sufficiently privileged client, such as
-qemu+ssh://root@localhost/system, then the remoteDispatchAuthList "allows"
-the authentication to use libvirt since @callerUid would be 0.
-
-(cherry picked from commit 2453501fc82d3b247affb6c9054dc65bf2f669b3)
-Signed-off-by: John Ferlan <jferlan@redhat.com>
-Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
----
- tools/virsh.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/tools/virsh.c b/tools/virsh.c
-index 7eb51ab7d..0b4365b0f 100644
---- a/tools/virsh.c
-+++ b/tools/virsh.c
-@@ -145,6 +145,7 @@ virshConnect(vshControl *ctl, const char *uri, bool readonly)
-     bool keepalive_forced = false;
-     virPolkitAgentPtr pkagent = NULL;
-     int authfail = 0;
-+    bool agentCreated = false;
- 
-     if (ctl->keepalive_interval >= 0) {
-         interval = ctl->keepalive_interval;
-@@ -166,10 +167,12 @@ virshConnect(vshControl *ctl, const char *uri, bool readonly)
-             goto cleanup;
- 
-         err = virGetLastError();
--        if (err && err->domain == VIR_FROM_POLKIT &&
-+        if (!agentCreated &&
-+            err && err->domain == VIR_FROM_POLKIT &&
-             err->code == VIR_ERR_AUTH_UNAVAILABLE) {
-             if (!pkagent && !(pkagent = virPolkitAgentCreate()))
-                 goto cleanup;
-+            agentCreated = true;
-         } else if (err && err->domain == VIR_FROM_POLKIT &&
-                    err->code == VIR_ERR_AUTH_FAILED) {
-             authfail++;
--- 
-2.13.0
-
diff --git a/SOURCES/libvirt-xenconfig-add-domxml-conversions-for-xen-xl.patch b/SOURCES/libvirt-xenconfig-add-domxml-conversions-for-xen-xl.patch
new file mode 100644
index 0000000..fa782f0
--- /dev/null
+++ b/SOURCES/libvirt-xenconfig-add-domxml-conversions-for-xen-xl.patch
@@ -0,0 +1,666 @@
+From bc7971b29f6c152a9c20aa3cda9bd361dcb61f14 Mon Sep 17 00:00:00 2001
+Message-Id: <bc7971b29f6c152a9c20aa3cda9bd361dcb61f14@dist-git>
+From: Wim ten Have <wim.ten.have@oracle.com>
+Date: Mon, 4 Dec 2017 13:38:48 +0100
+Subject: [PATCH] xenconfig: add domxml conversions for xen-xl
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1454889
+
+This patch converts NUMA configurations between the Xen libxl
+configuration file format and libvirt's XML format.
+
+XML HVM domain on a 4 node (2 cores/socket) configuration:
+
+  <cpu>
+    <numa>
+      <cell id='0' cpus='0-1' memory='2097152' unit='KiB'>
+        <distances>
+          <sibling id='0' value='10'/>
+          <sibling id='1' value='21'/>
+          <sibling id='2' value='31'/>
+          <sibling id='3' value='21'/>
+        </distances>
+      </cell>
+      <cell id='1' cpus='2-3' memory='2097152' unit='KiB'>
+        <distances>
+          <sibling id='0' value='21'/>
+          <sibling id='1' value='10'/>
+          <sibling id='2' value='21'/>
+          <sibling id='3' value='31'/>
+        </distances>
+      </cell>
+      <cell id='2' cpus='3-4' memory='2097152' unit='KiB'>
+        <distances>
+          <sibling id='0' value='31'/>
+          <sibling id='1' value='21'/>
+          <sibling id='2' value='10'/>
+          <sibling id='3' value='21'/>
+        </distances>
+      </cell>
+      <cell id='3' cpus='5-6' memory='2097152' unit='KiB'>
+        <distances>
+          <sibling id='0' value='21'/>
+          <sibling id='1' value='31'/>
+          <sibling id='2' value='21'/>
+          <sibling id='3' value='10'/>
+        </distances>
+      </cell>
+    </numa>
+  </cpu>
+
+Xen xl.cfg domain configuration:
+
+  vnuma = [["pnode=0","size=2048","vcpus=0-1","vdistances=10,21,31,21"],
+           ["pnode=1","size=2048","vcpus=2-3","vdistances=21,10,21,31"],
+           ["pnode=2","size=2048","vcpus=4-5","vdistances=31,21,10,21"],
+           ["pnode=3","size=2048","vcpus=6-7","vdistances=21,31,21,10"]]
+
+If there is no XML <distances> description amongst the <cell> data the
+conversion schema from xml to native will generate 10 for local and 20
+for all remote instances.
+
+Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
+Reviewed-by: Jim Fehlig <jfehlig@suse.com>
+Signed-off-by: Jim Fehlig <jfehlig@suse.com>
+(cherry picked from commit 03d0959af3a72eb2aed47a1d2dcf8ccbb39d4b0e)
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/conf/numa_conf.c     | 137 +++++++++++++++++++
+ src/conf/numa_conf.h     |  25 ++++
+ src/libvirt_private.syms |   5 +
+ src/xenconfig/xen_xl.c   | 335 +++++++++++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 502 insertions(+)
+
+diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
+index 5fbcc72041..7bba4120bd 100644
+--- a/src/conf/numa_conf.c
++++ b/src/conf/numa_conf.c
+@@ -1114,6 +1114,132 @@ virDomainNumaGetNodeCount(virDomainNumaPtr numa)
+ }
+ 
+ 
++size_t
++virDomainNumaSetNodeCount(virDomainNumaPtr numa, size_t nmem_nodes)
++{
++    if (!nmem_nodes) {
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("Cannot set an empty mem_nodes set"));
++        return 0;
++    }
++
++    if (numa->mem_nodes) {
++        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++                       _("Cannot alter an existing mem_nodes set"));
++        return 0;
++    }
++
++    if (VIR_ALLOC_N(numa->mem_nodes, nmem_nodes) < 0)
++        return 0;
++
++    numa->nmem_nodes = nmem_nodes;
++
++    return numa->nmem_nodes;
++}
++
++size_t
++virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
++                             size_t node,
++                             size_t cellid)
++{
++    virDomainNumaDistancePtr distances = NULL;
++
++    if (node < numa->nmem_nodes)
++        distances = numa->mem_nodes[node].distances;
++
++    /*
++     * Present the configured distance value. If
++     * out of range or not available set the platform
++     * defined default for local and remote nodes.
++     */
++    if (!distances ||
++        !distances[cellid].value ||
++        !numa->mem_nodes[node].ndistances)
++        return (node == cellid) ? LOCAL_DISTANCE : REMOTE_DISTANCE;
++
++    return distances[cellid].value;
++}
++
++
++int
++virDomainNumaSetNodeDistance(virDomainNumaPtr numa,
++                             size_t node,
++                             size_t cellid,
++                             unsigned int value)
++{
++    virDomainNumaDistancePtr distances;
++
++    if (node >= numa->nmem_nodes) {
++        virReportError(VIR_ERR_INTERNAL_ERROR,
++                       _("Argument 'node' %zu outranges "
++                         "defined number of NUMA nodes"),
++                       node);
++        return -1;
++    }
++
++    distances = numa->mem_nodes[node].distances;
++    if (!distances ||
++        cellid >= numa->mem_nodes[node].ndistances) {
++        virReportError(VIR_ERR_XML_ERROR, "%s",
++                       _("Arguments under memnode element do not "
++                         "correspond with existing guest's NUMA cell"));
++        return -1;
++    }
++
++    /*
++     * Advanced Configuration and Power Interface
++     * Specification version 6.1. Chapter 5.2.17
++     * System Locality Distance Information Table
++     * ... Distance values of 0-9 are reserved.
++     */
++    if (value < LOCAL_DISTANCE ||
++        value > UNREACHABLE) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("Distance value of %d is not in valid range"),
++                       value);
++        return -1;
++    }
++
++    if (value == LOCAL_DISTANCE && node != cellid) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("Distance value %d under node %zu is "
++                         "LOCAL_DISTANCE and should be set to 10"),
++                       value, node);
++        return -1;
++    }
++
++    distances[cellid].cellid = cellid;
++    distances[cellid].value = value;
++
++    return distances[cellid].value;
++}
++
++
++size_t
++virDomainNumaSetNodeDistanceCount(virDomainNumaPtr numa,
++                                  size_t node,
++                                  size_t ndistances)
++{
++    virDomainNumaDistancePtr distances;
++
++    distances = numa->mem_nodes[node].distances;
++    if (distances) {
++        virReportError(VIR_ERR_INTERNAL_ERROR,
++                       _("Cannot alter an existing nmem_nodes distances set for node: %zu"),
++                       node);
++        return 0;
++    }
++
++    if (VIR_ALLOC_N(distances, ndistances) < 0)
++        return 0;
++
++    numa->mem_nodes[node].distances = distances;
++    numa->mem_nodes[node].ndistances = ndistances;
++
++    return numa->mem_nodes[node].ndistances;
++}
++
++
+ virBitmapPtr
+ virDomainNumaGetNodeCpumask(virDomainNumaPtr numa,
+                             size_t node)
+@@ -1122,6 +1248,17 @@ virDomainNumaGetNodeCpumask(virDomainNumaPtr numa,
+ }
+ 
+ 
++virBitmapPtr
++virDomainNumaSetNodeCpumask(virDomainNumaPtr numa,
++                            size_t node,
++                            virBitmapPtr cpumask)
++{
++    numa->mem_nodes[node].cpumask = cpumask;
++
++    return numa->mem_nodes[node].cpumask;
++}
++
++
+ virDomainMemoryAccess
+ virDomainNumaGetNodeMemoryAccessMode(virDomainNumaPtr numa,
+                                      size_t node)
+diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h
+index 378b772e4b..4655de3aa7 100644
+--- a/src/conf/numa_conf.h
++++ b/src/conf/numa_conf.h
+@@ -87,6 +87,11 @@ int virDomainNumatuneMaybeGetNodeset(virDomainNumaPtr numatune,
+ 
+ size_t virDomainNumaGetNodeCount(virDomainNumaPtr numa);
+ 
++size_t virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
++                                    size_t node,
++                                    size_t sibling)
++    ATTRIBUTE_NONNULL(1);
++
+ virBitmapPtr virDomainNumaGetNodeCpumask(virDomainNumaPtr numa,
+                                          size_t node)
+     ATTRIBUTE_NONNULL(1);
+@@ -124,11 +129,31 @@ int virDomainNumatuneSet(virDomainNumaPtr numa,
+                          virBitmapPtr nodeset)
+     ATTRIBUTE_NONNULL(1);
+ 
++size_t virDomainNumaSetNodeCount(virDomainNumaPtr numa,
++                                 size_t nmem_nodes)
++    ATTRIBUTE_NONNULL(1);
++
+ void virDomainNumaSetNodeMemorySize(virDomainNumaPtr numa,
+                                     size_t node,
+                                     unsigned long long size)
+     ATTRIBUTE_NONNULL(1);
+ 
++int virDomainNumaSetNodeDistance(virDomainNumaPtr numa,
++                                 size_t node,
++                                 size_t sibling,
++                                 unsigned int value)
++    ATTRIBUTE_NONNULL(1);
++
++size_t virDomainNumaSetNodeDistanceCount(virDomainNumaPtr numa,
++                                         size_t node,
++                                         size_t ndistances)
++    ATTRIBUTE_NONNULL(1);
++
++virBitmapPtr virDomainNumaSetNodeCpumask(virDomainNumaPtr numa,
++                                         size_t node,
++                                         virBitmapPtr cpumask)
++    ATTRIBUTE_NONNULL(1);
++
+ /*
+  * Other accessors
+  */
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index ecf7036dff..19543e06ae 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -723,9 +723,14 @@ virDomainNumaGetMaxCPUID;
+ virDomainNumaGetMemorySize;
+ virDomainNumaGetNodeCount;
+ virDomainNumaGetNodeCpumask;
++virDomainNumaGetNodeDistance;
+ virDomainNumaGetNodeMemoryAccessMode;
+ virDomainNumaGetNodeMemorySize;
+ virDomainNumaNew;
++virDomainNumaSetNodeCount;
++virDomainNumaSetNodeCpumask;
++virDomainNumaSetNodeDistance;
++virDomainNumaSetNodeDistanceCount;
+ virDomainNumaSetNodeMemorySize;
+ virDomainNumatuneFormatNodeset;
+ virDomainNumatuneFormatXML;
+diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
+index 8acbfe3f69..81e780586f 100644
+--- a/src/xenconfig/xen_xl.c
++++ b/src/xenconfig/xen_xl.c
+@@ -309,6 +309,203 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def)
+     return -1;
+ }
+ 
++#ifdef LIBXL_HAVE_VNUMA
++static int
++xenParseXLVnuma(virConfPtr conf,
++                virDomainDefPtr def)
++{
++    int ret = -1;
++    char *tmp = NULL;
++    char **token = NULL;
++    size_t vcpus = 0;
++    size_t nr_nodes = 0;
++    size_t vnodeCnt = 0;
++    virCPUDefPtr cpu = NULL;
++    virConfValuePtr list;
++    virConfValuePtr vnode;
++    virDomainNumaPtr numa;
++
++    numa = def->numa;
++    if (numa == NULL)
++        return -1;
++
++    list = virConfGetValue(conf, "vnuma");
++    if (!list || list->type != VIR_CONF_LIST)
++        return 0;
++
++    vnode = list->list;
++    while (vnode && vnode->type == VIR_CONF_LIST) {
++        vnode = vnode->next;
++        nr_nodes++;
++    }
++
++    if (!virDomainNumaSetNodeCount(numa, nr_nodes))
++        goto cleanup;
++
++    if (VIR_ALLOC(cpu) < 0)
++        goto cleanup;
++
++    list = list->list;
++    while (list) {
++        int pnode = -1;
++        virBitmapPtr cpumask = NULL;
++        unsigned long long kbsize = 0;
++
++        /* Is there a sublist (vnode)? */
++        if (list && list->type == VIR_CONF_LIST) {
++            vnode = list->list;
++
++            while (vnode && vnode->type == VIR_CONF_STRING) {
++                const char *data;
++                const char *str = vnode->str;
++
++                if (!str ||
++                   !(data = strrchr(str, '='))) {
++                    virReportError(VIR_ERR_INTERNAL_ERROR,
++                                   _("vnuma vnode invalid format '%s'"),
++                                   str);
++                    goto cleanup;
++                }
++                data++;
++
++                if (*data) {
++                    size_t len;
++                    char vtoken[64];
++
++                    if (STRPREFIX(str, "pnode")) {
++                        unsigned int cellid;
++
++                        len = strlen(data);
++                        if (!virStrncpy(vtoken, data,
++                                        len, sizeof(vtoken))) {
++                            virReportError(VIR_ERR_INTERNAL_ERROR,
++                                           _("vnuma vnode %zu pnode '%s' too long for destination"),
++                                           vnodeCnt, data);
++                            goto cleanup;
++                        }
++
++                        if ((virStrToLong_ui(vtoken, NULL, 10, &cellid) < 0) ||
++                            (cellid >= nr_nodes)) {
++                            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                                           _("vnuma vnode %zu contains invalid pnode value '%s'"),
++                                           vnodeCnt, data);
++                            goto cleanup;
++                        }
++                        pnode = cellid;
++                    } else if (STRPREFIX(str, "size")) {
++                        len = strlen(data);
++                        if (!virStrncpy(vtoken, data,
++                                        len, sizeof(vtoken))) {
++                            virReportError(VIR_ERR_INTERNAL_ERROR,
++                                           _("vnuma vnode %zu size '%s' too long for destination"),
++                                           vnodeCnt, data);
++                            goto cleanup;
++                        }
++
++                        if (virStrToLong_ull(vtoken, NULL, 10, &kbsize) < 0)
++                            goto cleanup;
++
++                        virDomainNumaSetNodeMemorySize(numa, vnodeCnt, (kbsize * 1024));
++
++                    } else if (STRPREFIX(str, "vcpus")) {
++                        len = strlen(data);
++                        if (!virStrncpy(vtoken, data,
++                                        len, sizeof(vtoken))) {
++                            virReportError(VIR_ERR_INTERNAL_ERROR,
++                                           _("vnuma vnode %zu vcpus '%s' too long for destination"),
++                                           vnodeCnt, data);
++                            goto cleanup;
++                        }
++
++                        if ((virBitmapParse(vtoken, &cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) ||
++                            (virDomainNumaSetNodeCpumask(numa, vnodeCnt, cpumask) == NULL))
++                            goto cleanup;
++
++                        vcpus += virBitmapCountBits(cpumask);
++
++                    } else if (STRPREFIX(str, "vdistances")) {
++                        size_t i, ndistances;
++                        unsigned int value;
++
++                        len = strlen(data);
++                        if (!virStrncpy(vtoken, data,
++                                        len, sizeof(vtoken))) {
++                            virReportError(VIR_ERR_INTERNAL_ERROR,
++                                           _("vnuma vnode %zu vdistances '%s' too long for destination"),
++                                           vnodeCnt, data);
++                            goto cleanup;
++                        }
++
++                        if (VIR_STRDUP(tmp, vtoken) < 0)
++                            goto cleanup;
++
++                        if (!(token = virStringSplitCount(tmp, ",", 0, &ndistances)))
++                            goto cleanup;
++
++                        if (ndistances != nr_nodes) {
++                            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                                       _("vnuma pnode %d configured '%s' (count %zu) doesn't fit the number of specified vnodes %zu"),
++                                       pnode, str, ndistances, nr_nodes);
++                            goto cleanup;
++                        }
++
++                        if (virDomainNumaSetNodeDistanceCount(numa, vnodeCnt, ndistances) != ndistances)
++                            goto cleanup;
++
++                        for (i = 0; i < ndistances; i++) {
++                            if ((virStrToLong_ui(token[i], NULL, 10, &value) < 0) ||
++                                (virDomainNumaSetNodeDistance(numa, vnodeCnt, i, value) != value))
++                                goto cleanup;
++                        }
++
++                    } else {
++                        virReportError(VIR_ERR_CONF_SYNTAX,
++                                       _("Invalid vnuma configuration for vnode %zu"),
++                                       vnodeCnt);
++                        goto cleanup;
++                    }
++                }
++                vnode = vnode->next;
++            }
++        }
++
++        if ((pnode < 0) ||
++            (cpumask == NULL) ||
++            (kbsize == 0)) {
++            virReportError(VIR_ERR_CONF_SYNTAX,
++                           _("Incomplete vnuma configuration for vnode %zu"),
++                           vnodeCnt);
++            goto cleanup;
++        }
++
++        list = list->next;
++        vnodeCnt++;
++    }
++
++    if (def->maxvcpus == 0)
++        def->maxvcpus = vcpus;
++
++    if (def->maxvcpus < vcpus) {
++        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                       _("vnuma configuration contains %zu vcpus, which is greater than %zu maxvcpus"),
++                       vcpus, def->maxvcpus);
++        goto cleanup;
++    }
++
++    cpu->type = VIR_CPU_TYPE_GUEST;
++    def->cpu = cpu;
++
++    ret = 0;
++
++ cleanup:
++    if (ret)
++        VIR_FREE(cpu);
++    virStringListFree(token);
++    VIR_FREE(tmp);
++
++    return ret;
++}
++#endif
+ 
+ static int
+ xenParseXLDiskSrc(virDomainDiskDefPtr disk, char *srcstr)
+@@ -863,6 +1060,11 @@ xenParseXL(virConfPtr conf,
+     if (xenParseXLOS(conf, def, caps) < 0)
+         goto cleanup;
+ 
++#ifdef LIBXL_HAVE_VNUMA
++    if (xenParseXLVnuma(conf, def) < 0)
++        goto cleanup;
++#endif
++
+     if (xenParseXLDisk(conf, def) < 0)
+         goto cleanup;
+ 
+@@ -1005,6 +1207,134 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def)
+     return 0;
+ }
+ 
++#ifdef LIBXL_HAVE_VNUMA
++static int
++xenFormatXLVnode(virConfValuePtr list,
++                 virBufferPtr buf)
++{
++    int ret = -1;
++    virConfValuePtr numaPnode, tmp;
++
++    if (virBufferCheckError(buf) < 0)
++        goto cleanup;
++
++    if (VIR_ALLOC(numaPnode) < 0)
++        goto cleanup;
++
++    /* Place VNODE directive */
++    numaPnode->type = VIR_CONF_STRING;
++    numaPnode->str = virBufferContentAndReset(buf);
++
++    tmp = list->list;
++    while (tmp && tmp->next)
++        tmp = tmp->next;
++    if (tmp)
++        tmp->next = numaPnode;
++    else
++        list->list = numaPnode;
++    ret = 0;
++
++ cleanup:
++    virBufferFreeAndReset(buf);
++    return ret;
++}
++
++static int
++xenFormatXLVnuma(virConfValuePtr list,
++                 virDomainNumaPtr numa,
++                 size_t node,
++                 size_t nr_nodes)
++{
++    int ret = -1;
++    size_t i;
++
++    virBuffer buf = VIR_BUFFER_INITIALIZER;
++    virConfValuePtr numaVnode, tmp;
++
++    size_t nodeSize = virDomainNumaGetNodeMemorySize(numa, node) / 1024;
++    char *nodeVcpus = virBitmapFormat(virDomainNumaGetNodeCpumask(numa, node));
++
++    if (VIR_ALLOC(numaVnode) < 0)
++        goto cleanup;
++
++    numaVnode->type = VIR_CONF_LIST;
++    numaVnode->list = NULL;
++
++    /* pnode */
++    virBufferAsprintf(&buf, "pnode=%ld", node);
++    xenFormatXLVnode(numaVnode, &buf);
++
++    /* size */
++    virBufferAsprintf(&buf, "size=%ld", nodeSize);
++    xenFormatXLVnode(numaVnode, &buf);
++
++    /* vcpus */
++    virBufferAsprintf(&buf, "vcpus=%s", nodeVcpus);
++    xenFormatXLVnode(numaVnode, &buf);
++
++    /* distances */
++    virBufferAddLit(&buf, "vdistances=");
++    for (i = 0; i < nr_nodes; i++) {
++        virBufferAsprintf(&buf, "%zu",
++            virDomainNumaGetNodeDistance(numa, node, i));
++        if ((nr_nodes - i) > 1)
++            virBufferAddLit(&buf, ",");
++    }
++    xenFormatXLVnode(numaVnode, &buf);
++
++    tmp = list->list;
++    while (tmp && tmp->next)
++        tmp = tmp->next;
++    if (tmp)
++        tmp->next = numaVnode;
++    else
++        list->list = numaVnode;
++    ret = 0;
++
++ cleanup:
++    VIR_FREE(nodeVcpus);
++    return ret;
++}
++
++static int
++xenFormatXLDomainVnuma(virConfPtr conf,
++                       virDomainDefPtr def)
++{
++    virDomainNumaPtr numa = def->numa;
++    virConfValuePtr vnumaVal;
++    size_t i;
++    size_t nr_nodes;
++
++    if (numa == NULL)
++        return -1;
++
++    if (VIR_ALLOC(vnumaVal) < 0)
++        return -1;
++
++    vnumaVal->type = VIR_CONF_LIST;
++    vnumaVal->list = NULL;
++
++    nr_nodes = virDomainNumaGetNodeCount(numa);
++    for (i = 0; i < nr_nodes; i++) {
++        if (xenFormatXLVnuma(vnumaVal, numa, i, nr_nodes) < 0)
++            goto cleanup;
++    }
++
++    if (vnumaVal->list != NULL) {
++        int ret = virConfSetValue(conf, "vnuma", vnumaVal);
++            vnumaVal = NULL;
++            if (ret < 0)
++                return -1;
++    }
++    VIR_FREE(vnumaVal);
++
++    return 0;
++
++ cleanup:
++    virConfFreeValue(vnumaVal);
++    return -1;
++}
++#endif
+ 
+ static char *
+ xenFormatXLDiskSrcNet(virStorageSourcePtr src)
+@@ -1642,6 +1972,11 @@ xenFormatXL(virDomainDefPtr def, virConnectPtr conn)
+     if (xenFormatXLOS(conf, def) < 0)
+         goto cleanup;
+ 
++#ifdef LIBXL_HAVE_VNUMA
++    if (xenFormatXLDomainVnuma(conf, def) < 0)
++        goto cleanup;
++#endif
++
+     if (xenFormatXLDomainDisks(conf, def) < 0)
+         goto cleanup;
+ 
+-- 
+2.15.1
+
diff --git a/SOURCES/symlinks b/SOURCES/symlinks
index 803c87d..6158f09 100644
--- a/SOURCES/symlinks
+++ b/SOURCES/symlinks
@@ -1,3 +1,4 @@
+README README.md
 tests/virt-admin-self-test ./virsh-self-test
 tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-doorbell-detach.xml qemuhotplug-base-live+ivshmem-plain.xml
 tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-plain-detach.xml qemuhotplug-base-live.xml
@@ -34,15 +35,19 @@ tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-vhost-scsi-ccw.xml ../qemux
 tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-vhost-scsi-pci.xml ../qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi-pci.xml
 tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess.xml ../qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.xml
 tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml ../qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml
+tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-pages4.xml ../qemuxml2argvdata/qemuxml2argv-hugepages-pages4.xml
+tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-pages5.xml ../qemuxml2argvdata/qemuxml2argv-hugepages-pages5.xml
+tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-pages6.xml ../qemuxml2argvdata/qemuxml2argv-hugepages-pages6.xml
+tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-pages7.xml ../qemuxml2argvdata/qemuxml2argv-hugepages-pages7.xml
 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml ../qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml
 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml ../qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml
 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-eim.xml ../qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml
-tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml ../qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
-tests/qemuxml2xmloutdata/qemuxml2xmlout-luks-disks.xml ../qemuxml2argvdata/qemuxml2argv-luks-disks.xml
 tests/qemuxml2xmloutdata/qemuxml2xmlout-memory-hotplug-nvdimm-access.xml ../qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm-access.xml
 tests/qemuxml2xmloutdata/qemuxml2xmlout-memory-hotplug-nvdimm-label.xml ../qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm-label.xml
 tests/qemuxml2xmloutdata/qemuxml2xmlout-memory-hotplug-nvdimm.xml ../qemuxml2argvdata/qemuxml2argv-memory-hotplug-nvdimm.xml
+tests/qemuxml2xmloutdata/qemuxml2xmlout-net-user-addr.xml ../qemuxml2argvdata/qemuxml2argv-net-user-addr.xml
 tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev-notls.xml ../qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml
+tests/qemuxml2xmloutdata/qemuxml2xmlout-user-aliases.xml ../qemuxml2argvdata/qemuxml2argv-user-aliases.xml
 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml ../qemuxml2argvdata/qemuxml2argv-virtio-options.xml
 tests/vircaps2xmldata/linux-basic/node/node0/cpu0 ../../cpu/cpu0
 tests/vircaps2xmldata/linux-basic/node/node0/cpu1 ../../cpu/cpu1
@@ -68,6 +73,21 @@ tests/vircaps2xmldata/linux-caches/node/node0/cpu4 ../../cpu/cpu4
 tests/vircaps2xmldata/linux-caches/node/node0/cpu5 ../../cpu/cpu5
 tests/vircaps2xmldata/linux-caches/node/node0/cpu6 ../../cpu/cpu6
 tests/vircaps2xmldata/linux-caches/node/node0/cpu7 ../../cpu/cpu7
+tests/vircaps2xmldata/linux-resctrl-cdp/system ../linux-resctrl/system/
+tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpu0 ../../cpu/cpu0
+tests/vircaps2xmldata/linux-resctrl/system/node/node0/cpu0 ../../cpu/cpu0
+tests/vircaps2xmldata/linux-resctrl/system/node/node0/cpu1 ../../cpu/cpu1
+tests/vircaps2xmldata/linux-resctrl/system/node/node0/cpu2 ../../cpu/cpu2
+tests/vircaps2xmldata/linux-resctrl/system/node/node0/cpu3 ../../cpu/cpu3
+tests/vircaps2xmldata/linux-resctrl/system/node/node0/cpu4 ../../cpu/cpu4
+tests/vircaps2xmldata/linux-resctrl/system/node/node0/cpu5 ../../cpu/cpu5
+tests/vircaps2xmldata/linux-resctrl/system/node/node1/cpu10 ../../cpu/cpu10
+tests/vircaps2xmldata/linux-resctrl/system/node/node1/cpu11 ../../cpu/cpu11
+tests/vircaps2xmldata/linux-resctrl/system/node/node1/cpu6 ../../cpu/cpu6
+tests/vircaps2xmldata/linux-resctrl/system/node/node1/cpu7 ../../cpu/cpu7
+tests/vircaps2xmldata/linux-resctrl/system/node/node1/cpu8 ../../cpu/cpu8
+tests/vircaps2xmldata/linux-resctrl/system/node/node1/cpu9 ../../cpu/cpu9
+tests/virfilecachedata/9ca150bf3119b75dcac8e8bae4bc3a28e75bc3e262757001e8b953580f5e75ef.cache 5f3154560c130108b282a2aa15b1658aa16923e46497dd8deeb6be287ddb0ca0.cache
 tests/virhostcpudata/linux-deconf-cpus/node/node0/cpu0 ../../cpu/cpu0
 tests/virhostcpudata/linux-deconf-cpus/node/node0/cpu1 ../../cpu/cpu1
 tests/virhostcpudata/linux-deconf-cpus/node/node0/cpu10 ../../cpu/cpu10
diff --git a/SPECS/libvirt.spec b/SPECS/libvirt.spec
index 56ce958..0da1b6e 100644
--- a/SPECS/libvirt.spec
+++ b/SPECS/libvirt.spec
@@ -16,7 +16,6 @@
 # Always run autoreconf
 %{!?enable_autotools:%global enable_autotools 1}
 
-
 # The hypervisor drivers that run in libvirtd
 %define with_xen           0%{!?_without_xen:1}
 %define with_qemu          0%{!?_without_qemu:1}
@@ -37,7 +36,7 @@
     %define with_qemu_tcg 0
     %define qemu_kvm_arches x86_64
     %if 0%{?rhel} >= 7
-        %define qemu_kvm_arches x86_64 %{power64} aarch64
+        %define qemu_kvm_arches x86_64 %{power64} aarch64 s390x
     %endif
 %endif
 
@@ -72,6 +71,13 @@
 %define with_storage_gluster 0%{!?_without_storage_gluster:1}
 %define with_numactl          0%{!?_without_numactl:1}
 
+# F25+ has zfs-fuse
+%if 0%{?fedora} >= 25
+    %define with_storage_zfs      0%{!?_without_storage_zfs:1}
+%else
+    %define with_storage_zfs      0
+%endif
+
 # A few optional bits off by default, we enable later
 %define with_fuse          0%{!?_without_fuse:0}
 %define with_cgconfig      0%{!?_without_cgconfig:0}
@@ -116,6 +122,12 @@
     %endif
 %endif
 
+# zfs-fuse is not available on some architectures
+%ifarch s390 s390x aarch64
+    %define with_storage_zfs 0
+%endif
+
+
 # RHEL doesn't ship OpenVZ, VBox, UML, PowerHypervisor,
 # VMware, libxenserver (xenapi), libxenlight (Xen 4.1 and newer),
 # or HyperV.
@@ -227,17 +239,17 @@
 
 Summary: Library providing a simple virtualization API
 Name: libvirt
-Version: 3.2.0
-Release: 14%{?dist}.9%{?extra_release}
+Version: 3.9.0
+Release: 14%{?dist}%{?extra_release}
 License: LGPLv2+
 Group: Development/Libraries
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
-URL: http://libvirt.org/
+URL: https://libvirt.org/
 
-%if %(echo %{version} | grep -o \\. | wc -l) == 3
+%if %(echo %{version} | grep -q "\.0$"; echo $?) == 1
     %define mainturl stable_updates/
 %endif
-Source: http://libvirt.org/sources/%{?mainturl}libvirt-%{version}.tar.xz
+Source: https://libvirt.org/sources/%{?mainturl}libvirt-%{version}.tar.xz
 Source1: symlinks
 
 Patch1: libvirt-RHEL-screenshot-Implement-multiple-screen-support.patch
@@ -250,267 +262,182 @@ Patch7: libvirt-RHEL-Add-rhel-machine-types-to-qemuDomainMachineNeedsFDC.patch
 Patch8: libvirt-RHEL-qemu-Add-ability-to-set-sgio-values-for-hostdev.patch
 Patch9: libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch
 Patch10: libvirt-RHEL-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch
-Patch11: libvirt-storage-Fix-capacity-value-for-LUKS-encrypted-volumes.patch
-Patch12: libvirt-qemu-Add-device-id-for-mediated-devices-on-qemu-command-line.patch
-Patch13: libvirt-qemu-hotplug-Iterate-over-vcpu-0-in-individual-vcpu-hotplug-code.patch
-Patch14: libvirt-qemu-hotplug-Fix-formatting-strings-in-qemuDomainFilterHotplugVcpuEntities.patch
-Patch15: libvirt-qemu-hotplug-Clear-vcpu-ordering-for-coldplug-of-vcpus.patch
-Patch16: libvirt-qemu-hotplug-Add-validation-for-coldplug-of-individual-vcpus.patch
-Patch17: libvirt-qemu-hotplug-Validate-that-vcpu-hotplug-does-not-break-config.patch
-Patch18: libvirt-qemu-Split-virQEMUCapsInitArchQMPBasic.patch
-Patch19: libvirt-tests-Initialize-basic-capabilities-properly.patch
-Patch20: libvirt-qemu-Remove-redundant-capabilities.patch
-Patch21: libvirt-qemu-Advertise-ACPI-support-for-aarch64-guests.patch
-Patch22: libvirt-qemu-Enforce-ACPI-UEFI-requirements.patch
-Patch23: libvirt-tests-Test-ACPI-UEFI-requirements.patch
-Patch24: libvirt-qemu-Fix-regression-when-hyperv-vendor_id-feature-is-used.patch
-Patch25: libvirt-qemu-Fix-resource-leak-in-qemuDomainAddChardevTLSObjects-error-path.patch
-Patch26: libvirt-qemu-Break-endless-loop-if-qemuMigrationResetTLS-fails.patch
-Patch27: libvirt-qemu-Properly-reset-TLS-in-qemuProcessRecoverMigrationIn.patch
-Patch28: libvirt-qemu-Drop-resume-label-in-qemuProcessRecoverMigrationOut.patch
-Patch29: libvirt-qemu-Always-reset-TLS-in-qemuProcessRecoverMigrationOut.patch
-Patch30: libvirt-qemu-Don-t-reset-TLS-in-qemuMigrationRun.patch
-Patch31: libvirt-qemu-Don-t-reset-TLS-in-qemuMigrationCancel.patch
-Patch32: libvirt-qemu-Introduce-qemuMigrationReset.patch
-Patch33: libvirt-qemu-Simplify-qemuMigrationResetTLS.patch
-Patch34: libvirt-qemu-Properly-reset-all-migration-capabilities.patch
-Patch35: libvirt-qemu-Don-t-overwrite-existing-error-in-qemuMigrationReset.patch
-Patch36: libvirt-qemu-Fix-mdev-checking-for-VFIO-support.patch
-Patch37: libvirt-pci-recognize-report-GEN4-PCIe-4.0-card-16GT-s-Link-speed.patch
-Patch38: libvirt-qemu-refactor-qemuDomainMachine-functions.patch
-Patch39: libvirt-qemu-report-IDE-bus-in-domain-capabilities-only-if-it-s-supported.patch
-Patch40: libvirt-qemu-do-not-crash-on-USB-address-with-no-port-and-invalid-bus.patch
-Patch41: libvirt-conf-Add-check-for-non-scsi_host-parent-during-vport-delete.patch
-Patch42: libvirt-conf-add-a-new-parse-flag-VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION.patch
-Patch43: libvirt-qemu_domain-use-correct-default-USB-controller-on-ppc64.patch
-Patch44: libvirt-qemu-hotplug-Unexport-qemuDomainHotplugDelVcpu.patch
-Patch45: libvirt-qemu-hotplug-Don-t-save-status-XML-when-monitor-is-closed.patch
-Patch46: libvirt-util-check-ifa_addr-pointer-before-accessing-its-elements.patch
-Patch47: libvirt-util-allow-ignoring-SIOCSIFHWADDR-when-errno-is-EPERM.patch
-Patch48: libvirt-qemu-Ignore-missing-query-migrate-parameters.patch
-Patch49: libvirt-locking-Add-support-for-sanlock_strerror.patch
-Patch50: libvirt-qemu-Properly-reset-non-p2p-migration.patch
-Patch51: libvirt-qemu-Don-t-fail-if-physical-size-can-t-be-updated-in-qemuDomainGetBlockInfo.patch
-Patch52: libvirt-qemu-process-Clean-automatic-NUMA-cpu-pinning-information-on-shutdown.patch
-Patch53: libvirt-qemu-process-Don-t-leak-priv-usbaddrs-after-VM-restart.patch
-Patch54: libvirt-qemu-process-Clean-up-priv-migTLSAlias.patch
-Patch55: libvirt-Add-VIR_DOMAIN_JOB_OPERATION-typed-parameter.patch
-Patch56: libvirt-qemu-Report-VIR_DOMAIN_JOB_OPERATION.patch
-Patch57: libvirt-conf-Rename-mode-parameter-in-virCPUDefParseXML.patch
-Patch58: libvirt-Add-support-for-CPU-cache-specification.patch
-Patch59: libvirt-qemu-Add-support-for-guest-CPU-cache.patch
-Patch60: libvirt-qemu-Don-t-reset-events-migration-capability.patch
-Patch61: libvirt-qemu-Fix-persistent-migration-of-transient-domains.patch
-Patch62: libvirt-Fix-padding-of-encrypted-data.patch
-Patch63: libvirt-cpu-Introduce-virCPUCopyMigratable.patch
-Patch64: libvirt-qemu-Move-common-code-in-virQEMUCapsInitCPUModel-one-layer-up.patch
-Patch65: libvirt-qemu-Add-migratable-parameter-to-virQEMUCapsInitCPUModel.patch
-Patch66: libvirt-qemu-Introduce-virQEMUCapsSetHostModel.patch
-Patch67: libvirt-qemu-Move-qemuCaps-CPU-data-copying-into-a-separate-function.patch
-Patch68: libvirt-qemu-Introduce-virQEMUCapsHostCPUDataClear.patch
-Patch69: libvirt-qemu-Move-qemuCaps-host-CPU-data-in-a-struct.patch
-Patch70: libvirt-qemu-Prepare-qemuCaps-for-multiple-host-CPU-defs.patch
-Patch71: libvirt-qemu-Pass-migratable-host-CPU-model-to-virCPUUpdate.patch
-Patch72: libvirt-cpu-Drop-feature-filtering-from-virCPUUpdate.patch
-Patch73: libvirt-cpu-Introduce-virCPUGetHostIsSupported.patch
-Patch74: libvirt-qemu-Use-more-data-for-comparing-CPUs.patch
-Patch75: libvirt-qemu-don-t-kill-qemu-process-on-restart-if-networkNotify-fails.patch
-Patch76: libvirt-network-better-log-message-when-network-is-inactive-during-reconnect.patch
-Patch77: libvirt-disk-Resolve-issues-with-disk-partition-build-start-checks.patch
-Patch78: libvirt-disk-Force-usage-of-parted-when-checking-disk-format-for-bsd.patch
-Patch79: libvirt-storage-Modify-storageBackendWipeLocal-to-allow-zero-from-end-of-device.patch
-Patch80: libvirt-storage-Introduce-virStorageBackendZeroPartitionTable.patch
-Patch81: libvirt-logical-Use-virStorageBackendZeroPartitionTable.patch
-Patch82: libvirt-logical-Increase-the-size-of-the-data-to-wipe.patch
-Patch83: libvirt-disk-Use-virStorageBackendZeroPartitionTable.patch
-Patch84: libvirt-util-Add-virNetDevSetCoalesce-function.patch
-Patch85: libvirt-conf-docs-Add-support-for-coalesce-setting-s.patch
-Patch86: libvirt-Set-coalesce-settings-for-domain-interfaces.patch
-Patch87: libvirt-docs-fix-typo-in-closing-HTML-element.patch
-Patch88: libvirt-Don-t-leak-str-in-virDomainNetDefCoalesceParseXML.patch
-Patch89: libvirt-Remove-pointless-check-for-ret-in-virDomainNetDefCoalesceParseXML.patch
-Patch90: libvirt-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch
-Patch91: libvirt-qemu-change-the-logic-of-setting-default-USB-controller.patch
-Patch92: libvirt-qemu-use-nec-usb-xhci-as-a-default-controller-for-aarch64-if-available.patch
-Patch93: libvirt-qemu-introduce-QEMU_CAPS_DEVICE_QEMU_XHCI.patch
-Patch94: libvirt-qemu-add-support-for-qemu-xhci-USB-controller.patch
-Patch95: libvirt-qemu-use-qemu-xhci-USB-controller-by-default-for-ppc64-and-aarch64.patch
-Patch96: libvirt-util-make-macvtap-macvlan-generated-name-defines-available-to-other-files.patch
-Patch97: libvirt-conf-don-t-ignore-target-dev-blah-for-macvtap-interfaces.patch
-Patch98: libvirt-util-rename-move-VIR_NET_GENERATED_PREFIX-to-be-consistent.patch
-Patch99: libvirt-util-mdev-Use-a-local-variable-instead-of-a-direct-pointer-access.patch
-Patch100: libvirt-mdev-Fix-daemon-crash-on-domain-shutdown-after-reconnect.patch
-Patch101: libvirt-qemu-Provide-a-much-clearer-message-on-device-hot-plug.patch
-Patch102: libvirt-virsh-Add-tls-description-for-the-virsh-man-page.patch
-Patch103: libvirt-conf-Check-CPU-cache-for-ABI-stability.patch
-Patch104: libvirt-qemuDomainBuildNamespace-Move-dev-mountpoints-later.patch
-Patch105: libvirt-qemuDomainCreateDeviceRecursive-pass-a-structure-instead-of-bare-path.patch
-Patch106: libvirt-qemuDomainCreateDeviceRecursive-Don-t-try-to-create-devices-under-preserved-mount-points.patch
-Patch107: libvirt-qemuDomainAttachDeviceMknodRecursive-Don-t-try-to-create-devices-under-preserved-mount-points.patch
-Patch108: libvirt-qemuDomainDetachDeviceUnlink-Don-t-unlink-files-we-haven-t-created.patch
-Patch109: libvirt-util-introduce-virStringMatch.patch
-Patch110: libvirt-util-introduce-virBufferEscapeRegex.patch
-Patch111: libvirt-qemu-improve-detection-of-UNIX-path-generated-by-libvirt.patch
-Patch112: libvirt-Adding-POWER9-cpu-model-to-cpu_map.xml.patch
-Patch113: libvirt-qemu-driver-Allow-passing-disk-target-as-top-image-with-block-commit.patch
-Patch114: libvirt-qemu-monitor-Don-t-bother-extracting-vCPU-halted-state-in-text-monitor.patch
-Patch115: libvirt-conf-Don-t-assign-value-from-.TypeFromString-directly-to-enum.patch
-Patch116: libvirt-nodedev-Make-use-of-the-compile-time-missing-enum-in-switch-error.patch
-Patch117: libvirt-conf-nodedev-Split-virNodeDeviceDefFormat-into-more-functions.patch
-Patch118: libvirt-docs-Provide-a-nodedev-driver-stub-documentation.patch
-Patch119: libvirt-mdev-Pass-a-uuidstr-rather-than-an-mdev-object-to-some-util-functions.patch
-Patch120: libvirt-nodedev-conf-Split-PCI-sub-capability-parsing-to-separate-methods.patch
-Patch121: libvirt-nodedev-Introduce-new-mdev_types-and-mdev-nodedev-capabilities.patch
-Patch122: libvirt-nodedev-Introduce-the-mdev-capability-to-a-PCI-parent-device.patch
-Patch123: libvirt-nodedev-Introduce-mdev-capability-for-mediated-devices.patch
-Patch124: libvirt-docs-Document-the-mediated-devices-within-the-nodedev-driver.patch
-Patch125: libvirt-Do-not-release-unreserved-address-in-qemuDomainAttachRNGDevice.patch
-Patch126: libvirt-qemu-process-Clear-priv-namespaces-on-VM-shutdown.patch
-Patch127: libvirt-Revert-qemu-propagate-bridge-MTU-into-qemu-host_mtu-option.patch
-Patch128: libvirt-qemu-Properly-check-return-value-of-VIR_STRDUP-in-qemuDomainGetBlockIoTune.patch
-Patch129: libvirt-rpc-Bump-maximum-message-size-to-32M.patch
-Patch130: libvirt-Split-out-virDomainIOMMUDefFormat.patch
-Patch131: libvirt-qemu-allow-conditional-device-property-probing.patch
-Patch132: libvirt-qemu-refactor-qemuBuildIOMMUCommandLine.patch
-Patch133: libvirt-conf-add-ioapic-driver-to-features.patch
-Patch134: libvirt-qemu-format-kernel_irqchip-on-the-command-line.patch
-Patch135: libvirt-conf-add-driver-intremap-to-iommu.patch
-Patch136: libvirt-qemu-format-intel-iommu-intremap-on-the-command-line.patch
-Patch137: libvirt-conf-add-caching_mode-attribute-to-iommu-device.patch
-Patch138: libvirt-qemu-format-caching-mode-on-iommu-command-line.patch
-Patch139: libvirt-conf-split-out-virDomainIOMMUDefCheckABIStability.patch
-Patch140: libvirt-conf-add-ABI-stability-checks-for-IOMMU-options.patch
-Patch141: libvirt-conf-Resolve-corner-case-on-fc_host-deletion.patch
-Patch142: libvirt-pci-fix-link-maximum-speed-detection.patch
-Patch143: libvirt-qemu-Use-correct-variable-in-qemuDomainSetBlockIoTune.patch
-Patch144: libvirt-virsh-Track-when-create-pkttyagent.patch
-Patch145: libvirt-conf-add-eim-attribute-to-iommu-driver.patch
-Patch146: libvirt-qemu-format-eim-on-intel-iommu-command-line.patch
-Patch147: libvirt-rpc-Double-buffer-size-instead-of-quadrupling-buffer-size.patch
-Patch148: libvirt-rpc-Allow-up-to-256K-records-to-be-returned-per-domain-from-virConnectGetAllDomainStats.patch
-Patch149: libvirt-nodedev-Increase-the-netlink-socket-buffer-size-to-the-one-used-by-udev.patch
-Patch150: libvirt-util-hostcpu-Correctly-report-total-number-of-vcpus-in-virHostCPUGetMap.patch
-Patch151: libvirt-qemu-Report-shutdown-event-details.patch
-Patch152: libvirt-qemu-json-Fix-daemon-crash-on-handling-domain-shutdown-event.patch
-Patch153: libvirt-qemu-mkdir-memory_backing_dir-on-startup.patch
-Patch154: libvirt-qemu-Don-t-error-out-if-allocation-info-can-t-be-queried.patch
-Patch155: libvirt-daemon-Don-t-initialize-SASL-context-if-not-necessary.patch
-Patch156: libvirt-virDomainXMLOption-Introduce-virDomainABIStabilityDomain.patch
-Patch157: libvirt-virQEMUDriverDomainABIStability-Check-for-memoryBacking.patch
-Patch158: libvirt-qemu-process-Save-vcpu-ordering-information-on-reconnect.patch
-Patch159: libvirt-audit-Fix-the-output-message-for-shmem.patch
-Patch160: libvirt-qemu-Set-operation-on-completed-migration-job.patch
-Patch161: libvirt-qemu-Conditionally-allow-block-copy-for-persistent-domains.patch
-Patch162: libvirt-virsh-Add-support-for-VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB.patch
-Patch163: libvirt-qemu-Fix-serial-stub-console-allocation.patch
-Patch164: libvirt-conf-Make-error-reporting-in-virCPUDefIsEqual-optional.patch
-Patch165: libvirt-conf-Refactor-virCPUDefParseXML.patch
-Patch166: libvirt-conf-Make-virDomainSnapshotDefFormat-easier-to-read.patch
-Patch167: libvirt-conf-Pass-xmlopt-to-virDomainSnapshotDefFormat.patch
-Patch168: libvirt-qemu-Rename-xml_len-in-virQEMUSaveHeader-as-data_len.patch
-Patch169: libvirt-qemu-Fix-memory-leaks-in-qemuDomainSaveImageOpen.patch
-Patch170: libvirt-qemu-Introduce-virQEMUSaveData-New-Free.patch
-Patch171: libvirt-qemu-Introduce-virQEMUSaveDataFinish.patch
-Patch172: libvirt-qemu-Refactor-qemuDomainSaveHeader.patch
-Patch173: libvirt-qemu-Introduce-virQEMUSaveData-structure.patch
-Patch174: libvirt-conf-Introduce-virSaveCookie.patch
-Patch175: libvirt-conf-Add-save-cookie-callbacks-to-xmlopt.patch
-Patch176: libvirt-qemu-Implement-virSaveCookie-object-and-callbacks.patch
-Patch177: libvirt-qemu-Store-save-cookie-in-save-images-and-snapshots.patch
-Patch178: libvirt-qemu-Remember-CPU-def-from-domain-start.patch
-Patch179: libvirt-qemu-Report-the-original-CPU-in-migratable-xml.patch
-Patch180: libvirt-qemu-Always-send-persistent-XML-during-migration.patch
-Patch181: libvirt-qemu-Send-updated-CPU-in-migration-cookie.patch
-Patch182: libvirt-qemu-Store-updated-CPU-in-save-cookie.patch
-Patch183: libvirt-qemu-Use-updated-CPU-when-starting-QEMU-if-possible.patch
-Patch184: libvirt-docs-correct-improper-information-about-domain-states-in-virsh-manpage.patch
-Patch185: libvirt-qemu-Set-iface-MTU-on-hotplug.patch
-Patch186: libvirt-Use-a-separate-buffer-for-input-subelements.patch
-Patch187: libvirt-Use-a-separate-buffer-for-disk-driver.patch
-Patch188: libvirt-Use-a-separate-buffer-for-controller-driver.patch
-Patch189: libvirt-Use-a-separate-buffer-for-filesystem-driver.patch
-Patch190: libvirt-conf-introduce-virDomainControllerDriverFormat.patch
-Patch191: libvirt-conf-add-iotlb-attribute-to-iommu.patch
-Patch192: libvirt-qemu-format-device-iotlb-on-intel-iommu-command-line.patch
-Patch193: libvirt-qemuxml2xmltest-add-virtio-options-test.patch
-Patch194: libvirt-conf-use-a-leading-space-in-virDomainVirtioNetDriverFormat.patch
-Patch195: libvirt-Add-virtio-related-options-to-interfaces.patch
-Patch196: libvirt-add-virtio-related-options-to-memballoon.patch
-Patch197: libvirt-Add-virtio-related-options-to-disks.patch
-Patch198: libvirt-Add-virtio-related-options-to-controllers.patch
-Patch199: libvirt-Add-virtio-related-options-to-filesystems.patch
-Patch200: libvirt-Add-virtio-related-options-to-rng-devices.patch
-Patch201: libvirt-Add-virtio-related-options-to-video.patch
-Patch202: libvirt-Add-virtio-related-options-to-input-devices.patch
-Patch203: libvirt-qemuxml2argvtest-add-virtio-options-test-case.patch
-Patch204: libvirt-qemu-format-virtio-related-options-on-the-command-line.patch
-Patch205: libvirt-qemu-Allow-memAccess-for-hugepages-again.patch
-Patch206: libvirt-qemu-Prefer-hugepages-over-mem-source-file.patch
-Patch207: libvirt-qemu-Don-t-try-to-use-hugepages-if-not-enabled.patch
-Patch208: libvirt-qemu-Introduce-qemuDomainDefFromXML-helper.patch
-Patch209: libvirt-qemu-Add-qemuDomainMigratableDefCheckABIStability.patch
-Patch210: libvirt-qemu-Add-qemuDomainCheckABIStability.patch
-Patch211: libvirt-qemu-Use-qemuDomainCheckABIStability-where-needed.patch
-Patch212: libvirt-util-storage-Output-parsed-network-backing-store-string-to-debug-log.patch
-Patch213: libvirt-util-storage-Add-missing-return-to-virStorageSourceParseBackingJSONGluster.patch
-Patch214: libvirt-util-storage-make-virStorageSourceParseBackingJSONGlusterHost-universal.patch
-Patch215: libvirt-util-storage-Add-support-for-type-inet-in-virStorageSourceParseBackingJSONSocketAddress.patch
-Patch216: libvirt-util-storage-Split-out-parsing-of-TCP-network-host-from-JSON-pseudoprotocol.patch
-Patch217: libvirt-util-storage-Report-errors-when-source-host-data-is-missing.patch
-Patch218: libvirt-util-storage-Add-JSON-parser-for-new-options-in-iSCSI-protocol.patch
-Patch219: libvirt-util-storage-adapt-to-changes-in-JSON-format-for-NBD.patch
-Patch220: libvirt-util-storage-adapt-to-changes-in-JSON-format-for-ceph-rbd.patch
-Patch221: libvirt-util-storage-adapt-to-changes-in-JSON-format-for-ssh.patch
-Patch222: libvirt-util-storage-adapt-to-changes-in-JSON-format-for-sheepdog.patch
-Patch223: libvirt-qemu-Allow-live-updates-of-coalesce-settings.patch
-Patch224: libvirt-qemu-Pass-the-number-of-heads-even-with-vga-qxl.patch
-Patch225: libvirt-util-storage-Export-virStorageIsRelative.patch
-Patch226: libvirt-storage-Add-helper-to-retrieve-the-backing-store-string-of-a-storage-volume.patch
-Patch227: libvirt-qemu-snapshot-Load-data-necessary-for-relative-block-commit-to-work.patch
-Patch228: libvirt-util-storage-Make-backingFormat-optional-in-virStorageFileGetMetadataInternal.patch
-Patch229: libvirt-qemu-Change-coalesce-settings-on-hotplug-when-they-are-different.patch
-Patch230: libvirt-qemu-Do-not-skip-virCPUUpdateLive-if-priv-origCPU-is-set.patch
-Patch231: libvirt-qemu-Don-t-update-CPU-when-checking-ABI-stability.patch
-Patch232: libvirt-cpu_x86-Properly-disable-unknown-CPU-features.patch
-Patch233: libvirt-qemu-Add-qemuProcessFetchGuestCPU.patch
-Patch234: libvirt-qemu-Add-qemuProcessVerifyCPU.patch
-Patch235: libvirt-qemu-Rename-qemuProcessUpdateLiveGuestCPU.patch
-Patch236: libvirt-qemu-Add-qemuProcessUpdateLiveGuestCPU.patch
-Patch237: libvirt-qemu-Export-virQEMUCapsGuestIsNative.patch
-Patch238: libvirt-qemu-Move-qemuProcessReconnect-to-the-end-of-qemu_process.c.patch
-Patch239: libvirt-qemu-Update-host-model-CPUs-on-reconnect.patch
-Patch240: libvirt-qemu-Fix-qemuDomainGetBlockInfo-allocation-value-setting.patch
-Patch241: libvirt-qemuDomainBuildNamespace-Handle-special-file-mount-points.patch
-Patch242: libvirt-Add-support-for-virtio-net.tx_queue_size.patch
-Patch243: libvirt-qemu-Pass-virArch-to-virQEMUCapsCPUFilterFeatures.patch
-Patch244: libvirt-qemu-Publish-virQEMUCapsCPUFilterFeatures.patch
-Patch245: libvirt-qemu-Separate-CPU-updating-code-from-qemuProcessReconnect.patch
-Patch246: libvirt-conf-Introduce-virCPUDefFindFeature.patch
-Patch247: libvirt-qemu-Filter-CPU-features-when-using-host-CPU.patch
-Patch248: libvirt-qemu-Fix-CPU-model-broken-by-older-libvirt.patch
-Patch249: libvirt-qemu-block-commit-Don-t-overwrite-error-when-rolling-back-disk-labels.patch
-Patch250: libvirt-qemu-block-commit-Determine-relative-path-of-images-before-initializing.patch
-Patch251: libvirt-qemu-domain-Don-t-call-namespace-setup-for-storage-already-accessed-by-vm.patch
-Patch252: libvirt-util-add-virFileReadHeaderQuiet-wrapper-around-virFileReadHeaderFD.patch
-Patch253: libvirt-util-introduce-virHostCPUGetMicrocodeVersion.patch
-Patch254: libvirt-cpu_x86-Rename-virCPUx86MapInitialize.patch
-Patch255: libvirt-conf-include-x86-microcode-version-in-virsh-capabiltiies.patch
-Patch256: libvirt-qemu-capabilities-force-update-if-the-microcode-version-does-not-match.patch
-Patch257: libvirt-cpu-add-CPU-features-and-model-for-indirect-branch-prediction-protection.patch
-Patch258: libvirt-qemu-Properly-store-microcode-version-in-QEMU-caps-cache.patch
-Patch259: libvirt-qemuDomainAttachDeviceMknodHelper-Remove-symlink-before-creating-it.patch
-Patch260: libvirt-cpu_x86-Copy-CPU-signature-from-ancestor.patch
-Patch261: libvirt-qemu-take-current-async-job-into-account-in-qemuBlockNodeNamesDetect.patch
-Patch262: libvirt-qemu-migration-fix-race-on-cancelling-drive-mirror.patch
-Patch263: libvirt-qemu-drop-code-for-VIR_DOMAIN_JOB_BOUNDED-and-timeRemaining.patch
-Patch264: libvirt-qemu-introduce-qemu-domain-job-status.patch
-Patch265: libvirt-qemu-introduce-QEMU_DOMAIN_JOB_STATUS_POSTCOPY.patch
-Patch266: libvirt-qemu-start-all-async-job-with-job-status-active.patch
-Patch267: libvirt-qemu-introduce-migrating-job-status.patch
-Patch268: libvirt-qemu-migration-don-t-expose-incomplete-job-as-complete.patch
-Patch269: libvirt-qemu-Fix-type-of-a-completed-job.patch
-Patch270: libvirt-qemu-Fix-crash-in-offline-migration.patch
-Patch271: libvirt-RHEL-qemu-Report-full-stats-for-completed-migration.patch
+Patch11: libvirt-RHEL-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch
+Patch12: libvirt-conf-Don-t-inline-virDomainNetTypeSharesHostView.patch
+Patch13: libvirt-conf-s-virDomainObjGetShortName-virDomainDefGetShortName.patch
+Patch14: libvirt-qemu-Move-memPath-generation-from-memoryBackingDir-to-a-separate-function.patch
+Patch15: libvirt-qemu-Set-alias-for-memory-cell-in-qemuBuildMemoryCellBackendStr.patch
+Patch16: libvirt-qemu-Rename-qemuProcessBuildDestroyHugepagesPath.patch
+Patch17: libvirt-qemu-Destroy-whole-memory-tree.patch
+Patch18: libvirt-qemu-Use-predictable-file-names-for-memory-backend-file.patch
+Patch19: libvirt-conf-Properly-parse-backingStore.patch
+Patch20: libvirt-qemu-parse-Allocate-disk-definition-with-private-data.patch
+Patch21: libvirt-qemu-Tolerate-storage-source-private-data-being-NULL.patch
+Patch22: libvirt-qemu-domain-Don-t-allocate-storage-source-private-data-if-not-needed.patch
+Patch23: libvirt-conf-Fix-message-when-maximum-vCPU-count-is-less-than-current.patch
+Patch24: libvirt-Revert-virNetDevSupportBandwidth-Enable-QoS-for-vhostuser.patch
+Patch25: libvirt-tests-Rename-ppc64le-caps-to-ppc64.patch
+Patch26: libvirt-tests-Add-caps-for-QEMU-2.10.0-on-ppc64.patch
+Patch27: libvirt-qemu-Enable-configuration-of-HPT-resizing-for-pSeries-guests.patch
+Patch28: libvirt-tests-Add-tests-for-configuration-of-HPT-resizing.patch
+Patch29: libvirt-qemuBuildDriveDevStr-Prefer-default-aliases-for-IDE-bus.patch
+Patch30: libvirt-virQEMUCapsHasPCIMultiBus-Fix-def-type.patch
+Patch31: libvirt-qemuBuildDriveDevStr-Prefer-default-alias-for-SATA-bus.patch
+Patch32: libvirt-qemuBuildDeviceAddressStr-Prefer-default-alias-for-PCI-bus.patch
+Patch33: libvirt-qemu-domain-Don-t-call-namespace-setup-for-storage-already-accessed-by-vm.patch
+Patch34: libvirt-qemu-Properly-skip-char-device-redirected-to-in-QEMU-log.patch
+Patch35: libvirt-vierror-Define-VIR_ERROR_MAX_LENGTH-macro.patch
+Patch36: libvirt-qemu-Use-the-end-of-QEMU-log-for-reporting-errors.patch
+Patch37: libvirt-qemu-Move-snapshot-disk-validation-functions-into-one.patch
+Patch38: libvirt-qemu-domain-Despaghettify-qemuDomainDeviceDefValidate.patch
+Patch39: libvirt-qemu-domain-Move-hostdev-validation-into-separate-function.patch
+Patch40: libvirt-qemu-domain-Move-video-device-validation-into-separate-function.patch
+Patch41: libvirt-qemu-domain-Refactor-domain-device-validation-function.patch
+Patch42: libvirt-qemu-block-Add-function-to-check-if-storage-source-allows-concurrent-access.patch
+Patch43: libvirt-qemu-domain-Reject-shared-disk-access-if-backing-format-does-not-support-it.patch
+Patch44: libvirt-qemu-snapshot-Disallow-snapshot-of-unsupported-shared-disks.patch
+Patch45: libvirt-qemu-Disallow-pivot-of-shared-disks-to-unsupported-storage.patch
+Patch46: libvirt-qemu-caps-Add-capability-for-share-rw-disk-option.patch
+Patch47: libvirt-qemu-command-Mark-shared-disks-as-such-in-qemu.patch
+Patch48: libvirt-nodedev-Restore-setting-of-privileged.patch
+Patch49: libvirt-Introduce-virDomainInputDefGetPath.patch
+Patch50: libvirt-security-Introduce-functions-for-input-device-hot-un-plug.patch
+Patch51: libvirt-qemu-Introduce-functions-for-input-device-cgroup-manipulation.patch
+Patch52: libvirt-qemu-functions-for-dealing-with-input-device-namespaces-and-labels.patch
+Patch53: libvirt-qemu-Properly-label-and-create-evdev-on-input-device-hotplug.patch
+Patch54: libvirt-qemu-Add-QEMU_CAPS_DEVICE_SPAPR_VTY.patch
+Patch55: libvirt-qemu-rename-QEMU_CAPS_SCLP_S390-to-QEMU_CAPS_DEVICE_SCLPCONSOLE.patch
+Patch56: libvirt-qemu-add-QEMU_CAPS_DEVICE_SCLPLMCONSOLE.patch
+Patch57: libvirt-conf-qemu-Use-type-aware-switches-where-possible.patch
+Patch58: libvirt-docs-Improve-documentation-for-serial-consoles.patch
+Patch59: libvirt-qemu-Introduce-qemuDomainChrDefPostParse.patch
+Patch60: libvirt-conf-Run-devicePostParse-again-for-the-first-serial-device.patch
+Patch61: libvirt-conf-Introduce-VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE.patch
+Patch62: libvirt-conf-Drop-virDomainChrDeviceType.targetTypeAttr.patch
+Patch63: libvirt-conf-Introduce-virDomainChrTargetDefFormat.patch
+Patch64: libvirt-conf-Improve-error-handling-in-virDomainChrDefFormat.patch
+Patch65: libvirt-conf-Check-virDomainChrSourceDefFormat-return-value.patch
+Patch66: libvirt-conf-Improve-virDomainChrTargetDefFormat.patch
+Patch67: libvirt-conf-Remove-ATTRIBUTE_FALLTHROUGH-from-virDomainChrTargetDefFormat.patch
+Patch68: libvirt-qemu-Introduce-qemuDomainChrTargetDefValidate.patch
+Patch69: libvirt-qemu-Improve-qemuDomainChrTargetDefValidate.patch
+Patch70: libvirt-conf-Parse-and-format-virDomainChrSerialTargetModel.patch
+Patch71: libvirt-qemu-Set-targetModel-based-on-targetType-for-serial-devices.patch
+Patch72: libvirt-qemu-Validate-target-model-for-serial-devices.patch
+Patch73: libvirt-qemu-Format-targetModel-for-serial-devices.patch
+Patch74: libvirt-qemu-Remove-redundancy-in-qemuBuildSerialChrDeviceStr.patch
+Patch75: libvirt-conf-Add-target-type-and-model-for-spapr-vty.patch
+Patch76: libvirt-qemu-Support-usb-serial-and-pci-serial-on-pSeries.patch
+Patch77: libvirt-conf-Add-target-type-and-model-for-pl011.patch
+Patch78: libvirt-conf-add-VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP.patch
+Patch79: libvirt-qemu-switch-s390-s390x-default-console-back-to-serial.patch
+Patch80: libvirt-qemu-Add-QEMU_CAPS_DEVICE_ISA_SERIAL.patch
+Patch81: libvirt-qemu-Require-QEMU_CAPS_DEVICE_ISA_SERIAL-for-isa-serial.patch
+Patch82: libvirt-qemu-Add-QEMU_CAPS_DEVICE_PL011.patch
+Patch83: libvirt-qemu-Require-QEMU_CAPS_DEVICE_PL011-for-pl011.patch
+Patch84: libvirt-conf-fix-migratable-XML-for-graphics-if-socket-is-generated-based-on-config.patch
+Patch85: libvirt-storage-Extract-error-reporting-for-broken-chains.patch
+Patch86: libvirt-qemu-domain-Refactor-control-flow-in-qemuDomainDetermineDiskChain.patch
+Patch87: libvirt-qemu-process-Move-handling-of-non-backing-files-into-qemuDomainDetermineDiskChain.patch
+Patch88: libvirt-qemu-domain-Fix-backing-store-terminator-for-non-backing-local-files.patch
+Patch89: libvirt-numa-describe-siblings-distances-within-cells.patch
+Patch90: libvirt-xenconfig-add-domxml-conversions-for-xen-xl.patch
+Patch91: libvirt-virDomainNumaGetNodeDistance-Fix-input-arguments-validation.patch
+Patch92: libvirt-numa-Introduce-virDomainNumaNodeDistanceIsUsingDefaults.patch
+Patch93: libvirt-qemu_capabilities-Introcude-QEMU_CAPS_NUMA_DIST.patch
+Patch94: libvirt-qemu-Support-setting-NUMA-distances.patch
+Patch95: libvirt-conf-Fix-memory-leak-for-distances-in-virDomainNumaFree.patch
+Patch96: libvirt-virDomainDiskSourceNetworkParse-Don-t-leak-tlsCfg-or-haveTLS.patch
+Patch97: libvirt-virDomainDiskBackingStoreParse-Don-t-leak-idx.patch
+Patch98: libvirt-qemuStateInitialize-Don-t-leak-memoryBackingPath.patch
+Patch99: libvirt-Introduce-virDomainDeviceAliasIsUserAlias.patch
+Patch100: libvirt-qemu-prefer-the-PCI-bus-alias-from-status-XML.patch
+Patch101: libvirt-virQEMUCapsHasPCIMultiBus-use-def-os.arch.patch
+Patch102: libvirt-virQEMUCapsHasPCIMultiBus-assume-true-if-we-have-no-version-information.patch
+Patch103: libvirt-qemu-add-vmcoreinfo-support.patch
+Patch104: libvirt-security-introduce-virSecurityManager-Set-Restore-ChardevLabel.patch
+Patch105: libvirt-qemu-fix-security-labeling-for-attach-detach-of-char-devices.patch
+Patch106: libvirt-nwfilter-don-t-crash-listing-filters-in-unprivileged-daemon.patch
+Patch107: libvirt-docs-domain-Fix-documentation-of-the-snapshot-attribute-for-disk.patch
+Patch108: libvirt-storage-Don-t-dereference-driver-object-if-virStorageSource-is-not-initialized.patch
+Patch109: libvirt-qemu-blockjob-Reset-disk-source-index-after-pivot.patch
+Patch110: libvirt-qemu-Separate-fetching-CPU-definitions-from-filling-qemuCaps.patch
+Patch111: libvirt-qemu-Make-sure-host-model-uses-CPU-model-supported-by-QEMU.patch
+Patch112: libvirt-qemu-Avoid-comparing-size_t-with-1.patch
+Patch113: libvirt-migration.html-Clarify-configuration-file-handling-docs.patch
+Patch114: libvirt-conf-Add-infrastructure-for-disk-source-private-data-XML.patch
+Patch115: libvirt-util-storage-Add-helpers-to-parse-and-format-relPath-into-privateData.patch
+Patch116: libvirt-qemu-domain-Parse-and-format-relPath-into-disk-source-private-data.patch
+Patch117: libvirt-qemu-remove-input-device-after-receiving-the-event.patch
+Patch118: libvirt-conf-honor-maxnames-in-nodeListDevices-API.patch
+Patch119: libvirt-storage-Fixing-missing-backingStore-tag-from-volume-XML-dumps.patch
+Patch120: libvirt-util-add-virFileReadHeaderQuiet-wrapper-around-virFileReadHeaderFD.patch
+Patch121: libvirt-util-introduce-virHostCPUGetMicrocodeVersion.patch
+Patch122: libvirt-cpu_x86-Rename-virCPUx86MapInitialize.patch
+Patch123: libvirt-conf-include-x86-microcode-version-in-virsh-capabiltiies.patch
+Patch124: libvirt-qemu-capabilities-force-update-if-the-microcode-version-does-not-match.patch
+Patch125: libvirt-cpu-add-CPU-features-and-model-for-indirect-branch-prediction-protection.patch
+Patch126: libvirt-qemuDomainAttachDeviceMknodHelper-Remove-symlink-before-creating-it.patch
+Patch127: libvirt-RHEL-cpu-Fix-EPYC-IBRS-CPU-model.patch
+Patch128: libvirt-cpu_x86-Copy-CPU-signature-from-ancestor.patch
+Patch129: libvirt-qemu-Ignore-fallback-CPU-attribute-on-reconnect.patch
+Patch130: libvirt-qemu-Fix-type-of-a-completed-job.patch
+Patch131: libvirt-qemu-Fix-crash-in-offline-migration.patch
+Patch132: libvirt-Revert-qemu-monitor-do-not-report-error-on-shutdown.patch
+Patch133: libvirt-qemu-Refresh-caps-cache-after-booting-a-different-kernel.patch
+Patch134: libvirt-qemu-Don-t-initialize-struct-utsname.patch
+Patch135: libvirt-storage-util-Properly-ignore-errors-when-backing-volume-is-inaccessible.patch
+Patch136: libvirt-util-json-Add-helper-to-return-string-or-number-properties-as-string.patch
+Patch137: libvirt-util-storage-Parse-lun-for-iSCSI-protocol-from-JSON-as-string-or-number.patch
+Patch138: libvirt-util-Introduce-virFormatIntPretty.patch
+Patch139: libvirt-util-Make-prefix-optional-in-virBitampString.patch
+Patch140: libvirt-util-Rename-virBitmapString-to-virBitmapToString.patch
+Patch141: libvirt-util-Rename-virBitmapDataToString-to-virBitmapDataFormat.patch
+Patch142: libvirt-util-Don-t-output-too-many-zeros-from-virBitmapToString.patch
+Patch143: libvirt-util-Introduce-virBitmapNewString.patch
+Patch144: libvirt-util-Reintroduce-virBitmapSubtract.patch
+Patch145: libvirt-util-Introduce-virBitmapShrink.patch
+Patch146: libvirt-conf-Sort-cache-banks-in-capabilities-XML.patch
+Patch147: libvirt-conf-Format-cache-banks-in-capabilities-with-virFormatIntPretty.patch
+Patch148: libvirt-tests-Remove-executable-bits-on-plain-data-files.patch
+Patch149: libvirt-tests-Minor-adjustments-for-test-data.patch
+Patch150: libvirt-tests-Add-resctrl-skx-twocaches-test-case-to-vircaps2xmltest.patch
+Patch151: libvirt-util-Fix-leak-in-virStringTrimOptionalNewline.patch
+Patch152: libvirt-Rename-virResctrlInfo-to-virResctrlInfoPerCache.patch
+Patch153: libvirt-util-Add-virResctrlInfo.patch
+Patch154: libvirt-conf-Use-virResctrlInfo-in-capabilities.patch
+Patch155: libvirt-util-Remove-now-unneeded-resctrl-functions.patch
+Patch156: libvirt-fixup_resctrlinfo.patch
+Patch157: libvirt-resctrl-Add-functions-to-work-with-resctrl-allocations.patch
+Patch158: libvirt-conf-Add-support-for-cputune-cachetune.patch
+Patch159: libvirt-tests-Add-virresctrltest.patch
+Patch160: libvirt-qemu-Add-support-for-resctrl.patch
+Patch161: libvirt-tests-Clean-up-and-modify-some-vircaps2xmldata.patch
+Patch162: libvirt-resctl-stub-out-functions-with-Linux-only-APIs-used.patch
+Patch163: libvirt-util-Check-for-empty-allocation-instead-of-just-NULL-pointer.patch
+Patch164: libvirt-util-Use-resctrl-instead-of-resctrlfs-spelling.patch
+Patch165: libvirt-util-Make-it-possible-for-virResctrlAllocSetMask-to-replace-existing-mask.patch
+Patch166: libvirt-util-Remove-unused-variable-in-virResctrlGetInfo.patch
+Patch167: libvirt-util-Don-t-check-if-entries-under-sys-fs-resctrl-info-are-directories.patch
+Patch168: libvirt-util-Add-helpers-for-getting-resctrl-group-allocs.patch
+Patch169: libvirt-util-Use-default-group-s-mask-for-unspecified-resctrl-allocations.patch
+Patch170: libvirt-util-Don-t-overwrite-mask-in-virResctrlAllocFindUnused.patch
+Patch171: libvirt-qemu-Restore-machinename-even-without-cgroups.patch
+Patch172: libvirt-util-Extract-path-formatting-into-virResctrlAllocDeterminePath.patch
+Patch173: libvirt-qemu-Restore-resctrl-alloc-data-after-restart.patch
+Patch174: libvirt-qemu-migration-Refresh-device-information-after-transferring-state.patch
+Patch175: libvirt-qemuDomainRemoveMemoryDevice-unlink-memory-backing-file.patch
+Patch176: libvirt-util-Fix-possible-leak-in-virResctrlAllocMasksAssign.patch
+Patch177: libvirt-util-Clear-unused-part-of-the-map-in-virBitmapShrink.patch
+Patch178: libvirt-tests-Add-test-for-properly-removing-cachetune-entries.patch
+Patch179: libvirt-util-Check-if-kernel-provided-info-is-consistent-with-itself.patch
+Patch180: libvirt-qemu-Refresh-capabilities-when-creating-resctrl-allocation.patch
+Patch182: libvirt-util-bitmap-Fix-value-of-map_alloc-when-shrinking-bitmap.patch
+Patch183: libvirt-qemu-driver-Extract-vcpu-halted-state-directly.patch
+Patch184: libvirt-qemu-Remove-unused-cpuhalted-argument-from-qemuDomainHelperGetVcpus.patch
+Patch185: libvirt-qemu-domain-Store-vcpu-halted-state-as-a-tristate.patch
+Patch186: libvirt-qemu-Limit-refresh-of-CPU-halted-state-to-s390.patch
+Patch187: libvirt-conf-move-generated-member-from-virMacAddr-to-virDomainNetDef.patch
 
 Requires: libvirt-daemon = %{version}-%{release}
 Requires: libvirt-daemon-config-network = %{version}-%{release}
@@ -553,7 +480,11 @@ BuildRequires: libtool
 BuildRequires: /usr/bin/pod2man
 %endif
 BuildRequires: git
+%if 0%{?fedora} >= 27
+BuildRequires: perl-interpreter
+%else
 BuildRequires: perl
+%endif
 BuildRequires: python
 %if %{with_systemd}
 BuildRequires: systemd-units
@@ -562,7 +493,6 @@ BuildRequires: systemd-units
 BuildRequires: xen-devel
 %endif
 BuildRequires: libxml2-devel
-BuildRequires: xhtml1-dtds
 BuildRequires: libxslt
 BuildRequires: readline-devel
 BuildRequires: ncurses-devel
@@ -633,7 +563,7 @@ BuildRequires: parted-devel
 # For Multipath support
 BuildRequires: device-mapper-devel
 %if %{with_storage_rbd}
-    %if 0%{?rhel} >= 7
+    %if 0%{?fedora} || 0%{?rhel} >= 7
 BuildRequires: librados2-devel
 BuildRequires: librbd1-devel
     %else
@@ -647,6 +577,12 @@ BuildRequires: glusterfs-devel >= 3.4.1
 %if %{with_storage_sheepdog}
 BuildRequires: sheepdog
 %endif
+%if %{with_storage_zfs}
+# Support any conforming implementation of zfs. On stock Fedora
+# this is zfs-fuse, but could be zfsonlinux upstream RPMs
+BuildRequires: /sbin/zfs
+BuildRequires: /sbin/zpool
+%endif
 %if %{with_numactl}
 # For QEMU/LXC numa info
 BuildRequires: numactl-devel
@@ -979,6 +915,21 @@ sheepdog volumes using.
 %endif
 
 
+%if %{with_storage_zfs}
+%package daemon-driver-storage-zfs
+Summary: Storage driver plugin for ZFS
+Group: Development/Libraries
+Requires: libvirt-daemon-driver-storage-core = %{version}-%{release}
+# Support any conforming implementation of zfs
+Requires: /sbin/zfs
+Requires: /sbin/zpool
+
+%description daemon-driver-storage-zfs
+The storage driver backend adding implementation of the storage APIs for
+ZFS volumes.
+%endif
+
+
 %package daemon-driver-storage
 Summary: Storage driver plugin including all backends for the libvirtd daemon
 Group: Development/Libraries
@@ -997,6 +948,9 @@ Requires: libvirt-daemon-driver-storage-rbd = %{version}-%{release}
 %if %{with_storage_sheepdog}
 Requires: libvirt-daemon-driver-storage-sheepdog = %{version}-%{release}
 %endif
+%if %{with_storage_zfs}
+Requires: libvirt-daemon-driver-storage-zfs = %{version}-%{release}
+%endif
 
 %description daemon-driver-storage
 The storage driver plugin for the libvirtd daemon, providing
@@ -1134,13 +1088,7 @@ Requires: libvirt-daemon-driver-nodedev = %{version}-%{release}
 Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release}
 Requires: libvirt-daemon-driver-secret = %{version}-%{release}
 Requires: libvirt-daemon-driver-storage = %{version}-%{release}
-    %ifnarch %{power64} aarch64
-# On ppc64, ppc64le, and aarch64 there is no qemu-kvm, but we need
-# libvirt-daemon-kvm to be part of RHEL because layered products depend
-# on it.  Luckily, they also directly require qemu-kvm-rhev so it is
-# safe (although ugly and dirty) to drop the dependency here.
 Requires: qemu-kvm
-    %endif
 
 %description daemon-kvm
 Server side daemon and driver required to manage the virtualization
@@ -1332,10 +1280,6 @@ Libvirt plugin for NSS for translating domain names into IP addresses.
 
 
 %prep
-%if ! %{supported_platform}
-echo "This RPM requires either Fedora >= 20 or RHEL >= 6"
-exit 1
-%endif
 
 %setup -q
 
@@ -1386,6 +1330,11 @@ rm -f $PATCHLIST
 rm -rf .git
 
 %build
+%if ! %{supported_platform}
+echo "This RPM requires either Fedora >= 20 or RHEL >= 6"
+exit 1
+%endif
+
 %if %{with_xen}
     %define arg_xen --with-xen
 %else
@@ -1470,6 +1419,12 @@ rm -rf .git
     %define arg_storage_gluster --without-storage-gluster
 %endif
 
+%if %{with_storage_zfs}
+    %define arg_storage_zfs --with-storage-zfs
+%else
+    %define arg_storage_zfs --without-storage-zfs
+%endif
+
 %if %{with_numactl}
     %define arg_numactl --with-numactl
 %else
@@ -1544,6 +1499,8 @@ rm -rf .git
 
 # place macros above and build commands below this comment
 
+export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec)
+
 %if 0%{?enable_autotools}
  autoreconf -if
 %endif
@@ -1578,7 +1535,7 @@ rm -f po/stamp-po
            %{?arg_storage_rbd} \
            %{?arg_storage_sheepdog} \
            %{?arg_storage_gluster} \
-           --without-storage-zfs \
+           %{?arg_storage_zfs} \
            --without-storage-vstorage \
            %{?arg_numactl} \
            %{?arg_numad} \
@@ -1610,18 +1567,20 @@ rm -f po/stamp-po
            %{?enable_werror} \
            --enable-expensive-tests \
            %{arg_init_script}
-make %{?_smp_mflags}
+make %{?_smp_mflags} V=1
 gzip -9 ChangeLog
 
 %install
 rm -fr %{buildroot}
 
+export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec)
+
 # Avoid using makeinstall macro as it changes prefixes rather than setting
 # DESTDIR. Newer make_install macro would be better but it's not available
 # on RHEL 5, thus we need to expand it here.
-make %{?_smp_mflags} install DESTDIR=%{?buildroot} SYSTEMD_UNIT_DIR=%{_unitdir}
+make %{?_smp_mflags} install DESTDIR=%{?buildroot} SYSTEMD_UNIT_DIR=%{_unitdir} V=1
 
-make %{?_smp_mflags} -C examples distclean
+make %{?_smp_mflags} -C examples distclean V=1
 
 rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
 rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
@@ -1760,6 +1719,10 @@ fi
 /sbin/chkconfig --add virtlockd
 %endif
 
+# request daemon restart in posttrans
+mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || :
+touch %{_localstatedir}/lib/rpm-state/libvirt/restart || :
+
 %preun daemon
 %if %{with_systemd}
     %if %{with_systemd_macros}
@@ -1798,13 +1761,11 @@ fi
 if [ $1 -ge 1 ] ; then
     /bin/systemctl reload-or-try-restart virtlockd.service >/dev/null 2>&1 || :
     /bin/systemctl reload-or-try-restart virtlogd.service >/dev/null 2>&1 || :
-    /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || :
 fi
 %else
 if [ $1 -ge 1 ]; then
     /sbin/service virtlockd reload > /dev/null 2>&1 || :
     /sbin/service virtlogd reload > /dev/null 2>&1 || :
-    /sbin/service libvirtd condrestart > /dev/null 2>&1
 fi
 %endif
 
@@ -1814,7 +1775,6 @@ fi
 if [ "$1" -ge "1" ]; then
     /sbin/service virtlockd reload > /dev/null 2>&1 || :
     /sbin/service virtlogd reload > /dev/null 2>&1 || :
-    /sbin/service libvirtd condrestart > /dev/null 2>&1
 fi
 %endif
 
@@ -1837,6 +1797,16 @@ if [ $1 -ge 1 ] ; then
 %endif
 fi
 
+%posttrans daemon
+if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then
+%if %{with_systemd}
+    /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || :
+%else
+    /sbin/service libvirtd condrestart > /dev/null 2>&1 || :
+%endif
+fi
+rm -rf %{_localstatedir}/lib/rpm-state/libvirt || :
+
 %post daemon-config-network
 if test $1 -eq 1 && test ! -f %{_sysconfdir}/libvirt/qemu/networks/default.xml ; then
     # see if the network used by default network creates a conflict,
@@ -1875,23 +1845,35 @@ if test $1 -eq 1 && test ! -f %{_sysconfdir}/libvirt/qemu/networks/default.xml ;
     ln -s ../default.xml %{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml
 
     # Make sure libvirt picks up the new network defininiton
+    mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || :
+    touch %{_localstatedir}/lib/rpm-state/libvirt/restart || :
+fi
+
+%posttrans daemon-config-network
+if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then
 %if %{with_systemd}
-    /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 ||:
+    /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || :
 %else
     /sbin/service libvirtd condrestart > /dev/null 2>&1 || :
 %endif
-
 fi
-
+rm -rf %{_localstatedir}/lib/rpm-state/libvirt || :
 
 %post daemon-config-nwfilter
 cp %{_datadir}/libvirt/nwfilter/*.xml %{_sysconfdir}/libvirt/nwfilter/
 # Make sure libvirt picks up the new nwfilter defininitons
+mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || :
+touch %{_localstatedir}/lib/rpm-state/libvirt/restart || :
+
+%posttrans daemon-config-nwfilter
+if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then
 %if %{with_systemd}
-    /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 ||:
+    /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || :
 %else
     /sbin/service libvirtd condrestart > /dev/null 2>&1 || :
 %endif
+fi
+rm -rf %{_localstatedir}/lib/rpm-state/libvirt || :
 
 
 %if %{with_systemd}
@@ -1981,7 +1963,7 @@ exit 0
 %files
 
 %files docs
-%doc AUTHORS ChangeLog.gz NEWS README TODO
+%doc AUTHORS ChangeLog.gz NEWS README README.md
 %doc libvirt-docs/*
 
 # API docs
@@ -2038,6 +2020,8 @@ exit 0
 %dir %attr(0711, root, root) %{_localstatedir}/cache/libvirt/
 
 
+%dir %attr(0755, root, root) %{_libdir}/libvirt/
+%dir %attr(0755, root, root) %{_libdir}/libvirt/connection-driver/
 %dir %attr(0755, root, root) %{_libdir}/libvirt/lock-driver
 %attr(0755, root, root) %{_libdir}/libvirt/lock-driver/lockd.so
 
@@ -2067,6 +2051,7 @@ exit 0
 %{_mandir}/man8/libvirtd.8*
 %{_mandir}/man8/virtlogd.8*
 %{_mandir}/man8/virtlockd.8*
+%{_mandir}/man7/virkey*.7*
 
 %doc examples/polkit/*.rules
 
@@ -2140,6 +2125,11 @@ exit 0
 %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_sheepdog.so
 %endif
 
+%if %{with_storage_zfs}
+%files daemon-driver-storage-zfs
+%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_zfs.so
+%endif
+
 %if %{with_qemu}
 %files daemon-driver-qemu
 %dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/
@@ -2266,7 +2256,9 @@ exit 0
 %attr(0755, root, root) %{_libexecdir}/libvirt-guests.sh
 
 %files libs -f %{name}.lang
-%doc COPYING COPYING.LESSER
+# RHEL6 doesn't have 'license' macro
+%{!?_licensedir:%global license %%doc}
+%license COPYING COPYING.LESSER
 %config(noreplace) %{_sysconfdir}/libvirt/libvirt.conf
 %config(noreplace) %{_sysconfdir}/libvirt/libvirt-admin.conf
 %{_libdir}/libvirt.so.*
@@ -2359,27 +2351,90 @@ exit 0
 
 
 %changelog
-* Fri Jan 19 2018 Jiri Denemark <jdenemar@redhat.com> - 3.2.0-14.el7_4.9
-- qemu: Fix crash in offline migration (rhbz#1530130)
-- RHEL: qemu: Report full stats for completed migration (rhbz#1530130)
-
-* Tue Jan 16 2018 Jiri Denemark <jdenemar@redhat.com> - 3.2.0-14.el7_4.8
-- qemuDomainAttachDeviceMknodHelper: Remove symlink before creating it (rhbz#1532183)
-- cpu_x86: Copy CPU signature from ancestor (rhbz#1533418)
-- qemu: take current async job into account in qemuBlockNodeNamesDetect (rhbz#1530129)
-- qemu: migration: fix race on cancelling drive mirror (rhbz#1530129)
-- qemu: drop code for VIR_DOMAIN_JOB_BOUNDED and timeRemaining (rhbz#1530130)
-- qemu: introduce qemu domain job status (rhbz#1530130)
-- qemu: introduce QEMU_DOMAIN_JOB_STATUS_POSTCOPY (rhbz#1530130)
-- qemu: start all async job with job status active (rhbz#1530130)
-- qemu: introduce migrating job status (rhbz#1530130)
-- qemu: migration: don't expose incomplete job as complete (rhbz#1530130)
-- qemu: Fix type of a completed job (rhbz#1530130)
-
-* Tue Dec 19 2017 Jiri Denemark <jdenemar@redhat.com> - 3.2.0-14.el7_4.7
-- qemu: Properly store microcode version in QEMU caps cache (CVE-2017-5715)
-
-* Thu Dec 14 2017 Jiri Denemark <jdenemar@redhat.com> - 3.2.0-14.el7_4.6
+* Wed Mar  7 2018 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-14
+- conf: move 'generated' member from virMacAddr to virDomainNetDef (rhbz#1529338)
+
+* Tue Feb 13 2018 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-13
+- Revert "qemu: Expose rx/tx_queue_size in qemu.conf too" (rhbz#1541960)
+
+* Wed Feb  7 2018 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-12
+- util: Check if kernel-provided info is consistent with itself (rhbz#1540780)
+- qemu: Refresh capabilities when creating resctrl allocation (rhbz#1540780)
+- qemu: Expose rx/tx_queue_size in qemu.conf too (rhbz#1541960)
+- util: bitmap: Fix value of 'map_alloc' when shrinking bitmap (rhbz#1540817)
+- qemu: driver: Extract vcpu halted state directly (rhbz#1534585)
+- qemu: Remove unused 'cpuhalted' argument from qemuDomainHelperGetVcpus (rhbz#1534585)
+- qemu: domain: Store vcpu halted state as a tristate (rhbz#1534585)
+- qemu: Limit refresh of CPU halted state to s390 (rhbz#1534585)
+
+* Fri Feb  2 2018 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-11
+- qemu: migration: Refresh device information after transferring state (rhbz#1463168)
+- qemuDomainRemoveMemoryDevice: unlink() memory backing file (rhbz#1461214)
+- util: Fix possible leak in virResctrlAllocMasksAssign (rhbz#1540817)
+- util: Clear unused part of the map in virBitmapShrink (rhbz#1540817)
+- tests: Add test for properly removing cachetune entries (rhbz#1540817)
+
+* Wed Jan 31 2018 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-10
+- storage: util: Properly ignore errors when backing volume is inaccessible (rhbz#1540022)
+- util: json: Add helper to return string or number properties as string (rhbz#1540290)
+- util: storage: Parse 'lun' for iSCSI protocol from JSON as string or number (rhbz#1540290)
+- util: Introduce virFormatIntPretty (rhbz#1289368)
+- util: Make prefix optional in virBitampString (rhbz#1289368)
+- util: Rename virBitmapString to virBitmapToString (rhbz#1289368)
+- util: Rename virBitmapDataToString to virBitmapDataFormat (rhbz#1289368)
+- util: Don't output too many zeros from virBitmapToString (rhbz#1289368)
+- util: Introduce virBitmapNewString (rhbz#1289368)
+- util: Reintroduce virBitmapSubtract (rhbz#1289368)
+- util: Introduce virBitmapShrink (rhbz#1289368)
+- conf: Sort cache banks in capabilities XML (rhbz#1289368)
+- conf: Format cache banks in capabilities with virFormatIntPretty (rhbz#1289368)
+- tests: Remove executable bits on plain data files (rhbz#1289368)
+- tests: Minor adjustments for test data (rhbz#1289368)
+- tests: Add resctrl-skx-twocaches test case to vircaps2xmltest (rhbz#1289368)
+- util: Fix leak in virStringTrimOptionalNewline (rhbz#1289368)
+- Rename virResctrlInfo to virResctrlInfoPerCache (rhbz#1289368)
+- util: Add virResctrlInfo (rhbz#1289368)
+- conf: Use virResctrlInfo in capabilities (rhbz#1289368)
+- util: Remove now-unneeded resctrl functions (rhbz#1289368)
+- fixup_resctrlinfo (rhbz#1289368)
+- resctrl: Add functions to work with resctrl allocations (rhbz#1289368)
+- conf: Add support for cputune/cachetune (rhbz#1289368)
+- tests: Add virresctrltest (rhbz#1289368)
+- qemu: Add support for resctrl (rhbz#1289368)
+- tests: Clean up and modify some vircaps2xmldata (rhbz#1289368)
+- resctl: stub out functions with Linux-only APIs used (rhbz#1289368)
+- util: Check for empty allocation instead of just NULL pointer (rhbz#1289368)
+- util: Use "resctrl" instead of "resctrlfs" spelling (rhbz#1289368)
+- util: Make it possible for virResctrlAllocSetMask to replace existing mask (rhbz#1289368)
+- util: Remove unused variable in virResctrlGetInfo (rhbz#1289368)
+- util: Don't check if entries under /sys/fs/resctrl/(info/) are directories (rhbz#1289368)
+- util: Add helpers for getting resctrl group allocs (rhbz#1289368)
+- util: Use default group's mask for unspecified resctrl allocations (rhbz#1289368)
+- util: Don't overwrite mask in virResctrlAllocFindUnused (rhbz#1289368)
+- qemu: Restore machinename even without cgroups (rhbz#1289368)
+- util: Extract path formatting into virResctrlAllocDeterminePath (rhbz#1289368)
+- qemu: Restore resctrl alloc data after restart (rhbz#1289368)
+
+* Tue Jan 23 2018 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-9
+- qemu: Fix crash in offline migration (rhbz#1536351)
+- Revert "qemu: monitor: do not report error on shutdown" (rhbz#1536461)
+- qemu: Refresh caps cache after booting a different kernel (rhbz#1525182)
+- qemu: Don't initialize struct utsname (rhbz#1525182)
+
+* Tue Jan 16 2018 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-8
+- qemuDomainAttachDeviceMknodHelper: Remove symlink before creating it (rhbz#1528502)
+- RHEL: cpu: Fix EPYC-IBRS CPU model (CVE-2017-5715)
+- cpu_x86: Copy CPU signature from ancestor (rhbz#1533125)
+- qemu: Ignore fallback CPU attribute on reconnect (rhbz#1532980)
+- qemu: Fix type of a completed job (rhbz#1523036)
+
+* Thu Jan  4 2018 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-7
+- conf: Add infrastructure for disk source private data XML (rhbz#1523261)
+- util: storage: Add helpers to parse and format relPath into privateData (rhbz#1523261)
+- qemu: domain: Parse and format relPath into disk source private data (rhbz#1523261)
+- qemu: remove input device after receiving the event (rhbz#1524837)
+- conf: honor maxnames in nodeListDevices API (rhbz#1528572)
+- storage: Fixing missing 'backingStore' tag from volume XML dumps. (rhbz#1529663)
 - util: add virFileReadHeaderQuiet wrapper around virFileReadHeaderFD (CVE-2017-5715)
 - util: introduce virHostCPUGetMicrocodeVersion (CVE-2017-5715)
 - cpu_x86: Rename virCPUx86MapInitialize (CVE-2017-5715)
@@ -2387,36 +2442,158 @@ exit 0
 - qemu: capabilities: force update if the microcode version does not match (CVE-2017-5715)
 - cpu: add CPU features and model for indirect branch prediction protection (CVE-2017-5715)
 
-* Fri Dec  1 2017 Jiri Denemark <jdenemar@redhat.com> - 3.2.0-14.el7_4.5
-- qemu: block commit: Don't overwrite error when rolling back disk labels (rhbz#1516717)
-- qemu: block commit: Determine relative path of images before initializing (rhbz#1516717)
-- qemu: domain: Don't call namespace setup for storage already accessed by vm (rhbz#1516717)
-
-* Mon Nov  6 2017 Jiri Denemark <jdenemar@redhat.com> - 3.2.0-14.el7_4.4
-- qemu: Pass virArch * to virQEMUCapsCPUFilterFeatures (rhbz#1508549)
-- qemu: Publish virQEMUCapsCPUFilterFeatures (rhbz#1508549)
-- qemu: Separate CPU updating code from qemuProcessReconnect (rhbz#1508549)
-- conf: Introduce virCPUDefFindFeature (rhbz#1508549)
-- qemu: Filter CPU features when using host CPU (rhbz#1508549)
-- qemu: Fix CPU model broken by older libvirt (rhbz#1508549)
-
-* Tue Aug 22 2017 Jiri Denemark <jdenemar@redhat.com> - 3.2.0-14.el7_4.3
-- Add support for virtio-net.tx_queue_size (rhbz#1482514)
-
-* Tue Jul 18 2017 Jiri Denemark <jdenemar@redhat.com> - 3.2.0-14.el7_4.2
-- qemu: Fix qemuDomainGetBlockInfo allocation value setting (rhbz#1470127)
-- qemuDomainBuildNamespace: Handle special file mount points (rhbz#1471660)
-
-* Thu Jul 13 2017 Jiri Denemark <jdenemar@redhat.com> - 3.2.0-14.el7_4.1
-- qemu: Don't update CPU when checking ABI stability (rhbz#1470582)
-- cpu_x86: Properly disable unknown CPU features (rhbz#1470582)
-- qemu: Add qemuProcessFetchGuestCPU (rhbz#1470582)
-- qemu: Add qemuProcessVerifyCPU (rhbz#1470582)
-- qemu: Rename qemuProcessUpdateLiveGuestCPU (rhbz#1470582)
-- qemu: Add qemuProcessUpdateLiveGuestCPU (rhbz#1470582)
-- qemu: Export virQEMUCapsGuestIsNative (rhbz#1470582)
-- qemu: Move qemuProcessReconnect to the end of qemu_process.c (rhbz#1470582)
-- qemu: Update host-model CPUs on reconnect (rhbz#1470582)
+* Tue Dec 12 2017 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-6
+- security: introduce virSecurityManager(Set|Restore)ChardevLabel (rhbz#1465833)
+- qemu: fix security labeling for attach/detach of char devices (rhbz#1465833)
+- nwfilter: don't crash listing filters in unprivileged daemon (rhbz#1522879)
+- docs: domain: Fix documentation of the 'snapshot' attribute for <disk> (rhbz#1523070)
+- storage: Don't dereference driver object if virStorageSource is not initialized (rhbz#1522682)
+- qemu: blockjob: Reset disk source index after pivot (rhbz#1519745)
+- qemu: Separate fetching CPU definitions from filling qemuCaps (rhbz#1521202)
+- qemu: Make sure host-model uses CPU model supported by QEMU (rhbz#1521202)
+- qemu: Avoid comparing size_t with -1 (rhbz#1521202)
+- migration.html: Clarify configuration file handling docs (rhbz#1514930)
+
+* Tue Dec  5 2017 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-5
+- conf: fix migratable XML for graphics if socket is generated based on config (rhbz#1511407)
+- storage: Extract error reporting for broken chains (rhbz#1509110)
+- qemu: domain: Refactor control flow in qemuDomainDetermineDiskChain (rhbz#1509110)
+- qemu: process: Move handling of non-backing files into qemuDomainDetermineDiskChain (rhbz#1509110)
+- qemu: domain: Fix backing store terminator for non-backing local files (rhbz#1509110)
+- numa: describe siblings distances within cells (rhbz#1454889)
+- xenconfig: add domxml conversions for xen-xl (rhbz#1454889)
+- virDomainNumaGetNodeDistance: Fix input arguments validation (rhbz#1454889)
+- numa: Introduce virDomainNumaNodeDistanceIsUsingDefaults (rhbz#1454889)
+- qemu_capabilities: Introcude QEMU_CAPS_NUMA_DIST (rhbz#1454889)
+- qemu: Support setting NUMA distances (rhbz#1454889)
+- conf: Fix memory leak for distances in virDomainNumaFree (rhbz#1454889)
+- virDomainDiskSourceNetworkParse: Don't leak @tlsCfg or @haveTLS (rhbz#1519759)
+- virDomainDiskBackingStoreParse: Don't leak @idx (rhbz#1519759)
+- qemuStateInitialize: Don't leak @memoryBackingPath (rhbz#1519759)
+- Introduce virDomainDeviceAliasIsUserAlias (rhbz#1518148)
+- qemu: prefer the PCI bus alias from status XML (rhbz#1518148)
+- virQEMUCapsHasPCIMultiBus: use def->os.arch (rhbz#1518148)
+- virQEMUCapsHasPCIMultiBus: assume true if we have no version information (rhbz#1518148)
+- qemu: add vmcoreinfo support (rhbz#1395248)
+
+* Thu Nov 30 2017 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-4
+- nodedev: Restore setting of privileged (rhbz#1517372)
+- spec: Turn on verbose build (rhbz#1335534)
+- spec: Make the build reproducible (rhbz#1335534)
+- Introduce virDomainInputDefGetPath (rhbz#1509866)
+- security: Introduce functions for input device hot(un)plug (rhbz#1509866)
+- qemu: Introduce functions for input device cgroup manipulation (rhbz#1509866)
+- qemu: functions for dealing with input device namespaces and labels (rhbz#1509866)
+- qemu: Properly label and create evdev on input device hotplug (rhbz#1509866)
+- qemu: Add QEMU_CAPS_DEVICE_SPAPR_VTY (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- qemu: rename QEMU_CAPS_SCLP_S390 to QEMU_CAPS_DEVICE_SCLPCONSOLE (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- qemu: add QEMU_CAPS_DEVICE_SCLPLMCONSOLE (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf, qemu: Use type-aware switches where possible (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- docs: Improve documentation for serial consoles (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- qemu: Introduce qemuDomainChrDefPostParse() (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf: Run devicePostParse() again for the first serial device (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf: Introduce VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf: Drop virDomainChrDeviceType.targetTypeAttr (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf: Introduce virDomainChrTargetDefFormat() (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf: Improve error handling in virDomainChrDefFormat() (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf: Check virDomainChrSourceDefFormat() return value (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf: Improve virDomainChrTargetDefFormat() (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf: Remove ATTRIBUTE_FALLTHROUGH from virDomainChrTargetDefFormat() (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- qemu: Introduce qemuDomainChrTargetDefValidate() (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- qemu: Improve qemuDomainChrTargetDefValidate() (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf: Parse and format virDomainChrSerialTargetModel (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- qemu: Set targetModel based on targetType for serial devices (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- qemu: Validate target model for serial devices (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- qemu: Format targetModel for serial devices (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- qemu: Remove redundancy in qemuBuildSerialChrDeviceStr() (rhbz#1449265, rhbz#1512929, rhbz#1511421, rhbz#1512934)
+- conf: Add target type and model for spapr-vty (rhbz#1511421)
+- qemu: Support usb-serial and pci-serial on pSeries (rhbz#1512934)
+- conf: Add target type and model for pl011 (rhbz#1512929)
+- conf: add VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP (rhbz#1449265)
+- qemu: switch s390/s390x default console back to serial (rhbz#1449265)
+- qemu: Add QEMU_CAPS_DEVICE_ISA_SERIAL (rhbz#1512929)
+- qemu: Require QEMU_CAPS_DEVICE_ISA_SERIAL for isa-serial (rhbz#1512929)
+- qemu: Add QEMU_CAPS_DEVICE_PL011 (rhbz#1512929)
+- qemu: Require QEMU_CAPS_DEVICE_PL011 for pl011 (rhbz#1512929)
+
+* Fri Nov 24 2017 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-3
+- tests: Rename ppc64le caps to ppc64 (rhbz#1308743)
+- tests: Add caps for QEMU 2.10.0 on ppc64 (rhbz#1308743)
+- qemu: Enable configuration of HPT resizing for pSeries guests (rhbz#1308743)
+- tests: Add tests for configuration of HPT resizing (rhbz#1308743)
+- qemuBuildDriveDevStr: Prefer default aliases for IDE bus (rhbz#1434451)
+- virQEMUCapsHasPCIMultiBus: Fix @def type (rhbz#1434451)
+- qemuBuildDriveDevStr: Prefer default alias for SATA bus (rhbz#1434451)
+- qemuBuildDeviceAddressStr: Prefer default alias for PCI bus (rhbz#1434451)
+- qemu: domain: Don't call namespace setup for storage already accessed by vm (rhbz#1506072)
+- qemu: Properly skip "char device redirected to" in QEMU log (rhbz#1335534)
+- vierror: Define VIR_ERROR_MAX_LENGTH macro (rhbz#1335534)
+- qemu: Use the end of QEMU log for reporting errors (rhbz#1335534)
+- qemu: Move snapshot disk validation functions into one (rhbz#1511480)
+- qemu: domain: Despaghettify qemuDomainDeviceDefValidate (rhbz#1511480)
+- qemu: domain: Move hostdev validation into separate function (rhbz#1511480)
+- qemu: domain: Move video device validation into separate function (rhbz#1511480)
+- qemu: domain: Refactor domain device validation function (rhbz#1511480)
+- qemu: block: Add function to check if storage source allows concurrent access (rhbz#1511480)
+- qemu: domain: Reject shared disk access if backing format does not support it (rhbz#1511480)
+- qemu: snapshot: Disallow snapshot of unsupported shared disks (rhbz#1511480)
+- qemu: Disallow pivot of shared disks to unsupported storage (rhbz#1511480)
+- qemu: caps: Add capability for 'share-rw' disk option (rhbz#1378242)
+- qemu: command: Mark <shared/> disks as such in qemu (rhbz#1378242)
+
+* Wed Nov 15 2017 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-2
+- conf: Don't inline virDomainNetTypeSharesHostView (rhbz#1472263)
+- conf: s/virDomainObjGetShortName/virDomainDefGetShortName/ (rhbz#1461214)
+- qemu: Move memPath generation from memoryBackingDir to a separate function (rhbz#1461214)
+- qemu: Set alias for memory cell in qemuBuildMemoryCellBackendStr (rhbz#1461214)
+- qemu: Rename qemuProcessBuildDestroyHugepagesPath (rhbz#1461214)
+- qemu: Destroy whole memory tree (rhbz#1461214)
+- qemu: Use predictable file names for memory-backend-file (rhbz#1461214)
+- conf: Properly parse <backingStore/> (rhbz#1509110)
+- qemu: parse: Allocate disk definition with private data (rhbz#1510781)
+- qemu: Tolerate storage source private data being NULL (rhbz#1510323)
+- qemu: domain: Don't allocate storage source private data if not needed (rhbz#1510323)
+- conf: Fix message when maximum vCPU count is less than current (rhbz#1509151)
+- Revert "virNetDevSupportBandwidth: Enable QoS for vhostuser" (rhbz#1497410)
+
+* Thu Nov  2 2017 Jiri Denemark <jdenemar@redhat.com> - 3.9.0-1
+- Rebased to libvirt-3.9.0 (rhbz#1472263)
+- The rebase also fixes the following bugs:
+    rhbz#1343919, rhbz#1379218, rhbz#1379603, rhbz#1427049, rhbz#1434451
+    rhbz#1439991, rhbz#1447169, rhbz#1458630, rhbz#1460143, rhbz#1460602
+    rhbz#1460677, rhbz#1460962, rhbz#1463285, rhbz#1464300, rhbz#1464832
+    rhbz#1469552, rhbz#1472263, rhbz#1475250, rhbz#1484341, rhbz#1490279
+    rhbz#1494400, rhbz#1495171, rhbz#1495511, rhbz#1497396, rhbz#1497410
+    rhbz#1501239, rhbz#1501715, rhbz#1504592, rhbz#1506494
+
+* Tue Oct 10 2017 Jiri Denemark <jdenemar@redhat.com> - 3.8.0-1
+- Rebased to libvirt-3.8.0 (rhbz#1472263)
+- The rebase also fixes the following bugs:
+    rhbz#1075520, rhbz#1325066, rhbz#1341866, rhbz#1366446, rhbz#1368753
+    rhbz#1373783, rhbz#1439991, rhbz#1445600, rhbz#1448268, rhbz#1450317
+    rhbz#1454671, rhbz#1455023, rhbz#1455825, rhbz#1457610, rhbz#1460086
+    rhbz#1461301, rhbz#1462092, rhbz#1463168, rhbz#1464313, rhbz#1471225
+    rhbz#1472263, rhbz#1475227, rhbz#1476775, rhbz#1477880, rhbz#1481252
+    rhbz#1481309, rhbz#1485022, rhbz#1490705, rhbz#1490826, rhbz#1491217
+    rhbz#1494327
+
+* Wed Sep  6 2017 Jiri Denemark <jdenemar@redhat.com> - 3.7.0-2
+- m4: Disable -Wdisabled-optimization (rhbz#1472263)
+
+* Tue Sep  5 2017 Jiri Denemark <jdenemar@redhat.com> - 3.7.0-1
+- Rebased to libvirt-3.7.0 (rhbz#1472263)
+- The rebase also fixes the following bugs:
+    rhbz#815702, rhbz#1233129, rhbz#1242801, rhbz#1316370, rhbz#1436065
+    rhbz#1436574, rhbz#1445325, rhbz#1458146, rhbz#1282859, rhbz#1371892
+    rhbz#1419760, rhbz#1430988, rhbz#1431112, rhbz#1447618, rhbz#1448149
+    rhbz#1451557, rhbz#1451983, rhbz#1455819, rhbz#1459091, rhbz#1459785
+    rhbz#1460962, rhbz#1461270, rhbz#1464975, rhbz#1352529, rhbz#1445596
+    rhbz#1445598, rhbz#1452053, rhbz#1452441, rhbz#1458708, rhbz#1459592
+    rhbz#1462060, rhbz#1463957, rhbz#1464821, rhbz#1467826, rhbz#1472277
+    rhbz#1225339, rhbz#1254971, rhbz#1267191, rhbz#1436042, rhbz#1437797
+    rhbz#1442947, rhbz#1443434, rhbz#1448766, rhbz#1449712, rhbz#1449715
+    rhbz#1453194, rhbz#1458630, rhbz#1458638, rhbz#1462653, rhbz#1467245
+    rhbz#1484230, rhbz#1484234, rhbz#1487705
 
 * Wed Jun 21 2017 Jiri Denemark <jdenemar@redhat.com> - 3.2.0-14
 - qemu: Do not skip virCPUUpdateLive if priv->origCPU is set (rhbz#1441662)