-
-@@ -1431,6 +1433,39 @@
- Since 0.8.5 the policy
- attribute can be omitted and will default to require.
-
-+
-+
cache
-+
Since 3.3.0 the cache
-+ element describes the virtual CPU cache. If the element is missing,
-+ the hypervisor will use a sensible default.
-+
-+
-+
level
-+
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 cache elements with
-+ the level attribute set and those without the
-+ attribute is forbidden.
-+
-+
mode
-+
-+ The following values are supported:
-+
-+
emulate
-+
The hypervisor will provide a fake CPU cache data.
-+
-+
passthrough
-+
The real CPU cache data reported by the host CPU will be
-+ passed through to the virtual CPU.
-+
-+
disable
-+
The virtual CPU will report no CPU cache of the specified
-+ level (or no cache at all if the level attribute
-+ is missing).
-+ QEMU's virtio devices have some attributes related to the virtio transport under
-+ the driver element:
-+ The iommu attribute enables the use of emulated IOMMU
-+ by the device. The attribute ats controls the Address
-+ Translation Service support for PCIe devices. This is needed to make use
-+ of IOTLB support (see IOMMU device).
-+ Possible values are on or off.
-+ Since 3.5.0
-+
-@@ -5139,6 +5152,12 @@ qemu-kvm -net nic,model=? /dev/null
- In general you should leave this option alone, unless you
- are very certain you know what you are doing.
-
-+
- 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 cachetune 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 vcpus specifies to which vCPUs this allocation
++ applies. A vCPU can only be member of one cachetune element
++ allocations. Supported subelements are:
++
++
cache
++
++ This element controls the allocation of CPU cache and has the
++ following attributes:
++
++
level
++
++ Host cache level from which to allocate.
++
++
id
++
++ Host cache id from which to allocate.
++
++
type
++
++ Type of allocation. Can be code for code
++ (instructions), data for data or both
++ 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 both for host with CDP
++ (code/data prioritization) enabled.
++
++
size
++
++ The size of the region to allocate. The value by default is in
++ bytes, but the unit attribute can be used to scale
++ the value.
++
++
unit (optional)
++
++ If specified it is the unit such as KiB, MiB, GiB, or TiB
++ (described in the memory element
++ for Memory Allocation)
++ in which size is specified, defaults to bytes.
++
++
++
++
++
++
+
+
+
+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 @@
+
+
+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++ both
++ code
++ data
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
+
+
+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,
++ "\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, "alloc);
++ if (!alloc_id)
++ goto cleanup;
++
++ virBufferAsprintf(buf, " id='%s'", alloc_id);
++ }
++ virBufferAddLit(buf, ">\n");
++
++ virBufferAddBuffer(buf, &childrenBuf);
++ virBufferAddLit(buf, "\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 @@
++
++ QEMUGuest1
++ c7a5fdbd-edaf-9455-926a-d65c16db1809
++ 219136
++ 219136
++ 4
++
++
++
++
++
++
++
++
++
++
++
++
++
++ hvm
++
++
++
++ destroy
++ restart
++ destroy
++
++ /usr/bin/qemu-system-i686
++
++
++
++
++
++
++
++
+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 @@
++
++ QEMUGuest1
++ c7a5fdbd-edaf-9455-926a-d65c16db1809
++ 219136
++ 219136
++ 4
++
++
++
++
++
++
++
++ hvm
++
++
++
++ destroy
++ restart
++ destroy
++
++ /usr/bin/qemu-system-i686
++
++
++
++
++
++
++
++
+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 @@
++
++ QEMUGuest1
++ c7a5fdbd-edaf-9455-926a-d65c16db1809
++ 219136
++ 219136
++ 4
++
++
++
++
++
++
++
++
++
++ hvm
++
++
++
++ destroy
++ restart
++ destroy
++
++ /usr/bin/qemu-system-i686
++
++
++
++
++
++
++
++
+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 @@
++
++ QEMUGuest1
++ c7a5fdbd-edaf-9455-926a-d65c16db1809
++ 219136
++ 219136
++ 4
++
++
++
++
++
++
++
++ hvm
++
++
++
++ destroy
++ restart
++ destroy
++
++ /usr/bin/qemu-system-i686
++
++
++
++
++
++
++
++
+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 @@
++
++ QEMUGuest1
++ c7a5fdbd-edaf-9455-926a-d65c16db1809
++ 219136
++ 219136
++ 4
++
++
++
++
++
++
++ hvm
++
++
++
++ destroy
++ restart
++ destroy
++
++ /usr/bin/qemu-system-i686
++
++
++
++
++
++
++
++
+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 @@
++
++ QEMUGuest1
++ c7a5fdbd-edaf-9455-926a-d65c16db1809
++ 219136
++ 219136
++ 4
++
++
++
++
++
++
++
++
++
++
++ hvm
++
++
++
++ destroy
++ restart
++ destroy
++
++ /usr/bin/qemu-system-i686
++
++
++
++
++
++
++
++
+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
+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
+Reviewed-by: Pavel Hrdina
+(cherry picked from commit eccdcb81fcfd1641960d397c82986b4517841794)
+Signed-off-by: Jiri Denemark
+---
+ 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), usb-serial (usable whenever USB support
+ is available) and pci-serial (usable whenever PCI support
+ is available); since 3.10.0,
+- spapr-vio-serial (usable with ppc64/pseries guests)
+- is available as well.
++ spapr-vio-serial (usable with ppc64/pseries guests) and
++ system-serial (usable with aarch64/virt guests) are
++ available as well.
+
+
+
+@@ -6476,7 +6477,8 @@ qemu-kvm -net nic,model=? /dev/null
+ target type); pci-serial
+ (usable with the pci-serial target type);
+ spapr-vty (usable with the spapr-vio-serial
+- target type).
++ target type); pl011 (usable with the
++ system-serial target type).
+
+- All of the target types support configuring the guest-visible device
++ Most target types support configuring the guest-visible device
+ address as documented above; more
+ specifically, acceptable address types are isa (for
+ isa-serial), usb (for usb-serial),
+ pci (for pci-serial) and spapr-vio
+- (for spapr-vio-serial).
++ (for spapr-vio-serial). The system-serial
++ target type doesn't support specifying an address.
+
+@@ -6472,7 +6474,9 @@ qemu-kvm -net nic,model=? /dev/null
+ isa-serial (usable with the isa-serial target
+ type); usb-serial (usable with the usb-serial
+ target type); pci-serial
+- (usable with the pci-serial target type).
++ (usable with the pci-serial target type);
++ spapr-vty (usable with the spapr-vio-serial
++ target type).
+
+
+
+@@ -6484,8 +6488,9 @@ qemu-kvm -net nic,model=? /dev/null
+ All of the target types support configuring the guest-visible device
+ address as documented above; more
+ specifically, acceptable address types are isa (for
+- isa-serial), usb (for usb-serial)
+- and pci (for pci-serial).
++ isa-serial), usb (for usb-serial),
++ pci (for pci-serial) and spapr-vio
++ (for spapr-vio-serial).
+
+
+
+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 @@
+ isa-serial
+ usb-serial
+ pci-serial
++ spapr-vio-serial
+
+
+
+@@ -3582,6 +3583,7 @@
+ isa-serial
+ usb-serial
+ pci-serial
++ spapr-vty
+
+
+
+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 @@
++
++ guest
++ 1ccfd97d-5eb4-478a-bbe6-88d254c16db7
++ 524288
++ 1
++
++ hvm
++
++
++ /usr/bin/qemu-system-ppc64
++
++
++
++
++
++
+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 @@
++
++ guest
++ 1ccfd97d-5eb4-478a-bbe6-88d254c16db7
++ 524288
++ 1
++
++ hvm
++
++
++ /usr/bin/qemu-system-ppc64
++
++
++
++
++
++
++
++
+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 @@
++
++ guest
++ 1ccfd97d-5eb4-478a-bbe6-88d254c16db7
++ 524288
++ 1
++
++ hvm
++
++
++ /usr/bin/qemu-system-ppc64
++
++
++
++
++
++
++
+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 @@
++
++ guest
++ 1ccfd97d-5eb4-478a-bbe6-88d254c16db7
++ 524288
++ 1
++
++ hvm
++
++
++ /usr/bin/qemu-system-ppc64
++
++
++
++
++
++
++
++
+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 @@
++
++ guest
++ 1ccfd97d-5eb4-478a-bbe6-88d254c16db7
++ 524288
++ 1
++
++ hvm
++
++
++ /usr/bin/qemu-system-x86_64
++
++
++
++
++
++
++
++
+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 @@
++
++ guest
++ 1ccfd97d-5eb4-478a-bbe6-88d254c16db7
++ 524288
++ 1
++
++ hvm
++
++
++ /usr/bin/qemu-system-ppc64
++
++
++
++
++
++
+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 @@
+
+
+
+-
+-
++
++
+
+
+
+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 @@
++
++ guest
++ 1ccfd97d-5eb4-478a-bbe6-88d254c16db7
++ 524288
++ 524288
++ 1
++
++ hvm
++
++
++
++ destroy
++ restart
++ destroy
++
++ /usr/bin/qemu-system-ppc64
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+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 @@
+
+
+
+-
+-
++
++
+
+
+
+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 @@
+
+
+
+-
+-
++
++
+
+
+
+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 @@
+
+
+
+-
+-
++
++
+
+
+
+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 @@
+
+
+
+-
+-
++
++
+
+
+
+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 @@
+
+
+
+-
+-
++
++
+
+
+
+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 @@
++
++ guest
++ 1ccfd97d-5eb4-478a-bbe6-88d254c16db7
++ 524288
++ 524288
++ 1
++
++ hvm
++
++
++
++ destroy
++ restart
++ destroy
++
++ /usr/bin/qemu-system-ppc64
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+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:
-From: Jiri Denemark
-Date: Wed, 10 May 2017 13:05:16 +0200
-Subject: [PATCH] conf: Check CPU cache for ABI stability
-
-Signed-off-by: Jiri Denemark
-Reviewed-by: Daniel P. Berrange
-(cherry picked from commit 1e9cf6e09ce242c94731bd21707dd3bcd41f854f)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1449595
-
-Signed-off-by: Jiri Denemark
----
- 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
+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
+Reviewed-by: Pavel Hrdina
+(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
+---
+ 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, "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, "\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
-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
----
- 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
+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
+(cherry picked from commit bce925dadaf8fe4693abee88fb68aa7ede9d209e)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1472263
+
+Signed-off-by: Jiri Denemark
+---
+ 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
+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 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
+Reviewed-by: Pavel Hrdina
+(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
+---
+ 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,
+ "\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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+-
++
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+--
+2.15.1
+
diff --git a/SOURCES/libvirt-conf-Fix-backwards-migration-of-pSeries-guests.patch b/SOURCES/libvirt-conf-Fix-backwards-migration-of-pSeries-guests.patch
deleted file mode 100644
index cb4a237..0000000
--- a/SOURCES/libvirt-conf-Fix-backwards-migration-of-pSeries-guests.patch
+++ /dev/null
@@ -1,67 +0,0 @@
-From 7e3b03cbdee6a9fc694046ea3c98c5cdef941c92 Mon Sep 17 00:00:00 2001
-Message-Id: <7e3b03cbdee6a9fc694046ea3c98c5cdef941c92@dist-git>
-From: Andrea Bolognani
-Date: Tue, 25 Jul 2017 10:29:27 +0200
-Subject: [PATCH] conf: Fix backwards migration of pSeries guests
-
-Recent commits made it so that pci-root controllers for
-pSeries guests are automatically assigned the
-spapr-pci-host-bridge model name; however, that prevents
-guests to migrate to older versions of libvirt which don't
-know about that model name at all, which at the moment is
-all of them :)
-
-To avoid the issue, just strip the model name from PHBs
-when formatting the migratable XML; guests that use more
-than one PHB are not going to be migratable anyway.
-
-Signed-off-by: Andrea Bolognani
-(cherry picked from commit 9b45cd8fab1c7d7d07dd3ae64970b3c93b78e04c)
-
-Conflicts:
-
- * src/conf/domain_conf.c:
-
- caused by e146264aaadf5aecf727d8c7b3d85683b55b6c48,
- which significantly refactored
- virDomainControllerDefFormat(), not being in the tree.
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1431193
-
-Signed-off-by: Andrea Bolognani
-Signed-off-by: Jiri Denemark
----
- src/conf/domain_conf.c | 17 +++++++++++++++++
- 1 file changed, 17 insertions(+)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 86415964dc..f28f6aff63 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -21670,6 +21670,23 @@ virDomainControllerDefFormat(virBufferPtr buf,
- pcihole64 = true;
- if (def->opts.pciopts.modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE)
- pciModel = true;
-+ /* Historically, libvirt didn't support specifying a model name for
-+ * pci-root controllers; starting from 3.6.0, however, pSeries guests
-+ * use pci-root controllers with model name spapr-pci-host-bridge to
-+ * represent all PHBs, including the default one.
-+ *
-+ * In order to allow migration of pSeries guests from older libvirt
-+ * versions and back, we don't format the model name in the migratable
-+ * XML if it's spapr-pci-host-bridge, thus making "no model name" and
-+ * "spapr-pci-host-bridge model name" basically equivalent.
-+ *
-+ * The spapr-pci-host-bridge device is specific to pSeries.
-+ */
-+ if (def->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT &&
-+ def->opts.pciopts.modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE &&
-+ flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) {
-+ pciModel = false;
-+ }
- if (def->opts.pciopts.chassisNr != -1 ||
- def->opts.pciopts.chassis != -1 ||
- def->opts.pciopts.port != -1 ||
---
-2.13.3
-
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
+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
+Signed-off-by: Jiri Denemark
+---
+ 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
+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
+---
+ 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
+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
+Reviewed-by: John Ferlan
+(cherry picked from commit 63d95a19cc72d120d40092c1e97235d7b9d4eb29)
+Signed-off-by: Martin Kletzander
+---
+ 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,
+- "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,
++ "\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 @@
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+
+-
++
+
+
+
+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 @@
+
+
+
+-
+-
++
++
+
+
+
+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 @@
+
+
+
+-
++
+
+
+-
++
+
+
+
+--
+2.16.1
+
diff --git a/SOURCES/libvirt-conf-Implement-isolation-rules.patch b/SOURCES/libvirt-conf-Implement-isolation-rules.patch
deleted file mode 100644
index 603e2e0..0000000
--- a/SOURCES/libvirt-conf-Implement-isolation-rules.patch
+++ /dev/null
@@ -1,164 +0,0 @@
-From 672fd7d403ef52f10084c5c0b6aaeeb94f6fba2a Mon Sep 17 00:00:00 2001
-Message-Id: <672fd7d403ef52f10084c5c0b6aaeeb94f6fba2a@dist-git>
-From: Andrea Bolognani
-Date: Tue, 18 Jul 2017 12:10:06 +0200
-Subject: [PATCH] conf: Implement isolation rules
-
-These rules will make it possible for libvirt to
-automatically assign PCI addresses in a way that
-respects any isolation constraints devices might
-have.
-
-Signed-off-by: Andrea Bolognani
-Reviewed-by: Laine Stump
-(cherry picked from commit 209dc615e898f027b6dc8fa6acd3aeba5fd465bd)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1280542
-
-Signed-off-by: Andrea Bolognani
-Signed-off-by: Jiri Denemark
----
- src/conf/domain_addr.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++---
- src/conf/domain_addr.h | 3 +++
- 2 files changed, 72 insertions(+), 4 deletions(-)
-
-diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
-index a067493136..d586bb7e47 100644
---- a/src/conf/domain_addr.c
-+++ b/src/conf/domain_addr.c
-@@ -369,6 +369,20 @@ virDomainPCIAddressBusIsFullyReserved(virDomainPCIAddressBusPtr bus)
- }
-
-
-+bool
-+virDomainPCIAddressBusIsEmpty(virDomainPCIAddressBusPtr bus)
-+{
-+ size_t i;
-+
-+ for (i = bus->minSlot; i <= bus->maxSlot; i++) {
-+ if (bus->slot[i].functions)
-+ return false;
-+ }
-+
-+ return true;
-+}
-+
-+
- /* Ensure addr fits in the address set, by expanding it if needed
- *
- * Return value:
-@@ -548,7 +562,7 @@ static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
- virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr addrs,
- virPCIDeviceAddressPtr addr,
- virDomainPCIConnectFlags flags,
-- unsigned int isolationGroup ATTRIBUTE_UNUSED,
-+ unsigned int isolationGroup,
- bool fromConfig)
- {
- int ret = -1;
-@@ -586,6 +600,26 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr addrs,
- bus->slot[addr->slot].aggregate = true;
- }
-
-+ if (virDomainPCIAddressBusIsEmpty(bus) && !bus->isolationGroupLocked) {
-+ /* The first device decides the isolation group for the
-+ * entire bus */
-+ bus->isolationGroup = isolationGroup;
-+ VIR_DEBUG("PCI bus %.4x:%.2x assigned isolation group %u because of "
-+ "first device %s",
-+ addr->domain, addr->bus, isolationGroup, addrStr);
-+ } else if (bus->isolationGroup != isolationGroup && fromConfig) {
-+ /* If this is not the first function and its isolation group
-+ * doesn't match the bus', then it should not be using this
-+ * address. However, if the address comes from the user then
-+ * we comply with the request and change the isolation group
-+ * back to the default (because at that point isolation can't
-+ * be guaranteed anymore) */
-+ bus->isolationGroup = 0;
-+ VIR_DEBUG("PCI bus %.4x:%.2x assigned isolation group %u because of "
-+ "user assigned address %s",
-+ addr->domain, addr->bus, isolationGroup, addrStr);
-+ }
-+
- /* mark the requested function as reserved */
- bus->slot[addr->slot].functions |= (1 << addr->function);
- VIR_DEBUG("Reserving PCI address %s (aggregate='%s')", addrStr,
-@@ -763,7 +797,7 @@ static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
- virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
- virPCIDeviceAddressPtr next_addr,
- virDomainPCIConnectFlags flags,
-- unsigned int isolationGroup ATTRIBUTE_UNUSED,
-+ unsigned int isolationGroup,
- int function)
- {
- virPCIDeviceAddress a = { 0 };
-@@ -779,12 +813,17 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
- else
- a.function = function;
-
-- /* "Begin at the beginning," the King said, very gravely, "and go on
-- * till you come to the end: then stop." */
-+ /* When looking for a suitable bus for the device, start by being
-+ * very strict and ignoring all those where the isolation groups
-+ * don't match. This ensures all devices sharing the same isolation
-+ * group will end up on the same bus */
- for (a.bus = 0; a.bus < addrs->nbuses; a.bus++) {
- virDomainPCIAddressBusPtr bus = &addrs->buses[a.bus];
- bool found = false;
-
-+ if (bus->isolationGroup != isolationGroup)
-+ continue;
-+
- a.slot = bus->minSlot;
-
- if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, function,
-@@ -796,6 +835,32 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
- goto success;
- }
-
-+ /* We haven't been able to find a perfectly matching bus, but we
-+ * might still be able to make this work by altering the isolation
-+ * group for a bus that's currently empty. So let's try that */
-+ for (a.bus = 0; a.bus < addrs->nbuses; a.bus++) {
-+ virDomainPCIAddressBusPtr bus = &addrs->buses[a.bus];
-+ bool found = false;
-+
-+ /* We can only change the isolation group for a bus when
-+ * plugging in the first device; moreover, some buses are
-+ * prevented from ever changing it */
-+ if (!virDomainPCIAddressBusIsEmpty(bus) || bus->isolationGroupLocked)
-+ continue;
-+
-+ a.slot = bus->minSlot;
-+
-+ if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, function,
-+ flags, &found) < 0) {
-+ goto error;
-+ }
-+
-+ /* The isolation group for the bus will actually be changed
-+ * later, in virDomainPCIAddressReserveAddrInternal() */
-+ if (found)
-+ goto success;
-+ }
-+
- /* There were no free slots after the last used one */
- if (addrs->dryRun) {
- /* a is already set to the first new bus */
-diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
-index 01dbc5114f..ae6a342dbc 100644
---- a/src/conf/domain_addr.h
-+++ b/src/conf/domain_addr.h
-@@ -150,6 +150,9 @@ int virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
- bool virDomainPCIAddressBusIsFullyReserved(virDomainPCIAddressBusPtr bus)
- ATTRIBUTE_NONNULL(1);
-
-+bool virDomainPCIAddressBusIsEmpty(virDomainPCIAddressBusPtr bus)
-+ ATTRIBUTE_NONNULL(1);
-+
- bool virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs,
- virPCIDeviceAddressPtr addr)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
---
-2.13.3
-
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:
+From: Andrea Bolognani
+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
+Reviewed-by: Pavel Hrdina
+(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
+---
+ 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
+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
+Reviewed-by: Pavel Hrdina
+(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
+---
+ 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,
+ "\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,
+ "\n",
+- virDomainChrTargetTypeToString(def->deviceType,
+- def->targetType),
++ targetType,
+ def->target.port);
+ break;
+ }
+ ATTRIBUTE_FALLTHROUGH;
+
+- default:
++ case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
+ virBufferAsprintf(buf, "\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
+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
+Reviewed-by: Pavel Hrdina
+(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
+---
+ 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-isolation-groups.patch b/SOURCES/libvirt-conf-Introduce-isolation-groups.patch
deleted file mode 100644
index ef6ce9f..0000000
--- a/SOURCES/libvirt-conf-Introduce-isolation-groups.patch
+++ /dev/null
@@ -1,324 +0,0 @@
-From 0b739987779a9f197d558f9c3b31d557a564bb6d Mon Sep 17 00:00:00 2001
-Message-Id: <0b739987779a9f197d558f9c3b31d557a564bb6d@dist-git>
-From: Andrea Bolognani
-Date: Tue, 18 Jul 2017 12:10:05 +0200
-Subject: [PATCH] conf: Introduce isolation groups
-
-Isolation groups will eventually allow us to make sure certain
-devices, eg. PCI hostdevs, are assigned to guest PCI buses in
-a way that guarantees improved isolation, error detection and
-recovery for machine types and hypervisors that support it,
-eg. pSeries guest on QEMU.
-
-This patch merely defines storage for the new information
-we're going to need later on and makes sure it is passed from
-the hypervisor driver (QEMU / bhyve) down to the generic PCI
-address allocation code.
-
-Signed-off-by: Andrea Bolognani
-Reviewed-by: Laine Stump
-(cherry picked from commit b8b6abbcd431d02ac106ee729204552d80762aae)
-
-Conflicts:
-
- * src/conf/device_conf.h:
-
- caused by 54fa1b44afc8bfe4a36c7c4e3b2fe1fafde0506c, where
- virDomainDeviceInfo::loadparm is introduced, not being
- present in the tree;
-
- * src/conf/domain_conf.c:
-
- caused mostly by the absence of commit
- 0c53382d820aac4767895a727c01de23397a6aaa and hence the
- virDomainSkipBackcompatConsole() function, but
- 54fa1b44afc8bfe4a36c7c4e3b2fe1fafde0506c mentioned above
- also plays a role.
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1280542
-
-Signed-off-by: Andrea Bolognani
-Signed-off-by: Jiri Denemark
----
- src/bhyve/bhyve_device.c | 4 ++--
- src/conf/device_conf.h | 10 ++++++++++
- src/conf/domain_addr.c | 17 ++++++++++++-----
- src/conf/domain_addr.h | 9 ++++++++-
- src/conf/domain_conf.c | 2 ++
- src/qemu/qemu_domain_address.c | 35 ++++++++++++++++++-----------------
- 6 files changed, 52 insertions(+), 25 deletions(-)
-
-diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c
-index fdfd512e10..03aa6c93bd 100644
---- a/src/bhyve/bhyve_device.c
-+++ b/src/bhyve/bhyve_device.c
-@@ -57,7 +57,7 @@ bhyveCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
- }
-
- if (virDomainPCIAddressReserveAddr(addrs, addr,
-- VIR_PCI_CONNECT_TYPE_PCI_DEVICE) < 0) {
-+ VIR_PCI_CONNECT_TYPE_PCI_DEVICE, 0) < 0) {
- goto cleanup;
- }
-
-@@ -100,7 +100,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
- lpc_addr.slot = 0x1;
-
- if (virDomainPCIAddressReserveAddr(addrs, &lpc_addr,
-- VIR_PCI_CONNECT_TYPE_PCI_DEVICE) < 0) {
-+ VIR_PCI_CONNECT_TYPE_PCI_DEVICE, 0) < 0) {
- goto error;
- }
-
-diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
-index a20de853f8..6436a8cf3f 100644
---- a/src/conf/device_conf.h
-+++ b/src/conf/device_conf.h
-@@ -167,6 +167,16 @@ struct _virDomainDeviceInfo {
- * assignment, never saved and never reported.
- */
- int pciConnectFlags; /* enum virDomainPCIConnectFlags */
-+
-+ /* PCI devices will only be automatically placed on a PCI bus
-+ * that shares the same isolation group */
-+ unsigned int isolationGroup;
-+
-+ /* Usually, PCI buses will take on the same isolation group
-+ * as the first device that is plugged into them, but in some
-+ * cases we might want to prevent that from happening by
-+ * locking the isolation group */
-+ bool isolationGroupLocked;
- };
-
-
-diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
-index 8990372ae0..a067493136 100644
---- a/src/conf/domain_addr.c
-+++ b/src/conf/domain_addr.c
-@@ -548,6 +548,7 @@ static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
- virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr addrs,
- virPCIDeviceAddressPtr addr,
- virDomainPCIConnectFlags flags,
-+ unsigned int isolationGroup ATTRIBUTE_UNUSED,
- bool fromConfig)
- {
- int ret = -1;
-@@ -600,9 +601,11 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr addrs,
- int
- virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs,
- virPCIDeviceAddressPtr addr,
-- virDomainPCIConnectFlags flags)
-+ virDomainPCIConnectFlags flags,
-+ unsigned int isolationGroup)
- {
-- return virDomainPCIAddressReserveAddrInternal(addrs, addr, flags, true);
-+ return virDomainPCIAddressReserveAddrInternal(addrs, addr, flags,
-+ isolationGroup, true);
- }
-
- int
-@@ -638,7 +641,8 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
- goto cleanup;
-
- ret = virDomainPCIAddressReserveAddrInternal(addrs, &dev->addr.pci,
-- flags, true);
-+ flags, dev->isolationGroup,
-+ true);
- } else {
- ret = virDomainPCIAddressReserveNextAddr(addrs, dev, flags, -1);
- }
-@@ -759,6 +763,7 @@ static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
- virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
- virPCIDeviceAddressPtr next_addr,
- virDomainPCIConnectFlags flags,
-+ unsigned int isolationGroup ATTRIBUTE_UNUSED,
- int function)
- {
- virPCIDeviceAddress a = { 0 };
-@@ -839,10 +844,12 @@ virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
- {
- virPCIDeviceAddress addr;
-
-- if (virDomainPCIAddressGetNextAddr(addrs, &addr, flags, function) < 0)
-+ if (virDomainPCIAddressGetNextAddr(addrs, &addr, flags,
-+ dev->isolationGroup, function) < 0)
- return -1;
-
-- if (virDomainPCIAddressReserveAddrInternal(addrs, &addr, flags, false) < 0)
-+ if (virDomainPCIAddressReserveAddrInternal(addrs, &addr, flags,
-+ dev->isolationGroup, false) < 0)
- return -1;
-
- if (!addrs->dryRun) {
-diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
-index 49f30332f0..01dbc5114f 100644
---- a/src/conf/domain_addr.h
-+++ b/src/conf/domain_addr.h
-@@ -100,6 +100,12 @@ typedef struct {
- * bit is set, that function is in use by a device.
- */
- virDomainPCIAddressSlot slot[VIR_PCI_ADDRESS_SLOT_LAST + 1];
-+
-+ /* See virDomainDeviceInfo::isolationGroup */
-+ unsigned int isolationGroup;
-+
-+ /* See virDomainDeviceInfo::isolationGroupLocked */
-+ bool isolationGroupLocked;
- } virDomainPCIAddressBus;
- typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr;
-
-@@ -155,7 +161,8 @@ int virDomainPCIAddressSetGrow(virDomainPCIAddressSetPtr addrs,
-
- int virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs,
- virPCIDeviceAddressPtr addr,
-- virDomainPCIConnectFlags flags)
-+ virDomainPCIConnectFlags flags,
-+ unsigned int isolationGroup)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-
- int virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index f28f6aff63..5941a3a4c4 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -3608,6 +3608,8 @@ void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info)
- memset(&info->addr, 0, sizeof(info->addr));
- info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
- VIR_FREE(info->romfile);
-+ info->isolationGroup = 0;
-+ info->isolationGroupLocked = false;
- }
-
-
-diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
-index d19ffea7c9..02e214b8dd 100644
---- a/src/qemu/qemu_domain_address.c
-+++ b/src/qemu/qemu_domain_address.c
-@@ -1032,7 +1032,8 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
- }
-
- if (virDomainPCIAddressReserveAddr(addrs, addr,
-- info->pciConnectFlags) < 0) {
-+ info->pciConnectFlags,
-+ info->isolationGroup) < 0) {
- goto cleanup;
- }
-
-@@ -1077,6 +1078,10 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
- if (virDomainPCIAddressBusSetModel(&addrs->buses[idx], cont->model) < 0)
- goto error;
-
-+ /* Forward the information about isolation groups */
-+ addrs->buses[idx].isolationGroup = cont->info.isolationGroup;
-+ addrs->buses[idx].isolationGroupLocked = cont->info.isolationGroupLocked;
-+
- if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)
- hasPCIeRoot = true;
- }
-@@ -1193,7 +1198,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
- if (addrs->nbuses) {
- memset(&tmp_addr, 0, sizeof(tmp_addr));
- tmp_addr.slot = 1;
-- if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < 0)
-+ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0)
- goto cleanup;
- }
-
-@@ -1228,7 +1233,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
- goto cleanup;
- }
- } else {
-- if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < 0)
-+ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0)
- goto cleanup;
- primaryVideo->info.addr.pci = tmp_addr;
- primaryVideo->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-@@ -1253,7 +1258,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
- VIR_DEBUG("PCI address 0:0:2.0 in use, future addition of a video"
- " device will not be possible without manual"
- " intervention");
-- } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < 0) {
-+ } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) {
- goto cleanup;
- }
- }
-@@ -1329,10 +1334,8 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
- assign = true;
- }
- if (assign) {
-- if (virDomainPCIAddressReserveAddr(addrs,
-- &tmp_addr, flags) < 0) {
-+ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0)
- goto cleanup;
-- }
-
- cont->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
- cont->info.addr.pci.domain = 0;
-@@ -1354,10 +1357,8 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
- memset(&tmp_addr, 0, sizeof(tmp_addr));
- tmp_addr.slot = 0x1E;
- if (!virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
-- if (virDomainPCIAddressReserveAddr(addrs,
-- &tmp_addr, flags) < 0) {
-+ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0)
- goto cleanup;
-- }
-
- cont->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
- cont->info.addr.pci.domain = 0;
-@@ -1380,12 +1381,12 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
- tmp_addr.slot = 0x1F;
- tmp_addr.function = 0;
- tmp_addr.multi = VIR_TRISTATE_SWITCH_ON;
-- if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < 0)
-+ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0)
- goto cleanup;
-
- tmp_addr.function = 3;
- tmp_addr.multi = VIR_TRISTATE_SWITCH_ABSENT;
-- if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < 0)
-+ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0)
- goto cleanup;
- }
-
-@@ -1419,7 +1420,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
- goto cleanup;
- }
- } else {
-- if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < 0)
-+ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0)
- goto cleanup;
- primaryVideo->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
- primaryVideo->info.addr.pci = tmp_addr;
-@@ -1445,8 +1446,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
- " device will not be possible without manual"
- " intervention");
- virResetLastError();
-- } else if (virDomainPCIAddressReserveAddr(addrs,
-- &tmp_addr, flags) < 0) {
-+ } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) {
- goto cleanup;
- }
- }
-@@ -1467,7 +1467,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
- !virDeviceInfoPCIAddressWanted(&sound->info)) {
- continue;
- }
-- if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < 0)
-+ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0)
- goto cleanup;
-
- sound->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-@@ -1671,7 +1671,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
- if (foundAddr) {
- /* Reserve this function on the slot we found */
- if (virDomainPCIAddressReserveAddr(addrs, &addr,
-- cont->info.pciConnectFlags) < 0) {
-+ cont->info.pciConnectFlags,
-+ cont->info.isolationGroup) < 0) {
- goto error;
- }
-
---
-2.13.3
-
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
+Date: Wed, 29 Nov 2017 16:23:00 +0100
+Subject: [PATCH] conf: Introduce virDomainChrTargetDefFormat()
+
+Move formatting of the element for char devices out of
+virDomainChrDefFormat() and into its own function.
+
+Signed-off-by: Andrea Bolognani
+Reviewed-by: Pavel Hrdina
+(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
+---
+ 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 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
-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
-Reviewed-by: Pavel Hrdina
-(cherry picked from commit e37daa1fb69ec30042cbc38d489217edb656bc30)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark
----
- 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
-+ * .
-+ */
-+
-+#include
-+
-+#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, "\n");
-+ virBufferAdjustIndent(buf, 2);
-+
-+ if (saveCookie->format(buf, obj) < 0)
-+ return -1;
-+
-+ virBufferAdjustIndent(buf, -2);
-+ virBufferAddLit(buf, "\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
-+ * .
-+ */
-+#ifndef __VIR_SAVE_COOKIE_H__
-+# define __VIR_SAVE_COOKIE_H__
-+
-+# include
-+
-+# 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:
-From: Jiri Denemark
-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
-Reviewed-by: Pavel Hrdina
-(cherry picked from commit 25ec7f6fe959f2811bb014a8c1f0c92bdf9ca13d)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark
----
- 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:
-From: Jiri Denemark
-Date: Thu, 1 Jun 2017 15:57:55 +0200
-Subject: [PATCH] conf: Make virDomainSnapshotDefFormat easier to read
-
-Signed-off-by: Jiri Denemark
-Reviewed-by: Pavel Hrdina
-(cherry picked from commit 00968dca967f4bf9d4f496e5c971bff3f8147ed8)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark
----
- 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, "\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, "\n");
- virBufferAdjustIndent(&buf, 2);
-+
- virBufferEscapeString(&buf, "%s\n", def->name);
- if (def->description)
- virBufferEscapeString(&buf, "%s\n",
- def->description);
- virBufferAsprintf(&buf, "%s\n",
- virDomainSnapshotStateTypeToString(def->state));
-+
- if (def->parent) {
- virBufferAddLit(&buf, "\n");
- virBufferAdjustIndent(&buf, 2);
-@@ -715,14 +719,17 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
- virBufferAdjustIndent(&buf, -2);
- virBufferAddLit(&buf, "\n");
- }
-+
- virBufferAsprintf(&buf, "%lld\n",
- def->creationTime);
-+
- if (def->memory) {
- virBufferAsprintf(&buf, "memory));
- virBufferEscapeString(&buf, " file='%s'", def->file);
- virBufferAddLit(&buf, "/>\n");
- }
-+
- if (def->ndisks) {
- virBufferAddLit(&buf, "\n");
- virBufferAdjustIndent(&buf, 2);
-@@ -731,11 +738,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
- virBufferAdjustIndent(&buf, -2);
- virBufferAddLit(&buf, "\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, "\n");
- virBufferAdjustIndent(&buf, 2);
-@@ -743,8 +749,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
- virBufferAdjustIndent(&buf, -2);
- virBufferAddLit(&buf, "\n");
- }
-+
- if (internal)
- virBufferAsprintf(&buf, "%d\n", def->current);
-+
- virBufferAdjustIndent(&buf, -2);
- virBufferAddLit(&buf, "\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-Move-index-number-checking-to-drivers.patch b/SOURCES/libvirt-conf-Move-index-number-checking-to-drivers.patch
deleted file mode 100644
index 52cbf17..0000000
--- a/SOURCES/libvirt-conf-Move-index-number-checking-to-drivers.patch
+++ /dev/null
@@ -1,101 +0,0 @@
-From 711a3ca4a1c0c9bc31a98cd6afcedeb3107157c8 Mon Sep 17 00:00:00 2001
-Message-Id: <711a3ca4a1c0c9bc31a98cd6afcedeb3107157c8@dist-git>
-From: Andrea Bolognani
-Date: Mon, 17 Jul 2017 12:09:06 +0200
-Subject: [PATCH] conf: Move index number checking to drivers
-
-pSeries guests will soon be allowed to have multiple
-PHBs (pci-root controllers), which of course means that
-all but one of them will have a non-zero index; hence,
-we'll need to relax the current check.
-
-However, right now the check is performed in the conf
-module, which is generic rather than tied to the QEMU
-driver, and where we don't have information such as the
-guest machine type available.
-
-To make this change of behavior possible down the line,
-we need to move the check from the XML parser to the
-drivers. Luckily, only QEMU and bhyve are using PCI
-controllers, so this doesn't result in much duplication.
-
-Signed-off-by: Andrea Bolognani
-Reviewed-by: Laine Stump
-(cherry picked from commit 620c390c7308f61027cf28000fcfcfcb01e3ae89)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1431193
-
-Signed-off-by: Andrea Bolognani
-Signed-off-by: Jiri Denemark
----
- src/bhyve/bhyve_domain.c | 15 +++++++++++++++
- src/conf/domain_conf.c | 6 ------
- src/qemu/qemu_domain.c | 9 +++++++++
- 3 files changed, 24 insertions(+), 6 deletions(-)
-
-diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
-index 20c82937b5..71764554eb 100644
---- a/src/bhyve/bhyve_domain.c
-+++ b/src/bhyve/bhyve_domain.c
-@@ -122,6 +122,21 @@ bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
- bhyveDomainDiskDefAssignAddress(driver, disk, def) < 0)
- return -1;
- }
-+
-+ if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) {
-+ virDomainControllerDefPtr cont = dev->data.controller;
-+
-+ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
-+ (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT ||
-+ cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) &&
-+ cont->idx != 0) {
-+ virReportError(VIR_ERR_XML_ERROR, "%s",
-+ _("pci-root and pcie-root controllers "
-+ "should have index 0"));
-+ return -1;
-+ }
-+ }
-+
- return 0;
- }
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index d8ca25da38..8e5c487df8 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -9157,12 +9157,6 @@ virDomainControllerDefParseXML(xmlNodePtr node,
- "have an address"));
- goto error;
- }
-- if (def->idx > 0) {
-- virReportError(VIR_ERR_XML_ERROR, "%s",
-- _("pci-root and pcie-root controllers "
-- "should have index 0"));
-- goto error;
-- }
- if ((rc = virDomainParseScaledValue("./pcihole64", NULL,
- ctxt, &bytes, 1024,
- 1024ULL * ULONG_MAX, false)) < 0)
-diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
-index 1528c6a137..87a437eccf 100644
---- a/src/qemu/qemu_domain.c
-+++ b/src/qemu/qemu_domain.c
-@@ -3378,6 +3378,15 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
- break;
-
- case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
-+ if ((cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT ||
-+ cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) &&
-+ cont->idx != 0) {
-+ virReportError(VIR_ERR_XML_ERROR, "%s",
-+ _("pci-root and pcie-root controllers "
-+ "should have index 0"));
-+ return -1;
-+ }
-+
- if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS &&
- !qemuDomainIsI440FX(def)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
---
-2.13.3
-
diff --git a/SOURCES/libvirt-conf-Move-target-index-validation.patch b/SOURCES/libvirt-conf-Move-target-index-validation.patch
deleted file mode 100644
index 6c37fc1..0000000
--- a/SOURCES/libvirt-conf-Move-target-index-validation.patch
+++ /dev/null
@@ -1,93 +0,0 @@
-From 3e5618223a9e21597ed9e95edfc79139563be301 Mon Sep 17 00:00:00 2001
-Message-Id: <3e5618223a9e21597ed9e95edfc79139563be301@dist-git>
-From: Andrea Bolognani
-Date: Mon, 21 Aug 2017 14:46:38 +0200
-Subject: [PATCH] conf: Move target index validation
-
-Validation should happen after parsing, so the proper
-location for it is virDomainControllerDefValidate()
-rather than virDomainControllerDefParseXML().
-
-Signed-off-by: Andrea Bolognani
-(cherry picked from commit c9d75d655ae73693a08123aca75677caf579f9e9)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1479647
-
-Signed-off-by: Andrea Bolognani
-Signed-off-by: Jiri Denemark
----
- src/conf/domain_conf.c | 40 ++++++++++++++++++++++++----------------
- 1 file changed, 24 insertions(+), 16 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 7ba2bc01ca..7889f5335c 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -5046,12 +5046,34 @@ static int
- virDomainControllerDefValidate(const virDomainControllerDef *controller)
- {
- if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
-+ const virDomainPCIControllerOpts *opts = &controller->opts.pciopts;
-+
- if (controller->idx > 255) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("PCI controller index %d too high, maximum is 255"),
- controller->idx);
- return -1;
- }
-+
-+ /* Only validate the target index if it's been set */
-+ if (opts->targetIndex != -1) {
-+
-+ if (opts->targetIndex < 0 || opts->targetIndex > 31) {
-+ virReportError(VIR_ERR_XML_ERROR,
-+ _("PCI controller target index '%d' out of "
-+ "range - must be 0-31"),
-+ opts->targetIndex);
-+ return -1;
-+ }
-+
-+ if ((controller->idx == 0 && opts->targetIndex != 0) ||
-+ (controller->idx != 0 && opts->targetIndex == 0)) {
-+ virReportError(VIR_ERR_XML_ERROR, "%s",
-+ _("Only the PCI controller with index 0 can "
-+ "have target index 0, and vice versa"));
-+ return -1;
-+ }
-+ }
- }
- return 0;
- }
-@@ -9292,27 +9314,13 @@ virDomainControllerDefParseXML(xmlNodePtr node,
- }
- if (targetIndex) {
- if (virStrToLong_i(targetIndex, NULL, 0,
-- &def->opts.pciopts.targetIndex) < 0) {
-+ &def->opts.pciopts.targetIndex) < 0 ||
-+ def->opts.pciopts.targetIndex == -1) {
- virReportError(VIR_ERR_XML_ERROR,
- _("Invalid target index '%s' in PCI controller"),
- targetIndex);
- goto error;
- }
-- if (def->opts.pciopts.targetIndex < 0 ||
-- def->opts.pciopts.targetIndex > 31) {
-- virReportError(VIR_ERR_XML_ERROR,
-- _("PCI controller target index '%s' out of "
-- "range - must be 0-31"),
-- targetIndex);
-- goto error;
-- }
-- if ((def->idx == 0 && def->opts.pciopts.targetIndex != 0) ||
-- (def->idx != 0 && def->opts.pciopts.targetIndex == 0)) {
-- virReportError(VIR_ERR_XML_ERROR, "%s",
-- _("Only the PCI controller with index 0 can "
-- "have target index 0, and vice versa"));
-- goto error;
-- }
- }
- if (numaNode >= 0) {
- if (def->idx == 0) {
---
-2.14.1
-
diff --git a/SOURCES/libvirt-conf-Move-virDomainPCIAddressBusIsFullyReserved.patch b/SOURCES/libvirt-conf-Move-virDomainPCIAddressBusIsFullyReserved.patch
deleted file mode 100644
index 838066c..0000000
--- a/SOURCES/libvirt-conf-Move-virDomainPCIAddressBusIsFullyReserved.patch
+++ /dev/null
@@ -1,115 +0,0 @@
-From 9d0d053dc7f8af8ebb3c7fbb3a11335e4b50717b Mon Sep 17 00:00:00 2001
-Message-Id: <9d0d053dc7f8af8ebb3c7fbb3a11335e4b50717b@dist-git>
-From: Andrea Bolognani
-Date: Mon, 17 Jul 2017 12:08:58 +0200
-Subject: [PATCH] conf: Move virDomainPCIAddressBusIsFullyReserved()
-
-This function was private to the QEMU driver and was,
-accordingly, called qemuDomainPCIBusFullyReserved().
-
-However the function is really not QEMU-specific at
-all, so it makes sense to move it closer to the
-virDomainPCIAddressBus struct it operates on.
-
-Signed-off-by: Andrea Bolognani
-Reviewed-by: Laine Stump
-(cherry picked from commit c79f97c83ce1421f79756a9a344e8e77ceeeb1d8)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1431193
-
-Signed-off-by: Andrea Bolognani
-Signed-off-by: Jiri Denemark
----
- src/conf/domain_addr.c | 14 ++++++++++++++
- src/conf/domain_addr.h | 3 +++
- src/libvirt_private.syms | 1 +
- src/qemu/qemu_domain_address.c | 15 +--------------
- 4 files changed, 19 insertions(+), 14 deletions(-)
-
-diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
-index 639168effa..0ae1ed93af 100644
---- a/src/conf/domain_addr.c
-+++ b/src/conf/domain_addr.c
-@@ -355,6 +355,20 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
- }
-
-
-+bool
-+virDomainPCIAddressBusIsFullyReserved(virDomainPCIAddressBusPtr bus)
-+{
-+ size_t i;
-+
-+ for (i = bus->minSlot; i <= bus->maxSlot; i++) {
-+ if (!bus->slot[i].functions)
-+ return false;
-+ }
-+
-+ return true;
-+}
-+
-+
- /* Ensure addr fits in the address set, by expanding it if needed
- *
- * Return value:
-diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
-index f884b8af2b..c90a335919 100644
---- a/src/conf/domain_addr.h
-+++ b/src/conf/domain_addr.h
-@@ -141,6 +141,9 @@ int virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
- virDomainControllerModelPCI model)
- ATTRIBUTE_NONNULL(1);
-
-+bool virDomainPCIAddressBusIsFullyReserved(virDomainPCIAddressBusPtr bus)
-+ ATTRIBUTE_NONNULL(1);
-+
- bool virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs,
- virPCIDeviceAddressPtr addr)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
-index 9c596e3f1c..7876ffb208 100644
---- a/src/libvirt_private.syms
-+++ b/src/libvirt_private.syms
-@@ -105,6 +105,7 @@ virDomainCCWAddressSetFree;
- virDomainCCWAddressValidate;
- virDomainGetBlkioParametersAssignFromDef;
- virDomainPCIAddressAsString;
-+virDomainPCIAddressBusIsFullyReserved;
- virDomainPCIAddressBusSetModel;
- virDomainPCIAddressEnsureAddr;
- virDomainPCIAddressFlagsCompatible;
-diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
-index 3da6b7369d..ff57edb564 100644
---- a/src/qemu/qemu_domain_address.c
-+++ b/src/qemu/qemu_domain_address.c
-@@ -1494,19 +1494,6 @@ qemuDomainValidateDevicePCISlotsChipsets(virDomainDefPtr def,
- }
-
-
--static bool
--qemuDomainPCIBusFullyReserved(virDomainPCIAddressBusPtr bus)
--{
-- size_t i;
--
-- for (i = bus->minSlot; i <= bus->maxSlot; i++)
-- if (!bus->slot[i].functions)
-- return false;
--
-- return true;
--}
--
--
- /*
- * This assigns static PCI slots to all configured devices.
- * The ordering here is chosen to match the ordering used
-@@ -2038,7 +2025,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
- bool buses_reserved = true;
-
- for (i = 0; i < addrs->nbuses; i++) {
-- if (!qemuDomainPCIBusFullyReserved(&addrs->buses[i])) {
-+ if (!virDomainPCIAddressBusIsFullyReserved(&addrs->buses[i])) {
- buses_reserved = false;
- break;
- }
---
-2.13.3
-
diff --git a/SOURCES/libvirt-conf-Parse-and-format-target-index.patch b/SOURCES/libvirt-conf-Parse-and-format-target-index.patch
deleted file mode 100644
index fcc68a5..0000000
--- a/SOURCES/libvirt-conf-Parse-and-format-target-index.patch
+++ /dev/null
@@ -1,161 +0,0 @@
-From 4c2b1b9cf0bcd8af7a7d011cd758bb6f11e5477b Mon Sep 17 00:00:00 2001
-Message-Id: <4c2b1b9cf0bcd8af7a7d011cd758bb6f11e5477b@dist-git>
-From: Andrea Bolognani
-Date: Mon, 17 Jul 2017 12:09:09 +0200
-Subject: [PATCH] conf: Parse and format
-
-Signed-off-by: Andrea Bolognani
-Reviewed-by: Laine Stump
-(cherry picked from commit 47dd6e282ab8b0db662092cf0cc53163d805ac4d)
-
-Conflicts:
- * src/conf/domain_conf.c:
-
- caused by e146264aaadf5aecf727d8c7b3d85683b55b6c48,
- which significantly refactored
- virDomainControllerDefFormat(), not being in the tree.
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1431193
-
-Signed-off-by: Andrea Bolognani
-Signed-off-by: Jiri Denemark
----
- docs/formatdomain.html.in | 6 ++++++
- docs/schemas/domaincommon.rng | 5 +++++
- src/conf/domain_conf.c | 32 ++++++++++++++++++++++++++++++++
- src/conf/domain_conf.h | 1 +
- 4 files changed, 44 insertions(+)
-
-diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
-index dc8e7d2dc7..bc67a53408 100644
---- a/docs/formatdomain.html.in
-+++ b/docs/formatdomain.html.in
-@@ -3760,6 +3760,12 @@
- libvirt API to attach host devices to the correct
- pci-expander-bus when assigning them to the domain).
-
-+
index
-+
-+ pci-root controllers for pSeries guests use this attribute to
-+ record the order they will show up in the guest.
-+ Since 3.6.0
-+
-
-
- For machine types which provide an implicit PCI bus, the pci-root
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
-index 964e5c5bd5..b1461d4c61 100644
---- a/docs/schemas/domaincommon.rng
-+++ b/docs/schemas/domaincommon.rng
-@@ -1945,6 +1945,11 @@
-
-
-
-+
-+
-+
-+
-+
-
-
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 8a030c9b68..599db5cafe 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -1854,6 +1854,7 @@ virDomainControllerDefNew(virDomainControllerType type)
- def->opts.pciopts.chassis = -1;
- def->opts.pciopts.port = -1;
- def->opts.pciopts.busNr = -1;
-+ def->opts.pciopts.targetIndex = -1;
- def->opts.pciopts.numaNode = -1;
- break;
- case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
-@@ -8964,6 +8965,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
- char *chassis = NULL;
- char *port = NULL;
- char *busNr = NULL;
-+ char *targetIndex = NULL;
- int numaNode = -1;
- char *ioeventfd = NULL;
- char *portsStr = NULL;
-@@ -9036,6 +9038,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
- chassis = virXMLPropString(cur, "chassis");
- port = virXMLPropString(cur, "port");
- busNr = virXMLPropString(cur, "busNr");
-+ targetIndex = virXMLPropString(cur, "index");
- processedTarget = true;
- }
- }
-@@ -9254,6 +9257,30 @@ virDomainControllerDefParseXML(xmlNodePtr node,
- goto error;
- }
- }
-+ if (targetIndex) {
-+ if (virStrToLong_i(targetIndex, NULL, 0,
-+ &def->opts.pciopts.targetIndex) < 0) {
-+ virReportError(VIR_ERR_XML_ERROR,
-+ _("Invalid target index '%s' in PCI controller"),
-+ targetIndex);
-+ goto error;
-+ }
-+ if (def->opts.pciopts.targetIndex < 0 ||
-+ def->opts.pciopts.targetIndex > 31) {
-+ virReportError(VIR_ERR_XML_ERROR,
-+ _("PCI controller target index '%s' out of "
-+ "range - must be 0-31"),
-+ targetIndex);
-+ goto error;
-+ }
-+ if ((def->idx == 0 && def->opts.pciopts.targetIndex != 0) ||
-+ (def->idx != 0 && def->opts.pciopts.targetIndex == 0)) {
-+ virReportError(VIR_ERR_XML_ERROR, "%s",
-+ _("Only the PCI controller with index 0 can "
-+ "have target index 0, and vice versa"));
-+ goto error;
-+ }
-+ }
- if (numaNode >= 0)
- def->opts.pciopts.numaNode = numaNode;
- break;
-@@ -9275,6 +9302,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
- VIR_FREE(chassis);
- VIR_FREE(port);
- VIR_FREE(busNr);
-+ VIR_FREE(targetIndex);
- VIR_FREE(ioeventfd);
- VIR_FREE(portsStr);
- VIR_FREE(iothread);
-@@ -21615,6 +21643,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
- def->opts.pciopts.chassis != -1 ||
- def->opts.pciopts.port != -1 ||
- def->opts.pciopts.busNr != -1 ||
-+ def->opts.pciopts.targetIndex != -1 ||
- def->opts.pciopts.numaNode != -1)
- pciTarget = true;
- break;
-@@ -21655,6 +21684,9 @@ virDomainControllerDefFormat(virBufferPtr buf,
- if (def->opts.pciopts.busNr != -1)
- virBufferAsprintf(buf, " busNr='%d'",
- def->opts.pciopts.busNr);
-+ if (def->opts.pciopts.targetIndex != -1)
-+ virBufferAsprintf(buf, " index='%d'",
-+ def->opts.pciopts.targetIndex);
- if (def->opts.pciopts.numaNode == -1) {
- virBufferAddLit(buf, "/>\n");
- } else {
-diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
-index e287e6d7f3..50fdc6e2a6 100644
---- a/src/conf/domain_conf.h
-+++ b/src/conf/domain_conf.h
-@@ -786,6 +786,7 @@ struct _virDomainPCIControllerOpts {
- int chassis;
- int port;
- int busNr; /* used by pci-expander-bus, -1 == unspecified */
-+ int targetIndex; /* used by spapr-pci-host-bridge, -1 == unspecified */
- /* numaNode is a *subelement* of target (to match existing
- * item in memory target config) -1 == unspecified
- */
---
-2.13.3
-
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:
+From: Andrea Bolognani
+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
+Reviewed-by: Pavel Hrdina
+(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
+---
+ 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
+ <devices>
+ <!-- USB serial port -->
+ <serial type='pty'>
+- <target type='usb-serial' port='0'/>
++ <target type='usb-serial' port='0'>
++ <model name='usb-serial'/>
++ </target>
+ <address type='usb' bus='0' port='1'/>
+ </serial>
+ </devices>
+@@ -6463,6 +6465,16 @@ qemu-kvm -net nic,model=? /dev/null
+ is available).
+
+
++
++ Since 3.10.0, the target
++ element can have an optional model subelement;
++ valid values for its name attribute are:
++ isa-serial (usable with the isa-serial target
++ type); usb-serial (usable with the usb-serial
++ target type); pci-serial
++ (usable with the pci-serial target type).
++
\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
-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
-Reviewed-by: Pavel Hrdina
-(cherry picked from commit 957cd268a98043fe061227a8e829c622a6fb4b86)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark
----
- 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(¤tSnapshotXmlFilePath, "%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:
+From: Peter Krempa
+Date: Mon, 13 Nov 2017 13:25:01 +0100
+Subject: [PATCH] conf: Properly parse
+
+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
+---
+ 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 @@
+
+
+
++
+
+
+
+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 @@
+
+
+
++
+
+
+
+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 @@
+
+
+
++
+
+
+
+@@ -63,6 +64,7 @@
+
+
+
++
+
+
+
+@@ -79,6 +81,7 @@
+
+
+
++
+
+
+
+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 @@
+ /usr/bin/qemu-system-i686
+
+
++
+
+
+
+@@ -24,12 +25,14 @@
+
+
+
++
+
+
+
+
+
+
++
+
+
+
+@@ -39,6 +42,7 @@
+
+
+
++
+
+
+
+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 @@
+ /usr/bin/qemu-system-i686
+
+
++
+
+
+
+@@ -24,12 +25,14 @@
+
+
+
++
+
+
+
+
+
+
++
+
+
+
+@@ -39,6 +42,7 @@
+
+
+
++
+
+
+
+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 @@
+
+
+
++
+
+
+
+--
+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
-Date: Tue, 23 May 2017 09:29:36 +0200
-Subject: [PATCH] conf: Refactor virCPUDefParseXML
-
-Signed-off-by: Jiri Denemark
-Reviewed-by: Pavel Hrdina
-(cherry picked from commit 702013f3b3ad8bd28c326058e2dd9ea8afbd1e61)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1441662
-
-Signed-off-by: Jiri Denemark
----
- 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 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 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:
+From: Andrea Bolognani
+Date: Wed, 29 Nov 2017 16:23:04 +0100
+Subject: [PATCH] conf: Remove ATTRIBUTE_FALLTHROUGH from
+ virDomainChrTargetDefFormat()
+
+Formatting the 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
+Reviewed-by: Pavel Hrdina
+(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
+---
+ 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, "targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) {
+ virBufferAsprintf(buf,
+- "\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, "\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
-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
-(cherry picked from commit e841a41169dd726af13f29cb57fbafe658b7011a)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1428952
-
-Signed-off-by: Jiri Denemark
----
- 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
-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
-Signed-off-by: Jiri Denemark
----
- 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
+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
+Reviewed-by: Pavel Hrdina
+(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
+---
+ 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-Simplify-slot-allocation.patch b/SOURCES/libvirt-conf-Simplify-slot-allocation.patch
deleted file mode 100644
index 9d214e6..0000000
--- a/SOURCES/libvirt-conf-Simplify-slot-allocation.patch
+++ /dev/null
@@ -1,136 +0,0 @@
-From af91509dfc59e90262117b96a2a365d5ece29393 Mon Sep 17 00:00:00 2001
-Message-Id:
-From: Andrea Bolognani
-Date: Mon, 17 Jul 2017 12:09:03 +0200
-Subject: [PATCH] conf: Simplify slot allocation
-
-The current algorithm for slot allocation tries to be clever
-and avoid looking at buses / slots more than once unless it's
-necessary. Unfortunately that makes the code more complex,
-and it will cause problem later on in some situations unless
-even more complex code is added.
-
-Since the performance gains are going to be pretty modest
-anyway, we can just get rid of the extra complexity and use a
-completely straighforward implementation instead.
-
-Signed-off-by: Andrea Bolognani
-Reviewed-by: Laine Stump
-(cherry picked from commit 2bd0658d7cc886209a53bae23c20adbb7d4f91ac)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1431193
-
-Signed-off-by: Andrea Bolognani
-Signed-off-by: Jiri Denemark
----
- src/conf/domain_addr.c | 47 +++++++++--------------------------------------
- src/conf/domain_addr.h | 2 --
- 2 files changed, 9 insertions(+), 40 deletions(-)
-
-diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
-index b17bb61a1d..b8e5902c07 100644
---- a/src/conf/domain_addr.c
-+++ b/src/conf/domain_addr.c
-@@ -755,46 +755,34 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
- virDomainPCIConnectFlags flags,
- int function)
- {
-- /* default to starting the search for a free slot from
-- * the first slot of domain 0 bus 0...
-- */
- virPCIDeviceAddress a = { 0 };
-- bool found = false;
-
- if (addrs->nbuses == 0) {
- virReportError(VIR_ERR_XML_ERROR, "%s", _("No PCI buses available"));
- goto error;
- }
-
-- /* ...unless this search is for the exact same type of device as
-- * last time, then continue the search from the slot where we
-- * found the previous match (it's possible there will still be a
-- * function available on that slot).
-- */
-- if (flags == addrs->lastFlags)
-- a = addrs->lastaddr;
-- else
-- a.slot = addrs->buses[0].minSlot;
--
- /* if the caller asks for "any function", give them function 0 */
- if (function == -1)
- a.function = 0;
- else
- a.function = function;
-
-- while (a.bus < addrs->nbuses) {
-- if (virDomainPCIAddressFindUnusedFunctionOnBus(&addrs->buses[a.bus],
-- &a, function,
-+ /* "Begin at the beginning," the King said, very gravely, "and go on
-+ * till you come to the end: then stop." */
-+ for (a.bus = 0; a.bus < addrs->nbuses; a.bus++) {
-+ virDomainPCIAddressBusPtr bus = &addrs->buses[a.bus];
-+ bool found = false;
-+
-+ a.slot = bus->minSlot;
-+
-+ if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, function,
- flags, &found) < 0) {
- goto error;
- }
-
- if (found)
- goto success;
--
-- /* nothing on this bus, go to the next bus */
-- if (++a.bus < addrs->nbuses)
-- a.slot = addrs->buses[a.bus].minSlot;
- }
-
- /* There were no free slots after the last used one */
-@@ -805,20 +793,6 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
- /* this device will use the first slot of the new bus */
- a.slot = addrs->buses[a.bus].minSlot;
- goto success;
-- } else if (flags == addrs->lastFlags) {
-- /* Check the buses from 0 up to the last used one */
-- for (a.bus = 0; a.bus <= addrs->lastaddr.bus; a.bus++) {
-- a.slot = addrs->buses[a.bus].minSlot;
--
-- if (virDomainPCIAddressFindUnusedFunctionOnBus(&addrs->buses[a.bus],
-- &a, function,
-- flags, &found) < 0) {
-- goto error;
-- }
--
-- if (found)
-- goto success;
-- }
- }
-
- virReportError(VIR_ERR_INTERNAL_ERROR,
-@@ -865,9 +839,6 @@ virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
- if (virDomainPCIAddressReserveAddrInternal(addrs, &addr, flags, false) < 0)
- return -1;
-
-- addrs->lastaddr = addr;
-- addrs->lastFlags = flags;
--
- if (!addrs->dryRun) {
- dev->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
- dev->addr.pci = addr;
-diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
-index bb10f1abf3..a5afefda95 100644
---- a/src/conf/domain_addr.h
-+++ b/src/conf/domain_addr.h
-@@ -106,8 +106,6 @@ typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr;
- struct _virDomainPCIAddressSet {
- virDomainPCIAddressBus *buses;
- size_t nbuses;
-- virPCIDeviceAddress lastaddr;
-- virDomainPCIConnectFlags lastFlags;
- bool dryRun; /* on a dry run, new buses are auto-added
- and addresses aren't saved in device infos */
- };
---
-2.13.3
-
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
+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
+Reviewed-by: John Ferlan
+(cherry picked from commit b4698edcb0a459332b24410f59698005af37eecb)
+Signed-off-by: Martin Kletzander
+---
+ 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-Tweak-virDomainPCIAddressGetNextAddr-signature.patch b/SOURCES/libvirt-conf-Tweak-virDomainPCIAddressGetNextAddr-signature.patch
deleted file mode 100644
index ebfcb3a..0000000
--- a/SOURCES/libvirt-conf-Tweak-virDomainPCIAddressGetNextAddr-signature.patch
+++ /dev/null
@@ -1,82 +0,0 @@
-From 2d719331886e3f4ed927449ffde6a854e9deec1b Mon Sep 17 00:00:00 2001
-Message-Id: <2d719331886e3f4ed927449ffde6a854e9deec1b@dist-git>
-From: Andrea Bolognani
-Date: Mon, 17 Jul 2017 12:08:59 +0200
-Subject: [PATCH] conf: Tweak virDomainPCIAddressGetNextAddr() signature
-
-Move @function after @flags to match other functions in the
-same module like virDomainPCIAddressReserveNextAddr().
-
-Also move virDomainPCIAddressReserveNextAddr() closer to
-virDomainPCIAddressReserveAddr() in the header file.
-
-Signed-off-by: Andrea Bolognani
-Reviewed-by: Laine Stump
-(cherry picked from commit c949f6e69cbe91b9897e37e525181710f5c75b35)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1431193
-
-Signed-off-by: Andrea Bolognani
-Signed-off-by: Jiri Denemark
----
- src/conf/domain_addr.c | 6 +++---
- src/conf/domain_addr.h | 12 ++++++------
- 2 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
-index 0ae1ed93af..b17bb61a1d 100644
---- a/src/conf/domain_addr.c
-+++ b/src/conf/domain_addr.c
-@@ -752,8 +752,8 @@ virDomainPCIAddressFindUnusedFunctionOnBus(virDomainPCIAddressBusPtr bus,
- static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
- virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs,
- virPCIDeviceAddressPtr next_addr,
-- int function,
-- virDomainPCIConnectFlags flags)
-+ virDomainPCIConnectFlags flags,
-+ int function)
- {
- /* default to starting the search for a free slot from
- * the first slot of domain 0 bus 0...
-@@ -859,7 +859,7 @@ virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
- {
- virPCIDeviceAddress addr;
-
-- if (virDomainPCIAddressGetNextAddr(addrs, &addr, function, flags) < 0)
-+ if (virDomainPCIAddressGetNextAddr(addrs, &addr, flags, function) < 0)
- return -1;
-
- if (virDomainPCIAddressReserveAddrInternal(addrs, &addr, flags, false) < 0)
-diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
-index c90a335919..bb10f1abf3 100644
---- a/src/conf/domain_addr.h
-+++ b/src/conf/domain_addr.h
-@@ -158,6 +158,12 @@ int virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs,
- virDomainPCIConnectFlags flags)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-
-+int virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
-+ virDomainDeviceInfoPtr dev,
-+ virDomainPCIConnectFlags flags,
-+ int function)
-+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-+
- int virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
- virDomainDeviceInfoPtr dev,
- virDomainPCIConnectFlags flags)
-@@ -167,12 +173,6 @@ int virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
- virPCIDeviceAddressPtr addr)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-
--int virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
-- virDomainDeviceInfoPtr dev,
-- virDomainPCIConnectFlags flags,
-- int function)
-- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
--
- void virDomainPCIAddressSetAllMulti(virDomainDefPtr def)
- ATTRIBUTE_NONNULL(1);
-
---
-2.13.3
-
diff --git a/SOURCES/libvirt-conf-Use-the-correct-limit-for-the-number-of-PHBs.patch b/SOURCES/libvirt-conf-Use-the-correct-limit-for-the-number-of-PHBs.patch
deleted file mode 100644
index 4ceca53..0000000
--- a/SOURCES/libvirt-conf-Use-the-correct-limit-for-the-number-of-PHBs.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From e2bf7a17d464c989378278c3121425e7b90442e3 Mon Sep 17 00:00:00 2001
-Message-Id:
-From: Andrea Bolognani
-Date: Mon, 21 Aug 2017 14:46:39 +0200
-Subject: [PATCH] conf: Use the correct limit for the number of PHBs
-
-I mistakenly thought pSeries guests supported 32 PHBs,
-but it turns out they only support 31. Validate the
-target index accordingly.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1479647
-
-Signed-off-by: Andrea Bolognani
-(cherry picked from commit 64357c3f9373127aa8bdf5a829df4a9d895e1ef9)
-
-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1479647
-
-Signed-off-by: Andrea Bolognani
-Signed-off-by: Jiri Denemark
----
- src/conf/domain_conf.c | 4 ++--
- .../qemuxml2argv-pseries-phb-invalid-target-index-3.xml | 6 +++---
- 2 files changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
-index 7889f5335c..3d38f668fa 100644
---- a/src/conf/domain_conf.c
-+++ b/src/conf/domain_conf.c
-@@ -5058,10 +5058,10 @@ virDomainControllerDefValidate(const virDomainControllerDef *controller)
- /* Only validate the target index if it's been set */
- if (opts->targetIndex != -1) {
-
-- if (opts->targetIndex < 0 || opts->targetIndex > 31) {
-+ if (opts->targetIndex < 0 || opts->targetIndex > 30) {
- virReportError(VIR_ERR_XML_ERROR,
- _("PCI controller target index '%d' out of "
-- "range - must be 0-31"),
-+ "range - must be 0-30"),
- opts->targetIndex);
- return -1;
- }
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
-index 864c5d8758..3d99da4995 100644
---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
-@@ -8,10 +8,10 @@
-
-
- /usr/bin/qemu-system-ppc64
--
-+
-
--
-+
-
-
-
---
-2.14.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:
+From: Martin Kletzander
+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
+(cherry picked from commit 3bbae43d8cc79ef1cd0b9a4ea2440203a0edc959)
+Signed-off-by: Martin Kletzander
+---
+ 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?=
-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
-Signed-off-by: Jiri Denemark
----
- 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:
+From: Pino Toscano
+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 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
+Reviewed-by: Andrea Bolognani
+Reviewed-by: Pavel Hrdina
+(cherry picked from commit 21332bf6587c23409fecb06ab81dbc14dd52c10b)
+Signed-off-by: Jiri Denemark
+---
+ 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), usb-serial (usable whenever USB support
+ is available) and pci-serial (usable whenever PCI support
+ is available); since 3.10.0,
+- spapr-vio-serial (usable with ppc64/pseries guests) and
+- system-serial (usable with aarch64/virt guests) are
++ spapr-vio-serial (usable with ppc64/pseries guests),
++ system-serial (usable with aarch64/virt guests) and
++ sclp-serial (usable with s390 and s390x guests) are
+ available as well.
+
+
+@@ -6478,7 +6479,9 @@ qemu-kvm -net nic,model=? /dev/null
+ (usable with the pci-serial target type);
+ spapr-vty (usable with the spapr-vio-serial
+ target type); pl011 (usable with the
+- system-serial target type).
++ system-serial target type); sclpconsole and
++ sclplmconsole (usable with the sclp-serial
++ target type).
+
+
+
+@@ -6493,7 +6496,8 @@ qemu-kvm -net nic,model=? /dev/null
+ isa-serial), usb (for usb-serial),
+ pci (for pci-serial) and spapr-vio
+ (for spapr-vio-serial). The system-serial
+- target type doesn't support specifying an address.
++ and sclp-serial target types don't support specifying an
++ address.
+
+
+
+@@ -6541,8 +6545,11 @@ qemu-kvm -net nic,model=? /dev/null
+ virtio (usable whenever VirtIO support is available);
+ xen, lxc, uml and
+ openvz (available when the corresponding hypervisor is in
+- use); sclp and sclplm (usable for s390 and
+- s390x QEMU guests).
++ use). sclp and sclplm (usable for s390 and
++ s390x QEMU guests) are supported for compatibility reasons but should
++ not be used for new guests: use the sclpconsole and
++ sclplmconsole target models, respectively, with the
++ serial element instead.
+
-+ The caching_mode attribute with possible values
-+ on and off can be used to
-+ turn on the VT-d caching mode (useful for assigned devices).
-+ Since 3.4.0 (QEMU/KVM only)
-+
-@@ -7404,6 +7406,26 @@ qemu-kvm -net nic,model=? /dev/null
- Currently only the intel model is supported.
-
-
-+
driver
-+
-+
-+ The driver subelement can be used to configure
-+ additional options:
-+
-+
-+
intremap
-+
-+
-+ The intremap attribute with possible values
-+ on and off can be used to
-+ turn on interrupt remapping, a part of the VT-d functionality.
-+ Currently this requires split I/O APIC
-+ (<ioapic driver='qemu'/>).
-+ Since 3.4.0 (QEMU/KVM only)
-+
-+ The eim attribute (with possible values
-+ on and off) can be used to
-+ configure Extended Interrupt Mode. A q35 domain with
-+ split I/O APIC (as described in
-+ hypervisor features),
-+ and both interrupt remapping and EIM turned on for
-+ the IOMMU, will be able to use more than 255 vCPUs.
-+ Since 3.4.0 (QEMU/KVM only)
-+
Tune the I/O APIC. Possible values for the
-+ driver attribute are:
-+ kvm (default for KVM domains)
-+ and qemu which puts I/O APIC in userspace
-+ which is also known as a split I/O APIC mode.
-+ Since 3.4.0 (QEMU/KVM only)
-+
-+ The iotlb attribute with possible values
-+ on and off can be used to
-+ turn on the IOTLB used to cache address translation
-+ requests from devices.
-+ Since 3.5.0 (QEMU/KVM only)
-+
-+
-
-
-
-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 @@
-
-
-
-+
-+
-+
-+
-+
-
-
-
-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, "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 @@
-+
-+ QEMUGuest1
-+ c7a5fdbd-edaf-9455-926a-d65c16db1809
-+ 219100
-+ 219100
-+ 1
-+
-+ hvm
-+
-+
-+
-+
-+
-+
-+ destroy
-+ restart
-+ destroy
-+
-+ /usr/bin/qemu-system-x86_64
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-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
-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 or . And in
-those cases the guest can modify the settings itself.
-
-Signed-off-by: Martin Kletzander
-(cherry picked from commit 523c9960621eaf307ae8d4ae2735fb66f89d5634)
-Signed-off-by: Martin Kletzander
-Signed-off-by: Jiri Denemark
----
- 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
- Since 3.1.0
-
-
-+
-+ This element provides means of setting coalesce settings for
-+ some interface devices (currently only type network
-+ and bridge. Currently there is just one attribute,
-+ max, to tweak, in element frames for
-+ the rx group, which accepts a non-negative integer
-+ that specifies the maximum number of packets that will be
-+ received before an interrupt.
-+ Since 3.3.0
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-
-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, "\n");
-+ virBufferAdjustIndent(buf, 2);
-+
-+ virBufferAddLit(buf, "\n");
-+ virBufferAdjustIndent(buf, 2);
-+
-+ virBufferAsprintf(buf, "\n",
-+ coalesce->rx_max_coalesced_frames);
-+
-+ virBufferAdjustIndent(buf, -2);
-+ virBufferAddLit(buf, "\n");
-+
-+ virBufferAdjustIndent(buf, -2);
-+ virBufferAddLit(buf, "\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, "\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 @@
-+
-+ test
-+ 15d091de-0181-456b-9554-e4382dc1f1ab
-+ 1048576
-+ 1048576
-+ 1
-+
-+ hvm
-+
-+
-+
-+
-+
-+ destroy
-+ restart
-+ restart
-+
-+ /usr/bin/qemu-system-x86_64
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-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 @@
-+
-+ test
-+ 15d091de-0181-456b-9554-e4382dc1f1ab
-+ 1048576
-+ 1048576
-+ 1
-+
-+ hvm
-+
-+
-+
-+
-+
-+ destroy
-+ restart
-+ restart
-+
-+ /usr/bin/qemu-system-x86_64
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-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:
-From: Laine Stump
-Date: Tue, 2 May 2017 12:33:11 -0400
-Subject: [PATCH] conf: don't ignore 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
----
- 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 should not
-- start with either 'vnet' or 'vif', 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',
-+ which are prefixes reserved by libvirt and certain hypervisors.
-+ Manually specified targets using these prefixes may be ignored.
-
-
-
-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:
+From: Pavel Hrdina
+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
+Signed-off-by: Pavel Hrdina
+(cherry picked from commit cb06ea57ad80a964028f22fb49d6ab96648ae741)
+Signed-off-by: Pavel Hrdina
+Signed-off-by: Jiri Denemark
+---
+ 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:
+From: Pavel Hrdina
+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
+(cherry picked from commit bbf6573e94528ac8a8867855e6671b48e13f1cd1)
+Signed-off-by: Pavel Hrdina
+Reviewed-by: Erik Skultety
+Signed-off-by: Jiri Denemark
+---
+ 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
new file mode 100644
index 0000000..edf12a0
--- /dev/null
+++ b/SOURCES/libvirt-conf-include-x86-microcode-version-in-virsh-capabiltiies.patch
@@ -0,0 +1,133 @@
+From 4f1684dd855d48517e04507edadba2fd454e4ada Mon Sep 17 00:00:00 2001
+Message-Id: <4f1684dd855d48517e04507edadba2fd454e4ada@dist-git>
+From: Paolo Bonzini
+Date: Tue, 12 Dec 2017 16:23:40 +0100
+Subject: [PATCH] conf: include x86 microcode version in virsh capabiltiies
+
+A microcode update can cause the CPUID bits to change; an example
+from the past was the update that disabled TSX on several Haswell and
+Broadwell machines.
+
+In order to track the x86 microcode version in the QEMU capabilities,
+we have to fetch it and store it in the host CPU. This also makes the
+version visible in "virsh capabilities", which is a nice side effect.
+
+CVE-2017-5715
+
+Signed-off-by: Paolo Bonzini
+Signed-off-by: Jiri Denemark
+---
+ 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/cpu_conf.c b/src/conf/cpu_conf.c
+index 669935acf8..7e00299c66 100644
+--- a/src/conf/cpu_conf.c
++++ b/src/conf/cpu_conf.c
+@@ -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;
++ dst->microcodeVersion = src->microcodeVersion;
+ dst->nfeatures_max = src->nfeatures;
+ dst->nfeatures = 0;
+
+@@ -181,6 +182,7 @@ virCPUDefStealModel(virCPUDefPtr dst,
+
+ VIR_STEAL_PTR(dst->model, src->model);
+ VIR_STEAL_PTR(dst->features, src->features);
++ dst->microcodeVersion = src->microcodeVersion;
+ dst->nfeatures_max = src->nfeatures_max;
+ src->nfeatures_max = 0;
+ dst->nfeatures = src->nfeatures;
+@@ -382,6 +384,14 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
+ goto cleanup;
+ }
+ VIR_FREE(arch);
++
++ if (virXPathBoolean("boolean(./microcode[1]/@version)", ctxt) > 0 &&
++ virXPathUInt("string(./microcode[1]/@version)", ctxt,
++ &def->microcodeVersion) < 0) {
++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
++ _("invalid microcode version"));
++ goto cleanup;
++ }
+ }
+
+ if (!(def->model = virXPathString("string(./model[1])", ctxt)) &&
+@@ -720,6 +730,10 @@ virCPUDefFormatBuf(virBufferPtr buf,
+ if (formatModel && def->vendor)
+ virBufferEscapeString(buf, "%s\n", def->vendor);
+
++ if (def->type == VIR_CPU_TYPE_HOST && def->microcodeVersion)
++ virBufferAsprintf(buf, "\n",
++ def->microcodeVersion);
++
+ if (def->sockets && def->cores && def->threads) {
+ virBufferAddLit(buf, "sockets);
+diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
+index d1983f5d4f..9f2e7ee264 100644
+--- a/src/conf/cpu_conf.h
++++ b/src/conf/cpu_conf.h
+@@ -133,6 +133,7 @@ struct _virCPUDef {
+ char *vendor_id; /* vendor id returned by CPUID in the guest */
+ int fallback; /* enum virCPUFallback */
+ char *vendor;
++ unsigned int microcodeVersion;
+ unsigned int sockets;
+ unsigned int cores;
+ unsigned int threads;
+diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
+index 693e571a3d..ad35532fc1 100644
+--- a/src/cpu/cpu_x86.c
++++ b/src/cpu/cpu_x86.c
+@@ -33,6 +33,7 @@
+ #include "virbuffer.h"
+ #include "virendian.h"
+ #include "virstring.h"
++#include "virhostcpu.h"
+
+ #define VIR_FROM_THIS VIR_FROM_CPU
+
+@@ -153,6 +154,8 @@ struct _virCPUx86Map {
+ };
+
+ static virCPUx86MapPtr cpuMap;
++static unsigned int microcodeVersion;
++
+ int virCPUx86DriverOnceInit(void);
+ VIR_ONCE_GLOBAL_INIT(virCPUx86Driver);
+
+@@ -1409,6 +1412,8 @@ virCPUx86DriverOnceInit(void)
+ if (!(cpuMap = virCPUx86LoadMap()))
+ return -1;
+
++ microcodeVersion = virHostCPUGetMicrocodeVersion();
++
+ return 0;
+ }
+
+@@ -2424,6 +2429,9 @@ virCPUx86GetHost(virCPUDefPtr cpu,
+ virCPUDataPtr cpuData = NULL;
+ int ret = -1;
+
++ if (virCPUx86DriverInitialize() < 0)
++ goto cleanup;
++
+ if (!(cpuData = virCPUDataNew(archs[0])))
+ goto cleanup;
+
+@@ -2432,6 +2440,7 @@ virCPUx86GetHost(virCPUDefPtr cpu,
+ goto cleanup;
+
+ ret = x86DecodeCPUData(cpu, cpuData, models);
++ cpu->microcodeVersion = microcodeVersion;
+
+ cleanup:
+ virCPUx86DataFree(cpuData);
+--
+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?=
-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 subelement of
-to make adding new options easier.
-
-(cherry picked from commit fe262186dccfa5c5cbcfe5ab7eb95195cf3b10f5)
-Signed-off-by: Ján Tomko
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-Signed-off-by: Jiri Denemark
----
- 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, "\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, "\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
+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
+(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:
-From: Erik Skultety
-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
-(cherry picked from commit bfaaaf108da087c38cc0f2890ed96730a3734ba8)
-Signed-off-by: Erik Skultety
-Signed-off-by: Jiri Denemark
----
- 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, "%s\n",
-+ data->system.product_name);
-+ virBufferAddLit(buf, "\n");
-+ virBufferAdjustIndent(buf, 2);
-+ if (data->system.hardware.vendor_name)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->system.hardware.vendor_name);
-+ if (data->system.hardware.version)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->system.hardware.version);
-+ if (data->system.hardware.serial)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->system.hardware.serial);
-+ virUUIDFormat(data->system.hardware.uuid, uuidstr);
-+ virBufferAsprintf(buf, "%s\n", uuidstr);
-+ virBufferAdjustIndent(buf, -2);
-+ virBufferAddLit(buf, "\n");
-+
-+ virBufferAddLit(buf, "\n");
-+ virBufferAdjustIndent(buf, 2);
-+ if (data->system.firmware.vendor_name)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->system.firmware.vendor_name);
-+ if (data->system.firmware.version)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->system.firmware.version);
-+ if (data->system.firmware.release_date)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->system.firmware.release_date);
-+ virBufferAdjustIndent(buf, -2);
-+ virBufferAddLit(buf, "\n");
-+}
-+
-+
-+static void
-+virNodeDeviceCapPCIDefFormat(virBufferPtr buf,
-+ const virNodeDevCapData *data)
-+{
-+ size_t i;
-+
-+ virBufferAsprintf(buf, "%d\n",
-+ data->pci_dev.domain);
-+ virBufferAsprintf(buf, "%d\n", data->pci_dev.bus);
-+ virBufferAsprintf(buf, "%d\n",
-+ data->pci_dev.slot);
-+ virBufferAsprintf(buf, "%d\n",
-+ data->pci_dev.function);
-+ virBufferAsprintf(buf, "pci_dev.product);
-+ if (data->pci_dev.product_name)
-+ virBufferEscapeString(buf, ">%s\n",
-+ data->pci_dev.product_name);
-+ else
-+ virBufferAddLit(buf, " />\n");
-+ virBufferAsprintf(buf, "pci_dev.vendor);
-+ if (data->pci_dev.vendor_name)
-+ virBufferEscapeString(buf, ">%s\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, "\n");
-+ virBufferAdjustIndent(buf, 2);
-+ virBufferAsprintf(buf,
-+ "\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, "\n");
-+ }
-+ if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION) {
-+ virBufferAddLit(buf, "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,
-+ "\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, "\n");
-+ }
-+ }
-+ if (data->pci_dev.hdrType) {
-+ virBufferAsprintf(buf, "\n",
-+ virPCIHeaderTypeToString(data->pci_dev.hdrType));
-+ }
-+ if (data->pci_dev.nIommuGroupDevices) {
-+ virBufferAsprintf(buf, "\n",
-+ data->pci_dev.iommuGroupNumber);
-+ virBufferAdjustIndent(buf, 2);
-+ for (i = 0; i < data->pci_dev.nIommuGroupDevices; i++) {
-+ virBufferAsprintf(buf,
-+ "\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, "\n");
-+ }
-+ if (data->pci_dev.numa_node >= 0)
-+ virBufferAsprintf(buf, "\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, "%d\n", data->usb_dev.bus);
-+ virBufferAsprintf(buf, "%d\n",
-+ data->usb_dev.device);
-+ virBufferAsprintf(buf, "usb_dev.product);
-+ if (data->usb_dev.product_name)
-+ virBufferEscapeString(buf, ">%s\n",
-+ data->usb_dev.product_name);
-+ else
-+ virBufferAddLit(buf, " />\n");
-+ virBufferAsprintf(buf, "usb_dev.vendor);
-+ if (data->usb_dev.vendor_name)
-+ virBufferEscapeString(buf, ">%s\n",
-+ data->usb_dev.vendor_name);
-+ else
-+ virBufferAddLit(buf, " />\n");
-+}
-+
-+
-+static void
-+virNodeDeviceCapUSBInterfaceDefFormat(virBufferPtr buf,
-+ const virNodeDevCapData *data)
-+{
-+ virBufferAsprintf(buf, "%d\n",
-+ data->usb_if.number);
-+ virBufferAsprintf(buf, "%d\n",
-+ data->usb_if._class);
-+ virBufferAsprintf(buf, "%d\n",
-+ data->usb_if.subclass);
-+ virBufferAsprintf(buf, "%d\n",
-+ data->usb_if.protocol);
-+ if (data->usb_if.description)
-+ virBufferEscapeString(buf,
-+ "%s\n",
-+ data->usb_if.description);
-+}
-+
-+
-+static void
-+virNodeDeviceCapNetDefFormat(virBufferPtr buf,
-+ const virNodeDevCapData *data)
-+{
-+ size_t i;
-+
-+ virBufferEscapeString(buf, "%s\n",
-+ data->net.ifname);
-+ if (data->net.address)
-+ virBufferEscapeString(buf, "%s\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, "\n",
-+ virNetDevFeatureTypeToString(i));
-+ }
-+ }
-+ }
-+ if (data->net.subtype != VIR_NODE_DEV_CAP_NET_LAST) {
-+ const char *subtyp =
-+ virNodeDevNetCapTypeToString(data->net.subtype);
-+ virBufferEscapeString(buf, "\n",
-+ subtyp);
-+ }
-+}
-+
-+
-+static void
-+virNodeDeviceCapSCSIHostDefFormat(virBufferPtr buf,
-+ const virNodeDevCapData *data)
-+{
-+ virBufferAsprintf(buf, "%d\n",
-+ data->scsi_host.host);
-+ if (data->scsi_host.unique_id != -1)
-+ virBufferAsprintf(buf, "%d\n",
-+ data->scsi_host.unique_id);
-+ if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
-+ virBufferAddLit(buf, "\n");
-+ virBufferAdjustIndent(buf, 2);
-+ virBufferEscapeString(buf, "%s\n",
-+ data->scsi_host.wwnn);
-+ virBufferEscapeString(buf, "%s\n",
-+ data->scsi_host.wwpn);
-+ virBufferEscapeString(buf, "%s\n",
-+ data->scsi_host.fabric_wwn);
-+ virBufferAdjustIndent(buf, -2);
-+ virBufferAddLit(buf, "\n");
-+ }
-+ if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) {
-+ virBufferAddLit(buf, "\n");
-+ virBufferAdjustIndent(buf, 2);
-+ virBufferAsprintf(buf, "%d\n",
-+ data->scsi_host.max_vports);
-+ virBufferAsprintf(buf, "%d\n",
-+ data->scsi_host.vports);
-+ virBufferAdjustIndent(buf, -2);
-+ virBufferAddLit(buf, "\n");
-+ }
-+}
-+
-+
-+static void
-+virNodeDeviceCapSCSIDefFormat(virBufferPtr buf,
-+ const virNodeDevCapData *data)
-+{
-+ virBufferAsprintf(buf, "%d\n", data->scsi.host);
-+ virBufferAsprintf(buf, "%d\n", data->scsi.bus);
-+ virBufferAsprintf(buf, "%d\n",
-+ data->scsi.target);
-+ virBufferAsprintf(buf, "%d\n", data->scsi.lun);
-+ if (data->scsi.type)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->scsi.type);
-+}
-+
-+
-+static void
-+virNodeDeviceCapStorageDefFormat(virBufferPtr buf,
-+ const virNodeDevCapData *data)
-+{
-+ virBufferEscapeString(buf, "%s\n",
-+ data->storage.block);
-+ if (data->storage.bus)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->storage.bus);
-+ if (data->storage.drive_type)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->storage.drive_type);
-+ if (data->storage.model)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->storage.model);
-+ if (data->storage.vendor)
-+ virBufferEscapeString(buf, "%s\n",
-+ data->storage.vendor);
-+ if (data->storage.serial)
-+ virBufferEscapeString(buf, "%s\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, "\n");
-+ virBufferAdjustIndent(buf, 2);
-+ virBufferAsprintf(buf, "%d"
-+ "\n", avl ? 1 : 0);
-+ virBufferAsprintf(buf, "%llu\n",
-+ data->storage.removable_media_size);
-+ if (data->storage.media_label)
-+ virBufferEscapeString(buf,
-+ "%s\n",
-+ data->storage.media_label);
-+ if (data->storage.logical_block_size > 0)
-+ virBufferAsprintf(buf, "%llu"
-+ "\n",
-+ data->storage.logical_block_size);
-+ if (data->storage.num_blocks > 0)
-+ virBufferAsprintf(buf,
-+ "%llu\n",
-+ data->storage.num_blocks);
-+ virBufferAdjustIndent(buf, -2);
-+ virBufferAddLit(buf, "\n");
-+ } else {
-+ virBufferAsprintf(buf, "%llu\n",
-+ data->storage.size);
-+ if (data->storage.logical_block_size > 0)
-+ virBufferAsprintf(buf, "%llu"
-+ "\n",
-+ data->storage.logical_block_size);
-+ if (data->storage.num_blocks > 0)
-+ virBufferAsprintf(buf, "%llu\n",
-+ data->storage.num_blocks);
-+ }
-+ if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE)
-+ virBufferAddLit(buf, "\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, "\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, "%s\n",
-- data->system.product_name);
-- virBufferAddLit(&buf, "\n");
-- virBufferAdjustIndent(&buf, 2);
-- if (data->system.hardware.vendor_name)
-- virBufferEscapeString(&buf, "%s\n",
-- data->system.hardware.vendor_name);
-- if (data->system.hardware.version)
-- virBufferEscapeString(&buf, "%s\n",
-- data->system.hardware.version);
-- if (data->system.hardware.serial)
-- virBufferEscapeString(&buf, "%s\n",
-- data->system.hardware.serial);
-- virUUIDFormat(data->system.hardware.uuid, uuidstr);
-- virBufferAsprintf(&buf, "%s\n", uuidstr);
-- virBufferAdjustIndent(&buf, -2);
-- virBufferAddLit(&buf, "\n");
--
-- virBufferAddLit(&buf, "\n");
-- virBufferAdjustIndent(&buf, 2);
-- if (data->system.firmware.vendor_name)
-- virBufferEscapeString(&buf, "%s\n",
-- data->system.firmware.vendor_name);
-- if (data->system.firmware.version)
-- virBufferEscapeString(&buf, "%s\n",
-- data->system.firmware.version);
-- if (data->system.firmware.release_date)
-- virBufferEscapeString(&buf, "%s\n",
-- data->system.firmware.release_date);
-- virBufferAdjustIndent(&buf, -2);
-- virBufferAddLit(&buf, "\n");
-+ virNodeDeviceCapSystemDefFormat(&buf, data);
- break;
- case VIR_NODE_DEV_CAP_PCI_DEV:
-- virBufferAsprintf(&buf, "%d\n",
-- data->pci_dev.domain);
-- virBufferAsprintf(&buf, "%d\n", data->pci_dev.bus);
-- virBufferAsprintf(&buf, "%d\n",
-- data->pci_dev.slot);
-- virBufferAsprintf(&buf, "%d\n",
-- data->pci_dev.function);
-- virBufferAsprintf(&buf, "pci_dev.product);
-- if (data->pci_dev.product_name)
-- virBufferEscapeString(&buf, ">%s\n",
-- data->pci_dev.product_name);
-- else
-- virBufferAddLit(&buf, " />\n");
-- virBufferAsprintf(&buf, "pci_dev.vendor);
-- if (data->pci_dev.vendor_name)
-- virBufferEscapeString(&buf, ">%s\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, "\n");
-- virBufferAdjustIndent(&buf, 2);
-- virBufferAsprintf(&buf,
-- "\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, "\n");
-- }
-- if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION) {
-- virBufferAddLit(&buf, "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,
-- "\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, "\n");
-- }
-- }
-- if (data->pci_dev.hdrType) {
-- virBufferAsprintf(&buf, "\n",
-- virPCIHeaderTypeToString(data->pci_dev.hdrType));
-- }
-- if (data->pci_dev.nIommuGroupDevices) {
-- virBufferAsprintf(&buf, "\n",
-- data->pci_dev.iommuGroupNumber);
-- virBufferAdjustIndent(&buf, 2);
-- for (i = 0; i < data->pci_dev.nIommuGroupDevices; i++) {
-- virBufferAsprintf(&buf,
-- "\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, "\n");
-- }
-- if (data->pci_dev.numa_node >= 0)
-- virBufferAsprintf(&buf, "\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, "%d\n", data->usb_dev.bus);
-- virBufferAsprintf(&buf, "%d\n",
-- data->usb_dev.device);
-- virBufferAsprintf(&buf, "usb_dev.product);
-- if (data->usb_dev.product_name)
-- virBufferEscapeString(&buf, ">%s\n",
-- data->usb_dev.product_name);
-- else
-- virBufferAddLit(&buf, " />\n");
-- virBufferAsprintf(&buf, "usb_dev.vendor);
-- if (data->usb_dev.vendor_name)
-- virBufferEscapeString(&buf, ">%s\n",
-- data->usb_dev.vendor_name);
-- else
-- virBufferAddLit(&buf, " />\n");
-+ virNodeDeviceCapUSBDevDefFormat(&buf, data);
- break;
- case VIR_NODE_DEV_CAP_USB_INTERFACE:
-- virBufferAsprintf(&buf, "%d\n",
-- data->usb_if.number);
-- virBufferAsprintf(&buf, "%d\n",
-- data->usb_if._class);
-- virBufferAsprintf(&buf, "%d\n",
-- data->usb_if.subclass);
-- virBufferAsprintf(&buf, "%d\n",
-- data->usb_if.protocol);
-- if (data->usb_if.description)
-- virBufferEscapeString(&buf,
-- "%s\n",
-- data->usb_if.description);
-+ virNodeDeviceCapUSBInterfaceDefFormat(&buf, data);
- break;
- case VIR_NODE_DEV_CAP_NET:
-- virBufferEscapeString(&buf, "%s\n",
-- data->net.ifname);
-- if (data->net.address)
-- virBufferEscapeString(&buf, "%s\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, "\n",
-- virNetDevFeatureTypeToString(i));
-- }
-- }
-- }
-- if (data->net.subtype != VIR_NODE_DEV_CAP_NET_LAST) {
-- const char *subtyp =
-- virNodeDevNetCapTypeToString(data->net.subtype);
-- virBufferEscapeString(&buf, "\n",
-- subtyp);
-- }
-+ virNodeDeviceCapNetDefFormat(&buf, data);
- break;
- case VIR_NODE_DEV_CAP_SCSI_HOST:
-- virBufferAsprintf(&buf, "%d\n",
-- data->scsi_host.host);
-- if (data->scsi_host.unique_id != -1)
-- virBufferAsprintf(&buf, "%d\n",
-- data->scsi_host.unique_id);
-- if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
-- virBufferAddLit(&buf, "\n");
-- virBufferAdjustIndent(&buf, 2);
-- virBufferEscapeString(&buf, "%s\n",
-- data->scsi_host.wwnn);
-- virBufferEscapeString(&buf, "%s\n",
-- data->scsi_host.wwpn);
-- virBufferEscapeString(&buf, "%s\n",
-- data->scsi_host.fabric_wwn);
-- virBufferAdjustIndent(&buf, -2);
-- virBufferAddLit(&buf, "\n");
-- }
-- if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) {
-- virBufferAddLit(&buf, "\n");
-- virBufferAdjustIndent(&buf, 2);
-- virBufferAsprintf(&buf, "%d\n",
-- data->scsi_host.max_vports);
-- virBufferAsprintf(&buf, "%d\n",
-- data->scsi_host.vports);
-- virBufferAdjustIndent(&buf, -2);
-- virBufferAddLit(&buf, "\n");
-- }
--
-+ virNodeDeviceCapSCSIHostDefFormat(&buf, data);
- break;
--
- case VIR_NODE_DEV_CAP_SCSI_TARGET:
- virBufferEscapeString(&buf, "%s\n",
- data->scsi_target.name);
- break;
--
- case VIR_NODE_DEV_CAP_SCSI:
-- virBufferAsprintf(&buf, "%d\n", data->scsi.host);
-- virBufferAsprintf(&buf, "%d\n", data->scsi.bus);
-- virBufferAsprintf(&buf, "%d\n",
-- data->scsi.target);
-- virBufferAsprintf(&buf, "%d\n", data->scsi.lun);
-- if (data->scsi.type)
-- virBufferEscapeString(&buf, "%s\n",
-- data->scsi.type);
-+ virNodeDeviceCapSCSIDefFormat(&buf, data);
- break;
- case VIR_NODE_DEV_CAP_STORAGE:
-- virBufferEscapeString(&buf, "%s\n",
-- data->storage.block);
-- if (data->storage.bus)
-- virBufferEscapeString(&buf, "%s\n",
-- data->storage.bus);
-- if (data->storage.drive_type)
-- virBufferEscapeString(&buf, "%s\n",
-- data->storage.drive_type);
-- if (data->storage.model)
-- virBufferEscapeString(&buf, "%s\n",
-- data->storage.model);
-- if (data->storage.vendor)
-- virBufferEscapeString(&buf, "%s\n",
-- data->storage.vendor);
-- if (data->storage.serial)
-- virBufferEscapeString(&buf, "%s\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, "\n");
-- virBufferAdjustIndent(&buf, 2);
-- virBufferAsprintf(&buf, "%d"
-- "\n", avl ? 1 : 0);
-- virBufferAsprintf(&buf, "%llu\n",
-- data->storage.removable_media_size);
-- if (data->storage.media_label)
-- virBufferEscapeString(&buf,
-- "%s\n",
-- data->storage.media_label);
-- if (data->storage.logical_block_size > 0)
-- virBufferAsprintf(&buf, "%llu"
-- "\n",
-- data->storage.logical_block_size);
-- if (data->storage.num_blocks > 0)
-- virBufferAsprintf(&buf,
-- "%llu\n",
-- data->storage.num_blocks);
-- virBufferAdjustIndent(&buf, -2);
-- virBufferAddLit(&buf, "\n");
-- } else {
-- virBufferAsprintf(&buf, "%llu\n",
-- data->storage.size);
-- if (data->storage.logical_block_size > 0)
-- virBufferAsprintf(&buf, "%llu"
-- "\n",
-- data->storage.logical_block_size);
-- if (data->storage.num_blocks > 0)
-- virBufferAsprintf(&buf, "%llu\n",
-- data->storage.num_blocks);
-- }
-- if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE)
-- virBufferAddLit(&buf, "\n");
-+ virNodeDeviceCapStorageDefFormat(&buf, data);
- break;
- case VIR_NODE_DEV_CAP_SCSI_GENERIC:
- virBufferEscapeString(&buf, "%s\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
+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
+Reviewed-by: Pavel Hrdina
+(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
+---
+ 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:
+From: Michal Privoznik
+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
+Reviewed-by: John Ferlan
+(cherry picked from commit fe70fd0c106e7fbe4f7272e5c041324ea3633ce4)
+Signed-off-by: Michal Privoznik
+Signed-off-by: Jiri Denemark
+---
+ 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?=
-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
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1427005
-Signed-off-by: Jiri Denemark
----
- 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?=
-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
-(cherry picked from commit d1feb4773d41b928dc1079dfc19d17b5a0e5957b)
-Signed-off-by: Ján Tomko
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1283251
-Signed-off-by: Jiri Denemark
----
- 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, "\n", str);
-+ virBufferAsprintf(buf, "\n", str);
- } else {
- if (str)
-- virBufferAsprintf(buf, "\n", str);
-+ virBufferAsprintf(buf, "\n", str);
- else
- virBufferAddLit(buf, "\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
-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
-(cherry picked from commit 232d87c7dd081d126a079fb45178e0be096cc680)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark
----
- 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
-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
-(cherry picked from commit 05e91c79f19e0be96526098d58a3498dac3f8529)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark
----
- 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
-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
-(cherry picked from commit bf1a881715c905c67f7d38dcd5bd6c2afbff1f9b)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1444421
-
-Signed-off-by: Jiri Denemark
----
- 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
new file mode 100644
index 0000000..a915513
--- /dev/null
+++ b/SOURCES/libvirt-cpu-add-CPU-features-and-model-for-indirect-branch-prediction-protection.patch
@@ -0,0 +1,171 @@
+From 9df09ec5e1afef8659271c6cc4a5b741d5d06815 Mon Sep 17 00:00:00 2001
+Message-Id: <9df09ec5e1afef8659271c6cc4a5b741d5d06815@dist-git>
+From: Paolo Bonzini
+Date: Tue, 12 Dec 2017 16:23:42 +0100
+Subject: [PATCH] cpu: add CPU features and model for indirect branch
+ prediction protection
+
+CVE-2017-5715
+
+Signed-off-by: Paolo Bonzini
+Signed-off-by: Jiri Denemark
+---
+ 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 96f4ce60dd..a7888ec134 100644
+--- a/src/cpu/cpu_map.xml
++++ b/src/cpu/cpu_map.xml
+@@ -292,6 +292,15 @@
+
+
+
++
++
++
++
++
++
++
++
++
+
+
+
+@@ -420,6 +429,11 @@
+
+
+
++
++
++
++
++
+
+
+
+@@ -866,6 +880,10 @@
+
+
+
++
++
++
++
+
+
+
+@@ -903,6 +921,10 @@
+
+
+
++
++
++
++
+
+
+
+@@ -946,6 +968,10 @@
+
+
+
++
++
++
++
+
+
+
+@@ -995,6 +1021,10 @@
+
+
+
++
++
++
++
+
+
+
+@@ -1048,6 +1078,10 @@
+
+
+
++
++
++
++
+
+
+
+@@ -1103,6 +1137,10 @@
+
+
+
++
++
++
++
+
+
+
+@@ -1160,6 +1198,10 @@
+
+
+
++
++
++
++
+
+
+
+@@ -1219,6 +1261,10 @@
+
+
+
++
++
++
++
+
+
+
+@@ -1287,6 +1333,10 @@
+
+
+
++
++
++
++
+
+
+
+@@ -1362,6 +1412,10 @@
+
+
+
++
++
++
++
+
+
+
+@@ -1700,6 +1754,10 @@
+
+
+
++
++
++
++
+
+
+
+--
+2.15.1
+
diff --git a/SOURCES/libvirt-cpu_ppc64-Add-support-for-host-model-on-POWER9.patch b/SOURCES/libvirt-cpu_ppc64-Add-support-for-host-model-on-POWER9.patch
deleted file mode 100644
index db7e944..0000000
--- a/SOURCES/libvirt-cpu_ppc64-Add-support-for-host-model-on-POWER9.patch
+++ /dev/null
@@ -1,182 +0,0 @@
-From 3feb7797cfe7ac9cfd05fbc5d008527b1a88c06a Mon Sep 17 00:00:00 2001
-Message-Id: <3feb7797cfe7ac9cfd05fbc5d008527b1a88c06a@dist-git>
-From: Jiri Denemark
-Date: Wed, 17 May 2017 16:39:16 +0200
-Subject: [PATCH] cpu_ppc64: Add support for host-model on POWER9
-
-Signed-off-by: Jiri Denemark
-(cherry picked from commit 5c8c2d1633f3d2500e49132296793fc267648d2b)
-
-https://bugzilla.redhat.com/show_bug.cgi?id=1450770
-
-Signed-off-by: Jiri Denemark
----
- src/cpu/cpu_ppc64.c | 8 ++++----
- .../qemuxml2argv-pseries-cpu-compat-power9.args | 24 ++++++++++++++++++++++
- .../qemuxml2argv-pseries-cpu-compat-power9.xml | 21 +++++++++++++++++++
- tests/qemuxml2argvtest.c | 7 +++++++
- tests/testutilsqemu.c | 13 +++++++++++-
- tests/testutilsqemu.h | 1 +
- 6 files changed, 69 insertions(+), 5 deletions(-)
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
- create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml
-
-diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
-index f64592b558..bf08599049 100644
---- a/src/cpu/cpu_ppc64.c
-+++ b/src/cpu/cpu_ppc64.c
-@@ -92,22 +92,22 @@ ppc64CheckCompatibilityMode(const char *host_model,
- if (!compat_mode)
- return VIR_CPU_COMPARE_IDENTICAL;
-
-- /* Valid host CPUs: POWER6, POWER7, POWER8 */
-+ /* Valid host CPUs: POWER6, POWER7, POWER8, POWER9 */
- if (!STRPREFIX(host_model, "POWER") ||
- !(tmp = (char *) host_model + strlen("POWER")) ||
- virStrToLong_i(tmp, NULL, 10, &host) < 0 ||
-- host < 6 || host > 8) {
-+ host < 6 || host > 9) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s",
- _("Host CPU does not support compatibility modes"));
- goto out;
- }
-
-- /* Valid compatibility modes: power6, power7, power8 */
-+ /* Valid compatibility modes: power6, power7, power8, power9 */
- if (!STRPREFIX(compat_mode, "power") ||
- !(tmp = (char *) compat_mode + strlen("power")) ||
- virStrToLong_i(tmp, NULL, 10, &compat) < 0 ||
-- compat < 6 || compat > 8) {
-+ compat < 6 || compat > 9) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unknown compatibility mode %s"),
- compat_mode);
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
-new file mode 100644
-index 0000000000..af93d63dc9
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.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-ppc64 \
-+-name QEMUGuest1 \
-+-S \
-+-M pseries \
-+-cpu host,compat=power9 \
-+-m 256 \
-+-smp 4,sockets=4,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 \
-+-usb \
-+-chardev pty,id=charserial0 \
-+-device spapr-vty,chardev=charserial0,reg=0x30000000
-diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml
-new file mode 100644
-index 0000000000..30ab5c2679
---- /dev/null
-+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml
-@@ -0,0 +1,21 @@
-+
-+ QEMUGuest1
-+ c7a5fdbd-edaf-9455-926a-d65c16db1809
-+ 219100
-+ 219100
-+ 4
-+
-+ hvm
-+
-+
-+ power9
-+
-+
-+
-+ /usr/bin/qemu-system-ppc64
-+
-+
-+
-+
-+
-+
-diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
-index 5ca27f105d..6ac24c9bb0 100644
---- a/tests/qemuxml2argvtest.c
-+++ b/tests/qemuxml2argvtest.c
-@@ -1688,6 +1688,13 @@ mymain(void)
- QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
- DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
- QEMU_CAPS_CHARDEV, 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_CHARDEV, QEMU_CAPS_NODEFCONFIG);
-+ qemuTestSetHostCPU(driver.caps, NULL);
-+
- qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
-
- DO_TEST("pseries-panic-missing",
-diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
-index 4cc482dfb0..fe2941efbf 100644
---- a/tests/testutilsqemu.c
-+++ b/tests/testutilsqemu.c
-@@ -17,6 +17,7 @@
- virCPUDefPtr cpuDefault;
- virCPUDefPtr cpuHaswell;
- virCPUDefPtr cpuPower8;
-+virCPUDefPtr cpuPower9;
-
- static virCPUFeatureDef cpuDefaultFeatures[] = {
- { (char *) "ds", -1 },
-@@ -94,6 +95,15 @@ static virCPUDef cpuPower8Data = {
- .threads = 8,
- };
-
-+static virCPUDef cpuPower9Data = {
-+ .type = VIR_CPU_TYPE_HOST,
-+ .arch = VIR_ARCH_PPC64,
-+ .model = (char *) "POWER9",
-+ .sockets = 1,
-+ .cores = 16,
-+ .threads = 1,
-+};
-+
- static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines)
- {
- virCapsGuestMachinePtr *machines;
-@@ -334,7 +344,8 @@ virCapsPtr testQemuCapsInit(void)
-
- if (!(cpuDefault = virCPUDefCopy(&cpuDefaultData)) ||
- !(cpuHaswell = virCPUDefCopy(&cpuHaswellData)) ||
-- !(cpuPower8 = virCPUDefCopy(&cpuPower8Data)))
-+ !(cpuPower8 = virCPUDefCopy(&cpuPower8Data)) ||
-+ !(cpuPower9 = virCPUDefCopy(&cpuPower9Data)))
- goto cleanup;
-
- qemuTestSetHostCPU(caps, NULL);
-diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
-index 047a64d1ac..781b435cc2 100644
---- a/tests/testutilsqemu.h
-+++ b/tests/testutilsqemu.h
-@@ -21,6 +21,7 @@ virQEMUCapsPtr qemuTestParseCapabilities(virCapsPtr caps,
- extern virCPUDefPtr cpuDefault;
- extern virCPUDefPtr cpuHaswell;
- extern virCPUDefPtr cpuPower8;
-+extern virCPUDefPtr cpuPower9;
-
- void qemuTestSetHostArch(virCapsPtr caps,
- virArch arch);
---
-2.13.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
new file mode 100644
index 0000000..b81e716
--- /dev/null
+++ b/SOURCES/libvirt-cpu_x86-Copy-CPU-signature-from-ancestor.patch
@@ -0,0 +1,47 @@
+From 38b3d773dddd7f3cfe715b9cbabaa296c16c1290 Mon Sep 17 00:00:00 2001
+Message-Id: <38b3d773dddd7f3cfe715b9cbabaa296c16c1290@dist-git>
+From: Jiri Denemark
+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
+existing model, we forgot to copy the signature (family + model) from
+the original CPU model.
+
+We don't use this way of specifying CPU models, but it's still supported
+and it becomes useful when someone wants to quickly hack up a CPU model
+for testing or when creating additional variants of existing models to
+help with fixing some spectral issues.
+
+Signed-off-by: Jiri Denemark
+Reviewed-by: Pavel Hrdina
+(cherry picked from commit b427cf4831d0ea7aac9dd1a3aa7682478356a483)
+
+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
+signature of the original model from cpu_map.xml, libvirt will detect
+the host CPU as the original model + the new feature rather than
+reporting it as the -IBRS/-IBPB variant.
+
+Signed-off-by: Jiri Denemark
+---
+ src/cpu/cpu_x86.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
+index ad35532fc1..001109f701 100644
+--- a/src/cpu/cpu_x86.c
++++ b/src/cpu/cpu_x86.c
+@@ -1227,6 +1227,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
+ VIR_FREE(name);
+
+ model->vendor = ancestor->vendor;
++ model->signature = ancestor->signature;
+ if (x86DataCopy(&model->data, &ancestor->data) < 0)
+ goto error;
+ }
+--
+2.15.1
+
diff --git a/SOURCES/libvirt-cpu_x86-Rename-virCPUx86MapInitialize.patch b/SOURCES/libvirt-cpu_x86-Rename-virCPUx86MapInitialize.patch
new file mode 100644
index 0000000..b757b16
--- /dev/null
+++ b/SOURCES/libvirt-cpu_x86-Rename-virCPUx86MapInitialize.patch
@@ -0,0 +1,52 @@
+From b200b9cbb5c6c7d3d3b1bb4f745a7371cc35a429 Mon Sep 17 00:00:00 2001
+Message-Id:
+From: Jiri Denemark
+Date: Wed, 13 Dec 2017 22:30:31 +0100
+Subject: [PATCH] cpu_x86: Rename virCPUx86MapInitialize
+
+The function will be used to initialize internal data of the x86 CPU
+driver (including the CPU map).
+
+CVE-2017-5715
+
+Signed-off-by: Jiri Denemark
+---
+ src/cpu/cpu_x86.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
+index a6cbd45766..693e571a3d 100644
+--- a/src/cpu/cpu_x86.c
++++ b/src/cpu/cpu_x86.c
+@@ -153,8 +153,8 @@ struct _virCPUx86Map {
+ };
+
+ static virCPUx86MapPtr cpuMap;
+-int virCPUx86MapOnceInit(void);
+-VIR_ONCE_GLOBAL_INIT(virCPUx86Map);
++int virCPUx86DriverOnceInit(void);
++VIR_ONCE_GLOBAL_INIT(virCPUx86Driver);
+
+
+ typedef enum {
+@@ -1404,7 +1404,7 @@ virCPUx86LoadMap(void)
+
+
+ int
+-virCPUx86MapOnceInit(void)
++virCPUx86DriverOnceInit(void)
+ {
+ if (!(cpuMap = virCPUx86LoadMap()))
+ return -1;
+@@ -1416,7 +1416,7 @@ virCPUx86MapOnceInit(void)
+ static virCPUx86MapPtr
+ virCPUx86GetMap(void)
+ {
+- if (virCPUx86MapInitialize() < 0)
++ if (virCPUx86DriverInitialize() < 0)
+ return NULL;
+
+ return cpuMap;
+--
+2.15.1
+
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
-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
----
- 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
-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
-(cherry picked from commit 98f424d5038b362d1b62549930d0b9253106bdca)
-Signed-off-by: Jiri Denemark
----
- 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
-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
-(cherry picked from commit f2a123203105b4fe010aea866e87f8bcf5f31193)
-Signed-off-by: Jiri Denemark
----
- 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
-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
-Signed-off-by: Jiri Denemark
----
- 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
-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
-(cherry picked from commit a0a0b3cf71cbee1df40dd0fdebd7bb6a84682f09)
-Signed-off-by: Erik Skultety
-Signed-off-by: Jiri Denemark
----
- 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.
-
-
-
-@@ -75,6 +75,7 @@
- storage (Since 1.0.4),
- scsi_generic (Since 1.0.7),
- drm (Since 3.1.0), and
-+ mdev (Since 3.4.0).
- 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 type attribute which are exclusive.
-@@ -185,5 +186,170 @@
- ...
- <device>
-
-+
-+ A PCI device capable of creating mediated devices will include a nested
-+ capability mdev_types which enumerates all supported mdev
-+ types on the physical device, along with the type attributes available
-+ through sysfs:
-+
-+
-+
-+
type
-+
-+ 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 id which holds
-+ an official vendor-supplied identifier for the type.
-+ Since 3.4.0
-+
-+
-+
name
-+
-+ The name element holds a vendor-supplied code name for
-+ the given mediated device type. This is an optional element.
-+ Since 3.4.0
-+
-+
-+
deviceAPI
-+
-+ The value of this element describes how an instance of the given type
-+ will be presented to the guest by the VFIO framework.
-+ Since 3.4.0
-+
-+
-+
availableInstances
-+
-+ 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.
-+ Since 3.4.0
-+
-+
-+
-+
-+ For a more info about mediated devices, refer to the
-+ paragraph below.
-+
-+
-+
-+<device>
-+...
-+ <driver>
-+ <name>nvidia</name>
-+ </driver>
-+ <capability type='pci'>
-+...
-+ <capability type='mdev_types'>
-+ <type id='nvidia-11'>
-+ <name>GRID M60-0B</name>
-+ <deviceAPI>vfio-pci</deviceAPI>
-+ <availableInstances>16</availableInstances>
-+ </type>
-+ <!-- Here would come the rest of the available mdev types -->
-+ </capability>
-+...
-+ </capability>
-+</device>
-+ Mediated devices (Since 3.2.0) 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.
-+
-+
-+
-+ The following sub-elements and attributes are exposed within the
-+ capability element:
-+
-+
-+
-+
type
-+
-+ 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 id which holds
-+ an official vendor-supplied identifier for the type.
-+ Since 3.4.0
-+
-+
-+
iommuGroup
-+
-+ This element supports a single attribute number which holds
-+ the IOMMU group number the mediated device belongs to.
-+ Since 3.4.0
-+
-+ The support of mediated device's framework in libvirt's node device driver
-+ covers the following features:
-+
-+
-+
-+
-+ list available mediated devices on the host
-+ (Since 3.4.0)
-+
-+
-+ display device details
-+ (Since 3.4.0)
-+
-+
-+
-+
-+ 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 PCI host devices).
-+
-+
-+
-+ To see the supported mediated device types on a specific physical device
-+ use the following:
-+
-+
-+
-+$ ls /sys/class/mdev_bus/<device>/mdev_supported_types
-+
-+
-+ To manually instantiate a mediated device, use one of the following as a
-+ reference:
-+