import libvirt-6.0.0-25.module+el8.3.0+7176+57f10f42

This commit is contained in:
CentOS Sources 2020-07-28 02:55:52 -04:00 committed by Stepan Oksanichenko
parent d954e5c2e6
commit 67ba56b051
969 changed files with 107893 additions and 154833 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/libvirt-4.5.0.tar.xz
SOURCES/libvirt-6.0.0.tar.xz

View File

@ -1 +1 @@
5f097d246c0fba04d18ac7ec951ad56ffa1a8958 SOURCES/libvirt-4.5.0.tar.xz
9939a559e652d44b27e3404a26bcabe58988e4b4 SOURCES/libvirt-6.0.0.tar.xz

View File

@ -1,56 +0,0 @@
From e75abae126f9fcaf1e8478f0780ecae736f7d3e1 Mon Sep 17 00:00:00 2001
Message-Id: <e75abae126f9fcaf1e8478f0780ecae736f7d3e1@dist-git>
From: "Allen, John" <John.Allen@amd.com>
Date: Tue, 2 Jul 2019 17:05:34 +0200
Subject: [PATCH] Handle copying bitmaps to larger data buffers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If a bitmap of a shorter length than the data buffer is passed to
virBitmapToDataBuf, it will read off the end of the bitmap and copy junk
into the returned buffer. Add a check to only copy the length of the
bitmap to the buffer.
The problem can be observed after setting a vcpu affinity using the vcpupin
command on a system with a large number of cores:
# virsh vcpupin example_domain 0 0
# virsh vcpupin example_domain 0
VCPU CPU Affinity
---------------------------
0 0,192,197-198,202
Signed-off-by: John Allen <john.allen@amd.com>
(cherry picked from commit 51f9f80d350e633adf479c6a9b3c55f82ca9cbd4)
https: //bugzilla.redhat.com/show_bug.cgi?id=1703160
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Message-Id: <1a487c4f1ba9725eb7325debeeff2861d7047890.1562079635.git.eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/util/virbitmap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 49e542a4e6..7df0a2d4f3 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -831,11 +831,15 @@ virBitmapToDataBuf(virBitmapPtr bitmap,
unsigned char *bytes,
size_t len)
{
+ size_t nbytes = bitmap->map_len * (VIR_BITMAP_BITS_PER_UNIT / CHAR_BIT);
unsigned long *l;
size_t i, j;
memset(bytes, 0, len);
+ /* If bitmap and buffer differ in size, only fill to the smaller length */
+ len = MIN(len, nbytes);
+
/* htole64 is not provided by gnulib, so we do the conversion by hand */
l = bitmap->map;
for (i = j = 0; i < len; i++, j++) {
--
2.22.0

View File

@ -1,183 +0,0 @@
From 5347b12008842b5c86f766e391c6f3756afbff7d Mon Sep 17 00:00:00 2001
Message-Id: <5347b12008842b5c86f766e391c6f3756afbff7d@dist-git>
From: Daniel Henrique Barboza <danielhb413@gmail.com>
Date: Fri, 3 May 2019 13:54:53 +0200
Subject: [PATCH] PPC64 support for NVIDIA V100 GPU with NVLink2 passthrough
The NVIDIA V100 GPU has an onboard RAM that is mapped into the
host memory and accessible as normal RAM via an NVLink2 bridge. When
passed through in a guest, QEMU puts the NVIDIA RAM window in a
non-contiguous area, above the PCI MMIO area that starts at 32TiB.
This means that the NVIDIA RAM window starts at 64TiB and go all the
way to 128TiB.
This means that the guest might request a 64-bit window, for each PCI
Host Bridge, that goes all the way to 128TiB. However, the NVIDIA RAM
window isn't counted as regular RAM, thus this window is considered
only for the allocation of the Translation and Control Entry (TCE).
For more information about how NVLink2 support works in QEMU,
refer to the accepted implementation [1].
This memory layout differs from the existing VFIO case, requiring its
own formula. This patch changes the PPC64 code of
@qemuDomainGetMemLockLimitBytes to:
- detect if we have a NVLink2 bridge being passed through to the
guest. This is done by using the @ppc64VFIODeviceIsNV2Bridge function
added in the previous patch. The existence of the NVLink2 bridge in
the guest means that we are dealing with the NVLink2 memory layout;
- if an IBM NVLink2 bridge exists, passthroughLimit is calculated in a
different way to account for the extra memory the TCE table can alloc.
The 64TiB..128TiB window is more than enough to fit all possible
GPUs, thus the memLimit is the same regardless of passing through 1 or
multiple V100 GPUs.
Further reading explaining the background
[1] https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg03700.html
[2] https://www.redhat.com/archives/libvir-list/2019-March/msg00660.html
[3] https://www.redhat.com/archives/libvir-list/2019-April/msg00527.html
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
(cherry picked from commit 1a922648f67f56c4374d647feebf2adb9a642f96)
https://bugzilla.redhat.com/show_bug.cgi?id=1505998
Conflicts:
The upstream commit relied on:
- v4.7.0-37-gb72183223f
- v4.7.0-38-ga14f597266
which were not backported so virPCIDeviceAddressAsString had to
swapped for the former virDomainPCIAddressAsString in order to
compile.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Message-Id: <03c00ebf46d85b0615134ef8655e67a4c909b7da.1556884443.git.eskultet@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
---
src/qemu/qemu_domain.c | 80 ++++++++++++++++++++++++++++++++----------
1 file changed, 61 insertions(+), 19 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a8bc618389..21f0722495 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9813,7 +9813,7 @@ qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
* such as '0004:04:00.0', and tells if the device is a NVLink2
* bridge.
*/
-static ATTRIBUTE_UNUSED bool
+static bool
ppc64VFIODeviceIsNV2Bridge(const char *device)
{
const char *nvlink2Files[] = {"ibm,gpu", "ibm,nvlink",
@@ -9851,7 +9851,9 @@ getPPC64MemLockLimitBytes(virDomainDefPtr def)
unsigned long long maxMemory = 0;
unsigned long long passthroughLimit = 0;
size_t i, nPCIHostBridges = 0;
+ virPCIDeviceAddressPtr pciAddr;
bool usesVFIO = false;
+ bool nvlink2Capable = false;
for (i = 0; i < def->ncontrollers; i++) {
virDomainControllerDefPtr cont = def->controllers[i];
@@ -9869,7 +9871,17 @@ getPPC64MemLockLimitBytes(virDomainDefPtr def)
dev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
dev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
usesVFIO = true;
- break;
+
+ pciAddr = &dev->source.subsys.u.pci.addr;
+ if (virPCIDeviceAddressIsValid(pciAddr, false)) {
+ VIR_AUTOFREE(char *) pciAddrStr = NULL;
+
+ pciAddrStr = virDomainPCIAddressAsString(pciAddr);
+ if (ppc64VFIODeviceIsNV2Bridge(pciAddrStr)) {
+ nvlink2Capable = true;
+ break;
+ }
+ }
}
}
@@ -9896,29 +9908,59 @@ getPPC64MemLockLimitBytes(virDomainDefPtr def)
4096 * nPCIHostBridges +
8192;
- /* passthroughLimit := max( 2 GiB * #PHBs, (c)
- * memory (d)
- * + memory * 1/512 * #PHBs + 8 MiB ) (e)
+ /* NVLink2 support in QEMU is a special case of the passthrough
+ * mechanics explained in the usesVFIO case below. The GPU RAM
+ * is placed with a gap after maxMemory. The current QEMU
+ * implementation puts the NVIDIA RAM above the PCI MMIO, which
+ * starts at 32TiB and is the MMIO reserved for the guest main RAM.
*
- * (c) is the pre-DDW VFIO DMA window accounting. We're allowing 2 GiB
- * rather than 1 GiB
+ * This window ends at 64TiB, and this is where the GPUs are being
+ * placed. The next available window size is at 128TiB, and
+ * 64TiB..128TiB will fit all possible NVIDIA GPUs.
*
- * (d) is the with-DDW (and memory pre-registration and related
- * features) DMA window accounting - assuming that we only account RAM
- * once, even if mapped to multiple PHBs
+ * The same assumption as the most common case applies here:
+ * the guest will request a 64-bit DMA window, per PHB, that is
+ * big enough to map all its RAM, which is now at 128TiB due
+ * to the GPUs.
*
- * (e) is the with-DDW userspace view and overhead for the 64-bit DMA
- * window. This is based a bit on expected guest behaviour, but there
- * really isn't a way to completely avoid that. We assume the guest
- * requests a 64-bit DMA window (per PHB) just big enough to map all
- * its RAM. 4 kiB page size gives the 1/512; it will be less with 64
- * kiB pages, less still if the guest is mapped with hugepages (unlike
- * the default 32-bit DMA window, DDW windows can use large IOMMU
- * pages). 8 MiB is for second and further level overheads, like (b) */
- if (usesVFIO)
+ * Note that the NVIDIA RAM window must be accounted for the TCE
+ * table size, but *not* for the main RAM (maxMemory). This gives
+ * us the following passthroughLimit for the NVLink2 case:
+ *
+ * passthroughLimit = maxMemory +
+ * 128TiB/512KiB * #PHBs + 8 MiB */
+ if (nvlink2Capable) {
+ passthroughLimit = maxMemory +
+ 128 * (1ULL<<30) / 512 * nPCIHostBridges +
+ 8192;
+ } else if (usesVFIO) {
+ /* For regular (non-NVLink2 present) VFIO passthrough, the value
+ * of passthroughLimit is:
+ *
+ * passthroughLimit := max( 2 GiB * #PHBs, (c)
+ * memory (d)
+ * + memory * 1/512 * #PHBs + 8 MiB ) (e)
+ *
+ * (c) is the pre-DDW VFIO DMA window accounting. We're allowing 2
+ * GiB rather than 1 GiB
+ *
+ * (d) is the with-DDW (and memory pre-registration and related
+ * features) DMA window accounting - assuming that we only account
+ * RAM once, even if mapped to multiple PHBs
+ *
+ * (e) is the with-DDW userspace view and overhead for the 64-bit
+ * DMA window. This is based a bit on expected guest behaviour, but
+ * there really isn't a way to completely avoid that. We assume the
+ * guest requests a 64-bit DMA window (per PHB) just big enough to
+ * map all its RAM. 4 kiB page size gives the 1/512; it will be
+ * less with 64 kiB pages, less still if the guest is mapped with
+ * hugepages (unlike the default 32-bit DMA window, DDW windows
+ * can use large IOMMU pages). 8 MiB is for second and further level
+ * overheads, like (b) */
passthroughLimit = MAX(2 * 1024 * 1024 * nPCIHostBridges,
memory +
memory / 512 * nPCIHostBridges + 8192);
+ }
memKB = baseLimit + passthroughLimit;
--
2.21.0

View File

@ -1,5 +1,5 @@
From 74b69d4a7240c601fcd12c18d5e8d95d641ae922 Mon Sep 17 00:00:00 2001
Message-Id: <74b69d4a7240c601fcd12c18d5e8d95d641ae922@dist-git>
From a04fcb5b463c90c47705ca0f28e40b73c00b6b72 Mon Sep 17 00:00:00 2001
Message-Id: <a04fcb5b463c90c47705ca0f28e40b73c00b6b72@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Mon, 22 Feb 2016 12:51:51 +0100
Subject: [PATCH] RHEL: Add rhel machine types to qemuDomainMachineNeedsFDC
@ -13,23 +13,24 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1227880
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/qemu/qemu_domain.c | 3 +++
1 file changed, 3 insertions(+)
src/qemu/qemu_domain.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4c15d5a36a..4c2a162b85 100644
index a6dde15bad..0edf316fff 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9239,6 +9239,9 @@ qemuDomainMachineNeedsFDC(const char *machine)
STRPREFIX(p, "2.2") ||
STRPREFIX(p, "2.3"))
return false;
+ if (STRPREFIX(p, "rhel7.0.0") ||
+ STRPREFIX(p, "rhel7.1.0"))
+ return false;
return true;
@@ -12631,6 +12631,10 @@ qemuDomainMachineNeedsFDC(const char *machine,
return false;
}
return false;
+ if (STRPREFIX(p, "rhel7.0.0") ||
+ STRPREFIX(p, "rhel7.1.0"))
+ return false;
+
return true;
}
--
2.18.0
2.25.0

View File

@ -1,5 +1,5 @@
From 72c5455c00fcec50bae3e71a6fbd6330e524be0a Mon Sep 17 00:00:00 2001
Message-Id: <72c5455c00fcec50bae3e71a6fbd6330e524be0a@dist-git>
From 3e50b013277c7fa05987ceba440f8c4583b6c634 Mon Sep 17 00:00:00 2001
Message-Id: <3e50b013277c7fa05987ceba440f8c4583b6c634@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Mon, 27 Aug 2018 13:09:38 +0200
Subject: [PATCH] RHEL: Fix virConnectGetMaxVcpus output
@ -26,10 +26,10 @@ Reviewed-by: Andrea Bolognani <abologna@redhat.com>
1 file changed, 5 insertions(+)
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 1e31be5900..effe04ca3a 100644
index 7f14340f49..256976cce1 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -1186,6 +1186,11 @@ virHostCPUGetKVMMaxVCPUs(void)
@@ -1169,6 +1169,11 @@ virHostCPUGetKVMMaxVCPUs(void)
return -1;
}
@ -42,5 +42,5 @@ index 1e31be5900..effe04ca3a 100644
/* at first try KVM_CAP_MAX_VCPUS to determine the maximum count */
if ((ret = ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS)) > 0)
--
2.18.0
2.25.0

View File

@ -1,5 +1,5 @@
From 498389f6b88547c352add4b209d61896a5143c00 Mon Sep 17 00:00:00 2001
Message-Id: <498389f6b88547c352add4b209d61896a5143c00@dist-git>
From 0dd015e1aff1a56a4584824d1a97c9eacabf7f03 Mon Sep 17 00:00:00 2001
Message-Id: <0dd015e1aff1a56a4584824d1a97c9eacabf7f03@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 27 Mar 2015 12:48:40 +0100
Subject: [PATCH] RHEL: Hack around changed Broadwell/Haswell CPUs
@ -18,29 +18,31 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1199446
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/qemu/qemu_command.c | 29 +++++++++++++++++++
src/qemu/qemu_command.c | 21 +++++++++++++++++++
tests/qemuxml2argvdata/cpu-Haswell.args | 2 +-
.../qemuxml2argvdata/cpu-host-model-cmt.args | 3 +-
tests/qemuxml2argvdata/cpu-tsc-frequency.args | 2 +-
.../qemuxml2argvdata/cpu-host-model-cmt.args | 2 +-
.../cpu-translation.x86_64-4.0.0.args | 4 ++--
.../cpu-translation.x86_64-latest.args | 4 ++--
tests/qemuxml2argvdata/cpu-tsc-frequency.args | 4 ++--
tests/qemuxml2argvdata/q35-acpi-nouefi.args | 2 +-
tests/qemuxml2argvdata/q35-acpi-uefi.args | 2 +-
tests/qemuxml2argvdata/q35-noacpi-nouefi.args | 2 +-
7 files changed, 36 insertions(+), 6 deletions(-)
9 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4fc3176ad3..c1eefca639 100644
index 904d2beab5..e10cc7fc74 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6677,6 +6677,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
@@ -6469,6 +6469,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
{
size_t i;
virCapsPtr caps = NULL;
virCPUDefPtr cpu = def->cpu;
+ bool hle = false;
+ bool rtm = false;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
@@ -6734,6 +6736,11 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
switch ((virCPUMode) cpu->mode) {
case VIR_CPU_MODE_HOST_PASSTHROUGH:
@@ -6524,6 +6526,11 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id);
for (i = 0; i < cpu->nfeatures; i++) {
@ -52,7 +54,7 @@ index 4fc3176ad3..c1eefca639 100644
switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
case VIR_CPU_FEATURE_FORCE:
case VIR_CPU_FEATURE_REQUIRE:
@@ -6757,6 +6764,28 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
@@ -6541,6 +6548,20 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
}
}
@ -64,81 +66,104 @@ index 4fc3176ad3..c1eefca639 100644
+ */
+ if (STREQ_NULLABLE(cpu->model, "Broadwell") ||
+ STREQ_NULLABLE(cpu->model, "Haswell")) {
+ if (!rtm) {
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
+ virBufferAddLit(buf, ",rtm=on");
+ else
+ virBufferAddLit(buf, ",+rtm");
+ }
+ if (!hle) {
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
+ virBufferAddLit(buf, ",hle=on");
+ else
+ virBufferAddLit(buf, ",+hle");
+ }
+ if (!rtm)
+ qemuBuildCpuFeature(qemuCaps, buf, "rtm", true);
+ if (!hle)
+ qemuBuildCpuFeature(qemuCaps, buf, "hle", true);
+ }
+
ret = 0;
cleanup:
virObjectUnref(caps);
return 0;
}
diff --git a/tests/qemuxml2argvdata/cpu-Haswell.args b/tests/qemuxml2argvdata/cpu-Haswell.args
index c7ce396d05..6f20359524 100644
index a33b16f7ce..d35de5ea58 100644
--- a/tests/qemuxml2argvdata/cpu-Haswell.args
+++ b/tests/qemuxml2argvdata/cpu-Haswell.args
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
-name QEMUGuest1 \
-S \
-machine pc,accel=kvm,usb=off,dump-guest-core=off \
--cpu Haswell \
+-cpu Haswell,+rtm,+hle \
-m 214 \
-realtime mlock=off \
-smp 6,sockets=6,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxml2argvdata/cpu-host-model-cmt.args b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
index 8767278d11..d236aa9e09 100644
index 42f969fd62..c8795acb3e 100644
--- a/tests/qemuxml2argvdata/cpu-host-model-cmt.args
+++ b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
@@ -9,7 +9,8 @@ QEMU_AUDIO_DRV=none \
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
-S \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\
-+smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm \
++smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+rtm,\
++hle \
-+smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm \
++smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+rtm,+hle \
-m 214 \
-realtime mlock=off \
-smp 6,sockets=6,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
index f8e19fca24..08c672fd2c 100644
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
@@ -14,8 +14,8 @@ QEMU_AUDIO_DRV=none \
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc-i440fx-4.0,accel=tcg,usb=off,dump-guest-core=off \
-cpu Haswell,pclmuldq=on,ds_cpl=on,tsc_adjust=on,fxsr_opt=on,lahf_lm=on,\
-cmp_legacy=on,nodeid_msr=on,perfctr_core=on,perfctr_nb=on,kvm_pv_eoi=on,\
-kvm_pv_unhalt=on \
+cmp_legacy=on,nodeid_msr=on,perfctr_core=on,perfctr_nb=on,rtm=on,hle=on,\
+kvm_pv_eoi=on,kvm_pv_unhalt=on \
-m 214 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
index 9322b826f4..1dbfc9553b 100644
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
@@ -14,8 +14,8 @@ QEMU_AUDIO_DRV=none \
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,\
-cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,kvm-pv-eoi=on,\
-kvm-pv-unhalt=on \
+cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,rtm=on,hle=on,\
+kvm-pv-eoi=on,kvm-pv-unhalt=on \
-m 214 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/cpu-tsc-frequency.args b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
index 7824dea96f..216fd43014 100644
index 55b72b4404..45a777d468 100644
--- a/tests/qemuxml2argvdata/cpu-tsc-frequency.args
+++ b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
@@ -10,7 +10,7 @@ QEMU_AUDIO_DRV=none \
@@ -12,8 +12,8 @@ QEMU_AUDIO_DRV=none \
-S \
-machine pc,accel=kvm,usb=off,dump-guest-core=off \
-cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\
+smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,\
-+invtsc,tsc-frequency=3504000000 \
++invtsc,+rtm,+hle,tsc-frequency=3504000000 \
-+smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+invtsc,\
-tsc-frequency=3504000000 \
++smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+invtsc,+rtm,\
++hle,tsc-frequency=3504000000 \
-m 214 \
-realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxml2argvdata/q35-acpi-nouefi.args b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
index caef49ea16..a9375a35db 100644
index 09e06c96ea..aed56fb1fc 100644
--- a/tests/qemuxml2argvdata/q35-acpi-nouefi.args
+++ b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
-name guest \
-S \
-machine q35,accel=tcg,usb=off,dump-guest-core=off \
--cpu Haswell \
+-cpu Haswell,+rtm,+hle \
-m 1024 \
-realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
diff --git a/tests/qemuxml2argvdata/q35-acpi-uefi.args b/tests/qemuxml2argvdata/q35-acpi-uefi.args
index a3293aeb9d..8e3368b9e9 100644
index d00fe5bc1d..1f4bfe7f87 100644
--- a/tests/qemuxml2argvdata/q35-acpi-uefi.args
+++ b/tests/qemuxml2argvdata/q35-acpi-uefi.args
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
-name guest \
-S \
-machine q35,accel=tcg,usb=off,dump-guest-core=off \
@ -148,18 +173,18 @@ index a3293aeb9d..8e3368b9e9 100644
readonly=on \
-drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,\
diff --git a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
index fab2a6fcb0..0dd61840ef 100644
index de34dff1cf..ccea7f91f9 100644
--- a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
+++ b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
-name guest \
-S \
-machine q35,accel=tcg,usb=off,dump-guest-core=off \
--cpu Haswell \
+-cpu Haswell,+rtm,+hle \
-m 1024 \
-realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
--
2.18.0
2.25.0

View File

@ -1,146 +0,0 @@
From 54e270d7fb68b41002654374d395e4f260a24add Mon Sep 17 00:00:00 2001
Message-Id: <54e270d7fb68b41002654374d395e4f260a24add@dist-git>
From: Laine Stump <laine@redhat.com>
Date: Mon, 15 Oct 2018 20:31:02 -0400
Subject: [PATCH] RHEL: network: regain guest network connectivity after
firewalld switch to nftables
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is a DOWNSTREAM ONLY patch to temporarily get back guest network
connectivity while still allowing the firewalld backend to use
nftables (which is the default with RHEL8).
The circumstances that cause the problem:
In the past (when both libvirt and firewalld used iptables), if either
libvirt's rules *OR* firewalld's rules accepted a packet, it would be
accepted.
But now firewalld uses nftables for its backend, while libvirt's
firewall rules are still using iptables; iptables rules are still
processed, but at a different time during packet processing than the
firewalld nftables hooks. The result is that a packet must be accepted
by *BOTH* the libvirt iptables rules *AND* the firewalld nftable rules
in order to be accepted.
This causes pain for two types of traffic:
1) libvirt always adds rules to permit DNS and DHCP (and sometimes
TFTP) from guests to the host. But libvirt's bridges are in
firewalld's "default" zone (which is usually the zone called
"public"). The public zone allows ssh, but doesn't allow DNS, DHCP, or
TFTP. So guests connected to libvirt's bridges can't acquire an IP
address from DHCP, nor can they make DNS queries to the DNS server
libvirt has setup on the host.
2) firewalld's higher level "rich rules" don't yet have the ability to
configure the acceptance of forwarded traffic (traffic that is going
somewhere beyond the host), so any traffic that needs to be forwarded
is rejected.
libvirt can't send "direct" nftables rules (firewalld only supports
that for iptables), so we can't solve this problem by just sending
direct nftables rules instead of iptables rules.
However, we can take advantage of a quirk in firewalld zones that have
a default policy of accept (meaning any packet that doesn't match a
specific rule in the zone will be accepted) - this default accept will
also accept forwarded traffic (not just traffic destined for the host).
So, as a temporary solution to get all network traffic flowing, this
patch creates a new firewalld zone called "libvirt" which is setup to
include interfaces named virbr0-virbr9, and has a default policy of
accept. With this zone installed, libvirt networks that use the names
virbr0-virbr9 will have *all* their traffic accepted, both to the host
and to/from the rest of the network.
firewalld zones can't normally be added to the runtime config of
firewalld, so we have to reload all of the permanent config for it to
be recognized. This is done with a call to "firewall-cmd --reload"
during postinstall and postuninstall. In the case that firewalld is
inactive, firewall-cmd exits without doing anything (i.e. it doesn't
start up firewalld.service if it's not already started).
This obviously can't be a permanent solution, since it allows guests
to have access to *all* services on the host. However, it doesn't
allow QE and beta testers to test firewalld with an nftables backend
(which is important for firewalld and nftables devs) without breaking
network connectivity for libvirt managed virtual machines (so testing
of those can also take place.
Resolves: https://bugzilla.redhat.com/1638864
This problem is discussed in more detail in this message thread:
https://post-office.corp.redhat.com/mailman/private/virt-devel/2018-September/msg00145.html
https://post-office.corp.redhat.com/mailman/private/virt-devel/2018-October/msg00042.html
and in the BZ assigned to firewalld: https://bugzilla.redhat.com/1623841
Signed-off-by: Laine Stump <laine@laine.org>
Acked-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
libvirt.spec.in | 14 ++++++++++++++
src/network/Makefile.inc.am | 10 +++++++++-
src/network/libvirt.zone | 15 +++++++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
create mode 100644 src/network/libvirt.zone
diff --git a/src/network/Makefile.inc.am b/src/network/Makefile.inc.am
index 508c8c0422..20d899e699 100644
--- a/src/network/Makefile.inc.am
+++ b/src/network/Makefile.inc.am
@@ -87,6 +87,11 @@ install-data-network:
( cd $(DESTDIR)$(confdir)/qemu/networks/autostart && \
rm -f default.xml && \
$(LN_S) ../default.xml default.xml )
+if HAVE_FIREWALLD
+ $(MKDIR_P) "$(DESTDIR)$(prefix)/lib/firewalld/zones"
+ $(INSTALL_DATA) $(srcdir)/network/libvirt.zone \
+ $(DESTDIR)$(prefix)/lib/firewalld/zones/libvirt.xml
+endif HAVE_FIREWALLD
uninstall-data-network:
rm -f $(DESTDIR)$(confdir)/qemu/networks/autostart/default.xml
@@ -95,10 +100,13 @@ uninstall-data-network:
rmdir "$(DESTDIR)$(confdir)/qemu/networks" || :
rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/network" ||:
rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/network" ||:
+if HAVE_FIREWALLD
+ rm -f $(DESTDIR)$(prefix)/lib/firewalld/zones/libvirt.xml
+endif HAVE_FIREWALLD
endif WITH_NETWORK
-EXTRA_DIST += network/default.xml
+EXTRA_DIST += network/default.xml network/libvirt.zone
.PHONY: \
install-data-network \
diff --git a/src/network/libvirt.zone b/src/network/libvirt.zone
new file mode 100644
index 0000000000..355a70b4da
--- /dev/null
+++ b/src/network/libvirt.zone
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<zone target="ACCEPT">
+ <short>libvirt</short>
+ <description>All network connections are accepted. This also permits packets to/from interfaces in the zone to be forwarded. This zone is intended to be used only by libvirt virtual networks.</description>
+ <interface name="virbr0"/>
+ <interface name="virbr1"/>
+ <interface name="virbr2"/>
+ <interface name="virbr3"/>
+ <interface name="virbr4"/>
+ <interface name="virbr5"/>
+ <interface name="virbr6"/>
+ <interface name="virbr7"/>
+ <interface name="virbr8"/>
+ <interface name="virbr9"/>
+</zone>
--
2.19.1

View File

@ -1,5 +1,5 @@
From 2d4b19613c462e876ee1327d600f5cbbb998c540 Mon Sep 17 00:00:00 2001
Message-Id: <2d4b19613c462e876ee1327d600f5cbbb998c540@dist-git>
From fce502cf5233d800479c2efcf7721ab895db8998 Mon Sep 17 00:00:00 2001
Message-Id: <fce502cf5233d800479c2efcf7721ab895db8998@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 17 Dec 2018 20:42:30 -0500
Subject: [PATCH] RHEL: qemu: Add ability to set sgio values for hostdev
@ -19,22 +19,22 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit f2cf0ae7bc371c75f6c0e79192711f2b1d201b10)
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_conf.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
src/qemu/qemu_conf.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index a4f545ef92..3ea9784854 100644
index b62dd1df52..ce7869e6be 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1633,6 +1633,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
@@ -1810,6 +1810,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
virDomainDiskDefPtr disk = NULL;
virDomainHostdevDefPtr hostdev = NULL;
char *sysfs_path = NULL;
+ char *hostdev_path = NULL;
g_autofree char *sysfs_path = NULL;
+ g_autofree char *hostdev_path = NULL;
const char *path = NULL;
int val = -1;
int ret = -1;
@@ -1654,14 +1655,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
@@ -1830,14 +1831,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
if (!qemuIsSharedHostdev(hostdev))
return 0;
@ -43,7 +43,7 @@ index a4f545ef92..3ea9784854 100644
- _("'sgio' is not supported for SCSI "
- "generic device yet "));
+ if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
goto cleanup;
return -1;
- }
- return 0;
@ -51,8 +51,8 @@ index a4f545ef92..3ea9784854 100644
} else {
return 0;
}
@@ -1670,7 +1667,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
goto cleanup;
@@ -1846,7 +1843,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
return -1;
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
- val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
@ -64,14 +64,6 @@ index a4f545ef92..3ea9784854 100644
/* Do not do anything if unpriv_sgio is not supported by the kernel and the
* whitelist is enabled. But if requesting unfiltered access, always call
@@ -1683,6 +1684,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
ret = 0;
cleanup:
+ VIR_FREE(hostdev_path);
VIR_FREE(sysfs_path);
return ret;
}
--
2.20.1
2.25.0

View File

@ -1,5 +1,5 @@
From c39257f41ccb22272c6161777bf71390676bf7f0 Mon Sep 17 00:00:00 2001
Message-Id: <c39257f41ccb22272c6161777bf71390676bf7f0@dist-git>
From 5a192657ad4e08fc773fef90c6b07df3620fa1c2 Mon Sep 17 00:00:00 2001
Message-Id: <5a192657ad4e08fc773fef90c6b07df3620fa1c2@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 17 Dec 2018 20:42:31 -0500
Subject: [PATCH] RHEL: qemu: Add check for unpriv sgio for SCSI generic host
@ -23,26 +23,29 @@ Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 712005bcf26190dc6fd1fe56283377987909cc4b)
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_conf.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
src/qemu/qemu_conf.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 3ea9784854..7d15af9c0b 100644
index ce7869e6be..2a84972fd9 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1473,6 +1473,8 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver,
@@ -1717,13 +1717,29 @@ qemuSharedHostdevAddRemoveInternal(virQEMUDriverPtr driver,
{
char *dev_path = NULL;
char *key = NULL;
g_autofree char *dev_path = NULL;
g_autofree char *key = NULL;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
+ virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
int ret = -1;
if (!qemuIsSharedHostdev(hostdev))
@@ -1481,6 +1483,19 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver,
if (!(dev_path = qemuGetHostdevPath(hostdev)))
goto cleanup;
return 0;
- if (!(dev_path = qemuGetHostdevPath(hostdev)) ||
- !(key = qemuGetSharedDeviceKey(dev_path)))
+ if (!(dev_path = qemuGetHostdevPath(hostdev)))
+ return -1;
+
+ if ((ret = qemuCheckUnprivSGIO(driver->sharedDevices, dev_path,
+ scsisrc->sgio)) < 0) {
+ if (ret == -2) {
@ -51,14 +54,14 @@ index 3ea9784854..7d15af9c0b 100644
+ "conflicts with other active domains"),
+ scsihostsrc->adapter, scsihostsrc->bus,
+ scsihostsrc->target, scsihostsrc->unit);
+ ret = -1;
+ }
+ goto cleanup;
+ return -1;
+ }
+
if (!(key = qemuGetSharedDeviceKey(dev_path)))
goto cleanup;
+ if (!(key = qemuGetSharedDeviceKey(dev_path)))
return -1;
qemuDriverLock(driver);
--
2.20.1
2.25.0

View File

@ -1,8 +1,8 @@
From 861a1a4d299c57f31fa091c6b74cddf80681bdf0 Mon Sep 17 00:00:00 2001
Message-Id: <861a1a4d299c57f31fa091c6b74cddf80681bdf0@dist-git>
From e79d54ff8e760ac1a200a37fb05cc9aa758c48d3 Mon Sep 17 00:00:00 2001
Message-Id: <e79d54ff8e760ac1a200a37fb05cc9aa758c48d3@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 17 Dec 2018 20:42:33 -0500
Subject: [PATCH] qemu: Alter qemuSetUnprivSGIO hostdev shareable logic
Subject: [PATCH] RHEL: qemu: Alter qemuSetUnprivSGIO hostdev shareable logic
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -24,10 +24,10 @@ Reviewed-by: Ján Tomko <jtomko@redhat.com>
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index de0cbca083..5971f3eb64 100644
index faabc4d49f..590052b035 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1667,9 +1667,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
@@ -1844,9 +1844,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
hostdev = dev->data.hostdev;
@ -35,9 +35,9 @@ index de0cbca083..5971f3eb64 100644
- return 0;
-
if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
goto cleanup;
return -1;
@@ -1686,7 +1683,9 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
@@ -1863,7 +1860,9 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED) {
val = 1;
} else {
@ -49,5 +49,5 @@ index de0cbca083..5971f3eb64 100644
val = 1;
}
--
2.20.1
2.25.0

View File

@ -1,8 +1,8 @@
From c0f26a13c6ddd9aca729012d3a31347f77d52c68 Mon Sep 17 00:00:00 2001
Message-Id: <c0f26a13c6ddd9aca729012d3a31347f77d52c68@dist-git>
From fa46b5b4d5bb732462d0d5484cc010aa652d821b Mon Sep 17 00:00:00 2001
Message-Id: <fa46b5b4d5bb732462d0d5484cc010aa652d821b@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 17 Dec 2018 20:42:32 -0500
Subject: [PATCH] qemu: Alter @val usage in qemuSetUnprivSGIO
Subject: [PATCH] RHEL: qemu: Alter @val usage in qemuSetUnprivSGIO
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -23,20 +23,20 @@ Reviewed-by: Ján Tomko <jtomko@redhat.com>
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 7d15af9c0b..de0cbca083 100644
index 2a84972fd9..faabc4d49f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1650,7 +1650,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
char *sysfs_path = NULL;
char *hostdev_path = NULL;
@@ -1828,7 +1828,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
g_autofree char *sysfs_path = NULL;
g_autofree char *hostdev_path = NULL;
const char *path = NULL;
- int val = -1;
+ int val = 0;
int ret = -1;
/* "sgio" is only valid for block disk; cdrom
@@ -1682,11 +1682,14 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
goto cleanup;
* and floopy disk can have empty source.
@@ -1859,11 +1859,14 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
return -1;
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
- if (dev->type == VIR_DOMAIN_DEVICE_DISK)
@ -56,5 +56,5 @@ index 7d15af9c0b..de0cbca083 100644
/* Do not do anything if unpriv_sgio is not supported by the kernel and the
* whitelist is enabled. But if requesting unfiltered access, always call
--
2.20.1
2.25.0

View File

@ -1,5 +1,5 @@
From 11bfd4f26c090b95a100aaf056ecfa799dfce979 Mon Sep 17 00:00:00 2001
Message-Id: <11bfd4f26c090b95a100aaf056ecfa799dfce979@dist-git>
From 163740bff28c6f1a82663bc652f2cd5df39e4276 Mon Sep 17 00:00:00 2001
Message-Id: <163740bff28c6f1a82663bc652f2cd5df39e4276@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Fri, 25 Jan 2019 12:19:12 -0500
Subject: [PATCH] RHEL: qemu: Fix crash trying to use iSCSI hostdev
@ -26,10 +26,10 @@ Reviewed-by: Ján Tomko <jtomko@redhat.com>
1 file changed, 4 insertions(+)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 768e9d8308..a81298326f 100644
index 0674292fab..3d2f0e7bbb 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1667,6 +1667,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
@@ -1844,6 +1844,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
hostdev = dev->data.hostdev;
@ -38,8 +38,8 @@ index 768e9d8308..a81298326f 100644
+ return 0;
+
if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
goto cleanup;
return -1;
--
2.20.1
2.25.0

View File

@ -1,8 +1,8 @@
From d0f2fffa7c1a86f56f18143a1a14b9a32f8bcf16 Mon Sep 17 00:00:00 2001
Message-Id: <d0f2fffa7c1a86f56f18143a1a14b9a32f8bcf16@dist-git>
From f6a05ac3cb33c473de8ed49b53d22910fc0140df Mon Sep 17 00:00:00 2001
Message-Id: <f6a05ac3cb33c473de8ed49b53d22910fc0140df@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Wed, 16 Jan 2019 15:54:31 -0500
Subject: [PATCH] qemu: Fix logic error in qemuSetUnprivSGIO
Subject: [PATCH] RHEL: qemu: Fix logic error in qemuSetUnprivSGIO
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -38,11 +38,11 @@ Reviewed-by: Ján Tomko <jtomko@redhat.com>
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 5971f3eb64..768e9d8308 100644
index 590052b035..0674292fab 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1679,9 +1679,9 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
goto cleanup;
@@ -1856,9 +1856,9 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
return -1;
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
- if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
@ -55,5 +55,5 @@ index 5971f3eb64..768e9d8308 100644
/* Only settable if <shareable/> was present for hostdev */
if (qemuIsSharedHostdev(hostdev) &&
--
2.20.1
2.25.0

View File

@ -0,0 +1,42 @@
From ef5a82d50464478a302cb59804d03e4a3dada83e Mon Sep 17 00:00:00 2001
Message-Id: <ef5a82d50464478a302cb59804d03e4a3dada83e@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Fri, 6 Mar 2020 15:52:26 +0100
Subject: [PATCH] RHEL: qemuCheckUnprivSGIO: use @sysfs_path to get unpriv_sgio
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Downstream commit 65f4ff0e2c9a968b7ec65c8d751d4055cc212628
RHEL: qemuSetUnprivSGIO: Actually use calculated
@sysfs_path to set unpriv_sgio
removed the device_path -> sysfs_path conversion from
both virGetDeviceUnprivSGIO and virSetDeviceUnprivSGIO,
but only adjusted one of the callers.
https://bugzilla.redhat.com/show_bug.cgi?id=1808400
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200306145226.1610708-7-abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/qemu/qemu_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index b61d7e59fa..6a22d78ac6 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1430,7 +1430,7 @@ qemuCheckUnprivSGIO(virHashTablePtr sharedDevices,
if (!(virHashLookup(sharedDevices, key)))
return 0;
- if (virGetDeviceUnprivSGIO(device_path, &val) < 0)
+ if (virGetDeviceUnprivSGIO(sysfs_path, &val) < 0)
return -1;
/* Error message on failure needs to be handled in caller
--
2.25.1

View File

@ -0,0 +1,170 @@
From 717423e7a452b0715e95b492b15dc08983677d12 Mon Sep 17 00:00:00 2001
Message-Id: <717423e7a452b0715e95b492b15dc08983677d12@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 6 Mar 2020 15:52:25 +0100
Subject: [PATCH] RHEL: qemuSetUnprivSGIO: Actually use calculated @sysfs_path
to set unpriv_sgio
In previous commits I've attempted to make qemuSetUnprivSGIO()
construct a generic enough path for SCSI devices to set
unpriv_sgio. However, virSetDeviceUnprivSGIO() does not care
about that - it constructs the path on it's own again. This is
suboptimal in either case - we already have the path constructed.
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200306145226.1610708-6-abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/qemu/qemu_conf.c | 8 +++-----
src/util/virutil.c | 24 ++++++------------------
src/util/virutil.h | 2 --
3 files changed, 9 insertions(+), 25 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 6d6feb97cd..b61d7e59fa 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1430,7 +1430,7 @@ qemuCheckUnprivSGIO(virHashTablePtr sharedDevices,
if (!(virHashLookup(sharedDevices, key)))
return 0;
- if (virGetDeviceUnprivSGIO(device_path, NULL, &val) < 0)
+ if (virGetDeviceUnprivSGIO(device_path, &val) < 0)
return -1;
/* Error message on failure needs to be handled in caller
@@ -1789,7 +1789,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
virDomainDiskDefPtr disk = NULL;
virDomainHostdevDefPtr hostdev = NULL;
g_autofree char *sysfs_path = NULL;
- const char *path = NULL;
int val = 0;
/* "sgio" is only valid for block disk; cdrom
@@ -1797,13 +1796,12 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
*/
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
disk = dev->data.disk;
+ const char *path = virDomainDiskGetSource(disk);
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN ||
!virStorageSourceIsBlockLocal(disk->src))
return 0;
- path = virDomainDiskGetSource(disk);
-
if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
return -1;
@@ -1843,7 +1841,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
* virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_sgio.
*/
if ((virFileExists(sysfs_path) || val == 1) &&
- virSetDeviceUnprivSGIO(path, NULL, val) < 0)
+ virSetDeviceUnprivSGIO(sysfs_path, val) < 0)
return -1;
return 0;
diff --git a/src/util/virutil.c b/src/util/virutil.c
index f142951acf..4198473fce 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1421,18 +1421,13 @@ virGetUnprivSGIOSysfsPath(const char *path,
int
virSetDeviceUnprivSGIO(const char *path,
- const char *sysfs_dir,
int unpriv_sgio)
{
- char *sysfs_path = NULL;
char *val = NULL;
int ret = -1;
int rc;
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir)))
- return -1;
-
- if (!virFileExists(sysfs_path)) {
+ if (!virFileExists(path)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("unpriv_sgio is not supported by this kernel"));
goto cleanup;
@@ -1440,38 +1435,32 @@ virSetDeviceUnprivSGIO(const char *path,
val = g_strdup_printf("%d", unpriv_sgio);
- if ((rc = virFileWriteStr(sysfs_path, val, 0)) < 0) {
- virReportSystemError(-rc, _("failed to set %s"), sysfs_path);
+ if ((rc = virFileWriteStr(path, val, 0)) < 0) {
+ virReportSystemError(-rc, _("failed to set %s"), path);
goto cleanup;
}
ret = 0;
cleanup:
- VIR_FREE(sysfs_path);
VIR_FREE(val);
return ret;
}
int
virGetDeviceUnprivSGIO(const char *path,
- const char *sysfs_dir,
int *unpriv_sgio)
{
- char *sysfs_path = NULL;
char *buf = NULL;
char *tmp = NULL;
int ret = -1;
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir)))
- return -1;
-
- if (!virFileExists(sysfs_path)) {
+ if (!virFileExists(path)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("unpriv_sgio is not supported by this kernel"));
goto cleanup;
}
- if (virFileReadAll(sysfs_path, 1024, &buf) < 0)
+ if (virFileReadAll(path, 1024, &buf) < 0)
goto cleanup;
if ((tmp = strchr(buf, '\n')))
@@ -1479,13 +1468,12 @@ virGetDeviceUnprivSGIO(const char *path,
if (virStrToLong_i(buf, NULL, 10, unpriv_sgio) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("failed to parse value of %s"), sysfs_path);
+ _("failed to parse value of %s"), path);
goto cleanup;
}
ret = 0;
cleanup:
- VIR_FREE(sysfs_path);
VIR_FREE(buf);
return ret;
}
diff --git a/src/util/virutil.h b/src/util/virutil.h
index 1a6ae1787a..a2530e21b5 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -124,10 +124,8 @@ int virGetDeviceID(const char *path,
int *maj,
int *min);
int virSetDeviceUnprivSGIO(const char *path,
- const char *sysfs_dir,
int unpriv_sgio);
int virGetDeviceUnprivSGIO(const char *path,
- const char *sysfs_dir,
int *unpriv_sgio);
char *virGetUnprivSGIOSysfsPath(const char *path,
const char *sysfs_dir);
--
2.25.1

View File

@ -0,0 +1,228 @@
From f66beef45382be2aed6d021a409e90f8114c8671 Mon Sep 17 00:00:00 2001
Message-Id: <f66beef45382be2aed6d021a409e90f8114c8671@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 6 Mar 2020 15:52:21 +0100
Subject: [PATCH] RHEL: virscsi: Check device type before getting it's /dev
node name
Not all SCSI devices are block devices, therefore
/sys/bus/scsi/devices/X:X:X:X/block/ directory does not always
exist. Check if the SCSI device is a block device beforehand.
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200306145226.1610708-2-abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/util/virscsi.c | 146 ++++++++++++++++++++++++++++++---
tests/virscsidata/0-0-0-0/type | 1 +
tests/virscsidata/1-0-0-0/type | 1 +
3 files changed, 137 insertions(+), 11 deletions(-)
create mode 100644 tests/virscsidata/0-0-0-0/type
create mode 100644 tests/virscsidata/1-0-0-0/type
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 06659c45c7..c40857977f 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -50,6 +50,32 @@ struct _virUsedByInfo {
typedef struct _virUsedByInfo virUsedByInfo;
typedef virUsedByInfo *virUsedByInfoPtr;
+
+/* Keep in sync with scsi/scsi_proto.h */
+typedef enum {
+ VIR_SCSI_DEVICE_TYPE_NONE = -1,
+ VIR_SCSI_DEVICE_TYPE_DISK = 0x00,
+ VIR_SCSI_DEVICE_TYPE_TAPE = 0x01,
+ VIR_SCSI_DEVICE_TYPE_PRINTER = 0x02,
+ VIR_SCSI_DEVICE_TYPE_PROCESSOR = 0x03,
+ VIR_SCSI_DEVICE_TYPE_WORM = 0x04,
+ VIR_SCSI_DEVICE_TYPE_ROM = 0x05,
+ VIR_SCSI_DEVICE_TYPE_SCANNER = 0x06,
+ VIR_SCSI_DEVICE_TYPE_MOD = 0x07,
+ VIR_SCSI_DEVICE_TYPE_MEDIUM_CHANGER = 0x08,
+ VIR_SCSI_DEVICE_TYPE_COMM = 0x09,
+ VIR_SCSI_DEVICE_TYPE_RAID = 0x0c,
+ VIR_SCSI_DEVICE_TYPE_ENCLOSURE = 0x0d,
+ VIR_SCSI_DEVICE_TYPE_RBC = 0x0e,
+ VIR_SCSI_DEVICE_TYPE_OSD = 0x11,
+ VIR_SCSI_DEVICE_TYPE_ZBC = 0x14,
+ VIR_SCSI_DEVICE_TYPE_WLUN = 0x1e,
+ VIR_SCSI_DEVICE_TYPE_NO_LUN = 0x7f,
+
+ VIR_SCSI_DEVICE_TYPE_LAST,
+} virSCSIDeviceType;
+
+
struct _virSCSIDevice {
unsigned int adapter;
unsigned int bus;
@@ -134,6 +160,84 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
return sg;
}
+
+static int
+virSCSIDeviceGetType(const char *prefix,
+ unsigned int adapter,
+ unsigned int bus,
+ unsigned int target,
+ unsigned long long unit,
+ virSCSIDeviceType *type)
+{
+ int intType;
+
+ if (virFileReadValueInt(&intType,
+ "%s/%d:%u:%u:%llu/type",
+ prefix, adapter, bus, target, unit) < 0)
+ return -1;
+
+ switch (intType) {
+ case VIR_SCSI_DEVICE_TYPE_DISK:
+ case VIR_SCSI_DEVICE_TYPE_TAPE:
+ case VIR_SCSI_DEVICE_TYPE_PRINTER:
+ case VIR_SCSI_DEVICE_TYPE_PROCESSOR:
+ case VIR_SCSI_DEVICE_TYPE_WORM:
+ case VIR_SCSI_DEVICE_TYPE_ROM:
+ case VIR_SCSI_DEVICE_TYPE_SCANNER:
+ case VIR_SCSI_DEVICE_TYPE_MOD:
+ case VIR_SCSI_DEVICE_TYPE_MEDIUM_CHANGER:
+ case VIR_SCSI_DEVICE_TYPE_COMM:
+ case VIR_SCSI_DEVICE_TYPE_RAID:
+ case VIR_SCSI_DEVICE_TYPE_ENCLOSURE:
+ case VIR_SCSI_DEVICE_TYPE_RBC:
+ case VIR_SCSI_DEVICE_TYPE_OSD:
+ case VIR_SCSI_DEVICE_TYPE_ZBC:
+ case VIR_SCSI_DEVICE_TYPE_WLUN:
+ case VIR_SCSI_DEVICE_TYPE_NO_LUN:
+ *type = intType;
+ break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown SCSI device type: %x"),
+ intType);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static char *
+virSCSIDeviceGetDevNameBlock(const char *prefix,
+ unsigned int adapter,
+ unsigned int bus,
+ unsigned int target,
+ unsigned long long unit)
+{
+ DIR *dir = NULL;
+ struct dirent *entry;
+ g_autofree char *path = NULL;
+ char *name = NULL;
+
+ path = g_strdup_printf("%s/%d:%u:%u:%llu/block",
+ prefix, adapter, bus, target, unit);
+
+ if (virDirOpen(&dir, path) < 0)
+ goto cleanup;
+
+ while (virDirRead(dir, &entry, path) > 0) {
+ name = g_strdup(entry->d_name);
+ break;
+ }
+
+ cleanup:
+ VIR_DIR_CLOSE(dir);
+
+ return name;
+}
+
+
/* Returns device name (e.g. "sdc") on success, or NULL
* on failure.
*/
@@ -144,32 +248,52 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
unsigned int target,
unsigned long long unit)
{
- DIR *dir = NULL;
- struct dirent *entry;
- g_autofree char *path = NULL;
char *name = NULL;
unsigned int adapter_id;
+ virSCSIDeviceType type;
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
if (virSCSIDeviceGetAdapterId(adapter, &adapter_id) < 0)
return NULL;
- path = g_strdup_printf("%s/%d:%u:%u:%llu/block", prefix, adapter_id, bus,
- target, unit);
+ if (virSCSIDeviceGetType(prefix, adapter_id,
+ bus, target, unit, &type) < 0)
+ return NULL;
- if (virDirOpen(&dir, path) < 0)
- goto cleanup;
+ switch (type) {
+ case VIR_SCSI_DEVICE_TYPE_DISK:
+ name = virSCSIDeviceGetDevNameBlock(prefix, adapter_id, bus, target, unit);
+ break;
- while (virDirRead(dir, &entry, path) > 0) {
- name = g_strdup(entry->d_name);
+ case VIR_SCSI_DEVICE_TYPE_TAPE:
+ case VIR_SCSI_DEVICE_TYPE_PRINTER:
+ case VIR_SCSI_DEVICE_TYPE_PROCESSOR:
+ case VIR_SCSI_DEVICE_TYPE_WORM:
+ case VIR_SCSI_DEVICE_TYPE_ROM:
+ case VIR_SCSI_DEVICE_TYPE_SCANNER:
+ case VIR_SCSI_DEVICE_TYPE_MOD:
+ case VIR_SCSI_DEVICE_TYPE_MEDIUM_CHANGER:
+ case VIR_SCSI_DEVICE_TYPE_COMM:
+ case VIR_SCSI_DEVICE_TYPE_RAID:
+ case VIR_SCSI_DEVICE_TYPE_ENCLOSURE:
+ case VIR_SCSI_DEVICE_TYPE_RBC:
+ case VIR_SCSI_DEVICE_TYPE_OSD:
+ case VIR_SCSI_DEVICE_TYPE_ZBC:
+ case VIR_SCSI_DEVICE_TYPE_WLUN:
+ case VIR_SCSI_DEVICE_TYPE_NO_LUN:
+ case VIR_SCSI_DEVICE_TYPE_NONE:
+ case VIR_SCSI_DEVICE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported SCSI device type: %x"),
+ type);
break;
}
- cleanup:
- VIR_DIR_CLOSE(dir);
return name;
}
+
virSCSIDevicePtr
virSCSIDeviceNew(const char *sysfs_prefix,
const char *adapter,
diff --git a/tests/virscsidata/0-0-0-0/type b/tests/virscsidata/0-0-0-0/type
new file mode 100644
index 0000000000..573541ac97
--- /dev/null
+++ b/tests/virscsidata/0-0-0-0/type
@@ -0,0 +1 @@
+0
diff --git a/tests/virscsidata/1-0-0-0/type b/tests/virscsidata/1-0-0-0/type
new file mode 100644
index 0000000000..573541ac97
--- /dev/null
+++ b/tests/virscsidata/1-0-0-0/type
@@ -0,0 +1 @@
+0
--
2.25.1

View File

@ -0,0 +1,137 @@
From c9fc757c867d197c17350b6a9cabc63cc08105d2 Mon Sep 17 00:00:00 2001
Message-Id: <c9fc757c867d197c17350b6a9cabc63cc08105d2@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 6 Mar 2020 15:52:23 +0100
Subject: [PATCH] RHEL: virscsi: Introduce and use
virSCSIDeviceGetUnprivSGIOSysfsPath()
When constructing a path to the 'unpriv_sgio' file of given SCSI
device we don't need to go through /dev/* and major() + minor()
path. The generated path points to
/sys/dev/block/MAJ:MIN/queue/unpriv_sgio which is wrong if the
SCSI device in question is not a block device. We can generate a
different path: /sys/bus/scsi/devices/X:X:X:X/unpriv_sgio where
the file is directly accessible regardless of the SCSI device
type.
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200306145226.1610708-4-abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libvirt_private.syms | 1 +
src/qemu/qemu_conf.c | 18 +++++++++++-------
src/util/virscsi.c | 18 ++++++++++++++++++
src/util/virscsi.h | 5 +++++
4 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5dc99e03cf..1f97879faa 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2959,6 +2959,7 @@ virSCSIDeviceGetSgName;
virSCSIDeviceGetShareable;
virSCSIDeviceGetTarget;
virSCSIDeviceGetUnit;
+virSCSIDeviceGetUnprivSGIOSysfsPath;
virSCSIDeviceIsAvailable;
virSCSIDeviceListAdd;
virSCSIDeviceListCount;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 7aaf2862a4..6d6feb97cd 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1789,7 +1789,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
virDomainDiskDefPtr disk = NULL;
virDomainHostdevDefPtr hostdev = NULL;
g_autofree char *sysfs_path = NULL;
- g_autofree char *hostdev_path = NULL;
const char *path = NULL;
int val = 0;
@@ -1804,24 +1803,29 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
return 0;
path = virDomainDiskGetSource(disk);
+
+ if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
+ return -1;
+
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
hostdev = dev->data.hostdev;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
+ virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
if (hostdev->source.subsys.u.scsi.protocol ==
VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
return 0;
- if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
+ if (!(sysfs_path = virSCSIDeviceGetUnprivSGIOSysfsPath(NULL,
+ scsihostsrc->adapter,
+ scsihostsrc->bus,
+ scsihostsrc->target,
+ scsihostsrc->unit)))
return -1;
-
- path = hostdev_path;
} else {
return 0;
}
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
- return -1;
-
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
if (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 57958c06ea..1bba4051b6 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -322,6 +322,24 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
}
+char *
+virSCSIDeviceGetUnprivSGIOSysfsPath(const char *sysfs_prefix,
+ const char *adapter,
+ unsigned int bus,
+ unsigned int target,
+ unsigned long long unit)
+{
+ unsigned int adapter_id;
+ const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
+
+ if (virSCSIDeviceGetAdapterId(adapter, &adapter_id) < 0)
+ return NULL;
+
+ return g_strdup_printf("%s/%d:%u:%u:%llu/unpriv_sgio",
+ prefix, adapter_id, bus, target, unit);
+}
+
+
virSCSIDevicePtr
virSCSIDeviceNew(const char *sysfs_prefix,
const char *adapter,
diff --git a/src/util/virscsi.h b/src/util/virscsi.h
index 51627e0c05..c040d76716 100644
--- a/src/util/virscsi.h
+++ b/src/util/virscsi.h
@@ -42,6 +42,11 @@ char *virSCSIDeviceGetDevName(const char *sysfs_prefix,
unsigned int bus,
unsigned int target,
unsigned long long unit);
+char *virSCSIDeviceGetUnprivSGIOSysfsPath(const char *sysfs_prefix,
+ const char *adapter,
+ unsigned int bus,
+ unsigned int target,
+ unsigned long long unit);
virSCSIDevicePtr virSCSIDeviceNew(const char *sysfs_prefix,
const char *adapter,
--
2.25.1

View File

@ -0,0 +1,202 @@
From c481bcacd1f515d2e93036dc452a25e9ff06f7ae Mon Sep 17 00:00:00 2001
Message-Id: <c481bcacd1f515d2e93036dc452a25e9ff06f7ae@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 6 Mar 2020 15:52:22 +0100
Subject: [PATCH] RHEL: virscsi: Support TAPEs in virSCSIDeviceGetDevName()
If the SCSI device we want to get /dev node name for is TAPE
device we need to look at 'tape' symlink in the sysfs dir
corresponding to the device.
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200306145226.1610708-3-abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/util/virscsi.c | 28 +++++++++++++++
tests/virscsidata/2-0-0-0/model | 1 +
tests/virscsidata/2-0-0-0/scsi_tape/st0/dev | 1 +
tests/virscsidata/2-0-0-0/sg3/dev | 1 +
tests/virscsidata/2-0-0-0/tape | 1 +
tests/virscsidata/2-0-0-0/type | 1 +
tests/virscsidata/2-0-0-0/vendor | 1 +
tests/virscsidata/sg3 | 0
tests/virscsitest.c | 38 ++++++++++++++++++---
9 files changed, 67 insertions(+), 5 deletions(-)
create mode 100644 tests/virscsidata/2-0-0-0/model
create mode 100644 tests/virscsidata/2-0-0-0/scsi_tape/st0/dev
create mode 100644 tests/virscsidata/2-0-0-0/sg3/dev
create mode 120000 tests/virscsidata/2-0-0-0/tape
create mode 100644 tests/virscsidata/2-0-0-0/type
create mode 100644 tests/virscsidata/2-0-0-0/vendor
create mode 100644 tests/virscsidata/sg3
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index c40857977f..57958c06ea 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -238,6 +238,31 @@ virSCSIDeviceGetDevNameBlock(const char *prefix,
}
+static char *
+virSCSIDeviceGetDevNameTape(const char *prefix,
+ unsigned int adapter,
+ unsigned int bus,
+ unsigned int target,
+ unsigned long long unit)
+{
+ g_autofree char *path = NULL;
+ g_autofree char *resolvedPath = NULL;
+ g_autoptr(GError) err = NULL;
+
+ path = g_strdup_printf("%s/%d:%u:%u:%llu/tape",
+ prefix, adapter, bus, target, unit);
+
+ if (!(resolvedPath = g_file_read_link(path, &err))) {
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to read link: %s"),
+ err->message);
+ return NULL;
+ }
+
+ return g_path_get_basename(resolvedPath);
+}
+
+
/* Returns device name (e.g. "sdc") on success, or NULL
* on failure.
*/
@@ -266,6 +291,9 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
break;
case VIR_SCSI_DEVICE_TYPE_TAPE:
+ name = virSCSIDeviceGetDevNameTape(prefix, adapter_id, bus, target, unit);
+ break;
+
case VIR_SCSI_DEVICE_TYPE_PRINTER:
case VIR_SCSI_DEVICE_TYPE_PROCESSOR:
case VIR_SCSI_DEVICE_TYPE_WORM:
diff --git a/tests/virscsidata/2-0-0-0/model b/tests/virscsidata/2-0-0-0/model
new file mode 100644
index 0000000000..d2ab4715c3
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/model
@@ -0,0 +1 @@
+scsi_debug
diff --git a/tests/virscsidata/2-0-0-0/scsi_tape/st0/dev b/tests/virscsidata/2-0-0-0/scsi_tape/st0/dev
new file mode 100644
index 0000000000..3dd777e840
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/scsi_tape/st0/dev
@@ -0,0 +1 @@
+9:0
diff --git a/tests/virscsidata/2-0-0-0/sg3/dev b/tests/virscsidata/2-0-0-0/sg3/dev
new file mode 100644
index 0000000000..b369a59b3e
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/sg3/dev
@@ -0,0 +1 @@
+21:3
diff --git a/tests/virscsidata/2-0-0-0/tape b/tests/virscsidata/2-0-0-0/tape
new file mode 120000
index 0000000000..6ca7f77539
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/tape
@@ -0,0 +1 @@
+scsi_tape/st0
\ No newline at end of file
diff --git a/tests/virscsidata/2-0-0-0/type b/tests/virscsidata/2-0-0-0/type
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/type
@@ -0,0 +1 @@
+1
diff --git a/tests/virscsidata/2-0-0-0/vendor b/tests/virscsidata/2-0-0-0/vendor
new file mode 100644
index 0000000000..9b075671ea
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/vendor
@@ -0,0 +1 @@
+Linux
diff --git a/tests/virscsidata/sg3 b/tests/virscsidata/sg3
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/virscsitest.c b/tests/virscsitest.c
index d5a0da4753..e501d6d041 100644
--- a/tests/virscsitest.c
+++ b/tests/virscsitest.c
@@ -32,18 +32,34 @@ VIR_LOG_INIT("tests.scsitest");
static char *virscsi_prefix;
+typedef struct {
+ const char *adapter;
+ unsigned int bus;
+ unsigned int target;
+ unsigned int unit;
+ const char *expectedName;
+} testGetDevNameData;
+
static int
-test1(const void *data G_GNUC_UNUSED)
+testGetDevName(const void *opaque)
{
+ const testGetDevNameData *data = opaque;
char *name = NULL;
int ret = -1;
if (!(name = virSCSIDeviceGetDevName(virscsi_prefix,
- "scsi_host1", 0, 0, 0)))
+ data->adapter,
+ data->bus,
+ data->target,
+ data->unit)))
return -1;
- if (STRNEQ(name, "sdh"))
+ if (STRNEQ(name, data->expectedName)) {
+ fprintf(stderr,
+ "SCSI dev name mismatch, expected %s got %s",
+ data->expectedName, name);
goto cleanup;
+ }
ret = 0;
cleanup:
@@ -212,15 +228,27 @@ mymain(void)
CREATE_SYMLINK("0-0-0-0", "0:0:0:0");
CREATE_SYMLINK("1-0-0-0", "1:0:0:0");
+ CREATE_SYMLINK("2-0-0-0", "2:0:0:0");
CREATE_SYMLINK("sg0", "sg0");
+ CREATE_SYMLINK("sg3", "sg3");
CREATE_SYMLINK("sg8", "sg8");
VIR_FREE(virscsi_prefix);
virscsi_prefix = g_strdup(tmpdir);
- if (virTestRun("test1", test1, NULL) < 0)
- ret = -1;
+#define TEST_GET_DEV_NAME(adapter, bus, target, unit, expectedName) \
+ do { \
+ testGetDevNameData data = {adapter, bus, target, unit, expectedName}; \
+ if (virTestRun("test getDevname " expectedName, \
+ testGetDevName, &data) < 0) \
+ ret = -1; \
+ } while (0)
+
+ TEST_GET_DEV_NAME("scsi_host0", 0, 0, 0, "sda");
+ TEST_GET_DEV_NAME("scsi_host1", 0, 0, 0, "sdh");
+ TEST_GET_DEV_NAME("scsi_host2", 0, 0, 0, "st0");
+
if (virTestRun("test2", test2, NULL) < 0)
ret = -1;
--
2.25.1

View File

@ -0,0 +1,37 @@
From cd2640c256389b4041e4cd38fd72f77184bb4414 Mon Sep 17 00:00:00 2001
Message-Id: <cd2640c256389b4041e4cd38fd72f77184bb4414@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 6 Mar 2020 15:52:24 +0100
Subject: [PATCH] RHEL: virutil: Accept non-block devices in virGetDeviceID()
If a caller wants to learn major or minor number for a device,
let them. There's no need to check if the device is a block
device here.
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200306145226.1610708-5-abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/util/virutil.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/util/virutil.c b/src/util/virutil.c
index a0fd7618ee..f142951acf 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1379,9 +1379,6 @@ virGetDeviceID(const char *path, int *maj, int *min)
if (stat(path, &sb) < 0)
return -errno;
- if (!S_ISBLK(sb.st_mode))
- return -EINVAL;
-
if (maj)
*maj = major(sb.st_rdev);
if (min)
--
2.25.1

View File

@ -0,0 +1,62 @@
From ca7c7a8b07c31dc8bf96f7da6fb53af884e36ddb Mon Sep 17 00:00:00 2001
Message-Id: <ca7c7a8b07c31dc8bf96f7da6fb53af884e36ddb@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 4 Feb 2020 15:08:01 +0100
Subject: [PATCH] Remove checking of return value of virHashNew
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
There are two calls to virHashNew which check the return value. It's not
necessary any more as virHashNew always returns a valid pointer.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 6eab924daa243afa67f2cc20dcbdf521904bb62b)
https://bugzilla.redhat.com/show_bug.cgi?id=1793263
Message-Id: <08acb2e50b584a75c0131a628ee441f47e8fe823.1580824112.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/backup_conf.c | 6 +-----
src/qemu/qemu_monitor_json.c | 3 +--
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
index b370b686f1..64c8f6cc09 100644
--- a/src/conf/backup_conf.c
+++ b/src/conf/backup_conf.c
@@ -439,15 +439,11 @@ virDomainBackupAlignDisks(virDomainBackupDefPtr def,
virDomainDefPtr dom,
const char *suffix)
{
- g_autoptr(virHashTable) disks = NULL;
+ g_autoptr(virHashTable) disks = virHashNew(NULL);
size_t i;
int ndisks;
bool backup_all = false;
-
- if (!(disks = virHashNew(NULL)))
- return -1;
-
/* Unlikely to have a guest without disks but technically possible. */
if (!dom->ndisks) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 5d8c7e9b5e..3fc0bcb80c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2992,8 +2992,7 @@ qemuMonitorJSONBlockGetNamedNodeDataJSON(virJSONValuePtr nodes)
{
g_autoptr(virHashTable) ret = NULL;
- if (!(ret = virHashNew((virHashDataFree) qemuMonitorJSONBlockNamedNodeDataFree)))
- return NULL;
+ ret = virHashNew((virHashDataFree) qemuMonitorJSONBlockNamedNodeDataFree);
if (virJSONValueArrayForeachSteal(nodes,
qemuMonitorJSONBlockGetNamedNodeDataWorker,
--
2.25.0

View File

@ -0,0 +1,109 @@
From 160863c5cac5519c287462439b9ce8abc6a8237e Mon Sep 17 00:00:00 2001
Message-Id: <160863c5cac5519c287462439b9ce8abc6a8237e@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 16 Mar 2020 22:11:48 +0100
Subject: [PATCH] Remove qemuDomainSecretInfoNew
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Replace it by a direct call to qemuDomainSecretAESSetupFromSecret.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit f742461389c11a7d4cc8bda941814c4128eadf94)
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
Message-Id: <c14d98c90ae9d0e9c5e4fef6a8e5061411c43a78.1584391726.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_domain.c | 53 +++++++++++-------------------------------
1 file changed, 13 insertions(+), 40 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c286f50650..af23079d5d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1669,33 +1669,6 @@ qemuDomainSecretInfoNewPlain(virSecretUsageType usageType,
}
-/* qemuDomainSecretInfoNew:
- * @priv: pointer to domain private object
- * @srcAlias: Alias base to use for TLS object
- * @usageType: Secret usage type
- * @username: username
- * @looupDef: lookup def describing secret
- * @isLuks: boolean for luks lookup
- *
- * Helper function to create a secinfo to be used for secinfo consumers. This
- * sets up encrypted data to be used with qemu's 'secret' object.
- *
- * Returns @secinfo on success, NULL on failure. Caller is responsible
- * to eventually free @secinfo.
- */
-static qemuDomainSecretInfoPtr
-qemuDomainSecretInfoNew(qemuDomainObjPrivatePtr priv,
- const char *srcAlias,
- virSecretUsageType usageType,
- const char *username,
- virSecretLookupTypeDefPtr lookupDef,
- bool isLuks)
-{
- return qemuDomainSecretAESSetupFromSecret(priv, srcAlias, usageType, username,
- lookupDef, isLuks);
-}
-
-
/**
* qemuDomainSecretInfoTLSNew:
* @priv: pointer to domain private object
@@ -1722,9 +1695,9 @@ qemuDomainSecretInfoTLSNew(qemuDomainObjPrivatePtr priv,
}
seclookupdef.type = VIR_SECRET_LOOKUP_TYPE_UUID;
- return qemuDomainSecretInfoNew(priv, srcAlias,
- VIR_SECRET_USAGE_TYPE_TLS, NULL,
- &seclookupdef, false);
+ return qemuDomainSecretAESSetupFromSecret(priv, srcAlias,
+ VIR_SECRET_USAGE_TYPE_TLS,
+ NULL, &seclookupdef, false);
}
@@ -1814,11 +1787,11 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjPrivatePtr priv,
src->auth->username,
&src->auth->seclookupdef);
} else {
- srcPriv->secinfo = qemuDomainSecretInfoNew(priv, authalias,
- usageType,
- src->auth->username,
- &src->auth->seclookupdef,
- false);
+ srcPriv->secinfo = qemuDomainSecretAESSetupFromSecret(priv, authalias,
+ usageType,
+ src->auth->username,
+ &src->auth->seclookupdef,
+ false);
}
if (!srcPriv->secinfo)
@@ -1826,11 +1799,11 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjPrivatePtr priv,
}
if (hasEnc) {
- if (!(srcPriv->encinfo =
- qemuDomainSecretInfoNew(priv, encalias,
- VIR_SECRET_USAGE_TYPE_VOLUME, NULL,
- &src->encryption->secrets[0]->seclookupdef,
- true)))
+ if (!(srcPriv->encinfo = qemuDomainSecretAESSetupFromSecret(priv, encalias,
+ VIR_SECRET_USAGE_TYPE_VOLUME,
+ NULL,
+ &src->encryption->secrets[0]->seclookupdef,
+ true)))
return -1;
}
--
2.25.1

View File

@ -1,84 +0,0 @@
From 195908ad66fc52643d94eca0f45e5740f25e3e78 Mon Sep 17 00:00:00 2001
Message-Id: <195908ad66fc52643d94eca0f45e5740f25e3e78@dist-git>
From: Laine Stump <laine@laine.org>
Date: Fri, 1 Feb 2019 20:29:26 -0500
Subject: [PATCH] Revert "RHEL: network: regain guest network connectivity
after firewalld switch to nftables"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit 54e270d7fb68b41002654374d395e4f260a24add.
This patch appeared in libvirt-4.5.0-11.el8 (RHEL git commit id
2fb53957). It was a downstream-only temporary fix to the networking
issues resulting from firewalld's switch to using nftables. Now that
there is a permanent fix upstream we can revert this patch and use the
upstream patches instead.
https://bugzilla.redhat.com/1650320
Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
libvirt.spec.in | 14 --------------
src/network/Makefile.inc.am | 10 +---------
src/network/libvirt.zone | 15 ---------------
3 files changed, 1 insertion(+), 38 deletions(-)
delete mode 100644 src/network/libvirt.zone
diff --git a/src/network/Makefile.inc.am b/src/network/Makefile.inc.am
index 20d899e699..508c8c0422 100644
--- a/src/network/Makefile.inc.am
+++ b/src/network/Makefile.inc.am
@@ -87,11 +87,6 @@ install-data-network:
( cd $(DESTDIR)$(confdir)/qemu/networks/autostart && \
rm -f default.xml && \
$(LN_S) ../default.xml default.xml )
-if HAVE_FIREWALLD
- $(MKDIR_P) "$(DESTDIR)$(prefix)/lib/firewalld/zones"
- $(INSTALL_DATA) $(srcdir)/network/libvirt.zone \
- $(DESTDIR)$(prefix)/lib/firewalld/zones/libvirt.xml
-endif HAVE_FIREWALLD
uninstall-data-network:
rm -f $(DESTDIR)$(confdir)/qemu/networks/autostart/default.xml
@@ -100,13 +95,10 @@ uninstall-data-network:
rmdir "$(DESTDIR)$(confdir)/qemu/networks" || :
rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/network" ||:
rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/network" ||:
-if HAVE_FIREWALLD
- rm -f $(DESTDIR)$(prefix)/lib/firewalld/zones/libvirt.xml
-endif HAVE_FIREWALLD
endif WITH_NETWORK
-EXTRA_DIST += network/default.xml network/libvirt.zone
+EXTRA_DIST += network/default.xml
.PHONY: \
install-data-network \
diff --git a/src/network/libvirt.zone b/src/network/libvirt.zone
deleted file mode 100644
index 355a70b4da..0000000000
--- a/src/network/libvirt.zone
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<zone target="ACCEPT">
- <short>libvirt</short>
- <description>All network connections are accepted. This also permits packets to/from interfaces in the zone to be forwarded. This zone is intended to be used only by libvirt virtual networks.</description>
- <interface name="virbr0"/>
- <interface name="virbr1"/>
- <interface name="virbr2"/>
- <interface name="virbr3"/>
- <interface name="virbr4"/>
- <interface name="virbr5"/>
- <interface name="virbr6"/>
- <interface name="virbr7"/>
- <interface name="virbr8"/>
- <interface name="virbr9"/>
-</zone>
--
2.20.1

View File

@ -1,93 +0,0 @@
From 8069bb50b2548acd3f2176499ede205e6099c067 Mon Sep 17 00:00:00 2001
Message-Id: <8069bb50b2548acd3f2176499ede205e6099c067@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:18:17 +0200
Subject: [PATCH] Revert "Separate out StateAutoStart from StateInitialize"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit e4a969092bda5b3b952963fdf6658895165040b7.
Now that drivers may call virConnectOpen() on secondary drivers, it
doesn't make much sense to have autostart separated from driver
initialization callback. In fact, it creates a problem because one
driver during its initialization might try to fetch an object from
another driver but since the object is yet to be autostarted the fetch
fails. This has been observed in reality: qemu driver performs
qemuProcessReconnect() during qemu's stateInitialize phase which may
call virDomainDiskTranslateSourcePool() which connects to the storage
driver to look up the volume. But the storage driver did not autostart
its pools yet therefore volume lookup fails and the domain is killed.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 07a9c8bae8b80ef1650e6d05869cbf55c6aea837)
https://bugzilla.redhat.com/show_bug.cgi?id=1685151
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <4ed5f8f4edd0053cc14f4bb579a945b606b36f5a.1561641375.git.mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/driver-state.h | 4 ----
src/libvirt.c | 14 +-------------
2 files changed, 1 insertion(+), 17 deletions(-)
diff --git a/src/driver-state.h b/src/driver-state.h
index 1cb3e4faf3..e1e060bcc5 100644
--- a/src/driver-state.h
+++ b/src/driver-state.h
@@ -30,9 +30,6 @@ typedef int
virStateInhibitCallback callback,
void *opaque);
-typedef void
-(*virDrvStateAutoStart)(void);
-
typedef int
(*virDrvStateCleanup)(void);
@@ -48,7 +45,6 @@ typedef virStateDriver *virStateDriverPtr;
struct _virStateDriver {
const char *name;
virDrvStateInitialize stateInitialize;
- virDrvStateAutoStart stateAutoStart;
virDrvStateCleanup stateCleanup;
virDrvStateReload stateReload;
virDrvStateStop stateStop;
diff --git a/src/libvirt.c b/src/libvirt.c
index 52f4dd2808..c9e5f47fd4 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -637,11 +637,7 @@ virRegisterStateDriver(virStateDriverPtr driver)
* @callback: callback to invoke to inhibit shutdown of the daemon
* @opaque: data to pass to @callback
*
- * Initialize all virtualization drivers. Accomplished in two phases,
- * the first being state and structure initialization followed by any
- * auto start supported by the driver. This is done to ensure dependencies
- * that some drivers may have on another driver having been initialized
- * will exist, such as the storage driver's need to use the secret driver.
+ * Initialize all virtualization drivers.
*
* Returns 0 if all succeed, -1 upon any failure.
*/
@@ -669,14 +665,6 @@ virStateInitialize(bool privileged,
}
}
}
-
- for (i = 0; i < virStateDriverTabCount; i++) {
- if (virStateDriverTab[i]->stateAutoStart) {
- VIR_DEBUG("Running global auto start for %s state driver",
- virStateDriverTab[i]->name);
- virStateDriverTab[i]->stateAutoStart();
- }
- }
return 0;
}
--
2.22.0

View File

@ -1,163 +0,0 @@
From 6af885a53e425b88c7d9c123f64bbc4f8517b8a8 Mon Sep 17 00:00:00 2001
Message-Id: <6af885a53e425b88c7d9c123f64bbc4f8517b8a8@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Thu, 15 Nov 2018 06:43:58 -0500
Subject: [PATCH] Revert "access: Modify the VIR_ERR_ACCESS_DENIED to include
driverName"
https://bugzilla.redhat.com/show_bug.cgi?id=1631608 (RHEL8)
https://bugzilla.redhat.com/show_bug.cgi?id=1631606 (RHEL7)
This reverts commit ccc72d5cbdd85f66cb737134b3be40aac1df03ef.
Based on upstream comment to a follow-up patch, this didn't take the
right approach and the right thing to do is revert and rework.
Signed-off-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit b08396a5feab02fb3bb595603c888ee733aa178e)
Reviewed-by: Erik Skultety <eskultet@redhat.com>
---
src/access/viraccessmanager.c | 25 ++++++++++++-------------
src/rpc/gendispatch.pl | 2 +-
src/util/virerror.c | 4 ++--
3 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/src/access/viraccessmanager.c b/src/access/viraccessmanager.c
index 1dfff32b9d..e7b5bf38da 100644
--- a/src/access/viraccessmanager.c
+++ b/src/access/viraccessmanager.c
@@ -196,12 +196,11 @@ static void virAccessManagerDispose(void *object)
* should the admin need to debug things
*/
static int
-virAccessManagerSanitizeError(int ret,
- const char *driverName)
+virAccessManagerSanitizeError(int ret)
{
if (ret < 0) {
virResetLastError();
- virAccessError(VIR_ERR_ACCESS_DENIED, driverName, NULL);
+ virAccessError(VIR_ERR_ACCESS_DENIED, NULL);
}
return ret;
@@ -218,7 +217,7 @@ int virAccessManagerCheckConnect(virAccessManagerPtr manager,
if (manager->drv->checkConnect)
ret = manager->drv->checkConnect(manager, driverName, perm);
- return virAccessManagerSanitizeError(ret, driverName);
+ return virAccessManagerSanitizeError(ret);
}
@@ -234,7 +233,7 @@ int virAccessManagerCheckDomain(virAccessManagerPtr manager,
if (manager->drv->checkDomain)
ret = manager->drv->checkDomain(manager, driverName, domain, perm);
- return virAccessManagerSanitizeError(ret, driverName);
+ return virAccessManagerSanitizeError(ret);
}
int virAccessManagerCheckInterface(virAccessManagerPtr manager,
@@ -249,7 +248,7 @@ int virAccessManagerCheckInterface(virAccessManagerPtr manager,
if (manager->drv->checkInterface)
ret = manager->drv->checkInterface(manager, driverName, iface, perm);
- return virAccessManagerSanitizeError(ret, driverName);
+ return virAccessManagerSanitizeError(ret);
}
int virAccessManagerCheckNetwork(virAccessManagerPtr manager,
@@ -264,7 +263,7 @@ int virAccessManagerCheckNetwork(virAccessManagerPtr manager,
if (manager->drv->checkNetwork)
ret = manager->drv->checkNetwork(manager, driverName, network, perm);
- return virAccessManagerSanitizeError(ret, driverName);
+ return virAccessManagerSanitizeError(ret);
}
int virAccessManagerCheckNodeDevice(virAccessManagerPtr manager,
@@ -279,7 +278,7 @@ int virAccessManagerCheckNodeDevice(virAccessManagerPtr manager,
if (manager->drv->checkNodeDevice)
ret = manager->drv->checkNodeDevice(manager, driverName, nodedev, perm);
- return virAccessManagerSanitizeError(ret, driverName);
+ return virAccessManagerSanitizeError(ret);
}
int virAccessManagerCheckNWFilter(virAccessManagerPtr manager,
@@ -294,7 +293,7 @@ int virAccessManagerCheckNWFilter(virAccessManagerPtr manager,
if (manager->drv->checkNWFilter)
ret = manager->drv->checkNWFilter(manager, driverName, nwfilter, perm);
- return virAccessManagerSanitizeError(ret, driverName);
+ return virAccessManagerSanitizeError(ret);
}
int virAccessManagerCheckNWFilterBinding(virAccessManagerPtr manager,
@@ -309,7 +308,7 @@ int virAccessManagerCheckNWFilterBinding(virAccessManagerPtr manager,
if (manager->drv->checkNWFilterBinding)
ret = manager->drv->checkNWFilterBinding(manager, driverName, binding, perm);
- return virAccessManagerSanitizeError(ret, driverName);
+ return virAccessManagerSanitizeError(ret);
}
int virAccessManagerCheckSecret(virAccessManagerPtr manager,
@@ -324,7 +323,7 @@ int virAccessManagerCheckSecret(virAccessManagerPtr manager,
if (manager->drv->checkSecret)
ret = manager->drv->checkSecret(manager, driverName, secret, perm);
- return virAccessManagerSanitizeError(ret, driverName);
+ return virAccessManagerSanitizeError(ret);
}
int virAccessManagerCheckStoragePool(virAccessManagerPtr manager,
@@ -339,7 +338,7 @@ int virAccessManagerCheckStoragePool(virAccessManagerPtr manager,
if (manager->drv->checkStoragePool)
ret = manager->drv->checkStoragePool(manager, driverName, pool, perm);
- return virAccessManagerSanitizeError(ret, driverName);
+ return virAccessManagerSanitizeError(ret);
}
int virAccessManagerCheckStorageVol(virAccessManagerPtr manager,
@@ -355,5 +354,5 @@ int virAccessManagerCheckStorageVol(virAccessManagerPtr manager,
if (manager->drv->checkStorageVol)
ret = manager->drv->checkStorageVol(manager, driverName, pool, vol, perm);
- return virAccessManagerSanitizeError(ret, driverName);
+ return virAccessManagerSanitizeError(ret);
}
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index f599002056..0c4648c0fb 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -2199,7 +2199,7 @@ elsif ($mode eq "client") {
print " virObjectUnref(mgr);\n";
if ($action eq "Ensure") {
print " if (rv == 0)\n";
- print " virReportError(VIR_ERR_ACCESS_DENIED, conn->driver->name, NULL);\n";
+ print " virReportError(VIR_ERR_ACCESS_DENIED, NULL);\n";
print " return $fail;\n";
} else {
print " virResetLastError();\n";
diff --git a/src/util/virerror.c b/src/util/virerror.c
index 5f50fa0349..f198f27957 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -1439,9 +1439,9 @@ virErrorMsg(virErrorNumber error, const char *info)
break;
case VIR_ERR_ACCESS_DENIED:
if (info == NULL)
- errmsg = _("access denied from '%s'");
+ errmsg = _("access denied");
else
- errmsg = _("access denied from '%s': %s");
+ errmsg = _("access denied: %s");
break;
case VIR_ERR_DBUS_SERVICE:
if (info == NULL)
--
2.19.2

View File

@ -1,108 +0,0 @@
From 2395bf301cf76ffa863a3c2e125d52345cfbf6b5 Mon Sep 17 00:00:00 2001
Message-Id: <2395bf301cf76ffa863a3c2e125d52345cfbf6b5@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:08:23 +0200
Subject: [PATCH] Revert "util: vircgroup: pass parent cgroup into
virCgroupDetectControllersCB"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit 7bca1c9bdc85247446129f856e27c80a32819e17.
As it turns out it's not a good idea on systemd hosts. The root
cgroup can have all controllers enabled but they don't have to be
enabled for sub-cgroups.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit d117431143d5b6dcfc8fae4a6b3fae23881d0937)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <754b0ac5a0f1bd21e79eaeb71f6d2ab811446168.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/util/vircgroup.c | 2 +-
src/util/vircgroupbackend.h | 3 +--
src/util/vircgroupv1.c | 3 +--
src/util/vircgroupv2.c | 17 ++++++-----------
4 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index ff2a0b75b5..a7fb595bce 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -412,7 +412,7 @@ virCgroupDetect(virCgroupPtr group,
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
if (group->backends[i]) {
- int rc = group->backends[i]->detectControllers(group, controllers, parent);
+ int rc = group->backends[i]->detectControllers(group, controllers);
if (rc < 0)
return -1;
controllersAvailable |= rc;
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 05af118ec1..a825dc4be7 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -96,8 +96,7 @@ typedef char *
typedef int
(*virCgroupDetectControllersCB)(virCgroupPtr group,
- int controllers,
- virCgroupPtr parent);
+ int controllers);
typedef bool
(*virCgroupHasControllerCB)(virCgroupPtr cgroup,
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 5b218c7f78..58bd20d636 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -419,8 +419,7 @@ virCgroupV1StealPlacement(virCgroupPtr group)
static int
virCgroupV1DetectControllers(virCgroupPtr group,
- int controllers,
- virCgroupPtr parent ATTRIBUTE_UNUSED)
+ int controllers)
{
size_t i;
size_t j;
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index bdeab397a3..b0ed889cc8 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -285,21 +285,16 @@ virCgroupV2ParseControllersFile(virCgroupPtr group)
static int
virCgroupV2DetectControllers(virCgroupPtr group,
- int controllers,
- virCgroupPtr parent)
+ int controllers)
{
size_t i;
- if (parent) {
- group->unified.controllers = parent->unified.controllers;
- } else {
- if (virCgroupV2ParseControllersFile(group) < 0)
- return -1;
+ if (virCgroupV2ParseControllersFile(group) < 0)
+ return -1;
- /* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
- * exists with usage stats. */
- group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
- }
+ /* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
+ * exists with usage stats. */
+ group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
if (controllers >= 0)
group->unified.controllers &= controllers;
--
2.22.0

View File

@ -1,295 +0,0 @@
From 799c9dd37390878a54be303b3e3e27445049bf2b Mon Sep 17 00:00:00 2001
Message-Id: <799c9dd37390878a54be303b3e3e27445049bf2b@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:18:16 +0200
Subject: [PATCH] Revert "virStateDriver - Separate AutoStart from Initialize"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit cefb97fb815c81fc882da752f45effd23bcb9b4b.
The stateAutoStart callback will be removed in the next commit.
Therefore move autostarting of domains, networks and storage
pools back into stateInitialize callbacks.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit fc380c2e018ae15347d4c281a7e74896c48cac4a)
https://bugzilla.redhat.com/show_bug.cgi?id=1685151
The difference to the upstream commit is uml driver change. In
upstream, the uml driver was dropped, but it's still kept around
in downstream.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <a8e69f65b397c81c2a68597cca6c8ac04df24153.1561641375.git.mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libxl/libxl_driver.c | 14 +++-----------
src/lxc/lxc_driver.c | 16 ++--------------
src/network/bridge_driver.c | 22 ++++------------------
src/qemu/qemu_driver.c | 17 ++---------------
src/storage/storage_driver.c | 19 ++-----------------
src/uml/uml_driver.c | 17 ++---------------
6 files changed, 15 insertions(+), 90 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 5a5e792957..99bb010af4 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -773,6 +773,9 @@ libxlStateInitialize(bool privileged,
NULL, NULL) < 0)
goto error;
+ virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
+ libxl_driver);
+
virDomainObjListForEach(libxl_driver->domains, libxlDomainManagedSaveLoad,
libxl_driver);
@@ -784,16 +787,6 @@ libxlStateInitialize(bool privileged,
return -1;
}
-static void
-libxlStateAutoStart(void)
-{
- if (!libxl_driver)
- return;
-
- virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
- libxl_driver);
-}
-
static int
libxlStateReload(void)
{
@@ -6479,7 +6472,6 @@ static virConnectDriver libxlConnectDriver = {
static virStateDriver libxlStateDriver = {
.name = "LIBXL",
.stateInitialize = libxlStateInitialize,
- .stateAutoStart = libxlStateAutoStart,
.stateCleanup = libxlStateCleanup,
.stateReload = libxlStateReload,
};
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index f9794e0655..527fa72083 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1646,6 +1646,8 @@ static int lxcStateInitialize(bool privileged,
NULL, NULL) < 0)
goto cleanup;
+ virLXCProcessAutostartAll(lxc_driver);
+
virObjectUnref(caps);
return 0;
@@ -1655,19 +1657,6 @@ static int lxcStateInitialize(bool privileged,
return -1;
}
-/**
- * lxcStateAutoStart:
- *
- * Function to autostart the LXC daemons
- */
-static void lxcStateAutoStart(void)
-{
- if (!lxc_driver)
- return;
-
- virLXCProcessAutostartAll(lxc_driver);
-}
-
static void lxcNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
{
virLXCDriverPtr driver = opaque;
@@ -5550,7 +5539,6 @@ static virConnectDriver lxcConnectDriver = {
static virStateDriver lxcStateDriver = {
.name = LXC_DRIVER_NAME,
.stateInitialize = lxcStateInitialize,
- .stateAutoStart = lxcStateAutoStart,
.stateCleanup = lxcStateCleanup,
.stateReload = lxcStateReload,
};
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index d153a8cdb6..a60d7db685 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -755,6 +755,10 @@ networkStateInitialize(bool privileged,
networkReloadFirewallRules(network_driver);
networkRefreshDaemons(network_driver);
+ virNetworkObjListForEach(network_driver->networks,
+ networkAutostartConfig,
+ network_driver);
+
network_driver->networkEventState = virObjectEventStateNew();
#ifdef WITH_FIREWALLD
@@ -794,23 +798,6 @@ networkStateInitialize(bool privileged,
}
-/**
- * networkStateAutoStart:
- *
- * Function to AutoStart the bridge configs
- */
-static void
-networkStateAutoStart(void)
-{
- if (!network_driver)
- return;
-
- virNetworkObjListForEach(network_driver->networks,
- networkAutostartConfig,
- network_driver);
-}
-
-
/**
* networkStateReload:
*
@@ -5616,7 +5603,6 @@ static virConnectDriver networkConnectDriver = {
static virStateDriver networkStateDriver = {
.name = "bridge",
.stateInitialize = networkStateInitialize,
- .stateAutoStart = networkStateAutoStart,
.stateCleanup = networkStateCleanup,
.stateReload = networkStateReload,
};
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2da87992fd..056d324a62 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -911,6 +911,8 @@ qemuStateInitialize(bool privileged,
qemuProcessReconnectAll(qemu_driver);
+ qemuAutostartDomains(qemu_driver);
+
return 0;
error:
@@ -921,20 +923,6 @@ qemuStateInitialize(bool privileged,
return -1;
}
-/**
- * qemuStateAutoStart:
- *
- * Function to auto start the QEMU daemons
- */
-static void
-qemuStateAutoStart(void)
-{
- if (!qemu_driver)
- return;
-
- qemuAutostartDomains(qemu_driver);
-}
-
static void qemuNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
{
virQEMUDriverPtr driver = opaque;
@@ -21846,7 +21834,6 @@ static virConnectDriver qemuConnectDriver = {
static virStateDriver qemuStateDriver = {
.name = QEMU_DRIVER_NAME,
.stateInitialize = qemuStateInitialize,
- .stateAutoStart = qemuStateAutoStart,
.stateCleanup = qemuStateCleanup,
.stateReload = qemuStateReload,
.stateStop = qemuStateStop,
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 254818e308..f61fb074e6 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -291,6 +291,8 @@ storageStateInitialize(bool privileged,
storagePoolUpdateAllState();
+ storageDriverAutostart();
+
driver->storageEventState = virObjectEventStateNew();
storageDriverUnlock();
@@ -307,22 +309,6 @@ storageStateInitialize(bool privileged,
goto cleanup;
}
-/**
- * storageStateAutoStart:
- *
- * Function to auto start the storage driver
- */
-static void
-storageStateAutoStart(void)
-{
- if (!driver)
- return;
-
- storageDriverLock();
- storageDriverAutostart();
- storageDriverUnlock();
-}
-
/**
* storageStateReload:
*
@@ -2843,7 +2829,6 @@ static virConnectDriver storageConnectDriver = {
static virStateDriver stateDriver = {
.name = "storage",
.stateInitialize = storageStateInitialize,
- .stateAutoStart = storageStateAutoStart,
.stateCleanup = storageStateCleanup,
.stateReload = storageStateReload,
};
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index c77988f01e..296adf55d1 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -575,6 +575,8 @@ umlStateInitialize(bool privileged,
umlDriverUnlock(uml_driver);
+ umlAutostartConfigs(uml_driver);
+
VIR_FREE(userdir);
return 0;
@@ -590,20 +592,6 @@ umlStateInitialize(bool privileged,
return -1;
}
-/**
- * umlStateAutoStart:
- *
- * Function to autostart the Uml daemons
- */
-static void
-umlStateAutoStart(void)
-{
- if (!uml_driver)
- return;
-
- umlAutostartConfigs(uml_driver);
-}
-
static void umlNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
{
struct uml_driver *driver = opaque;
@@ -2826,7 +2814,6 @@ static virConnectDriver umlConnectDriver = {
static virStateDriver umlStateDriver = {
.name = "UML",
.stateInitialize = umlStateInitialize,
- .stateAutoStart = umlStateAutoStart,
.stateCleanup = umlStateCleanup,
.stateReload = umlStateReload,
};
--
2.22.0

View File

@ -1,83 +0,0 @@
From ddea95c1c2e32c6454c89aa83d78b26a83564cd4 Mon Sep 17 00:00:00 2001
Message-Id: <ddea95c1c2e32c6454c89aa83d78b26a83564cd4@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:07:11 +0200
Subject: [PATCH] Revert "vircgroup: cleanup controllers not managed by systemd
on error"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit 1602aa28f820ada66f707cef3e536e8572fbda1e.
There is no need to call virCgroupRemove() nor virCgroupFree() if
virCgroupEnableMissingControllers() fails because it will not modify
'group' at all.
The cleanup of directories is done in virCgroupMakeGroup().
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 199eee6aae7af3d813fbe98660c7e0fa1a8ae7b7)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <53288dd310e0305ac3179693e64684eb8b3a31ab.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/util/vircgroup.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index a376b9b89a..7ec1399bc6 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1059,7 +1059,6 @@ virCgroupNewMachineSystemd(const char *name,
int rv;
virCgroupPtr init;
VIR_AUTOFREE(char *) path = NULL;
- virErrorPtr saved = NULL;
VIR_DEBUG("Trying to setup machine '%s' via systemd", name);
if ((rv = virSystemdCreateMachine(name,
@@ -1092,24 +1091,20 @@ virCgroupNewMachineSystemd(const char *name,
if (virCgroupEnableMissingControllers(path, pidleader,
controllers, group) < 0) {
- goto error;
+ return -1;
}
- if (virCgroupAddProcess(*group, pidleader) < 0)
- goto error;
+ if (virCgroupAddProcess(*group, pidleader) < 0) {
+ virErrorPtr saved = virSaveLastError();
+ virCgroupRemove(*group);
+ virCgroupFree(group);
+ if (saved) {
+ virSetError(saved);
+ virFreeError(saved);
+ }
+ }
return 0;
-
- error:
- saved = virSaveLastError();
- virCgroupRemove(*group);
- virCgroupFree(group);
- if (saved) {
- virSetError(saved);
- virFreeError(saved);
- }
-
- return -1;
}
--
2.22.0

View File

@ -1,60 +0,0 @@
From 254da75ea1a9c2cade909534153f444bb8981c2a Mon Sep 17 00:00:00 2001
Message-Id: <254da75ea1a9c2cade909534153f444bb8981c2a@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 27 Aug 2018 08:27:47 -0400
Subject: [PATCH] access: Fix nwfilter-binding ACL access API name generation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
https://bugzilla.redhat.com/show_bug.cgi?id=1611320
Generation of the ACL API policy is a "automated process"
based on this perl script which "worked" with the changes to
add nwfilter binding API's because they had the "nwfilter"
prefix; however, the generated output name was incorrect
based on the remote protocol algorithm which expected to
generate names such as 'nwfilter-binding.action' instead
of 'nwfilter.binding-action'.
This effectively changes src/access/org.libvirt.api.policy entries:
org.libvirt.api.nwfilter.binding-create ==>
org.libvirt.api.nwfilter-binding.create
org.libvirt.api.nwfilter.binding-delete ==>
org.libvirt.api.nwfilter-binding.delete
org.libvirt.api.nwfilter.binding-getattr ==>
org.libvirt.api.nwfilter-binding.getattr
org.libvirt.api.nwfilter.binding-read ==>
org.libvirt.api.nwfilter-binding.read
Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 6ef65e3c96d5d1f16a16daca83b81b818d461e64)
https: //bugzilla.redhat.com/show_bug.cgi?id=1622540
Reviewed-by: Erik Skultety <eskultet@redhat.com>
---
src/access/genpolkit.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/access/genpolkit.pl b/src/access/genpolkit.pl
index 968cb8c55c..e074c90eb6 100755
--- a/src/access/genpolkit.pl
+++ b/src/access/genpolkit.pl
@@ -22,8 +22,8 @@ use warnings;
my @objects = (
"CONNECT", "DOMAIN", "INTERFACE",
- "NETWORK","NODE_DEVICE", "NWFILTER",
- "SECRET", "STORAGE_POOL", "STORAGE_VOL",
+ "NETWORK","NODE_DEVICE", "NWFILTER_BINDING", "NWFILTER",
+ "SECRET", "STORAGE_POOL", "STORAGE_VOL",
);
my $objects = join ("|", @objects);
--
2.18.0

View File

@ -1,173 +0,0 @@
From 85750b0466aa3719d3d2447abaab2e87db92f552 Mon Sep 17 00:00:00 2001
Message-Id: <85750b0466aa3719d3d2447abaab2e87db92f552@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 5 Nov 2018 07:48:37 -0500
Subject: [PATCH] access: Modify the VIR_ERR_ACCESS_DENIED to include
driverName
https://bugzilla.redhat.com/show_bug.cgi?id=1631608 (RHEL 8.0)
https://bugzilla.redhat.com/show_bug.cgi?id=1631606 (RHEL 7.7)
Changes made to manage and utilize a secondary connection
driver to APIs outside the scope of the primary connection
driver have resulted in some confusion processing polkit rules
since the simple "access denied" error message doesn't provide
enough of a clue when combined with the "authentication failed:
access denied by policy" as to which connection driver refused
or failed the ACL check.
In order to provide some context, let's modify the existing
"access denied" error returne from the various vir*EnsureACL
API's to provide the connection driver name that is causing
the failure. This should provide the context for writing the
polkit rules that would allow access via the driver.
Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit ccc72d5cbdd85f66cb737134b3be40aac1df03ef)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/access/viraccessmanager.c | 25 +++++++++++++------------
src/rpc/gendispatch.pl | 2 +-
src/util/virerror.c | 4 ++--
3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/access/viraccessmanager.c b/src/access/viraccessmanager.c
index e7b5bf38da..1dfff32b9d 100644
--- a/src/access/viraccessmanager.c
+++ b/src/access/viraccessmanager.c
@@ -196,11 +196,12 @@ static void virAccessManagerDispose(void *object)
* should the admin need to debug things
*/
static int
-virAccessManagerSanitizeError(int ret)
+virAccessManagerSanitizeError(int ret,
+ const char *driverName)
{
if (ret < 0) {
virResetLastError();
- virAccessError(VIR_ERR_ACCESS_DENIED, NULL);
+ virAccessError(VIR_ERR_ACCESS_DENIED, driverName, NULL);
}
return ret;
@@ -217,7 +218,7 @@ int virAccessManagerCheckConnect(virAccessManagerPtr manager,
if (manager->drv->checkConnect)
ret = manager->drv->checkConnect(manager, driverName, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
@@ -233,7 +234,7 @@ int virAccessManagerCheckDomain(virAccessManagerPtr manager,
if (manager->drv->checkDomain)
ret = manager->drv->checkDomain(manager, driverName, domain, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckInterface(virAccessManagerPtr manager,
@@ -248,7 +249,7 @@ int virAccessManagerCheckInterface(virAccessManagerPtr manager,
if (manager->drv->checkInterface)
ret = manager->drv->checkInterface(manager, driverName, iface, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckNetwork(virAccessManagerPtr manager,
@@ -263,7 +264,7 @@ int virAccessManagerCheckNetwork(virAccessManagerPtr manager,
if (manager->drv->checkNetwork)
ret = manager->drv->checkNetwork(manager, driverName, network, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckNodeDevice(virAccessManagerPtr manager,
@@ -278,7 +279,7 @@ int virAccessManagerCheckNodeDevice(virAccessManagerPtr manager,
if (manager->drv->checkNodeDevice)
ret = manager->drv->checkNodeDevice(manager, driverName, nodedev, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckNWFilter(virAccessManagerPtr manager,
@@ -293,7 +294,7 @@ int virAccessManagerCheckNWFilter(virAccessManagerPtr manager,
if (manager->drv->checkNWFilter)
ret = manager->drv->checkNWFilter(manager, driverName, nwfilter, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckNWFilterBinding(virAccessManagerPtr manager,
@@ -308,7 +309,7 @@ int virAccessManagerCheckNWFilterBinding(virAccessManagerPtr manager,
if (manager->drv->checkNWFilterBinding)
ret = manager->drv->checkNWFilterBinding(manager, driverName, binding, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckSecret(virAccessManagerPtr manager,
@@ -323,7 +324,7 @@ int virAccessManagerCheckSecret(virAccessManagerPtr manager,
if (manager->drv->checkSecret)
ret = manager->drv->checkSecret(manager, driverName, secret, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckStoragePool(virAccessManagerPtr manager,
@@ -338,7 +339,7 @@ int virAccessManagerCheckStoragePool(virAccessManagerPtr manager,
if (manager->drv->checkStoragePool)
ret = manager->drv->checkStoragePool(manager, driverName, pool, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckStorageVol(virAccessManagerPtr manager,
@@ -354,5 +355,5 @@ int virAccessManagerCheckStorageVol(virAccessManagerPtr manager,
if (manager->drv->checkStorageVol)
ret = manager->drv->checkStorageVol(manager, driverName, pool, vol, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 0c4648c0fb..f599002056 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -2199,7 +2199,7 @@ elsif ($mode eq "client") {
print " virObjectUnref(mgr);\n";
if ($action eq "Ensure") {
print " if (rv == 0)\n";
- print " virReportError(VIR_ERR_ACCESS_DENIED, NULL);\n";
+ print " virReportError(VIR_ERR_ACCESS_DENIED, conn->driver->name, NULL);\n";
print " return $fail;\n";
} else {
print " virResetLastError();\n";
diff --git a/src/util/virerror.c b/src/util/virerror.c
index f198f27957..5f50fa0349 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -1439,9 +1439,9 @@ virErrorMsg(virErrorNumber error, const char *info)
break;
case VIR_ERR_ACCESS_DENIED:
if (info == NULL)
- errmsg = _("access denied");
+ errmsg = _("access denied from '%s'");
else
- errmsg = _("access denied: %s");
+ errmsg = _("access denied from '%s': %s");
break;
case VIR_ERR_DBUS_SERVICE:
if (info == NULL)
--
2.19.1

View File

@ -1,159 +0,0 @@
From 541a154e0f98604f63cb22356287dfa3858748c9 Mon Sep 17 00:00:00 2001
Message-Id: <541a154e0f98604f63cb22356287dfa3858748c9@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Thu, 15 Nov 2018 06:43:59 -0500
Subject: [PATCH] access: Modify the VIR_ERR_ACCESS_DENIED to include
driverName
https://bugzilla.redhat.com/show_bug.cgi?id=1631608 (RHEL8)
https://bugzilla.redhat.com/show_bug.cgi?id=1631606 (RHEL7)
Changes made to manage and utilize a secondary connection
driver to APIs outside the scope of the primary connection
driver have resulted in some confusion processing polkit rules
since the simple "access denied" error message doesn't provide
enough of a clue when combined with the "authentication failed:
access denied by policy" as to which connection driver refused
or failed the ACL check.
In order to provide some context, let's modify the existing
"access denied" error returned from the various vir*EnsureACL
API's to provide the connection driver name that is causing
the failure. This should provide the context for writing the
polkit rules that would allow access via the driver, but yet
still adhere to the virAccessManagerSanitizeError commentary
regarding not telling the user why access was denied.
Signed-off-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit 605496be609e153526fcdd3e98df8cf5244bc8fa)
Reviewed-by: Erik Skultety <eskultet@redhat.com>
---
src/access/viraccessmanager.c | 26 ++++++++++++++------------
src/rpc/gendispatch.pl | 3 ++-
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/access/viraccessmanager.c b/src/access/viraccessmanager.c
index e7b5bf38da..f5d62604cf 100644
--- a/src/access/viraccessmanager.c
+++ b/src/access/viraccessmanager.c
@@ -196,11 +196,13 @@ static void virAccessManagerDispose(void *object)
* should the admin need to debug things
*/
static int
-virAccessManagerSanitizeError(int ret)
+virAccessManagerSanitizeError(int ret,
+ const char *driverName)
{
if (ret < 0) {
virResetLastError();
- virAccessError(VIR_ERR_ACCESS_DENIED, NULL);
+ virAccessError(VIR_ERR_ACCESS_DENIED,
+ _("'%s' denied access"), driverName);
}
return ret;
@@ -217,7 +219,7 @@ int virAccessManagerCheckConnect(virAccessManagerPtr manager,
if (manager->drv->checkConnect)
ret = manager->drv->checkConnect(manager, driverName, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
@@ -233,7 +235,7 @@ int virAccessManagerCheckDomain(virAccessManagerPtr manager,
if (manager->drv->checkDomain)
ret = manager->drv->checkDomain(manager, driverName, domain, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckInterface(virAccessManagerPtr manager,
@@ -248,7 +250,7 @@ int virAccessManagerCheckInterface(virAccessManagerPtr manager,
if (manager->drv->checkInterface)
ret = manager->drv->checkInterface(manager, driverName, iface, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckNetwork(virAccessManagerPtr manager,
@@ -263,7 +265,7 @@ int virAccessManagerCheckNetwork(virAccessManagerPtr manager,
if (manager->drv->checkNetwork)
ret = manager->drv->checkNetwork(manager, driverName, network, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckNodeDevice(virAccessManagerPtr manager,
@@ -278,7 +280,7 @@ int virAccessManagerCheckNodeDevice(virAccessManagerPtr manager,
if (manager->drv->checkNodeDevice)
ret = manager->drv->checkNodeDevice(manager, driverName, nodedev, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckNWFilter(virAccessManagerPtr manager,
@@ -293,7 +295,7 @@ int virAccessManagerCheckNWFilter(virAccessManagerPtr manager,
if (manager->drv->checkNWFilter)
ret = manager->drv->checkNWFilter(manager, driverName, nwfilter, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckNWFilterBinding(virAccessManagerPtr manager,
@@ -308,7 +310,7 @@ int virAccessManagerCheckNWFilterBinding(virAccessManagerPtr manager,
if (manager->drv->checkNWFilterBinding)
ret = manager->drv->checkNWFilterBinding(manager, driverName, binding, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckSecret(virAccessManagerPtr manager,
@@ -323,7 +325,7 @@ int virAccessManagerCheckSecret(virAccessManagerPtr manager,
if (manager->drv->checkSecret)
ret = manager->drv->checkSecret(manager, driverName, secret, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckStoragePool(virAccessManagerPtr manager,
@@ -338,7 +340,7 @@ int virAccessManagerCheckStoragePool(virAccessManagerPtr manager,
if (manager->drv->checkStoragePool)
ret = manager->drv->checkStoragePool(manager, driverName, pool, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
int virAccessManagerCheckStorageVol(virAccessManagerPtr manager,
@@ -354,5 +356,5 @@ int virAccessManagerCheckStorageVol(virAccessManagerPtr manager,
if (manager->drv->checkStorageVol)
ret = manager->drv->checkStorageVol(manager, driverName, pool, vol, perm);
- return virAccessManagerSanitizeError(ret);
+ return virAccessManagerSanitizeError(ret, driverName);
}
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 0c4648c0fb..a8b9f5aeca 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -2199,7 +2199,8 @@ elsif ($mode eq "client") {
print " virObjectUnref(mgr);\n";
if ($action eq "Ensure") {
print " if (rv == 0)\n";
- print " virReportError(VIR_ERR_ACCESS_DENIED, NULL);\n";
+ print " virReportError(VIR_ERR_ACCESS_DENIED,\n";
+ print" _(\"'%s' denied access\"), conn->driver->name);\n";
print " return $fail;\n";
} else {
print " virResetLastError();\n";
--
2.19.2

View File

@ -1,61 +0,0 @@
From 3eaa16967f0546c5d1596bb6c36767cbe01040b9 Mon Sep 17 00:00:00 2001
Message-Id: <3eaa16967f0546c5d1596bb6c36767cbe01040b9@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Wed, 15 May 2019 21:40:56 +0100
Subject: [PATCH] admin: reject clients unless their UID matches the current
UID
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The admin protocol RPC messages are only intended for use by the user
running the daemon. As such they should not be allowed for any client
UID that does not match the server UID.
Fixes CVE-2019-10132
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 96f41cd765c9e525fe28ee5abbfbf4a79b3720c7)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <20190515204058.28077-2-berrange@redhat.com>
---
src/admin/admin_server_dispatch.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/admin/admin_server_dispatch.c b/src/admin/admin_server_dispatch.c
index b78ff902c0..9f25813ae3 100644
--- a/src/admin/admin_server_dispatch.c
+++ b/src/admin/admin_server_dispatch.c
@@ -66,6 +66,28 @@ remoteAdmClientNew(virNetServerClientPtr client ATTRIBUTE_UNUSED,
void *opaque)
{
struct daemonAdmClientPrivate *priv;
+ uid_t clientuid;
+ gid_t clientgid;
+ pid_t clientpid;
+ unsigned long long timestamp;
+
+ if (virNetServerClientGetUNIXIdentity(client,
+ &clientuid,
+ &clientgid,
+ &clientpid,
+ &timestamp) < 0)
+ return NULL;
+
+ VIR_DEBUG("New client pid %lld uid %lld",
+ (long long)clientpid,
+ (long long)clientuid);
+
+ if (geteuid() != clientuid) {
+ virReportRestrictedError(_("Disallowing client %lld with uid %lld"),
+ (long long)clientpid,
+ (long long)clientuid);
+ return NULL;
+ }
if (VIR_ALLOC(priv) < 0)
return NULL;
--
2.22.0

View File

@ -1,46 +0,0 @@
From bab30af2d83e27d9141545cb9dcff51924e52b4d Mon Sep 17 00:00:00 2001
Message-Id: <bab30af2d83e27d9141545cb9dcff51924e52b4d@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Tue, 18 Jun 2019 13:30:02 +0200
Subject: [PATCH] api: disallow virConnect*HypervisorCPU on read-only
connections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
These APIs can be used to execute arbitrary emulators.
Forbid them on read-only connections.
Fixes: CVE-2019-10168
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Message-Id: <470651092e7d6a4ba5875cf8885fd3714d5ea189.1560857354.git.jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libvirt-host.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/libvirt-host.c b/src/libvirt-host.c
index e20d6ee250..2978825d22 100644
--- a/src/libvirt-host.c
+++ b/src/libvirt-host.c
@@ -1041,6 +1041,7 @@ virConnectCompareHypervisorCPU(virConnectPtr conn,
virCheckConnectReturn(conn, VIR_CPU_COMPARE_ERROR);
virCheckNonNullArgGoto(xmlCPU, error);
+ virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->connectCompareHypervisorCPU) {
int ret;
@@ -1234,6 +1235,7 @@ virConnectBaselineHypervisorCPU(virConnectPtr conn,
virCheckConnectReturn(conn, NULL);
virCheckNonNullArgGoto(xmlCPUs, error);
+ virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->connectBaselineHypervisorCPU) {
char *cpu;
--
2.22.0

View File

@ -1,38 +0,0 @@
From 2b0e20b240848c84932aa549e8ec2b6e0a5646fa Mon Sep 17 00:00:00 2001
Message-Id: <2b0e20b240848c84932aa549e8ec2b6e0a5646fa@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Tue, 18 Jun 2019 13:30:01 +0200
Subject: [PATCH] api: disallow virConnectGetDomainCapabilities on read-only
connections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This API can be used to execute arbitrary emulators.
Forbid it on read-only connections.
Fixes: CVE-2019-10167
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Message-Id: <eeefd7cf2afba696bed78582e086bfbd3ed23e00.1560857354.git.jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libvirt-domain.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 3855dfe0dd..a1c913bd86 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11279,6 +11279,7 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
virResetLastError();
virCheckConnectReturn(conn, NULL);
+ virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->connectGetDomainCapabilities) {
char *ret;
--
2.22.0

View File

@ -0,0 +1,45 @@
From 0c1bec6a89f97c77ba9e0ed4146deb8606ea6f16 Mon Sep 17 00:00:00 2001
Message-Id: <0c1bec6a89f97c77ba9e0ed4146deb8606ea6f16@dist-git>
From: Jonathon Jongsma <jjongsma@redhat.com>
Date: Wed, 25 Mar 2020 11:21:19 -0500
Subject: [PATCH] api: disallow virDomainAgentSetResponseTimeout() on read-only
connections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This function changes the amount of time that libvirt waits for a
response from the guest agent for all guest agent commands. Since this
is a configuration change, it should not be allowed on read-only
connections.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 4cc90c2e62df653e909ad31fd810224bf8bcf913)
https://bugzilla.redhat.com/show_bug.cgi?id=1814508
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Message-Id: <20200325162119.9047-2-jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/libvirt-domain.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index eb66999f07..3deee54e48 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -12554,6 +12554,8 @@ virDomainAgentSetResponseTimeout(virDomainPtr domain,
virCheckDomainReturn(domain, -1);
conn = domain->conn;
+ virCheckReadOnlyGoto(conn->flags, error);
+
if (conn->driver->domainAgentSetResponseTimeout) {
if (conn->driver->domainAgentSetResponseTimeout(domain, timeout, flags) < 0)
goto error;
--
2.26.0

View File

@ -1,40 +0,0 @@
From 0673d5b707d68562732b78c89fe339e8558f8496 Mon Sep 17 00:00:00 2001
Message-Id: <0673d5b707d68562732b78c89fe339e8558f8496@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Tue, 18 Jun 2019 13:30:00 +0200
Subject: [PATCH] api: disallow virDomainManagedSaveDefineXML on read-only
connections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The virDomainManagedSaveDefineXML can be used to alter the domain's
config used for managedsave or even execute arbitrary emulator binaries.
Forbid it on read-only connections.
Fixes: CVE-2019-10166
Reported-by: Matthias Gerstner <mgerstner@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Message-Id: <352bf5e963a6482d426f97b0ef36ca019e69280b.1560857354.git.jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libvirt-domain.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 0ba85b9360..3855dfe0dd 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -9487,6 +9487,7 @@ virDomainManagedSaveDefineXML(virDomainPtr domain, const char *dxml,
virCheckDomainReturn(domain, -1);
conn = domain->conn;
+ virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainManagedSaveDefineXML) {
int ret;
--
2.22.0

View File

@ -1,98 +0,0 @@
From 8533d820c378ae31176922703b7368f586a59bc0 Mon Sep 17 00:00:00 2001
Message-Id: <8533d820c378ae31176922703b7368f586a59bc0@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Tue, 18 Jun 2019 13:29:59 +0200
Subject: [PATCH] api: disallow virDomainSaveImageGetXMLDesc on read-only
connections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The virDomainSaveImageGetXMLDesc API is taking a path parameter,
which can point to any path on the system. This file will then be
read and parsed by libvirtd running with root privileges.
Forbid it on read-only connections.
Fixes: CVE-2019-10161
Reported-by: Matthias Gerstner <mgerstner@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Conflicts:
src/libvirt-domain.c
src/remote/remote_protocol.x
Upstream commit 12a51f372 which introduced the VIR_DOMAIN_SAVE_IMAGE_XML_SECURE
alias for VIR_DOMAIN_XML_SECURE is not backported.
Just skip the commit since we now disallow the whole API on read-only
connections, regardless of the flag.
Message-Id: <4c14d609cd7b548459b9ef2f59728fa5c5e38268.1560857354.git.jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libvirt-domain.c | 11 ++---------
src/qemu/qemu_driver.c | 2 +-
src/remote/remote_protocol.x | 3 +--
3 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index ad0ded9ee3..0ba85b9360 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -1073,9 +1073,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,
* previously by virDomainSave() or virDomainSaveFlags().
*
* No security-sensitive data will be included unless @flags contains
- * VIR_DOMAIN_XML_SECURE; this flag is rejected on read-only
- * connections. For this API, @flags should not contain either
- * VIR_DOMAIN_XML_INACTIVE or VIR_DOMAIN_XML_UPDATE_CPU.
+ * VIR_DOMAIN_XML_SECURE.
*
* Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of
* error. The caller must free() the returned value.
@@ -1091,12 +1089,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
virCheckConnectReturn(conn, NULL);
virCheckNonNullArgGoto(file, error);
-
- if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
- virReportError(VIR_ERR_OPERATION_DENIED, "%s",
- _("virDomainSaveImageGetXMLDesc with secure flag"));
- goto error;
- }
+ virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainSaveImageGetXMLDesc) {
char *ret;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 88c08f88ee..2da87992fd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6786,7 +6786,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
if (fd < 0)
goto cleanup;
- if (virDomainSaveImageGetXMLDescEnsureACL(conn, def, flags) < 0)
+ if (virDomainSaveImageGetXMLDescEnsureACL(conn, def) < 0)
goto cleanup;
ret = qemuDomainDefFormatXML(driver, def, flags);
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 28c8febabd..52b92334fa 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -5226,8 +5226,7 @@ enum remote_procedure {
/**
* @generate: both
* @priority: high
- * @acl: domain:read
- * @acl: domain:read_secure:VIR_DOMAIN_XML_SECURE
+ * @acl: domain:write
*/
REMOTE_PROC_DOMAIN_SAVE_IMAGE_GET_XML_DESC = 235,
--
2.22.0

View File

@ -1,65 +0,0 @@
From a26ad1b57617abc4de8a0d13716b898d311ee01e Mon Sep 17 00:00:00 2001
Message-Id: <a26ad1b57617abc4de8a0d13716b898d311ee01e@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:18:15 +0200
Subject: [PATCH] bhyve: Move autostarting of domains into bhyveStateInitialize
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The stateAutoStart callback will go away shortly. Therefore, move
the autostart call into state initialize callback.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 31c3c35c940010a793fea8351751bb04fab1a6d4)
https://bugzilla.redhat.com/show_bug.cgi?id=1685151
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <1a93e2bef531c11190c652fcfb73b568ee73e487.1561641375.git.mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/bhyve/bhyve_driver.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 9284b51783..ec016ecc0c 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1270,6 +1270,8 @@ bhyveStateInitialize(bool privileged,
virBhyveProcessReconnectAll(bhyve_driver);
+ bhyveAutostartDomains(bhyve_driver);
+
return 0;
cleanup:
@@ -1297,15 +1299,6 @@ bhyveDriverGetGrubCaps(virConnectPtr conn)
return 0;
}
-static void
-bhyveStateAutoStart(void)
-{
- if (!bhyve_driver)
- return;
-
- bhyveAutostartDomains(bhyve_driver);
-}
-
static int
bhyveConnectGetMaxVcpus(virConnectPtr conn,
const char *type)
@@ -1713,7 +1706,6 @@ static virConnectDriver bhyveConnectDriver = {
static virStateDriver bhyveStateDriver = {
.name = "bhyve",
.stateInitialize = bhyveStateInitialize,
- .stateAutoStart = bhyveStateAutoStart,
.stateCleanup = bhyveStateCleanup,
};
--
2.22.0

View File

@ -1,67 +0,0 @@
From dd083516c7057ee50e59290643634156daf0773b Mon Sep 17 00:00:00 2001
Message-Id: <dd083516c7057ee50e59290643634156daf0773b@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:18 +0200
Subject: [PATCH] conf: Add definitions for 'uid' and 'fid' PCI address
attributes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add zPCI definitions in preparation of extending the PCI address
with parameters uid (user-defined identifier) and fid (PCI function
identifier).
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry-picked from commit 30522c78c11d9ff6c6c177dfca4a0da8057095fe)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-2-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
cfg.mk | 1 +
src/util/virpci.h | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/cfg.mk b/cfg.mk
index e3e94bf6f0..7fd2b1dcb6 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -472,6 +472,7 @@ sc_prohibit_canonicalize_file_name:
# Insist on correct types for [pug]id.
sc_correct_id_types:
@prohibit='\<(int|long) *[pug]id\>' \
+ exclude='exempt from syntax-check' \
halt='use pid_t for pid, uid_t for uid, gid_t for gid' \
$(_sc_search_regexp)
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 794b7e59db..01df652b86 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -36,6 +36,13 @@ typedef virPCIDeviceAddress *virPCIDeviceAddressPtr;
typedef struct _virPCIDeviceList virPCIDeviceList;
typedef virPCIDeviceList *virPCIDeviceListPtr;
+typedef struct _virZPCIDeviceAddress virZPCIDeviceAddress;
+typedef virZPCIDeviceAddress *virZPCIDeviceAddressPtr;
+struct _virZPCIDeviceAddress {
+ unsigned int uid; /* exempt from syntax-check */
+ unsigned int fid;
+};
+
struct _virPCIDeviceAddress {
unsigned int domain;
unsigned int bus;
--
2.22.0

View File

@ -0,0 +1,449 @@
From 4abdfae3b67295a0143f650768630e009d1b2798 Mon Sep 17 00:00:00 2001
Message-Id: <4abdfae3b67295a0143f650768630e009d1b2798@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 16 Mar 2020 22:11:57 +0100
Subject: [PATCH] conf: Add support for cookies for HTTP based disks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add possibility to specify one or more cookies for http based disks.
This patch adds the config parser, storage and validation of the
cookies.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 3b076391befc3fe72deb0c244ac6c2b4c100b410)
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
Message-Id: <3135a30f0d0a1a4bb8da02c49f10a1bcf3a394f4.1584391727.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatdomain.html.in | 10 ++
docs/schemas/domaincommon.rng | 24 ++++
src/conf/domain_conf.c | 82 +++++++++++++
src/libvirt_private.syms | 1 +
src/util/virstoragefile.c | 115 ++++++++++++++++++
src/util/virstoragefile.h | 15 +++
.../disk-network-http.xml | 8 ++
7 files changed, 255 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 2cce247958..5a10d64e83 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2839,6 +2839,9 @@
&lt;driver name='qemu' type='raw'/&gt;
&lt;source protocol="http" name="url_path"&gt;
&lt;host name="hostname" port="80"/&gt;
+ &lt;cookies&gt;
+ &lt;cookie name="test"&gt;somevalue&lt;/cookie&gt;
+ &lt;/cookies&gt;
&lt;/source&gt;
&lt;target dev='hde' bus='ide' tray='open'/&gt;
&lt;readonly/&gt;
@@ -3382,6 +3385,13 @@
certificate validation. Supported values are <code>yes</code> and
<code>no</code>. <span class="since">Since 6.2.0</span>
</dd>
+ <dt><code>cookies</code></dt>
+ <dd>
+ For <code>http</code> and <code>https</code> accessed storage it's
+ possible to pass one or more cookies. The cookie name and value
+ must conform to the HTTP specification.
+ <span class="since">Since 6.2.0</span>
+ </dd>
</dl>
<p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 548601b61c..bdf35e64f6 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1817,6 +1817,24 @@
</element>
</define>
+ <define name="diskSourceNetworkProtocolHTTPCookies">
+ <element name="cookies">
+ <oneOrMore>
+ <element name="cookie">
+ <attribute name="name">
+ <data type="string">
+ <param name="pattern">[!#$%&amp;'*+\-.0-9A-Z\^_`a-z|~]+</param>
+ </data>
+ </attribute>
+ <data type="string">
+ <param name="pattern">[!#$%&amp;'()*+\-./0-9:&gt;=&lt;?@A-Z\^_`\[\]a-z|~]+</param>
+ </data>
+ </element>
+ </oneOrMore>
+ <empty/>
+ </element>
+ </define>
+
<define name="diskSourceNetworkProtocolHTTPS">
<element name="source">
<attribute name="protocol">
@@ -1833,6 +1851,9 @@
<optional>
<ref name="diskSourceNetworkProtocolSSLVerify"/>
</optional>
+ <optional>
+ <ref name="diskSourceNetworkProtocolHTTPCookies"/>
+ </optional>
</element>
</define>
@@ -1849,6 +1870,9 @@
<optional>
<ref name="encryption"/>
</optional>
+ <optional>
+ <ref name="diskSourceNetworkProtocolHTTPCookies"/>
+ </optional>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 70bbc35bb3..d066d3aac1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9249,6 +9249,62 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node,
}
+static virStorageNetCookieDefPtr
+virDomainStorageNetCookieParse(xmlNodePtr node,
+ xmlXPathContextPtr ctxt)
+{
+ VIR_XPATH_NODE_AUTORESTORE(ctxt);
+ g_autoptr(virStorageNetCookieDef) cookie = NULL;
+
+ ctxt->node = node;
+
+ cookie = g_new0(virStorageNetCookieDef, 1);
+
+ if (!(cookie->name = virXPathString("string(./@name)", ctxt))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s", _("missing cookie name"));
+ return NULL;
+ }
+
+ if (!(cookie->value = virXPathString("string(.)", ctxt))) {
+ virReportError(VIR_ERR_XML_ERROR, _("missing value for cookie '%s'"),
+ cookie->name);
+ return NULL;
+ }
+
+ return g_steal_pointer(&cookie);
+}
+
+
+static int
+virDomainStorageNetCookiesParse(xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
+ virStorageSourcePtr src)
+{
+ VIR_XPATH_NODE_AUTORESTORE(ctxt);
+ g_autofree xmlNodePtr *nodes = NULL;
+ ssize_t nnodes;
+ size_t i;
+
+ ctxt->node = node;
+
+ if ((nnodes = virXPathNodeSet("./cookie", ctxt, &nodes)) < 0)
+ return -1;
+
+ src->cookies = g_new0(virStorageNetCookieDefPtr, nnodes);
+ src->ncookies = nnodes;
+
+ for (i = 0; i < nnodes; i++) {
+ if (!(src->cookies[i] = virDomainStorageNetCookieParse(nodes[i], ctxt)))
+ return -1;
+ }
+
+ if (virStorageSourceNetCookiesValidate(src) < 0)
+ return -1;
+
+ return 0;
+}
+
+
static int
virDomainDiskSourceNetworkParse(xmlNodePtr node,
xmlXPathContextPtr ctxt,
@@ -9260,6 +9316,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
g_autofree char *haveTLS = NULL;
g_autofree char *tlsCfg = NULL;
g_autofree char *sslverifystr = NULL;
+ xmlNodePtr tmpnode;
if (!(protocol = virXMLPropString(node, "protocol"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -9345,6 +9402,13 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
src->sslverify = verify;
}
+ if ((src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP ||
+ src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS) &&
+ (tmpnode = virXPathNode("./cookies", ctxt))) {
+ if (virDomainStorageNetCookiesParse(tmpnode, ctxt, src) < 0)
+ return -1;
+ }
+
return 0;
}
@@ -24281,6 +24345,22 @@ virDomainSourceDefFormatSeclabel(virBufferPtr buf,
}
+static void
+virDomainDiskSourceFormatNetworkCookies(virBufferPtr buf,
+ virStorageSourcePtr src)
+{
+ g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
+ size_t i;
+
+ for (i = 0; i < src->ncookies; i++) {
+ virBufferEscapeString(&childBuf, "<cookie name='%s'>", src->cookies[i]->name);
+ virBufferEscapeString(&childBuf, "%s</cookie>\n", src->cookies[i]->value);
+ }
+
+ virXMLFormatElement(buf, "cookies", NULL, &childBuf);
+}
+
+
static int
virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
virBufferPtr childBuf,
@@ -24331,6 +24411,8 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
virTristateBoolTypeToString(src->sslverify));
}
+ virDomainDiskSourceFormatNetworkCookies(childBuf, src);
+
return 0;
}
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index dbbec0d567..ac5527ef01 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3123,6 +3123,7 @@ virStorageSourceIsEmpty;
virStorageSourceIsLocalStorage;
virStorageSourceIsRelative;
virStorageSourceIsSameLocation;
+virStorageSourceNetCookiesValidate;
virStorageSourceNetworkAssignDefaultPorts;
virStorageSourceNew;
virStorageSourceNewFromBacking;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index cfa77fccf8..6350168d73 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2157,6 +2157,118 @@ virStorageSourceSeclabelsCopy(virStorageSourcePtr to,
}
+void
+virStorageNetCookieDefFree(virStorageNetCookieDefPtr def)
+{
+ if (!def)
+ return;
+
+ g_free(def->name);
+ g_free(def->value);
+
+ g_free(def);
+}
+
+
+static void
+virStorageSourceNetCookiesClear(virStorageSourcePtr src)
+{
+ size_t i;
+
+ if (!src || !src->cookies)
+ return;
+
+ for (i = 0; i < src->ncookies; i++)
+ virStorageNetCookieDefFree(src->cookies[i]);
+
+ g_clear_pointer(&src->cookies, g_free);
+ src->ncookies = 0;
+}
+
+
+static void
+virStorageSourceNetCookiesCopy(virStorageSourcePtr to,
+ const virStorageSource *from)
+{
+ size_t i;
+
+ if (from->ncookies == 0)
+ return;
+
+ to->cookies = g_new0(virStorageNetCookieDefPtr, from->ncookies);
+ to->ncookies = from->ncookies;
+
+ for (i = 0; i < from->ncookies; i++) {
+ to->cookies[i]->name = g_strdup(from->cookies[i]->name);
+ to->cookies[i]->value = g_strdup(from->cookies[i]->value);
+ }
+}
+
+
+/* see https://tools.ietf.org/html/rfc6265#section-4.1.1 */
+static const char virStorageSourceCookieValueInvalidChars[] =
+ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
+ "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
+ " \",;\\";
+
+/* in addition cookie name can't contain these */
+static const char virStorageSourceCookieNameInvalidChars[] =
+ "()<>@:/[]?={}";
+
+static int
+virStorageSourceNetCookieValidate(virStorageNetCookieDefPtr def)
+{
+ /* name must have at least 1 character */
+ if (*(def->name) == '\0') {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("cookie name must not be empty"));
+ return -1;
+ }
+
+ /* check invalid characters in name */
+ if (virStringHasChars(def->name, virStorageSourceCookieValueInvalidChars) ||
+ virStringHasChars(def->name, virStorageSourceCookieNameInvalidChars)) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("cookie name '%s' contains invalid characters"),
+ def->name);
+ return -1;
+ }
+
+ /* check invalid characters in value */
+ if (virStringHasChars(def->value, virStorageSourceCookieValueInvalidChars)) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("value of cookie '%s' contains invalid characters"),
+ def->name);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int
+virStorageSourceNetCookiesValidate(virStorageSourcePtr src)
+{
+ size_t i;
+ size_t j;
+
+ for (i = 0; i < src->ncookies; i++) {
+ if (virStorageSourceNetCookieValidate(src->cookies[i]) < 0)
+ return -1;
+
+ for (j = i + 1; j < src->ncookies; j++) {
+ if (STREQ(src->cookies[i]->name, src->cookies[j]->name)) {
+ virReportError(VIR_ERR_XML_ERROR, _("duplicate cookie '%s'"),
+ src->cookies[i]->name);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+
static virStorageTimestampsPtr
virStorageTimestampsCopy(const virStorageTimestamps *src)
{
@@ -2299,6 +2411,8 @@ virStorageSourceCopy(const virStorageSource *src,
def->nhosts = src->nhosts;
}
+ virStorageSourceNetCookiesCopy(def, src);
+
if (src->srcpool &&
!(def->srcpool = virStorageSourcePoolDefCopy(src->srcpool)))
return NULL;
@@ -2560,6 +2674,7 @@ virStorageSourceClear(virStorageSourcePtr def)
VIR_FREE(def->volume);
VIR_FREE(def->snapshot);
VIR_FREE(def->configFile);
+ virStorageSourceNetCookiesClear(def);
virStorageSourcePoolDefFree(def->srcpool);
virBitmapFree(def->features);
VIR_FREE(def->compat);
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index fab4248c3d..1c7c046ad6 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -162,6 +162,17 @@ struct _virStorageNetHostDef {
char *socket; /* path to unix socket */
};
+typedef struct _virStorageNetCookieDef virStorageNetCookieDef;
+typedef virStorageNetCookieDef *virStorageNetCookieDefPtr;
+struct _virStorageNetCookieDef {
+ char *name;
+ char *value;
+};
+
+void virStorageNetCookieDefFree(virStorageNetCookieDefPtr def);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageNetCookieDef, virStorageNetCookieDefFree);
+
/* Information for a storage volume from a virStoragePool */
/*
@@ -276,6 +287,8 @@ struct _virStorageSource {
the source definition */
size_t nhosts;
virStorageNetHostDefPtr hosts;
+ size_t ncookies;
+ virStorageNetCookieDefPtr *cookies;
virStorageSourcePoolDefPtr srcpool;
virStorageAuthDefPtr auth;
bool authInherited;
@@ -477,6 +490,8 @@ int virStorageSourceUpdateCapacity(virStorageSourcePtr src,
int virStorageSourceNewFromBacking(virStorageSourcePtr parent,
virStorageSourcePtr *backing);
+int virStorageSourceNetCookiesValidate(virStorageSourcePtr src);
+
virStorageSourcePtr virStorageSourceCopy(const virStorageSource *src,
bool backingChain)
ATTRIBUTE_NONNULL(1);
diff --git a/tests/genericxml2xmlindata/disk-network-http.xml b/tests/genericxml2xmlindata/disk-network-http.xml
index bdcc1977f2..bafb77c8ec 100644
--- a/tests/genericxml2xmlindata/disk-network-http.xml
+++ b/tests/genericxml2xmlindata/disk-network-http.xml
@@ -33,6 +33,10 @@
<driver name='qemu' type='raw'/>
<source protocol='http' name='test3.img'>
<host name='example.org' port='1234'/>
+ <cookies>
+ <cookie name='test'>testcookievalue</cookie>
+ <cookie name='test2'>blurb</cookie>
+ </cookies>
</source>
<target dev='vdc' bus='virtio'/>
</disk>
@@ -41,6 +45,10 @@
<source protocol='https' name='test4.img'>
<host name='example.org' port='1234'/>
<ssl verify='yes'/>
+ <cookies>
+ <cookie name='test'>testcookievalue</cookie>
+ <cookie name='test2'>blurb</cookie>
+ </cookies>
</source>
<target dev='vdd' bus='virtio'/>
</disk>
--
2.25.1

View File

@ -0,0 +1,160 @@
From 45ecbd824c92bd05a46557bfcaff39196f701e6c Mon Sep 17 00:00:00 2001
Message-Id: <45ecbd824c92bd05a46557bfcaff39196f701e6c@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 30 Mar 2020 17:21:45 +0200
Subject: [PATCH] conf: Add support for http(s) query strings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add a new attribute for holding the query part for http(s) disks.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 56368124728f0d65dde07244c741b459fcd6b939)
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
Message-Id: <b60abcf1e7711e9e29175e1fdcfe2820d5694a17.1585581552.git.pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
docs/formatdomain.html.in | 7 ++++++-
docs/schemas/domaincommon.rng | 6 ++++++
src/conf/domain_conf.c | 5 +++++
src/util/virstoragefile.c | 2 ++
src/util/virstoragefile.h | 1 +
tests/qemuxml2argvdata/disk-network-http.xml | 2 +-
.../qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml | 2 +-
7 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 143db21d4d..9c588185df 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2837,7 +2837,7 @@
&lt;/disk&gt;
&lt;disk type='network' device='cdrom'&gt;
&lt;driver name='qemu' type='raw'/&gt;
- &lt;source protocol="http" name="url_path"&gt;
+ &lt;source protocol="http" name="url_path" query="foo=bar&amp;amp;baz=flurb&gt;
&lt;host name="hostname" port="80"/&gt;
&lt;cookies&gt;
&lt;cookie name="test"&gt;somevalue&lt;/cookie&gt;
@@ -3103,6 +3103,11 @@
('tls' <span class="since">Since 4.5.0</span>)
</p>
+ <p>For protocols <code>http</code> and <code>https</code> an
+ optional attribute <code>query</code> specifies the query string.
+ (<span class="since">Since 6.2.0</span>)
+ </p>
+
<p>For "iscsi" (<span class="since">since 1.0.4</span>), the
<code>name</code> attribute may include a logical unit number,
separated from the target's name by a slash (e.g.,
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index e17f7ff8c0..dd8f27243a 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1869,6 +1869,9 @@
</choice>
</attribute>
<attribute name="name"/>
+ <optional>
+ <attribute name="query"/>
+ </optional>
<ref name="diskSourceCommon"/>
<ref name="diskSourceNetworkHost"/>
<optional>
@@ -1894,6 +1897,9 @@
</choice>
</attribute>
<attribute name="name"/>
+ <optional>
+ <attribute name="query"/>
+ </optional>
<ref name="diskSourceCommon"/>
<ref name="diskSourceNetworkHost"/>
<optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e3755fa285..28160a2967 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9382,6 +9382,10 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
/* config file currently only works with remote disks */
src->configFile = virXPathString("string(./config/@file)", ctxt);
+ if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP ||
+ src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS)
+ src->query = virXMLPropString(node, "query");
+
if (virDomainStorageNetworkParseHosts(node, &src->hosts, &src->nhosts) < 0)
return -1;
@@ -24390,6 +24394,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
path = g_strdup_printf("%s/%s", src->volume, src->path);
virBufferEscapeString(attrBuf, " name='%s'", path ? path : src->path);
+ virBufferEscapeString(attrBuf, " query='%s'", src->query);
if (src->haveTLS != VIR_TRISTATE_BOOL_ABSENT &&
!(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index f8d741f040..4082e3f5f7 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2418,6 +2418,7 @@ virStorageSourceCopy(const virStorageSource *src,
def->compat = g_strdup(src->compat);
def->tlsAlias = g_strdup(src->tlsAlias);
def->tlsCertdir = g_strdup(src->tlsCertdir);
+ def->query = g_strdup(src->query);
if (src->sliceStorage)
def->sliceStorage = virStorageSourceSliceCopy(src->sliceStorage);
@@ -2696,6 +2697,7 @@ virStorageSourceClear(virStorageSourcePtr def)
VIR_FREE(def->volume);
VIR_FREE(def->snapshot);
VIR_FREE(def->configFile);
+ VIR_FREE(def->query);
virStorageSourceNetCookiesClear(def);
virStorageSourcePoolDefFree(def->srcpool);
virBitmapFree(def->features);
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 0230f44652..8089d1e07f 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -285,6 +285,7 @@ struct _virStorageSource {
char *snapshot; /* for storage systems supporting internal snapshots */
char *configFile; /* some storage systems use config file as part of
the source definition */
+ char *query; /* query string for HTTP based protocols */
size_t nhosts;
virStorageNetHostDefPtr hosts;
size_t ncookies;
diff --git a/tests/qemuxml2argvdata/disk-network-http.xml b/tests/qemuxml2argvdata/disk-network-http.xml
index 93e6617433..3abf499019 100644
--- a/tests/qemuxml2argvdata/disk-network-http.xml
+++ b/tests/qemuxml2argvdata/disk-network-http.xml
@@ -42,7 +42,7 @@
</disk>
<disk type='network' device='disk'>
<driver name='qemu' type='raw'/>
- <source protocol='https' name='test4.img'>
+ <source protocol='https' name='test4.img' query='par=val&amp;other=ble'>
<host name='example.org' port='1234'/>
<ssl verify='no'/>
<cookies>
diff --git a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml b/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml
index 60073c227c..45b01841ec 100644
--- a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml
@@ -46,7 +46,7 @@
</disk>
<disk type='network' device='disk'>
<driver name='qemu' type='raw'/>
- <source protocol='https' name='test4.img'>
+ <source protocol='https' name='test4.img' query='par=val&amp;other=ble'>
<host name='example.org' port='1234'/>
<ssl verify='no'/>
<cookies>
--
2.26.0

View File

@ -0,0 +1,242 @@
From ffe8028ca07eb049b12d5c152b3d66489378d731 Mon Sep 17 00:00:00 2001
Message-Id: <ffe8028ca07eb049b12d5c152b3d66489378d731@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 16 Mar 2020 22:11:56 +0100
Subject: [PATCH] conf: Add support for modifying ssl validation for https/ftps
disks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
To allow turning off verification of SSL cerificates add a new element
<ssl> to the disk source XML which will allow configuring the validation
process using the 'verify' attribute.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 25481e25b14108373bf2e5e95c04fe30bff96bb4)
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
Message-Id: <ede13179128fc9ef05036a5408f4115132a2c12d.1584391727.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatdomain.html.in | 9 ++++
docs/schemas/domaincommon.rng | 51 ++++++++++++++++++-
src/conf/domain_conf.c | 19 +++++++
src/util/virstoragefile.c | 1 +
src/util/virstoragefile.h | 1 +
.../disk-network-http.xml | 9 ++++
6 files changed, 88 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e9830ab231..2cce247958 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2847,6 +2847,7 @@
&lt;driver name='qemu' type='raw'/&gt;
&lt;source protocol="https" name="url_path"&gt;
&lt;host name="hostname" port="443"/&gt;
+ &lt;ssl verify="no"/&gt;
&lt;/source&gt;
&lt;target dev='hdf' bus='ide' tray='open'/&gt;
&lt;readonly/&gt;
@@ -3373,6 +3374,14 @@
The <code>offset</code> and <code>size</code> values are in bytes.
<span class="since">Since 6.1.0</span>
</dd>
+ <dt><code>ssl</code></dt>
+ <dd>
+ For <code>https</code> and <code>ftps</code> accessed storage it's
+ possible to tweak the SSL transport parameters with this element.
+ The <code>verify</code> attribute allows to turn on or off SSL
+ certificate validation. Supported values are <code>yes</code> and
+ <code>no</code>. <span class="since">Since 6.2.0</span>
+ </dd>
</dl>
<p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index aa70e340b9..548601b61c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1808,12 +1808,39 @@
</element>
</define>
+ <define name="diskSourceNetworkProtocolSSLVerify">
+ <element name="ssl">
+ <attribute name="verify">
+ <ref name="virYesNo"/>
+ </attribute>
+ <empty/>
+ </element>
+ </define>
+
+ <define name="diskSourceNetworkProtocolHTTPS">
+ <element name="source">
+ <attribute name="protocol">
+ <choice>
+ <value>https</value>
+ </choice>
+ </attribute>
+ <attribute name="name"/>
+ <ref name="diskSourceCommon"/>
+ <ref name="diskSourceNetworkHost"/>
+ <optional>
+ <ref name="encryption"/>
+ </optional>
+ <optional>
+ <ref name="diskSourceNetworkProtocolSSLVerify"/>
+ </optional>
+ </element>
+ </define>
+
<define name="diskSourceNetworkProtocolHTTP">
<element name="source">
<attribute name="protocol">
<choice>
<value>http</value>
- <value>https</value>
</choice>
</attribute>
<attribute name="name"/>
@@ -1825,13 +1852,31 @@
</element>
</define>
+ <define name="diskSourceNetworkProtocolFTPS">
+ <element name="source">
+ <attribute name="protocol">
+ <choice>
+ <value>ftps</value>
+ </choice>
+ </attribute>
+ <attribute name="name"/>
+ <ref name="diskSourceCommon"/>
+ <ref name="diskSourceNetworkHost"/>
+ <optional>
+ <ref name="encryption"/>
+ </optional>
+ <optional>
+ <ref name="diskSourceNetworkProtocolSSLVerify"/>
+ </optional>
+ </element>
+ </define>
+
<define name="diskSourceNetworkProtocolSimple">
<element name="source">
<attribute name="protocol">
<choice>
<value>sheepdog</value>
<value>ftp</value>
- <value>ftps</value>
<value>tftp</value>
</choice>
</attribute>
@@ -1909,6 +1954,8 @@
<ref name="diskSourceNetworkProtocolRBD"/>
<ref name="diskSourceNetworkProtocolISCSI"/>
<ref name="diskSourceNetworkProtocolHTTP"/>
+ <ref name="diskSourceNetworkProtocolHTTPS"/>
+ <ref name="diskSourceNetworkProtocolFTPS"/>
<ref name="diskSourceNetworkProtocolSimple"/>
<ref name="diskSourceNetworkProtocolVxHS"/>
</choice>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b3c4084c38..70bbc35bb3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9259,6 +9259,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
g_autofree char *protocol = NULL;
g_autofree char *haveTLS = NULL;
g_autofree char *tlsCfg = NULL;
+ g_autofree char *sslverifystr = NULL;
if (!(protocol = virXMLPropString(node, "protocol"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -9331,6 +9332,19 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
virStorageSourceInitiatorParseXML(ctxt, &src->initiator);
+ if ((src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS ||
+ src->protocol == VIR_STORAGE_NET_PROTOCOL_FTPS) &&
+ (sslverifystr = virXPathString("string(./ssl/@verify)", ctxt))) {
+ int verify;
+ if ((verify = virTristateBoolTypeFromString(sslverifystr)) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("invalid ssl verify mode '%s'"), sslverifystr);
+ return -1;
+ }
+
+ src->sslverify = verify;
+ }
+
return 0;
}
@@ -24312,6 +24326,11 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
virStorageSourceInitiatorFormatXML(&src->initiator, childBuf);
+ if (src->sslverify != VIR_TRISTATE_BOOL_ABSENT) {
+ virBufferAsprintf(childBuf, "<ssl verify='%s'/>\n",
+ virTristateBoolTypeToString(src->sslverify));
+ }
+
return 0;
}
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index b88763b267..cfa77fccf8 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2270,6 +2270,7 @@ virStorageSourceCopy(const virStorageSource *src,
def->cachemode = src->cachemode;
def->discard = src->discard;
def->detect_zeroes = src->detect_zeroes;
+ def->sslverify = src->sslverify;
/* storage driver metadata are not copied */
def->drv = NULL;
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 5b995d54ab..fab4248c3d 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -282,6 +282,7 @@ struct _virStorageSource {
virStorageEncryptionPtr encryption;
bool encryptionInherited;
virStoragePRDefPtr pr;
+ virTristateBool sslverify;
virStorageSourceNVMeDefPtr nvme; /* type == VIR_STORAGE_TYPE_NVME */
diff --git a/tests/genericxml2xmlindata/disk-network-http.xml b/tests/genericxml2xmlindata/disk-network-http.xml
index fde1222fd0..bdcc1977f2 100644
--- a/tests/genericxml2xmlindata/disk-network-http.xml
+++ b/tests/genericxml2xmlindata/disk-network-http.xml
@@ -25,6 +25,7 @@
<driver name='qemu' type='raw'/>
<source protocol='https' name='test2.img'>
<host name='example.org' port='443'/>
+ <ssl verify='no'/>
</source>
<target dev='vdb' bus='virtio'/>
</disk>
@@ -35,6 +36,14 @@
</source>
<target dev='vdc' bus='virtio'/>
</disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='https' name='test4.img'>
+ <host name='example.org' port='1234'/>
+ <ssl verify='yes'/>
+ </source>
+ <target dev='vdd' bus='virtio'/>
+ </disk>
<controller type='usb' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
<input type='mouse' bus='ps2'/>
--
2.25.1

View File

@ -0,0 +1,205 @@
From 3050ddce41896311b8c3ad06f148bea358e597b8 Mon Sep 17 00:00:00 2001
Message-Id: <3050ddce41896311b8c3ad06f148bea358e597b8@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 16 Mar 2020 22:11:58 +0100
Subject: [PATCH] conf: Add support for setting timeout and readahead size for
network disks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Some disk backends support configuring the readahead buffer or timeout
for requests. Add the knobs to the XML.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 63fd46177367c6653c4c986558f6d0e4a700cfcc)
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
Message-Id: <2694bc6f9a327f89d82da18320e7137152915ad3.1584391727.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatdomain.html.in | 16 +++++++++++++
docs/schemas/domaincommon.rng | 23 +++++++++++++++++++
src/conf/domain_conf.c | 19 +++++++++++++++
src/util/virstoragefile.c | 2 ++
src/util/virstoragefile.h | 3 +++
.../disk-network-http.xml | 2 ++
6 files changed, 65 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 5a10d64e83..2b8f9eabc2 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2842,6 +2842,8 @@
&lt;cookies&gt;
&lt;cookie name="test"&gt;somevalue&lt;/cookie&gt;
&lt;/cookies&gt;
+ &lt;readahead size='65536'/&gt;
+ &lt;timeout seconds='6'/&gt;
&lt;/source&gt;
&lt;target dev='hde' bus='ide' tray='open'/&gt;
&lt;readonly/&gt;
@@ -3392,6 +3394,20 @@
must conform to the HTTP specification.
<span class="since">Since 6.2.0</span>
</dd>
+ <dt><code>readahead</code></dt>
+ <dd>
+ Specifies the size of the readahead buffer for protocols
+ which support it. (all 'curl' based drivers in qemu). The size
+ is in bytes. Note that '0' is considered as if the value is not
+ provided.
+ <span class="since">Since 6.2.0</span>
+ </dd>
+ <dt><code>timeout</code></dt>
+ <dd>
+ Specifies the connection timeout for protocols which support it.
+ Note that '0' is considered as if the value is not provided.
+ <span class="since">Since 6.2.0</span>
+ </dd>
</dl>
<p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index bdf35e64f6..3a0edbed97 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1808,6 +1808,25 @@
</element>
</define>
+ <define name="diskSourceNetworkProtocolPropsCommon">
+ <optional>
+ <element name="readahead">
+ <attribute name="size">
+ <ref name="positiveInteger"/>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name="timeout">
+ <attribute name="seconds">
+ <ref name="positiveInteger"/>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
+ </define>
+
<define name="diskSourceNetworkProtocolSSLVerify">
<element name="ssl">
<attribute name="verify">
@@ -1854,6 +1873,7 @@
<optional>
<ref name="diskSourceNetworkProtocolHTTPCookies"/>
</optional>
+ <ref name="diskSourceNetworkProtocolPropsCommon"/>
</element>
</define>
@@ -1873,6 +1893,7 @@
<optional>
<ref name="diskSourceNetworkProtocolHTTPCookies"/>
</optional>
+ <ref name="diskSourceNetworkProtocolPropsCommon"/>
</element>
</define>
@@ -1892,6 +1913,7 @@
<optional>
<ref name="diskSourceNetworkProtocolSSLVerify"/>
</optional>
+ <ref name="diskSourceNetworkProtocolPropsCommon"/>
</element>
</define>
@@ -1910,6 +1932,7 @@
<optional>
<ref name="encryption"/>
</optional>
+ <ref name="diskSourceNetworkProtocolPropsCommon"/>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d066d3aac1..8aec85e83c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9409,6 +9409,19 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
return -1;
}
+ if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP ||
+ src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS ||
+ src->protocol == VIR_STORAGE_NET_PROTOCOL_FTP ||
+ src->protocol == VIR_STORAGE_NET_PROTOCOL_FTPS) {
+
+ if (virXPathULongLong("string(./readahead/@size)", ctxt, &src->readahead) == -2 ||
+ virXPathULongLong("string(./timeout/@seconds)", ctxt, &src->timeout) == -2) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("invalid readahead size or timeout"));
+ return -1;
+ }
+ }
+
return 0;
}
@@ -24413,6 +24426,12 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
virDomainDiskSourceFormatNetworkCookies(childBuf, src);
+ if (src->readahead)
+ virBufferAsprintf(childBuf, "<readahead size='%llu'/>\n", src->readahead);
+
+ if (src->timeout)
+ virBufferAsprintf(childBuf, "<timeout seconds='%llu'/>\n", src->timeout);
+
return 0;
}
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 6350168d73..7893e054c3 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2383,6 +2383,8 @@ virStorageSourceCopy(const virStorageSource *src,
def->discard = src->discard;
def->detect_zeroes = src->detect_zeroes;
def->sslverify = src->sslverify;
+ def->readahead = src->readahead;
+ def->timeout = src->timeout;
/* storage driver metadata are not copied */
def->drv = NULL;
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 1c7c046ad6..1abdaf89ce 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -296,6 +296,9 @@ struct _virStorageSource {
bool encryptionInherited;
virStoragePRDefPtr pr;
virTristateBool sslverify;
+ /* both values below have 0 as default value */
+ unsigned long long readahead; /* size of the readahead buffer in bytes */
+ unsigned long long timeout; /* connection timeout in seconds */
virStorageSourceNVMeDefPtr nvme; /* type == VIR_STORAGE_TYPE_NVME */
diff --git a/tests/genericxml2xmlindata/disk-network-http.xml b/tests/genericxml2xmlindata/disk-network-http.xml
index bafb77c8ec..a8430b8365 100644
--- a/tests/genericxml2xmlindata/disk-network-http.xml
+++ b/tests/genericxml2xmlindata/disk-network-http.xml
@@ -49,6 +49,8 @@
<cookie name='test'>testcookievalue</cookie>
<cookie name='test2'>blurb</cookie>
</cookies>
+ <readahead size='65536'/>
+ <timeout seconds='10'/>
</source>
<target dev='vdd' bus='virtio'/>
</disk>
--
2.25.1

View File

@ -1,76 +0,0 @@
From c2afbedc310ac1a65a5ee96c8fa4103e926483c4 Mon Sep 17 00:00:00 2001
Message-Id: <c2afbedc310ac1a65a5ee96c8fa4103e926483c4@dist-git>
From: Han Han <hhan@redhat.com>
Date: Tue, 28 Aug 2018 10:30:51 +0200
Subject: [PATCH] conf: Add validation of input devices
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
https://bugzilla.redhat.com/show_bug.cgi?id=1591151
Add function virDomainInputDefValidate to validate input devices.
Make sure evdev attribute of source element is not used by mouse,
keyboard, and tablet input device.
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit deb057fd364cb57614c6dea7b05c247231f9ae4f)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
https: //bugzilla.redhat.com/show_bug.cgi?id=1591240
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
---
src/conf/domain_conf.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 51a79ad8b1..16e52d149d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5760,6 +5760,29 @@ virDomainVsockDefValidate(const virDomainVsockDef *vsock)
return 0;
}
+static int
+virDomainInputDefValidate(const virDomainInputDef *input)
+{
+ switch ((virDomainInputType) input->type) {
+ case VIR_DOMAIN_INPUT_TYPE_MOUSE:
+ case VIR_DOMAIN_INPUT_TYPE_TABLET:
+ case VIR_DOMAIN_INPUT_TYPE_KBD:
+ case VIR_DOMAIN_INPUT_TYPE_LAST:
+ if (input->source.evdev) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("setting source evdev path only supported for "
+ "passthrough input devices"));
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
+ break;
+ }
+
+ return 0;
+}
+
static int
virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
@@ -5799,9 +5822,11 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
case VIR_DOMAIN_DEVICE_VSOCK:
return virDomainVsockDefValidate(dev->data.vsock);
+ case VIR_DOMAIN_DEVICE_INPUT:
+ return virDomainInputDefValidate(dev->data.input);
+
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_FS:
- case VIR_DOMAIN_DEVICE_INPUT:
case VIR_DOMAIN_DEVICE_SOUND:
case VIR_DOMAIN_DEVICE_WATCHDOG:
case VIR_DOMAIN_DEVICE_GRAPHICS:
--
2.18.0

View File

@ -1,527 +0,0 @@
From 87e3a5f2f797c79516a560ddc224074c834ef528 Mon Sep 17 00:00:00 2001
Message-Id: <87e3a5f2f797c79516a560ddc224074c834ef528@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:27 +0200
Subject: [PATCH] conf: Allocate/release 'uid' and 'fid' in PCI address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch adds new functions for reservation, assignment and release
to handle the uid/fid. If the uid/fid is defined in the domain XML,
they will be reserved directly in the collecting phase. If any of them
is not defined, we will find out an available value for them from the
zPCI address hashtable, and reserve them. For the hotplug case there
might not be a zPCI definition. So allocate and reserve uid/fid the
case. Assign if needed and reserve uid/fid for the defined case.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit f183b87fc1dbcc6446ac3c1cef9cdd345b9725fb)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Conflicts:
* src/libvirt_private.syms
+ several symbols are not present in the list
- missing 9ad119f4db5, ab3f781a10c, edeef779585, b899726faa5
* src/qemu/qemu_domain_address.c
+ the old name for virDeviceInfoPCIAddressIsPresent() is used
- missing 76151a53a100
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-11-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/device_conf.c | 16 +++
src/conf/device_conf.h | 3 +
src/conf/domain_addr.c | 244 +++++++++++++++++++++++++++++++++
src/conf/domain_addr.h | 12 ++
src/libvirt_private.syms | 5 +
src/qemu/qemu_domain_address.c | 59 +++++++-
6 files changed, 338 insertions(+), 1 deletion(-)
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index cadac32603..76370d30a2 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -28,6 +28,7 @@
#include "viruuid.h"
#include "virbuffer.h"
#include "device_conf.h"
+#include "domain_addr.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_DEVICE
@@ -230,6 +231,21 @@ int virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
}
+bool
+virDeviceInfoPCIAddressExtensionIsWanted(const virDomainDeviceInfo *info)
+{
+ return (info->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) &&
+ virZPCIDeviceAddressIsEmpty(&info->addr.pci.zpci);
+}
+
+bool
+virDeviceInfoPCIAddressExtensionIsPresent(const virDomainDeviceInfo *info)
+{
+ return (info->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) &&
+ !virZPCIDeviceAddressIsEmpty(&info->addr.pci.zpci);
+}
+
+
int
virPCIDeviceAddressParseXML(xmlNodePtr node,
virPCIDeviceAddressPtr addr)
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index c79066ec02..6bef2f093a 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -214,6 +214,9 @@ virDeviceInfoPCIAddressPresent(const virDomainDeviceInfo *info)
!virPCIDeviceAddressIsEmpty(&info->addr.pci);
}
+bool virDeviceInfoPCIAddressExtensionIsWanted(const virDomainDeviceInfo *info);
+bool virDeviceInfoPCIAddressExtensionIsPresent(const virDomainDeviceInfo *info);
+
int virPCIDeviceAddressParseXML(xmlNodePtr node,
virPCIDeviceAddressPtr addr);
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 9e0a0fdf95..a58910c394 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -33,6 +33,238 @@
VIR_LOG_INIT("conf.domain_addr");
+static int
+virDomainZPCIAddressReserveId(virHashTablePtr set,
+ unsigned int id,
+ const char *name)
+{
+ if (virHashLookup(set, &id)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("zPCI %s %o is already reserved"),
+ name, id);
+ return -1;
+ }
+
+ if (virHashAddEntry(set, &id, (void*)1) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to reserve %s %o"),
+ name, id);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int
+virDomainZPCIAddressReserveUid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ return virDomainZPCIAddressReserveId(set, addr->uid, "uid");
+}
+
+
+static int
+virDomainZPCIAddressReserveFid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ return virDomainZPCIAddressReserveId(set, addr->fid, "fid");
+}
+
+
+static int
+virDomainZPCIAddressAssignId(virHashTablePtr set,
+ unsigned int *id,
+ unsigned int min,
+ unsigned int max,
+ const char *name)
+{
+ while (virHashLookup(set, &min)) {
+ if (min == max) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("There is no more free %s."),
+ name);
+ return -1;
+ }
+ ++min;
+ }
+ *id = min;
+
+ return 0;
+}
+
+
+static int
+virDomainZPCIAddressAssignUid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ return virDomainZPCIAddressAssignId(set, &addr->uid, 1,
+ VIR_DOMAIN_DEVICE_ZPCI_MAX_UID, "uid");
+}
+
+
+static int
+virDomainZPCIAddressAssignFid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ return virDomainZPCIAddressAssignId(set, &addr->fid, 0,
+ VIR_DOMAIN_DEVICE_ZPCI_MAX_FID, "fid");
+}
+
+
+static void
+virDomainZPCIAddressReleaseId(virHashTablePtr set,
+ unsigned int *id,
+ const char *name)
+{
+ if (virHashRemoveEntry(set, id) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Release %s %o failed"),
+ name, *id);
+ }
+
+ *id = 0;
+}
+
+
+static void
+virDomainZPCIAddressReleaseUid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ virDomainZPCIAddressReleaseId(set, &addr->uid, "uid");
+}
+
+
+static void
+virDomainZPCIAddressReleaseFid(virHashTablePtr set,
+ virZPCIDeviceAddressPtr addr)
+{
+ virDomainZPCIAddressReleaseId(set, &addr->fid, "fid");
+}
+
+
+static void
+virDomainZPCIAddressReleaseIds(virDomainZPCIAddressIdsPtr zpciIds,
+ virZPCIDeviceAddressPtr addr)
+{
+ if (!zpciIds || virZPCIDeviceAddressIsEmpty(addr))
+ return;
+
+ virDomainZPCIAddressReleaseUid(zpciIds->uids, addr);
+
+ virDomainZPCIAddressReleaseFid(zpciIds->fids, addr);
+}
+
+
+static int
+virDomainZPCIAddressReserveNextUid(virHashTablePtr uids,
+ virZPCIDeviceAddressPtr zpci)
+{
+ if (virDomainZPCIAddressAssignUid(uids, zpci) < 0)
+ return -1;
+
+ if (virDomainZPCIAddressReserveUid(uids, zpci) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+static int
+virDomainZPCIAddressReserveNextFid(virHashTablePtr fids,
+ virZPCIDeviceAddressPtr zpci)
+{
+ if (virDomainZPCIAddressAssignFid(fids, zpci) < 0)
+ return -1;
+
+ if (virDomainZPCIAddressReserveFid(fids, zpci) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+static int
+virDomainZPCIAddressReserveAddr(virDomainZPCIAddressIdsPtr zpciIds,
+ virZPCIDeviceAddressPtr addr)
+{
+ if (virDomainZPCIAddressReserveUid(zpciIds->uids, addr) < 0)
+ return -1;
+
+ if (virDomainZPCIAddressReserveFid(zpciIds->fids, addr) < 0) {
+ virDomainZPCIAddressReleaseUid(zpciIds->uids, addr);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int
+virDomainZPCIAddressReserveNextAddr(virDomainZPCIAddressIdsPtr zpciIds,
+ virZPCIDeviceAddressPtr addr)
+{
+ if (virDomainZPCIAddressReserveNextUid(zpciIds->uids, addr) < 0)
+ return -1;
+
+ if (virDomainZPCIAddressReserveNextFid(zpciIds->fids, addr) < 0) {
+ virDomainZPCIAddressReleaseUid(zpciIds->uids, addr);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int
+virDomainPCIAddressExtensionReserveAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+{
+ if (addr->extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) {
+ /* Reserve uid/fid to ZPCI device which has defined uid/fid
+ * in the domain.
+ */
+ return virDomainZPCIAddressReserveAddr(addrs->zpciIds, &addr->zpci);
+ }
+
+ return 0;
+}
+
+
+int
+virDomainPCIAddressExtensionReserveNextAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+{
+ if (addr->extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) {
+ virZPCIDeviceAddress zpci = { 0 };
+
+ if (virDomainZPCIAddressReserveNextAddr(addrs->zpciIds, &zpci) < 0)
+ return -1;
+
+ if (!addrs->dryRun)
+ addr->zpci = zpci;
+ }
+
+ return 0;
+}
+
+static int
+virDomainPCIAddressExtensionEnsureAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+{
+ if (addr->extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) {
+ virZPCIDeviceAddressPtr zpci = &addr->zpci;
+
+ if (virZPCIDeviceAddressIsEmpty(zpci))
+ return virDomainZPCIAddressReserveNextAddr(addrs->zpciIds, zpci);
+ else
+ return virDomainZPCIAddressReserveAddr(addrs->zpciIds, zpci);
+ }
+
+ return 0;
+}
+
+
virDomainPCIConnectFlags
virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model)
{
@@ -729,12 +961,24 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
ret = virDomainPCIAddressReserveNextAddr(addrs, dev, flags, -1);
}
+ dev->addr.pci.extFlags = dev->pciAddrExtFlags;
+ ret = virDomainPCIAddressExtensionEnsureAddr(addrs, &dev->addr.pci);
+
cleanup:
VIR_FREE(addrStr);
return ret;
}
+void
+virDomainPCIAddressExtensionReleaseAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+{
+ if (addr->extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI)
+ virDomainZPCIAddressReleaseIds(addrs->zpciIds, &addr->zpci);
+}
+
+
void
virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
virPCIDeviceAddressPtr addr)
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index b01e6b9d20..e5ce4868d5 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -166,6 +166,14 @@ bool virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs,
virPCIDeviceAddressPtr addr)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+int virDomainPCIAddressExtensionReserveAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
+int virDomainPCIAddressExtensionReserveNextAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
int virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs,
virPCIDeviceAddressPtr addr,
virDomainPCIConnectFlags flags,
@@ -187,6 +195,10 @@ void virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
virPCIDeviceAddressPtr addr)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+void virDomainPCIAddressExtensionReleaseAddr(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressPtr addr)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
void virDomainPCIAddressSetAllMulti(virDomainDefPtr def)
ATTRIBUTE_NONNULL(1);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b2a2a1f265..ee7625b0f3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -93,6 +93,8 @@ virCPUModeTypeToString;
# conf/device_conf.h
+virDeviceInfoPCIAddressExtensionIsPresent;
+virDeviceInfoPCIAddressExtensionIsWanted;
virDomainDeviceInfoAddressIsEqual;
virDomainDeviceInfoCopy;
virInterfaceLinkFormat;
@@ -114,6 +116,9 @@ virDomainPCIAddressAsString;
virDomainPCIAddressBusIsFullyReserved;
virDomainPCIAddressBusSetModel;
virDomainPCIAddressEnsureAddr;
+virDomainPCIAddressExtensionReleaseAddr;
+virDomainPCIAddressExtensionReserveAddr;
+virDomainPCIAddressExtensionReserveNextAddr;
virDomainPCIAddressReleaseAddr;
virDomainPCIAddressReserveAddr;
virDomainPCIAddressReserveNextAddr;
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index ba870d56b1..8338241cba 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1405,6 +1405,24 @@ qemuDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
}
+static int
+qemuDomainAssignPCIAddressExtension(virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainDeviceDefPtr device ATTRIBUTE_UNUSED,
+ virDomainDeviceInfoPtr info,
+ void *opaque)
+{
+ virDomainPCIAddressSetPtr addrs = opaque;
+ virPCIDeviceAddressPtr addr = &info->addr.pci;
+
+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+ addr->extFlags = info->pciAddrExtFlags;
+
+ if (virDeviceInfoPCIAddressExtensionIsWanted(info))
+ return virDomainPCIAddressExtensionReserveNextAddr(addrs, addr);
+
+ return 0;
+}
+
static int
qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
virDomainDeviceDefPtr device,
@@ -1498,6 +1516,31 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
return ret;
}
+static int
+qemuDomainCollectPCIAddressExtension(virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainDeviceDefPtr device,
+ virDomainDeviceInfoPtr info,
+ void *opaque)
+{
+ virDomainPCIAddressSetPtr addrs = opaque;
+ virPCIDeviceAddressPtr addr = &info->addr.pci;
+
+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+ addr->extFlags = info->pciAddrExtFlags;
+
+ if (!virDeviceInfoPCIAddressExtensionIsPresent(info) ||
+ ((device->type == VIR_DOMAIN_DEVICE_HOSTDEV) &&
+ (device->data.hostdev->parent.type != VIR_DOMAIN_DEVICE_NONE))) {
+ /* If a hostdev has a parent, its info will be a part of the
+ * parent, and will have its address collected during the scan
+ * of the parent's device type.
+ */
+ return 0;
+ }
+
+ return virDomainPCIAddressExtensionReserveAddr(addrs, addr);
+}
+
static virDomainPCIAddressSetPtr
qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
@@ -1589,6 +1632,12 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
if (virDomainDeviceInfoIterate(def, qemuDomainCollectPCIAddress, addrs) < 0)
goto error;
+ if (virDomainDeviceInfoIterate(def,
+ qemuDomainCollectPCIAddressExtension,
+ addrs) < 0) {
+ goto error;
+ }
+
return addrs;
error:
@@ -2590,6 +2639,9 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (qemuDomainAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
goto cleanup;
+ if (virDomainDeviceInfoIterate(def, qemuDomainAssignPCIAddressExtension, addrs) < 0)
+ goto cleanup;
+
/* Only for *new* domains with pcie-root (and no other
* manually specified PCI controllers in the definition): If,
* after assigning addresses/reserving slots for all devices,
@@ -2684,6 +2736,9 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (qemuDomainAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
goto cleanup;
+ if (virDomainDeviceInfoIterate(def, qemuDomainAssignPCIAddressExtension, addrs) < 0)
+ goto cleanup;
+
/* set multi attribute for devices at function 0 of
* any slot that has multiple functions in use
*/
@@ -3143,8 +3198,10 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
if (!devstr)
devstr = info->alias;
- if (virDeviceInfoPCIAddressPresent(info))
+ if (virDeviceInfoPCIAddressPresent(info)) {
virDomainPCIAddressReleaseAddr(priv->pciaddrs, &info->addr.pci);
+ virDomainPCIAddressExtensionReleaseAddr(priv->pciaddrs, &info->addr.pci);
+ }
if (virDomainUSBAddressRelease(priv->usbaddrs, info) < 0)
VIR_WARN("Unable to release USB address on %s", NULLSTR(devstr));
--
2.22.0

View File

@ -0,0 +1,58 @@
From 898e0003ae21e9fbe49995980c8746e9d2ac9b8b Mon Sep 17 00:00:00 2001
Message-Id: <898e0003ae21e9fbe49995980c8746e9d2ac9b8b@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 23 Jun 2020 14:23:06 +0200
Subject: [PATCH] conf: Don't format http cookies unless
VIR_DOMAIN_DEF_FORMAT_SECURE is used
Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410
(v6.1.0-122-g3b076391be) we support http cookies. Since they may contain
somewhat sensitive information we should not format them into the XML
unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted.
Reported-by: Han Han <hhan@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
(cherry picked from commit a5b064bf4b17a9884d7d361733737fb614ad8979)
CVE-2020-14301
Message-Id: <592a0b594666f580e743b6bd2b4ddccbd1e0cc7c.1592914898.git.pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/conf/domain_conf.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ed9ca0e9d8..60962ee7c1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -24377,11 +24377,15 @@ virDomainSourceDefFormatSeclabel(virBufferPtr buf,
static void
virDomainDiskSourceFormatNetworkCookies(virBufferPtr buf,
- virStorageSourcePtr src)
+ virStorageSourcePtr src,
+ unsigned int flags)
{
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
size_t i;
+ if (!(flags & VIR_DOMAIN_DEF_FORMAT_SECURE))
+ return;
+
for (i = 0; i < src->ncookies; i++) {
virBufferEscapeString(&childBuf, "<cookie name='%s'>", src->cookies[i]->name);
virBufferEscapeString(&childBuf, "%s</cookie>\n", src->cookies[i]->value);
@@ -24442,7 +24446,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
virTristateBoolTypeToString(src->sslverify));
}
- virDomainDiskSourceFormatNetworkCookies(childBuf, src);
+ virDomainDiskSourceFormatNetworkCookies(childBuf, src, flags);
if (src->readahead)
virBufferAsprintf(childBuf, "<readahead size='%llu'/>\n", src->readahead);
--
2.27.0

View File

@ -0,0 +1,97 @@
From 3ff27fe469c36e5655231f6759150350b17de298 Mon Sep 17 00:00:00 2001
Message-Id: <3ff27fe469c36e5655231f6759150350b17de298@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 13 Mar 2020 13:08:09 +0100
Subject: [PATCH] conf: Don't generate machine names with a dot
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
According to the linked BZ, machined expects either valid
hostname or valid FQDN (see systemd commit
v239-3092-gd65652f1f2). While in case of multiple dots, a
trailing one doesn't violate FQDN, it does violate the rule in
case of something simple, like "domain.". But it's safe to remove
it in both cases.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1808499
Fixes: 45464db8ba502764cf37ec9335770248bdb3d9a8
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 2695191a44eb7375225b4ad073825ed3563a172a)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <355e05e31ec98522fa0e03a0c2c7af8ca097070d.1584101247.git.mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 14 +++++++-------
tests/virsystemdtest.c | 5 +++--
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4b297c96bc..b3c4084c38 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30688,20 +30688,20 @@ static void
virDomainMachineNameAppendValid(virBufferPtr buf,
const char *name)
{
- bool skip_dot = false;
+ bool skip = true;
for (; *name; name++) {
if (strlen(virBufferCurrentContent(buf)) >= 64)
break;
- if (*name == '.') {
- if (!skip_dot)
+ if (*name == '.' || *name == '-') {
+ if (!skip)
virBufferAddChar(buf, *name);
- skip_dot = true;
+ skip = true;
continue;
}
- skip_dot = false;
+ skip = false;
if (!strchr(HOSTNAME_CHARS, *name))
continue;
@@ -30709,8 +30709,8 @@ virDomainMachineNameAppendValid(virBufferPtr buf,
virBufferAddChar(buf, *name);
}
- /* trailing dashes are not allowed */
- virBufferTrimChars(buf, "-");
+ /* trailing dashes or dots are not allowed */
+ virBufferTrimChars(buf, "-.");
}
#undef HOSTNAME_CHARS
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index 26876850b8..eb510b40e4 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -733,7 +733,7 @@ mymain(void)
TEST_MACHINE("demo", 1, "qemu-1-demo");
TEST_MACHINE("demo-name", 2, "qemu-2-demo-name");
TEST_MACHINE("demo!name", 3, "qemu-3-demoname");
- TEST_MACHINE(".demo", 4, "qemu-4-.demo");
+ TEST_MACHINE(".demo", 4, "qemu-4-demo");
TEST_MACHINE("bull\U0001f4a9", 5, "qemu-5-bull");
TEST_MACHINE("demo..name", 6, "qemu-6-demo.name");
TEST_MACHINE("12345678901234567890123456789012345678901234567890123456789", 7,
@@ -743,7 +743,8 @@ mymain(void)
TEST_MACHINE("kstest-network-device-default-httpks_(c9eed63e-981e-48ec-acdc-56b3f8c5f678)", 100,
"qemu-100-kstest-network-device-default-httpksc9eed63e-981e-48ec");
TEST_MACHINE("kstest-network-device-default-httpks_(c9eed63e-981e-48ec--cdc-56b3f8c5f678)", 10,
- "qemu-10-kstest-network-device-default-httpksc9eed63e-981e-48ec");
+ "qemu-10-kstest-network-device-default-httpksc9eed63e-981e-48ec-c");
+ TEST_MACHINE("demo.-.test.", 11, "qemu-11-demo.test");
# define TESTS_PM_SUPPORT_HELPER(name, function) \
do { \
--
2.25.1

View File

@ -1,69 +0,0 @@
From 2e3774564235a185a2cc4b7a22c17de17498db68 Mon Sep 17 00:00:00 2001
Message-Id: <2e3774564235a185a2cc4b7a22c17de17498db68@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 18 Apr 2019 19:36:31 +0200
Subject: [PATCH] conf: Expose virDomainSCSIDriveAddressIsUsed
RHEl-7.7: https://bugzilla.redhat.com/show_bug.cgi?id=1692296
RHEL-8.1.0: https://bugzilla.redhat.com/show_bug.cgi?id=1692354
This function checks if given drive address is already present in
passed domain definition. Expose the function as it will be used
shortly.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
(cherry picked from commit 89237d534f0fe950d06a2081089154160c6c2224)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <ef6c1d914a1f6bf0cdb44006b9adf6edf7bb4d41.1555608962.git.mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/conf/domain_conf.c | 2 +-
src/conf/domain_conf.h | 4 ++++
src/libvirt_private.syms | 1 +
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d431441f62..e62f78471c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4404,7 +4404,7 @@ virDomainDriveAddressIsUsedByHostdev(const virDomainDef *def,
* Return true if the SCSI drive address is already in use, false
* otherwise.
*/
-static bool
+bool
virDomainSCSIDriveAddressIsUsed(const virDomainDef *def,
const virDomainDeviceDriveAddress *addr)
{
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f05fca284f..dbccf2cf24 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2789,6 +2789,10 @@ virDomainXMLNamespacePtr
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
ATTRIBUTE_NONNULL(1);
+bool
+virDomainSCSIDriveAddressIsUsed(const virDomainDef *def,
+ const virDomainDeviceDriveAddress *addr);
+
int virDomainDefPostParse(virDomainDefPtr def,
virCapsPtr caps,
unsigned int parseFlags,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 624151056a..df27ac4b3a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -520,6 +520,7 @@ virDomainRunningReasonTypeToString;
virDomainSaveConfig;
virDomainSaveStatus;
virDomainSaveXML;
+virDomainSCSIDriveAddressIsUsed;
virDomainSeclabelTypeFromString;
virDomainSeclabelTypeToString;
virDomainShmemDefEquals;
--
2.21.0

View File

@ -1,35 +0,0 @@
From b1c91c78451c59b0ebe3aafa17eef764e69be28c Mon Sep 17 00:00:00 2001
Message-Id: <b1c91c78451c59b0ebe3aafa17eef764e69be28c@dist-git>
From: Han Han <hhan@redhat.com>
Date: Tue, 31 Jul 2018 10:42:27 +0200
Subject: [PATCH] conf: Fix a error msg typo in virDomainVideoDefValidate
https://bugzilla.redhat.com/show_bug.cgi?id=1607825
Introduced by commit d48813e8.
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
(cherry picked from commit d1c4480390da7243e37daee37f8a40cb439a6a7c)
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/conf/domain_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 23288aa01b..a05aad056d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5697,7 +5697,7 @@ virDomainVideoDefValidate(const virDomainVideoDef *video,
if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_NONE &&
def->nvideos > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("a '%s' video type must be the only video device "
+ _("a 'none' video type must be the only video device "
"defined for the domain"));
return -1;
}
--
2.18.0

View File

@ -1,113 +0,0 @@
From 27213f01f9320cf0fec49980f78a100e64025ba4 Mon Sep 17 00:00:00 2001
Message-Id: <27213f01f9320cf0fec49980f78a100e64025ba4@dist-git>
From: Andrea Bolognani <abologna@redhat.com>
Date: Fri, 7 Sep 2018 17:53:32 +0200
Subject: [PATCH] conf: Fix check for chardev source path
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Attempting to use a chardev definition like
<serial type='unix'>
<target type='isa-serial'/>
</serial>
correctly results in an error being reported, since the source
path - a required piece of information - is missing; however,
the very similar
<serial type='unix'>
<target type='pci-serial'/>
</serial>
was happily accepted by libvirt, only to result in libvirtd
crashing as soon as the guest was started.
The issue was caused by checking the chardev's targetType
against whitelisted values from virDomainChrChannelTargetType
without first checking the chardev's deviceType to make sure
it is actually a channel, for which the check makes sense,
rather than a different type of chardev.
The only reason this wasn't spotted earlier is that the
whitelisted values just so happen to correspond to USB and
PCI serial devices and Xen and UML consoles respectively,
all of which are fairly uncommon.
https://bugzilla.redhat.com/show_bug.cgi?id=1609720
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 614193fac67445a7e92bf620ffef726ed1bd6f07)
https://bugzilla.redhat.com/show_bug.cgi?id=1609723
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
---
src/conf/domain_conf.c | 11 +++++++----
.../serial-unix-missing-source.xml | 15 +++++++++++++++
tests/qemuxml2argvtest.c | 1 +
3 files changed, 23 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuxml2argvdata/serial-unix-missing-source.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a881b43b51..240b33f28c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5523,11 +5523,14 @@ virDomainChrSourceDefValidate(const virDomainChrSourceDef *def,
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
- /* path can be auto generated */
+ /* The source path can be auto generated for certain specific
+ * types of channels, but in most cases we should report an
+ * error if the user didn't provide it */
if (!def->data.nix.path &&
- (!chr_def ||
- (chr_def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN &&
- chr_def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO))) {
+ !(chr_def &&
+ chr_def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
+ (chr_def->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN ||
+ chr_def->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing source path attribute for char device"));
return -1;
diff --git a/tests/qemuxml2argvdata/serial-unix-missing-source.xml b/tests/qemuxml2argvdata/serial-unix-missing-source.xml
new file mode 100644
index 0000000000..1e1221f12d
--- /dev/null
+++ b/tests/qemuxml2argvdata/serial-unix-missing-source.xml
@@ -0,0 +1,15 @@
+<domain type='qemu'>
+ <name>guest</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>1048576</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='aarch64' machine='virt'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-aarch64</emulator>
+ <serial type='unix'>
+ <target type='pci-serial'/>
+ </serial>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 608a2b6ce3..ebe9c8a131 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1363,6 +1363,7 @@ mymain(void)
DO_TEST("serial-unix-chardev",
QEMU_CAPS_DEVICE_ISA_SERIAL);
DO_TEST_CAPS_LATEST("serial-unix-chardev");
+ DO_TEST_PARSE_ERROR("serial-unix-missing-source", NONE);
DO_TEST("serial-tcp-chardev",
QEMU_CAPS_DEVICE_ISA_SERIAL);
DO_TEST("serial-udp-chardev",
--
2.19.1

View File

@ -0,0 +1,143 @@
From 6d5174acd7530d554ac2651f3e6a5da9f69fe6e4 Mon Sep 17 00:00:00 2001
Message-Id: <6d5174acd7530d554ac2651f3e6a5da9f69fe6e4@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 19 Feb 2020 15:10:20 +0100
Subject: [PATCH] conf: Implement support for <slices> of disk source
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Implement parsing and formatting of the 'storage' slice.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit bbf5d05cfd003e33600009cac7ea98ef1539dd7c)
https://bugzilla.redhat.com/show_bug.cgi?id=1791788
Message-Id: <d31bb27ae30140c9deb696972ee76a90d7bcc610.1582120424.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 86 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b46b92aecf..5c11f49463 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9441,6 +9441,57 @@ virDomainStorageSourceParseBase(const char *type,
}
+static virStorageSourceSlicePtr
+virDomainStorageSourceParseSlice(xmlNodePtr node,
+ xmlXPathContextPtr ctxt)
+{
+ VIR_XPATH_NODE_AUTORESTORE(ctxt);
+ g_autofree char *offset = NULL;
+ g_autofree char *size = NULL;
+ g_autofree virStorageSourceSlicePtr ret = g_new0(virStorageSourceSlice, 1);
+
+ ctxt->node = node;
+
+ if (!(offset = virXPathString("string(./@offset)", ctxt)) ||
+ !(size = virXPathString("string(./@size)", ctxt))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("missing offset or size attribute of slice"));
+ return NULL;
+ }
+
+ if (virStrToLong_ullp(offset, NULL, 10, &ret->offset) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("malformed value '%s' of 'offset' attribute of slice"),
+ offset);
+ return NULL;
+ }
+
+ if (virStrToLong_ullp(size, NULL, 10, &ret->size) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("malformed value '%s' of 'size' attribute of slice"),
+ size);
+ return NULL;
+ }
+
+ return g_steal_pointer(&ret);
+}
+
+
+static int
+virDomainStorageSourceParseSlices(virStorageSourcePtr src,
+ xmlXPathContextPtr ctxt)
+{
+ xmlNodePtr node;
+
+ if ((node = virXPathNode("./slices/slice[@type='storage']", ctxt))) {
+ if (!(src->sliceStorage = virDomainStorageSourceParseSlice(node, ctxt)))
+ return -1;
+ }
+
+ return 0;
+}
+
+
/**
* virDomainStorageSourceParse:
* @node: XML node pointing to the source element to parse
@@ -9506,6 +9557,9 @@ virDomainStorageSourceParse(xmlNodePtr node,
if (virDomainDiskSourcePRParse(node, ctxt, &src->pr) < 0)
return -1;
+ if (virDomainStorageSourceParseSlices(src, ctxt) < 0)
+ return -1;
+
if (virSecurityDeviceLabelDefParseXML(&src->seclabels, &src->nseclabels,
ctxt, flags) < 0)
return -1;
@@ -24226,6 +24280,36 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
}
+static void
+virDomainDiskSourceFormatSlice(virBufferPtr buf,
+ const char *slicetype,
+ virStorageSourceSlicePtr slice)
+{
+ g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
+
+ if (!slice)
+ return;
+
+ virBufferAsprintf(&attrBuf, " type='%s'", slicetype);
+ virBufferAsprintf(&attrBuf, " offset='%llu'", slice->offset);
+ virBufferAsprintf(&attrBuf, " size='%llu'", slice->size);
+
+ virXMLFormatElement(buf, "slice", &attrBuf, NULL);
+}
+
+
+static void
+virDomainDiskSourceFormatSlices(virBufferPtr buf,
+ virStorageSourcePtr src)
+{
+ g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
+
+ virDomainDiskSourceFormatSlice(&childBuf, "storage", src->sliceStorage);
+
+ virXMLFormatElement(buf, "slices", NULL, &childBuf);
+}
+
+
/**
* virDomainDiskSourceFormat:
* @buf: output buffer
@@ -24296,6 +24380,8 @@ virDomainDiskSourceFormat(virBufferPtr buf,
return -1;
}
+ virDomainDiskSourceFormatSlices(&childBuf, src);
+
if (src->type != VIR_STORAGE_TYPE_NETWORK)
virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels,
src->seclabels, flags);
--
2.25.0

View File

@ -0,0 +1,129 @@
From eb6bdf4798eea9bae5ddca1fdd13fb5ef6e99596 Mon Sep 17 00:00:00 2001
Message-Id: <eb6bdf4798eea9bae5ddca1fdd13fb5ef6e99596@dist-git>
From: Andrea Bolognani <abologna@redhat.com>
Date: Fri, 14 Feb 2020 13:12:35 +0100
Subject: [PATCH] conf: Introduce VIR_DOMAIN_TIMER_NAME_ARMVTIMER
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This new timer model will be used to control the behavior of the
virtual timer for KVM ARM/virt guests.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 3809e88a87e5898c9cf3a277cb32e20fca8fb2d0)
https://bugzilla.redhat.com/show_bug.cgi?id=1762634
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200214121237.623948-5-abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 1 +
src/conf/domain_conf.h | 1 +
src/libxl/libxl_conf.c | 1 +
src/libxl/xen_common.c | 1 +
src/qemu/qemu_command.c | 2 ++
src/qemu/qemu_domain.c | 3 +++
7 files changed, 10 insertions(+)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 026e753567..19476a2735 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1239,6 +1239,7 @@
<choice>
<value>hpet</value>
<value>pit</value>
+ <value>armvtimer</value>
</choice>
</attribute>
<optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 58f72b3b0f..68d9ce9c4e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1062,6 +1062,7 @@ VIR_ENUM_IMPL(virDomainTimerName,
"tsc",
"kvmclock",
"hypervclock",
+ "armvtimer",
);
VIR_ENUM_IMPL(virDomainTimerTrack,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ee8eb3ddc0..ef2c1b80f7 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1989,6 +1989,7 @@ typedef enum {
VIR_DOMAIN_TIMER_NAME_TSC,
VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
+ VIR_DOMAIN_TIMER_NAME_ARMVTIMER,
VIR_DOMAIN_TIMER_NAME_LAST
} virDomainTimerNameType;
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 2488bb9d32..ffac890262 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -361,6 +361,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK:
case VIR_DOMAIN_TIMER_NAME_RTC:
case VIR_DOMAIN_TIMER_NAME_PIT:
+ case VIR_DOMAIN_TIMER_NAME_ARMVTIMER:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported timer type (name) '%s'"),
virDomainTimerNameTypeToString(clock.timers[i]->name));
diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index 415549a42c..9a385eba0d 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -2182,6 +2182,7 @@ xenFormatCPUFeatures(virConfPtr conf, virDomainDefPtr def)
case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK:
case VIR_DOMAIN_TIMER_NAME_RTC:
case VIR_DOMAIN_TIMER_NAME_PIT:
+ case VIR_DOMAIN_TIMER_NAME_ARMVTIMER:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported timer type (name) '%s'"),
virDomainTimerNameTypeToString(def->clock.timers[i]->name));
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0ad09baa1d..e1e19e0fcc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6200,6 +6200,7 @@ qemuBuildClockCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_TIMER_NAME_TSC:
case VIR_DOMAIN_TIMER_NAME_KVMCLOCK:
case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK:
+ case VIR_DOMAIN_TIMER_NAME_ARMVTIMER:
/* Timers above are handled when building -cpu. */
case VIR_DOMAIN_TIMER_NAME_LAST:
break;
@@ -6631,6 +6632,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
if (timer->frequency > 0)
virBufferAsprintf(&buf, ",tsc-frequency=%lu", timer->frequency);
break;
+ case VIR_DOMAIN_TIMER_NAME_ARMVTIMER:
case VIR_DOMAIN_TIMER_NAME_PLATFORM:
case VIR_DOMAIN_TIMER_NAME_PIT:
case VIR_DOMAIN_TIMER_NAME_RTC:
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 846d1ecb29..4de4f9da53 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5504,6 +5504,9 @@ qemuDomainDefValidateClockTimers(const virDomainDef *def,
return -1;
}
break;
+
+ case VIR_DOMAIN_TIMER_NAME_ARMVTIMER:
+ break;
}
}
--
2.25.0

View File

@ -1,241 +0,0 @@
From 7888472ef1d57d992995a16dc7c9ba0fe18562a8 Mon Sep 17 00:00:00 2001
Message-Id: <7888472ef1d57d992995a16dc7c9ba0fe18562a8@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:22 +0200
Subject: [PATCH] conf: Introduce address caching for PCI extensions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch provides a caching mechanism for the device address
extensions uid and fid on S390. For efficient sparse address allocation,
we introduce two hash tables for uid/fid which hold the address set
information per domain. Also in order to improve performance of
searching available value, we introduce our own callbacks for the two
hashtables. In this way, uid/fid is saved in hash key and hash value
could be any non-NULL pointer due to no operation on hash value. That is
also the reason why we don't introduce hash value free callback.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 28831e1f1ec001882e907f03f7618f7c00ebc98d)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Conflicts:
* src/conf/domain_addr.h
+ context
- missing b72183223f3b
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-6-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/bhyve/bhyve_device.c | 3 +-
src/conf/domain_addr.c | 93 +++++++++++++++++++++++++++++++++-
src/conf/domain_addr.h | 10 +++-
src/qemu/qemu_domain_address.c | 6 ++-
4 files changed, 108 insertions(+), 4 deletions(-)
diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c
index 03aa6c93bd..8f0862b0b6 100644
--- a/src/bhyve/bhyve_device.c
+++ b/src/bhyve/bhyve_device.c
@@ -71,7 +71,8 @@ bhyveDomainPCIAddressSetCreate(virDomainDefPtr def, unsigned int nbuses)
{
virDomainPCIAddressSetPtr addrs;
- if ((addrs = virDomainPCIAddressSetAlloc(nbuses)) == NULL)
+ if ((addrs = virDomainPCIAddressSetAlloc(nbuses,
+ VIR_PCI_ADDRESS_EXTENSION_NONE)) == NULL)
return NULL;
if (virDomainPCIAddressBusSetModel(&addrs->buses[0],
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 39f22b82eb..3e33549c3d 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -27,6 +27,7 @@
#include "virlog.h"
#include "virstring.h"
#include "domain_addr.h"
+#include "virhashcode.h"
#define VIR_FROM_THIS VIR_FROM_DOMAIN
@@ -741,8 +742,93 @@ virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
addrs->buses[addr->bus].slot[addr->slot].functions &= ~(1 << addr->function);
}
+
+static uint32_t
+virZPCIAddrKeyCode(const void *name,
+ uint32_t seed)
+{
+ unsigned int value = *((unsigned int *)name);
+ return virHashCodeGen(&value, sizeof(value), seed);
+}
+
+
+static bool
+virZPCIAddrKeyEqual(const void *namea,
+ const void *nameb)
+{
+ return *((unsigned int *)namea) == *((unsigned int *)nameb);
+}
+
+
+static void *
+virZPCIAddrKeyCopy(const void *name)
+{
+ unsigned int *copy;
+
+ if (VIR_ALLOC(copy) < 0)
+ return NULL;
+
+ *copy = *((unsigned int *)name);
+ return (void *)copy;
+}
+
+
+static void
+virZPCIAddrKeyFree(void *name)
+{
+ VIR_FREE(name);
+}
+
+
+static void
+virDomainPCIAddressSetExtensionFree(virDomainPCIAddressSetPtr addrs)
+{
+ if (!addrs || !addrs->zpciIds)
+ return;
+
+ virHashFree(addrs->zpciIds->uids);
+ virHashFree(addrs->zpciIds->fids);
+ VIR_FREE(addrs->zpciIds);
+}
+
+
+static int
+virDomainPCIAddressSetExtensionAlloc(virDomainPCIAddressSetPtr addrs,
+ virPCIDeviceAddressExtensionFlags extFlags)
+{
+ if (extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) {
+ if (addrs->zpciIds)
+ return 0;
+
+ if (VIR_ALLOC(addrs->zpciIds) < 0)
+ return -1;
+
+ if (!(addrs->zpciIds->uids = virHashCreateFull(10, NULL,
+ virZPCIAddrKeyCode,
+ virZPCIAddrKeyEqual,
+ virZPCIAddrKeyCopy,
+ virZPCIAddrKeyFree)))
+ goto error;
+
+ if (!(addrs->zpciIds->fids = virHashCreateFull(10, NULL,
+ virZPCIAddrKeyCode,
+ virZPCIAddrKeyEqual,
+ virZPCIAddrKeyCopy,
+ virZPCIAddrKeyFree)))
+ goto error;
+ }
+
+ return 0;
+
+ error:
+ virDomainPCIAddressSetExtensionFree(addrs);
+ return -1;
+}
+
+
virDomainPCIAddressSetPtr
-virDomainPCIAddressSetAlloc(unsigned int nbuses)
+virDomainPCIAddressSetAlloc(unsigned int nbuses,
+ virPCIDeviceAddressExtensionFlags extFlags)
{
virDomainPCIAddressSetPtr addrs;
@@ -753,6 +839,10 @@ virDomainPCIAddressSetAlloc(unsigned int nbuses)
goto error;
addrs->nbuses = nbuses;
+
+ if (virDomainPCIAddressSetExtensionAlloc(addrs, extFlags) < 0)
+ goto error;
+
return addrs;
error:
@@ -767,6 +857,7 @@ virDomainPCIAddressSetFree(virDomainPCIAddressSetPtr addrs)
if (!addrs)
return;
+ virDomainPCIAddressSetExtensionFree(addrs);
VIR_FREE(addrs->buses);
VIR_FREE(addrs);
}
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index fd06008e26..b01e6b9d20 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -116,6 +116,12 @@ typedef struct {
} virDomainPCIAddressBus;
typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr;
+typedef struct {
+ virHashTablePtr uids;
+ virHashTablePtr fids;
+} virDomainZPCIAddressIds;
+typedef virDomainZPCIAddressIds *virDomainZPCIAddressIdsPtr;
+
struct _virDomainPCIAddressSet {
virDomainPCIAddressBus *buses;
size_t nbuses;
@@ -125,6 +131,7 @@ struct _virDomainPCIAddressSet {
bool areMultipleRootsSupported;
/* If true, the guest can use the pcie-to-pci-bridge controller */
bool isPCIeToPCIBridgeSupported;
+ virDomainZPCIAddressIdsPtr zpciIds;
};
typedef struct _virDomainPCIAddressSet virDomainPCIAddressSet;
typedef virDomainPCIAddressSet *virDomainPCIAddressSetPtr;
@@ -132,7 +139,8 @@ typedef virDomainPCIAddressSet *virDomainPCIAddressSetPtr;
char *virDomainPCIAddressAsString(virPCIDeviceAddressPtr addr)
ATTRIBUTE_NONNULL(1);
-virDomainPCIAddressSetPtr virDomainPCIAddressSetAlloc(unsigned int nbuses);
+virDomainPCIAddressSetPtr virDomainPCIAddressSetAlloc(unsigned int nbuses,
+ virPCIDeviceAddressExtensionFlags extFlags);
void virDomainPCIAddressSetFree(virDomainPCIAddressSetPtr addrs);
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 3d01d14b46..ba870d56b1 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1508,8 +1508,12 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
size_t i;
bool hasPCIeRoot = false;
virDomainControllerModelPCI defaultModel;
+ virPCIDeviceAddressExtensionFlags extFlags = VIR_PCI_ADDRESS_EXTENSION_NONE;
- if ((addrs = virDomainPCIAddressSetAlloc(nbuses)) == NULL)
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI))
+ extFlags |= VIR_PCI_ADDRESS_EXTENSION_ZPCI;
+
+ if ((addrs = virDomainPCIAddressSetAlloc(nbuses, extFlags)) == NULL)
return NULL;
addrs->dryRun = dryRun;
--
2.22.0

View File

@ -1,283 +0,0 @@
From 050eb598af9291f385998cb1127d5bdf83305501 Mon Sep 17 00:00:00 2001
Message-Id: <050eb598af9291f385998cb1127d5bdf83305501@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:21 +0200
Subject: [PATCH] conf: Introduce extension flag and zPCI member for PCI
address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch introduces PCI address extension flag for virDomainDeviceInfo
and virPCIDeviceAddress. The extension flag in virDomainDeviceInfo is
used internally during calculating PCI extension flag. The one in
virPCIDeviceAddress is the duplicate to indicate extension address is
being used. Currently only zPCI extension address is introduced to deal
with 'uid' and 'fid' on the S390 platform.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 478e5f90fd4c0c0a8c1b3a8e19b9cae93ed78a4e)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Conflicts:
* src/qemu/qemu_domain_address.c
+ context
- missing db98a426a640
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-5-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/device_conf.h | 4 +
src/conf/domain_addr.h | 5 ++
src/qemu/qemu_domain_address.c | 140 ++++++++++++++++++++++++++++++++-
src/util/virpci.h | 2 +
4 files changed, 149 insertions(+), 2 deletions(-)
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index a31ce9c376..c79066ec02 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -164,6 +164,10 @@ struct _virDomainDeviceInfo {
* assignment, never saved and never reported.
*/
int pciConnectFlags; /* enum virDomainPCIConnectFlags */
+ /* pciAddrExtFlags is only used internally to calculate PCI
+ * address extension flags during address assignment.
+ */
+ int pciAddrExtFlags; /* enum virDomainPCIAddressExtensionFlags */
char *loadparm;
/* PCI devices will only be automatically placed on a PCI bus
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index 3236b7d6de..fd06008e26 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -29,6 +29,11 @@
# define VIR_PCI_ADDRESS_SLOT_LAST 31
# define VIR_PCI_ADDRESS_FUNCTION_LAST 7
+typedef enum {
+ VIR_PCI_ADDRESS_EXTENSION_NONE = 0, /* no extension */
+ VIR_PCI_ADDRESS_EXTENSION_ZPCI = 1 << 0, /* zPCI support */
+} virPCIDeviceAddressExtensionFlags;
+
typedef enum {
VIR_PCI_CONNECT_HOTPLUGGABLE = 1 << 0, /* is hotplug needed/supported */
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 79d2b9f9c4..3d01d14b46 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -511,6 +511,64 @@ qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def,
}
+static bool
+qemuDomainDeviceSupportZPCI(virDomainDeviceDefPtr device)
+{
+ switch ((virDomainDeviceType)device->type) {
+ case VIR_DOMAIN_DEVICE_CHR:
+ return false;
+
+ case VIR_DOMAIN_DEVICE_CONTROLLER:
+ case VIR_DOMAIN_DEVICE_DISK:
+ case VIR_DOMAIN_DEVICE_LEASE:
+ case VIR_DOMAIN_DEVICE_FS:
+ case VIR_DOMAIN_DEVICE_NET:
+ case VIR_DOMAIN_DEVICE_INPUT:
+ case VIR_DOMAIN_DEVICE_SOUND:
+ case VIR_DOMAIN_DEVICE_VIDEO:
+ case VIR_DOMAIN_DEVICE_HOSTDEV:
+ case VIR_DOMAIN_DEVICE_WATCHDOG:
+ case VIR_DOMAIN_DEVICE_GRAPHICS:
+ case VIR_DOMAIN_DEVICE_HUB:
+ case VIR_DOMAIN_DEVICE_REDIRDEV:
+ case VIR_DOMAIN_DEVICE_SMARTCARD:
+ case VIR_DOMAIN_DEVICE_MEMBALLOON:
+ case VIR_DOMAIN_DEVICE_NVRAM:
+ case VIR_DOMAIN_DEVICE_RNG:
+ case VIR_DOMAIN_DEVICE_SHMEM:
+ case VIR_DOMAIN_DEVICE_TPM:
+ case VIR_DOMAIN_DEVICE_PANIC:
+ case VIR_DOMAIN_DEVICE_MEMORY:
+ case VIR_DOMAIN_DEVICE_IOMMU:
+ case VIR_DOMAIN_DEVICE_VSOCK:
+ break;
+
+ case VIR_DOMAIN_DEVICE_NONE:
+ case VIR_DOMAIN_DEVICE_LAST:
+ default:
+ virReportEnumRangeError(virDomainDeviceType, device->type);
+ return false;
+ }
+
+ return true;
+}
+
+
+static virPCIDeviceAddressExtensionFlags
+qemuDomainDeviceCalculatePCIAddressExtensionFlags(virQEMUCapsPtr qemuCaps,
+ virDomainDeviceDefPtr dev)
+{
+ virPCIDeviceAddressExtensionFlags extFlags = 0;
+
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI) &&
+ qemuDomainDeviceSupportZPCI(dev)) {
+ extFlags |= VIR_PCI_ADDRESS_EXTENSION_ZPCI;
+ }
+
+ return extFlags;
+}
+
+
/**
* qemuDomainDeviceCalculatePCIConnectFlags:
*
@@ -993,6 +1051,56 @@ qemuDomainFillAllPCIConnectFlags(virDomainDefPtr def,
}
+/**
+ * qemuDomainFillDevicePCIExtensionFlagsIter:
+ *
+ * @def: the entire DomainDef
+ * @dev: The device to be checked
+ * @info: virDomainDeviceInfo within the device
+ * @opaque: qemu capabilities
+ *
+ * Sets the pciAddressExtFlags for a single device's info. Has properly
+ * formatted arguments to be called by virDomainDeviceInfoIterate().
+ *
+ * Always returns 0 - there is no failure.
+ */
+static int
+qemuDomainFillDevicePCIExtensionFlagsIter(virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainDeviceDefPtr dev,
+ virDomainDeviceInfoPtr info,
+ void *opaque)
+{
+ virQEMUCapsPtr qemuCaps = opaque;
+
+ info->pciAddrExtFlags =
+ qemuDomainDeviceCalculatePCIAddressExtensionFlags(qemuCaps, dev);
+
+ return 0;
+}
+
+
+/**
+ * qemuDomainFillAllPCIExtensionFlags:
+ *
+ * @def: the entire DomainDef
+ * @qemuCaps: as you'd expect
+ *
+ * Set the info->pciAddressExtFlags for all devices in the domain.
+ *
+ * Returns 0 on success or -1 on failure (the only possibility of
+ * failure would be some internal problem with
+ * virDomainDeviceInfoIterate())
+ */
+static int
+qemuDomainFillAllPCIExtensionFlags(virDomainDefPtr def,
+ virQEMUCapsPtr qemuCaps)
+{
+ return virDomainDeviceInfoIterate(def,
+ qemuDomainFillDevicePCIExtensionFlagsIter,
+ qemuCaps);
+}
+
+
/**
* qemuDomainFindUnusedIsolationGroupIter:
* @def: domain definition
@@ -1267,6 +1375,27 @@ qemuDomainFillDevicePCIConnectFlags(virDomainDefPtr def,
}
+/**
+ * qemuDomainFillDevicePCIExtensionFlags:
+ *
+ * @dev: The device to be checked
+ * @info: virDomainDeviceInfo within the device
+ * @qemuCaps: as you'd expect
+ *
+ * Set the info->pciAddressExtFlags for a single device.
+ *
+ * No return value.
+ */
+static void
+qemuDomainFillDevicePCIExtensionFlags(virDomainDeviceDefPtr dev,
+ virDomainDeviceInfoPtr info,
+ virQEMUCapsPtr qemuCaps)
+{
+ info->pciAddrExtFlags =
+ qemuDomainDeviceCalculatePCIAddressExtensionFlags(qemuCaps, dev);
+}
+
+
static int
qemuDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
virDomainDeviceInfoPtr dev)
@@ -2400,6 +2529,9 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (qemuDomainFillAllPCIConnectFlags(def, qemuCaps, driver) < 0)
goto cleanup;
+ if (qemuDomainFillAllPCIExtensionFlags(def, qemuCaps) < 0)
+ goto cleanup;
+
if (qemuDomainSetupIsolationGroups(def) < 0)
goto cleanup;
@@ -2435,7 +2567,8 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
*/
virDomainDeviceInfo info = {
.pciConnectFlags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
- VIR_PCI_CONNECT_TYPE_PCI_DEVICE)
+ VIR_PCI_CONNECT_TYPE_PCI_DEVICE),
+ .pciAddrExtFlags = VIR_PCI_ADDRESS_EXTENSION_NONE
};
bool buses_reserved = true;
@@ -2472,7 +2605,8 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
qemuDomainHasPCIeRoot(def)) {
virDomainDeviceInfo info = {
.pciConnectFlags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
- VIR_PCI_CONNECT_TYPE_PCIE_DEVICE)
+ VIR_PCI_CONNECT_TYPE_PCIE_DEVICE),
+ .pciAddrExtFlags = VIR_PCI_ADDRESS_EXTENSION_NONE
};
/* if there isn't an empty pcie-root-port, this will
@@ -2989,6 +3123,8 @@ qemuDomainEnsurePCIAddress(virDomainObjPtr obj,
qemuDomainFillDevicePCIConnectFlags(obj->def, dev, priv->qemuCaps, driver);
+ qemuDomainFillDevicePCIExtensionFlags(dev, info, priv->qemuCaps);
+
return virDomainPCIAddressEnsureAddr(priv->pciaddrs, info,
info->pciConnectFlags);
}
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 01df652b86..b366d7d9c3 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -49,6 +49,8 @@ struct _virPCIDeviceAddress {
unsigned int slot;
unsigned int function;
int multi; /* virTristateSwitch */
+ int extFlags; /* enum virPCIDeviceAddressExtensionFlags */
+ virZPCIDeviceAddress zpci;
};
typedef enum {
--
2.22.0

View File

@ -1,416 +0,0 @@
From 5ad0f7cc1b2444ee9355229316fb008919d22c71 Mon Sep 17 00:00:00 2001
Message-Id: <5ad0f7cc1b2444ee9355229316fb008919d22c71@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Thu, 19 Jul 2018 15:04:02 +0200
Subject: [PATCH] conf: Introduce new <hostdev> attribute 'display'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
QEMU 2.12 introduced a new type of display for mediated devices using
vfio-pci backend which allows a mediated device to be used as a VGA
compatible device as an alternative to an emulated video device. QEMU
exposes this feature via a vfio device property 'display' with supported
values 'on/off/auto' (libvirt will default to 'off').
This patch adds the necessary bits to domain config handling in order to
expose this feature. Since there's no convenient way for libvirt to come
up with usable defaults for the display setting, simply because libvirt
is not able to figure out which of the display implementations - dma-buf
which requires OpenGL support vs vfio regions which doesn't need OpenGL
(works with OpenGL enabled too) - the underlying mdev uses.
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
(cherry picked from commit d54e45b6edd7623e488a19e30bc4148a21fa8b03)
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatdomain.html.in | 20 +++-
docs/schemas/domaincommon.rng | 5 +
src/conf/domain_conf.c | 19 +++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_domain.c | 98 ++++++++++++++++++-
.../qemuxml2argvdata/hostdev-mdev-display.xml | 39 ++++++++
.../hostdev-mdev-display.xml | 47 +++++++++
tests/qemuxml2xmltest.c | 1 +
8 files changed, 222 insertions(+), 8 deletions(-)
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-display.xml
create mode 100644 tests/qemuxml2xmloutdata/hostdev-mdev-display.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 9dd22554ad..3554c3dc30 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4510,9 +4510,23 @@
guest. Currently, <code>model='vfio-pci'</code> and
<code>model='vfio-ccw'</code> (<span class="since">Since 4.4.0</span>)
is supported. Refer <a href="drvnodedev.html#MDEV">MDEV</a> to create
- a mediated device on the host. There are also some implications on the
- usage of guest's address type depending on the <code>model</code>
- attribute, see the <code>address</code> element below.
+ a mediated device on the host.
+ <span class="since">Since 4.6.0 (QEMU 2.12)</span> an optional
+ <code>display</code> attribute may be used to enable or disable
+ support for an accelerated remote desktop backed by a mediated
+ device (such as NVIDIA vGPU or Intel GVT-g) as an alternative to
+ emulated <a href="#elementsVideo">video devices</a>. This attribute
+ is limited to <code>model='vfio-pci'</code> only. Supported values
+ are either <code>on</code> or <code>off</code> (default is 'off').
+ It is required to use a
+ <a href="#elementsGraphics">graphical framebuffer</a> in order to
+ use this attribute, currently only supported with VNC, Spice and
+ egl-headless graphics devices.
+ <p>
+ Note: There are also some implications on the usage of guest's
+ address type depending on the <code>model</code> attribute,
+ see the <code>address</code> element below.
+ </p>
</dd>
</dl>
<p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 157726752c..be8430ab22 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4579,6 +4579,11 @@
<value>vfio-ccw</value>
</choice>
</attribute>
+ <optional>
+ <attribute name="display">
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
<element name="source">
<ref name="mdevaddress"/>
</element>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 72086f9e86..830c298158 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7656,6 +7656,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
char *rawio = NULL;
char *backendStr = NULL;
char *model = NULL;
+ char *display = NULL;
int backend;
int ret = -1;
virDomainHostdevSubsysPCIPtr pcisrc = &def->source.subsys.u.pci;
@@ -7675,6 +7676,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
sgio = virXMLPropString(node, "sgio");
rawio = virXMLPropString(node, "rawio");
model = virXMLPropString(node, "model");
+ display = virXMLPropString(node, "display");
/* @type is passed in from the caller rather than read from the
* xml document, because it is specified in different places for
@@ -7762,6 +7764,15 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
model);
goto cleanup;
}
+
+ if (display &&
+ (mdevsrc->display = virTristateSwitchTypeFromString(display)) <= 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("unknown value '%s' for <hostdev> attribute "
+ "'display'"),
+ display);
+ goto cleanup;
+ }
}
switch (def->source.subsys.type) {
@@ -7815,6 +7826,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
VIR_FREE(rawio);
VIR_FREE(backendStr);
VIR_FREE(model);
+ VIR_FREE(display);
return ret;
}
@@ -26568,9 +26580,14 @@ virDomainHostdevDefFormat(virBufferPtr buf,
virTristateBoolTypeToString(scsisrc->rawio));
}
- if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV)
+ if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) {
virBufferAsprintf(buf, " model='%s'",
virMediatedDeviceModelTypeToString(mdevsrc->model));
+ if (mdevsrc->display != VIR_TRISTATE_SWITCH_ABSENT)
+ virBufferAsprintf(buf, " display='%s'",
+ virTristateSwitchTypeToString(mdevsrc->display));
+ }
+
}
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3deda1d978..8ca9558ceb 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -382,6 +382,7 @@ typedef struct _virDomainHostdevSubsysMediatedDev virDomainHostdevSubsysMediated
typedef virDomainHostdevSubsysMediatedDev *virDomainHostdevSubsysMediatedDevPtr;
struct _virDomainHostdevSubsysMediatedDev {
int model; /* enum virMediatedDeviceModelType */
+ int display; /* virTristateSwitch */
char uuidstr[VIR_UUID_STRING_BUFLEN]; /* mediated device's uuid string */
};
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9498594857..5337f1ce55 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4451,9 +4451,48 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
static int
-qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
- const virDomainDef *def)
+qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
+ const virDomainDef *def,
+ virQEMUCapsPtr qemuCaps)
{
+ if (mdevsrc->display == VIR_TRISTATE_SWITCH_ABSENT)
+ return 0;
+
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VFIO_PCI_DISPLAY)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("display property of device vfio-pci is "
+ "not supported by this version of QEMU"));
+ return -1;
+ }
+
+ if (mdevsrc->model != VIR_MDEV_MODEL_TYPE_VFIO_PCI) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("<hostdev> attribute 'display' is only supported"
+ " with model='vfio-pci'"));
+
+ return -1;
+ }
+
+ if (mdevsrc->display == VIR_TRISTATE_SWITCH_ON) {
+ if (def->ngraphics == 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("graphics device is needed for attribute value "
+ "'display=on' in <hostdev>"));
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
+static int
+qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
+ const virDomainDef *def,
+ virQEMUCapsPtr qemuCaps)
+{
+ const virDomainHostdevSubsysMediatedDev *mdevsrc;
+
/* forbid capabilities mode hostdev in this kind of hypervisor */
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -4463,6 +4502,24 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
return -1;
}
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
+ switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) {
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
+ break;
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
+ mdevsrc = &hostdev->source.subsys.u.mdev;
+ return qemuDomainMdevDefValidate(mdevsrc, def, qemuCaps);
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
+ default:
+ virReportEnumRangeError(virDomainHostdevSubsysType,
+ hostdev->source.subsys.type);
+ return -1;
+ }
+ }
+
return 0;
}
@@ -5595,7 +5652,8 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
break;
case VIR_DOMAIN_DEVICE_HOSTDEV:
- ret = qemuDomainDeviceDefValidateHostdev(dev->data.hostdev, def);
+ ret = qemuDomainDeviceDefValidateHostdev(dev->data.hostdev, def,
+ qemuCaps);
break;
case VIR_DOMAIN_DEVICE_VIDEO:
@@ -6205,6 +6263,35 @@ qemuDomainVsockDefPostParse(virDomainVsockDefPtr vsock)
}
+static int
+qemuDomainHostdevDefMdevPostParse(virDomainHostdevSubsysMediatedDevPtr mdevsrc,
+ virQEMUCapsPtr qemuCaps)
+{
+ /* QEMU 2.12 added support for vfio-pci display type, we default to
+ * 'display=off' to stay safe from future changes */
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VFIO_PCI_DISPLAY) &&
+ mdevsrc->display == VIR_TRISTATE_SWITCH_ABSENT)
+ mdevsrc->display = VIR_TRISTATE_SWITCH_OFF;
+
+ return 0;
+}
+
+
+static int
+qemuDomainHostdevDefPostParse(virDomainHostdevDefPtr hostdev,
+ virQEMUCapsPtr qemuCaps)
+{
+ virDomainHostdevSubsysPtr subsys = &hostdev->source.subsys;
+
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV &&
+ qemuDomainHostdevDefMdevPostParse(&subsys->u.mdev, qemuCaps) < 0)
+ return -1;
+
+ return 0;
+}
+
+
static int
qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
const virDomainDef *def,
@@ -6255,11 +6342,14 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
ret = qemuDomainVsockDefPostParse(dev->data.vsock);
break;
+ case VIR_DOMAIN_DEVICE_HOSTDEV:
+ ret = qemuDomainHostdevDefPostParse(dev->data.hostdev, qemuCaps);
+ break;
+
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT:
case VIR_DOMAIN_DEVICE_SOUND:
- case VIR_DOMAIN_DEVICE_HOSTDEV:
case VIR_DOMAIN_DEVICE_WATCHDOG:
case VIR_DOMAIN_DEVICE_GRAPHICS:
case VIR_DOMAIN_DEVICE_HUB:
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display.xml b/tests/qemuxml2argvdata/hostdev-mdev-display.xml
new file mode 100644
index 0000000000..f37e08e1b9
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-display.xml
@@ -0,0 +1,39 @@
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ </controller>
+ <graphics type='vnc'/>
+ <hostdev mode='subsystem' type='mdev' model='vfio-pci' display='on'>
+ <source>
+ <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/>
+ </source>
+ </hostdev>
+ <video>
+ <model type='qxl' heads='1'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/hostdev-mdev-display.xml b/tests/qemuxml2xmloutdata/hostdev-mdev-display.xml
new file mode 100644
index 0000000000..94c11b1199
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hostdev-mdev-display.xml
@@ -0,0 +1,47 @@
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes'>
+ <listen type='address'/>
+ </graphics>
+ <video>
+ <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='on'>
+ <source>
+ <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </hostdev>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index fa57221d62..e418e67f6c 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -479,6 +479,7 @@ mymain(void)
DO_TEST("hostdev-pci-address", NONE);
DO_TEST("hostdev-vfio", NONE);
DO_TEST("hostdev-mdev-precreated", NONE);
+ DO_TEST("hostdev-mdev-display", QEMU_CAPS_VFIO_PCI_DISPLAY);
DO_TEST("pci-rom", NONE);
DO_TEST("pci-rom-disabled", NONE);
DO_TEST("pci-rom-disabled-invalid", NONE);
--
2.18.0

View File

@ -1,504 +0,0 @@
From 2010df9c6a8a4ff984e3f1b697398da648342953 Mon Sep 17 00:00:00 2001
Message-Id: <2010df9c6a8a4ff984e3f1b697398da648342953@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Thu, 19 Jul 2018 15:04:05 +0200
Subject: [PATCH] conf: Introduce new video type 'none'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Historically, we've always enabled an emulated video device every time we
see that graphics should be supported with a guest. With the appearance
of mediated devices which can support QEMU's vfio-display capability,
users might want to use such a device as the only video device.
Therefore introduce a new, effectively a 'disable', type for video
device.
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
(cherry picked from commit d48813e81af798e3027edcc2f41be2630111ba65)
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatdomain.html.in | 13 +++-
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 61 +++++++++++++------
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 12 +++-
src/qemu/qemu_domain.c | 2 +
src/qemu/qemu_domain_address.c | 7 ++-
tests/domaincapsschemadata/full.xml | 1 +
.../video-invalid-multiple-devices.xml | 33 ++++++++++
tests/qemuxml2argvdata/video-none-device.args | 27 ++++++++
tests/qemuxml2argvdata/video-none-device.xml | 39 ++++++++++++
tests/qemuxml2argvtest.c | 4 +-
.../qemuxml2xmloutdata/video-none-device.xml | 42 +++++++++++++
tests/qemuxml2xmltest.c | 1 +
14 files changed, 220 insertions(+), 24 deletions(-)
create mode 100644 tests/qemuxml2argvdata/video-invalid-multiple-devices.xml
create mode 100644 tests/qemuxml2argvdata/video-none-device.args
create mode 100644 tests/qemuxml2argvdata/video-none-device.xml
create mode 100644 tests/qemuxml2xmloutdata/video-none-device.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0e8f0a125f..42acf7a828 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6666,9 +6666,18 @@ qemu-kvm -net nic,model=? /dev/null
The <code>model</code> element has a mandatory <code>type</code>
attribute which takes the value "vga", "cirrus", "vmvga", "xen",
"vbox", "qxl" (<span class="since">since 0.8.6</span>),
- "virtio" (<span class="since">since 1.3.0</span>)
- or "gop" (<span class="since">since 3.2.0</span>)
+ "virtio" (<span class="since">since 1.3.0</span>),
+ "gop" (<span class="since">since 3.2.0</span>), or
+ "none" (<span class="since">since 4.6.0</span>)
depending on the hypervisor features available.
+ The purpose of the type <code>none</code> is to instruct libvirt not
+ to add a default video device in the guest (see the paragraph above).
+ This legacy behaviour can be inconvenient in cases where GPU mediated
+ devices are meant to be the only rendering device within a guest and
+ so specifying another <code>video</code> device along with type
+ <code>none</code>.
+ Refer to <a id="elementsHostDev">Host device assignment</a> to see
+ how to add a mediated device into a guest.
</p>
<p>
You can provide the amount of video memory in kibibytes (blocks of
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index be8430ab22..ac04af51a1 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3454,6 +3454,7 @@
<value>vbox</value>
<value>virtio</value>
<value>gop</value>
+ <value>none</value>
</choice>
</attribute>
<group>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 830c298158..23288aa01b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -590,7 +590,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"qxl",
"parallels",
"virtio",
- "gop")
+ "gop",
+ "none")
VIR_ENUM_IMPL(virDomainVideoVGAConf, VIR_DOMAIN_VIDEO_VGACONF_LAST,
"io",
@@ -5106,22 +5107,30 @@ virDomainDefPostParseVideo(virDomainDefPtr def,
if (def->nvideos == 0)
return 0;
- virDomainDeviceDef device = {
- .type = VIR_DOMAIN_DEVICE_VIDEO,
- .data.video = def->videos[0],
- };
+ if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_NONE) {
+ /* we don't want to format any values we automatically fill in for
+ * videos into the XML, so clear them
+ */
+ virDomainVideoDefClear(def->videos[0]);
+ def->videos[0]->type = VIR_DOMAIN_VIDEO_TYPE_NONE;
+ } else {
+ virDomainDeviceDef device = {
+ .type = VIR_DOMAIN_DEVICE_VIDEO,
+ .data.video = def->videos[0],
+ };
- /* Mark the first video as primary. If the user specified
- * primary="yes", the parser already inserted the device at
- * def->videos[0]
- */
- def->videos[0]->primary = true;
+ /* Mark the first video as primary. If the user specified
+ * primary="yes", the parser already inserted the device at
+ * def->videos[0]
+ */
+ def->videos[0]->primary = true;
- /* videos[0] might have been added in AddImplicitDevices, after we've
- * done the per-device post-parse */
- if (virDomainDefPostParseDeviceIterator(def, &device,
- NULL, opaque) < 0)
- return -1;
+ /* videos[0] might have been added in AddImplicitDevices, after we've
+ * done the per-device post-parse */
+ if (virDomainDefPostParseDeviceIterator(def, &device,
+ NULL, opaque) < 0)
+ return -1;
+ }
return 0;
}
@@ -5670,13 +5679,30 @@ virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev)
static int
-virDomainVideoDefValidate(const virDomainVideoDef *video)
+virDomainVideoDefValidate(const virDomainVideoDef *video,
+ const virDomainDef *def)
{
+ size_t i;
+
if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing video model and cannot determine default"));
return -1;
}
+
+ /* it doesn't make sense to pair video device type 'none' with any other
+ * types, there can be only a single video device in such case
+ */
+ for (i = 0; i < def->nvideos; i++) {
+ if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_NONE &&
+ def->nvideos > 1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("a '%s' video type must be the only video device "
+ "defined for the domain"));
+ return -1;
+ }
+ }
+
return 0;
}
@@ -5738,7 +5764,7 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
return virDomainHostdevDefValidate(dev->data.hostdev);
case VIR_DOMAIN_DEVICE_VIDEO:
- return virDomainVideoDefValidate(dev->data.video);
+ return virDomainVideoDefValidate(dev->data.video, def);
case VIR_DOMAIN_DEVICE_MEMORY:
return virDomainMemoryDefValidate(dev->data.memory);
@@ -15048,6 +15074,7 @@ virDomainVideoDefaultRAM(const virDomainDef *def,
case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
case VIR_DOMAIN_VIDEO_TYPE_GOP:
+ case VIR_DOMAIN_VIDEO_TYPE_NONE:
case VIR_DOMAIN_VIDEO_TYPE_LAST:
default:
return 0;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8ca9558ceb..5e2f21dea3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1424,6 +1424,7 @@ typedef enum {
VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
VIR_DOMAIN_VIDEO_TYPE_VIRTIO,
VIR_DOMAIN_VIDEO_TYPE_GOP,
+ VIR_DOMAIN_VIDEO_TYPE_NONE,
VIR_DOMAIN_VIDEO_TYPE_LAST
} virDomainVideoType;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1fce45134f..954265feb0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -105,7 +105,8 @@ VIR_ENUM_IMPL(qemuVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"qxl",
"", /* don't support parallels */
"", /* no need for virtio */
- "" /* don't support gop */);
+ "" /* don't support gop */,
+ "" /* 'none' doesn't make sense here */);
VIR_ENUM_DECL(qemuDeviceVideo)
@@ -119,7 +120,8 @@ VIR_ENUM_IMPL(qemuDeviceVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"qxl-vga",
"", /* don't support parallels */
"virtio-vga",
- "" /* don't support gop */);
+ "" /* don't support gop */,
+ "" /* 'none' doesn't make sense here */);
VIR_ENUM_DECL(qemuDeviceVideoSecondary)
@@ -133,7 +135,8 @@ VIR_ENUM_IMPL(qemuDeviceVideoSecondary, VIR_DOMAIN_VIDEO_TYPE_LAST,
"qxl",
"", /* don't support parallels */
"virtio-gpu",
- "" /* don't support gop */);
+ "" /* don't support gop */,
+ "" /* 'none' doesn't make sense here */);
VIR_ENUM_DECL(qemuSoundCodec)
@@ -4421,6 +4424,9 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
char *str = NULL;
virDomainVideoDefPtr video = def->videos[i];
+ if (video->type == VIR_DOMAIN_VIDEO_TYPE_NONE)
+ continue;
+
if (video->primary) {
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY)) {
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5337f1ce55..508846116b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4528,6 +4528,8 @@ static int
qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video)
{
switch ((virDomainVideoType) video->type) {
+ case VIR_DOMAIN_VIDEO_TYPE_NONE:
+ return 0;
case VIR_DOMAIN_VIDEO_TYPE_XEN:
case VIR_DOMAIN_VIDEO_TYPE_VBOX:
case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index ab2ac022f1..e6996934b8 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -821,6 +821,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
case VIR_DOMAIN_VIDEO_TYPE_GOP:
+ case VIR_DOMAIN_VIDEO_TYPE_NONE:
case VIR_DOMAIN_VIDEO_TYPE_LAST:
return 0;
}
@@ -1532,7 +1533,8 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
goto cleanup;
}
- if (def->nvideos > 0) {
+ if (def->nvideos > 0 &&
+ def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_NONE) {
/* Because the PIIX3 integrated IDE/USB controllers are
* already at slot 1, when qemu looks for the first free slot
* to place the VGA controller (which is always the first
@@ -1540,6 +1542,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
* at slot 2.
*/
virDomainVideoDefPtr primaryVideo = def->videos[0];
+
if (virDeviceInfoPCIAddressWanted(&primaryVideo->info)) {
memset(&tmp_addr, 0, sizeof(tmp_addr));
tmp_addr.slot = 2;
@@ -2105,6 +2108,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
/* Video devices */
for (i = 0; i < def->nvideos; i++) {
+ if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_NONE)
+ continue;
if (!virDeviceInfoPCIAddressWanted(&def->videos[i]->info))
continue;
diff --git a/tests/domaincapsschemadata/full.xml b/tests/domaincapsschemadata/full.xml
index 154c4a6fe9..eafba1ae5b 100644
--- a/tests/domaincapsschemadata/full.xml
+++ b/tests/domaincapsschemadata/full.xml
@@ -74,6 +74,7 @@
<value>parallels</value>
<value>virtio</value>
<value>gop</value>
+ <value>none</value>
</enum>
</video>
<hostdev supported='yes'>
diff --git a/tests/qemuxml2argvdata/video-invalid-multiple-devices.xml b/tests/qemuxml2argvdata/video-invalid-multiple-devices.xml
new file mode 100644
index 0000000000..3f105efaae
--- /dev/null
+++ b/tests/qemuxml2argvdata/video-invalid-multiple-devices.xml
@@ -0,0 +1,33 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <video>
+ <model type='qxl'/>
+ </video>
+ <video>
+ <model type='none'/>
+ </video>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/video-none-device.args b/tests/qemuxml2argvdata/video-none-device.args
new file mode 100644
index 0000000000..1b03c0cb97
--- /dev/null
+++ b/tests/qemuxml2argvdata/video-none-device.args
@@ -0,0 +1,27 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+-vnc 127.0.0.1:0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/video-none-device.xml b/tests/qemuxml2argvdata/video-none-device.xml
new file mode 100644
index 0000000000..4b591562b7
--- /dev/null
+++ b/tests/qemuxml2argvdata/video-none-device.xml
@@ -0,0 +1,39 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='vnc'/>
+ <video>
+ <model type='none'/>
+ </video>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 9237a4fb89..3cff4ffb5e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1998,7 +1998,9 @@ mymain(void)
QEMU_CAPS_DEVICE_VIRTIO_VGA,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS);
- DO_TEST_PARSE_ERROR("video-invalid", NONE);
+ DO_TEST("video-none-device",
+ QEMU_CAPS_VNC);
+ DO_TEST_PARSE_ERROR("video-invalid-multiple-devices", NONE);
DO_TEST("virtio-rng-default",
QEMU_CAPS_DEVICE_VIRTIO_RNG,
diff --git a/tests/qemuxml2xmloutdata/video-none-device.xml b/tests/qemuxml2xmloutdata/video-none-device.xml
new file mode 100644
index 0000000000..6e76b394fe
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/video-none-device.xml
@@ -0,0 +1,42 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes'>
+ <listen type='address'/>
+ </graphics>
+ <video>
+ <model type='none'/>
+ </video>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index e418e67f6c..e35644d479 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1145,6 +1145,7 @@ mymain(void)
QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS,
QEMU_CAPS_VNC,
QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW);
+ DO_TEST("video-none-device", NONE);
DO_TEST("intel-iommu",
QEMU_CAPS_DEVICE_INTEL_IOMMU);
--
2.18.0

View File

@ -1,574 +0,0 @@
From fddd43e717869d56e481c3fde2d5ee6b5513a1f5 Mon Sep 17 00:00:00 2001
Message-Id: <fddd43e717869d56e481c3fde2d5ee6b5513a1f5@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:25 +0200
Subject: [PATCH] conf: Introduce parser, formatter for uid and fid
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch introduces new XML parser/formatter functions. Uid is
16-bit and non-zero. Fid is 32-bit. They are the two attributes of zpci
which is introduced as PCI address element. Zpci element is parsed and
formatted along with PCI address. And add the related test cases.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit b4833b2c2f7be8a68eb6495ed57ed61918e3ecd8)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Conflicts:
* src/conf/device_conf.c
+ context
- missing edeef779585
* tests/qemuxml2argvtest.c
+ context
- missing a0ff9fbe5cad, 0bdb704383f7
Changed:
* tests/qemuxml2argvdata/disk-virtio-s390-zpci.args
tests/qemuxml2argvdata/hostdev-vfio-zpci.args
+ no -boot in output
- missing caccbba64aa9
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-9-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/schemas/basictypes.rng | 27 ++++++++++
docs/schemas/domaincommon.rng | 1 +
src/conf/device_conf.c | 53 +++++++++++++++++++
src/conf/domain_addr.c | 3 ++
src/conf/domain_conf.c | 12 ++++-
src/libvirt_private.syms | 2 +
src/util/virpci.c | 26 +++++++++
src/util/virpci.h | 6 +++
.../disk-virtio-s390-zpci.args | 26 +++++++++
.../disk-virtio-s390-zpci.xml | 19 +++++++
tests/qemuxml2argvdata/hostdev-vfio-zpci.args | 24 +++++++++
tests/qemuxml2argvdata/hostdev-vfio-zpci.xml | 21 ++++++++
tests/qemuxml2argvtest.c | 7 +++
.../disk-virtio-s390-zpci.xml | 31 +++++++++++
.../qemuxml2xmloutdata/hostdev-vfio-zpci.xml | 32 +++++++++++
tests/qemuxml2xmltest.c | 6 +++
16 files changed, 295 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/disk-virtio-s390-zpci.args
create mode 100644 tests/qemuxml2argvdata/disk-virtio-s390-zpci.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci.args
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci.xml
create mode 100644 tests/qemuxml2xmloutdata/disk-virtio-s390-zpci.xml
create mode 100644 tests/qemuxml2xmloutdata/hostdev-vfio-zpci.xml
diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index b45a7fcdc8..97e14d7ca8 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -65,6 +65,17 @@
</data>
</choice>
</define>
+ <define name="uint32">
+ <choice>
+ <data type="string">
+ <param name="pattern">(0x)?[0-9a-fA-F]{1,8}</param>
+ </data>
+ <data type="unsignedInt">
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">4294967295</param>
+ </data>
+ </choice>
+ </define>
<define name="UUID">
<choice>
@@ -111,6 +122,22 @@
</attribute>
</optional>
</define>
+ <define name="zpciaddress">
+ <optional>
+ <element name="zpci">
+ <optional>
+ <attribute name="uid">
+ <ref name="uint16"/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="fid">
+ <ref name="uint32"/>
+ </attribute>
+ </optional>
+ </element>
+ </optional>
+ </define>
<!-- a 6 byte MAC address in ASCII-hex format, eg "12:34:56:78:9A:BC" -->
<!-- The lowest bit of the 1st byte is the "multicast" bit. a -->
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 70a7767d9c..2b6d4dced6 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5186,6 +5186,7 @@
<value>pci</value>
</attribute>
<ref name="pciaddress"/>
+ <ref name="zpciaddress"/>
</group>
<group>
<attribute name="type">
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index d69f94fadf..cadac32603 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -32,6 +32,45 @@
#define VIR_FROM_THIS VIR_FROM_DEVICE
+static int
+virZPCIDeviceAddressParseXML(xmlNodePtr node,
+ virPCIDeviceAddressPtr addr)
+{
+ virZPCIDeviceAddress def = { 0 };
+ char *uid;
+ char *fid;
+ int ret = -1;
+
+ uid = virXMLPropString(node, "uid");
+ fid = virXMLPropString(node, "fid");
+
+ if (uid &&
+ virStrToLong_uip(uid, NULL, 0, &def.uid) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <address> 'uid' attribute"));
+ goto cleanup;
+ }
+
+ if (fid &&
+ virStrToLong_uip(fid, NULL, 0, &def.fid) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <address> 'fid' attribute"));
+ goto cleanup;
+ }
+
+ if (!virZPCIDeviceAddressIsEmpty(&def) &&
+ !virZPCIDeviceAddressIsValid(&def))
+ goto cleanup;
+
+ addr->zpci = def;
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(uid);
+ VIR_FREE(fid);
+ return ret;
+}
+
int
virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst,
virDomainDeviceInfoPtr src)
@@ -196,6 +235,8 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
virPCIDeviceAddressPtr addr)
{
char *domain, *slot, *bus, *function, *multi;
+ xmlNodePtr cur;
+ xmlNodePtr zpci = NULL;
int ret = -1;
memset(addr, 0, sizeof(*addr));
@@ -245,6 +286,18 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(addr, true))
goto cleanup;
+ cur = node->children;
+ while (cur) {
+ if (cur->type == XML_ELEMENT_NODE &&
+ virXMLNodeNameEqual(cur, "zpci")) {
+ zpci = cur;
+ }
+ cur = cur->next;
+ }
+
+ if (zpci && virZPCIDeviceAddressParseXML(zpci, addr) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 3e33549c3d..9e0a0fdf95 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1054,6 +1054,9 @@ virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
dev->isolationGroup, false) < 0)
return -1;
+ addr.extFlags = dev->addr.pci.extFlags;
+ addr.zpci = dev->addr.pci.zpci;
+
if (!addrs->dryRun) {
dev->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
dev->addr.pci = addr;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bcb0558bc3..29ebf0a930 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6448,6 +6448,7 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
unsigned int flags)
{
virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
+ virBuffer childBuf = VIR_BUFFER_INITIALIZER;
if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) {
virBufferAsprintf(buf, "<boot order='%u'", info->bootIndex);
@@ -6510,6 +6511,14 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
virBufferAsprintf(&attrBuf, " multifunction='%s'",
virTristateSwitchTypeToString(info->addr.pci.multi));
}
+
+ if (!virZPCIDeviceAddressIsEmpty(&info->addr.pci.zpci)) {
+ virBufferSetChildIndent(&childBuf, buf);
+ virBufferAsprintf(&childBuf,
+ "<zpci uid='0x%.4x' fid='0x%.8x'/>\n",
+ info->addr.pci.zpci.uid,
+ info->addr.pci.zpci.fid);
+ }
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
@@ -6577,9 +6586,10 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
break;
}
- virXMLFormatElement(buf, "address", &attrBuf, NULL);
+ virXMLFormatElement(buf, "address", &attrBuf, &childBuf);
virBufferFreeAndReset(&attrBuf);
+ virBufferFreeAndReset(&childBuf);
}
static int
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index df27ac4b3a..b2a2a1f265 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2569,6 +2569,8 @@ virPCIHeaderTypeToString;
virPCIIsVirtualFunction;
virPCIStubDriverTypeFromString;
virPCIStubDriverTypeToString;
+virZPCIDeviceAddressIsEmpty;
+virZPCIDeviceAddressIsValid;
# util/virperf.h
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 8d02366664..3a1e49a7a7 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2597,6 +2597,32 @@ virPCIDeviceAddressParse(char *address,
#ifdef __linux__
+bool
+virZPCIDeviceAddressIsValid(virZPCIDeviceAddressPtr zpci)
+{
+ /* We don't need to check fid because fid covers
+ * all range of uint32 type.
+ */
+ if (zpci->uid > VIR_DOMAIN_DEVICE_ZPCI_MAX_UID ||
+ zpci->uid == 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Invalid PCI address uid='0x%.4x', "
+ "must be > 0x0000 and <= 0x%.4x"),
+ zpci->uid,
+ VIR_DOMAIN_DEVICE_ZPCI_MAX_UID);
+ return false;
+ }
+
+ return true;
+}
+
+bool
+virZPCIDeviceAddressIsEmpty(const virZPCIDeviceAddress *addr)
+{
+ return !(addr->uid || addr->fid);
+}
+
+
/*
* returns true if equal
*/
diff --git a/src/util/virpci.h b/src/util/virpci.h
index b366d7d9c3..1ed9e2381e 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -36,6 +36,9 @@ typedef virPCIDeviceAddress *virPCIDeviceAddressPtr;
typedef struct _virPCIDeviceList virPCIDeviceList;
typedef virPCIDeviceList *virPCIDeviceListPtr;
+# define VIR_DOMAIN_DEVICE_ZPCI_MAX_UID UINT16_MAX
+# define VIR_DOMAIN_DEVICE_ZPCI_MAX_FID UINT32_MAX
+
typedef struct _virZPCIDeviceAddress virZPCIDeviceAddress;
typedef virZPCIDeviceAddress *virZPCIDeviceAddressPtr;
struct _virZPCIDeviceAddress {
@@ -235,6 +238,9 @@ int virPCIGetAddrString(unsigned int domain,
int virPCIDeviceAddressParse(char *address, virPCIDeviceAddressPtr bdf);
+bool virZPCIDeviceAddressIsValid(virZPCIDeviceAddressPtr zpci);
+bool virZPCIDeviceAddressIsEmpty(const virZPCIDeviceAddress *addr);
+
int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
int pfNetDevIdx,
char **pfname,
diff --git a/tests/qemuxml2argvdata/disk-virtio-s390-zpci.args b/tests/qemuxml2argvdata/disk-virtio-s390-zpci.args
new file mode 100644
index 0000000000..20e63a15b5
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-virtio-s390-zpci.args
@@ -0,0 +1,26 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name QEMUGuest1 \
+-S \
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot c \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-pci,bus=pci.0,addr=0x8,drive=drive-virtio-disk0,\
+id=virtio-disk0 \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0000
diff --git a/tests/qemuxml2argvdata/disk-virtio-s390-zpci.xml b/tests/qemuxml2argvdata/disk-virtio-s390-zpci.xml
new file mode 100644
index 0000000000..8bf4a23670
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-virtio-s390-zpci.xml
@@ -0,0 +1,19 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'>
+ <zpci uid='0x0019' fid='0x0000001f'/>
+ </address>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci.args b/tests/qemuxml2argvdata/hostdev-vfio-zpci.args
new file mode 100644
index 0000000000..622c504da0
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci.args
@@ -0,0 +1,24 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name QEMUGuest1 \
+-S \
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot c \
+-device vfio-pci,host=00:00.0,id=hostdev0,bus=pci.0,addr=0x8 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x1
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci.xml b/tests/qemuxml2argvdata/hostdev-vfio-zpci.xml
new file mode 100644
index 0000000000..002b99c52d
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci.xml
@@ -0,0 +1,21 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <controller type='pci' index='0' model='pci-root'/>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <driver name='vfio'/>
+ <source>
+ <address domain='0x0000' bus='0x00' slot='0x00' function='0x0'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'>
+ <zpci uid='0x0019' fid='0x0000001f'/>
+ </address>
+ </hostdev>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7f25cccf9d..2eb2505971 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1038,6 +1038,10 @@ mymain(void)
QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
DO_TEST("disk-virtio-scsi-ccw", QEMU_CAPS_VIRTIO_SCSI,
QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
+ DO_TEST("disk-virtio-s390-zpci",
+ QEMU_CAPS_DEVICE_ZPCI,
+ QEMU_CAPS_CCW,
+ QEMU_CAPS_VIRTIO_S390);
DO_TEST("disk-order",
QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI);
DO_TEST("disk-virtio-drive-queues",
@@ -1628,6 +1632,9 @@ mymain(void)
DO_TEST_PARSE_ERROR("hostdev-mdev-display-missing-graphics",
QEMU_CAPS_DEVICE_VFIO_PCI,
QEMU_CAPS_VFIO_PCI_DISPLAY);
+ DO_TEST("hostdev-vfio-zpci",
+ QEMU_CAPS_DEVICE_VFIO_PCI,
+ QEMU_CAPS_DEVICE_ZPCI);
DO_TEST("pci-rom", NONE);
DO_TEST("pci-rom-disabled", NONE);
DO_TEST("pci-rom-disabled-invalid", NONE);
diff --git a/tests/qemuxml2xmloutdata/disk-virtio-s390-zpci.xml b/tests/qemuxml2xmloutdata/disk-virtio-s390-zpci.xml
new file mode 100644
index 0000000000..37684c82b1
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/disk-virtio-s390-zpci.xml
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'>
+ <zpci uid='0x0019' fid='0x0000001f'/>
+ </address>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </memballoon>
+ <panic model='s390'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/hostdev-vfio-zpci.xml b/tests/qemuxml2xmloutdata/hostdev-vfio-zpci.xml
new file mode 100644
index 0000000000..fc8c38ab66
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hostdev-vfio-zpci.xml
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <controller type='pci' index='0' model='pci-root'/>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <driver name='vfio'/>
+ <source>
+ <address domain='0x0000' bus='0x00' slot='0x00' function='0x0'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'>
+ <zpci uid='0x0019' fid='0x0000001f'/>
+ </address>
+ </hostdev>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </memballoon>
+ <panic model='s390'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 2a2bf01ffa..a787f4f4a3 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -400,6 +400,9 @@ mymain(void)
QEMU_CAPS_VIRTIO_SCSI);
DO_TEST("disk-virtio-scsi-ioeventfd",
QEMU_CAPS_VIRTIO_SCSI);
+ DO_TEST("disk-virtio-s390-zpci",
+ QEMU_CAPS_DEVICE_ZPCI,
+ QEMU_CAPS_CCW);
DO_TEST("disk-scsi-megasas",
QEMU_CAPS_SCSI_MEGASAS);
DO_TEST("disk-scsi-mptsas1068",
@@ -482,6 +485,9 @@ mymain(void)
DO_TEST("hostdev-usb-address", NONE);
DO_TEST("hostdev-pci-address", NONE);
DO_TEST("hostdev-vfio", NONE);
+ DO_TEST("hostdev-vfio-zpci",
+ QEMU_CAPS_DEVICE_ZPCI,
+ QEMU_CAPS_CCW);
DO_TEST("hostdev-mdev-precreated", NONE);
DO_TEST("hostdev-mdev-display", QEMU_CAPS_VFIO_PCI_DISPLAY);
DO_TEST("pci-rom", NONE);
--
2.22.0

View File

@ -1,103 +0,0 @@
From 0bed2e17ea6469ccabb374c0520a97706b281911 Mon Sep 17 00:00:00 2001
Message-Id: <0bed2e17ea6469ccabb374c0520a97706b281911@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:26:06 +0200
Subject: [PATCH] conf: Introduce virCPUDefCheckFeatures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This API can be used to check whether a CPU definition contains features
matching a given filter.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 4e6f58b8d55d44fa9f80736b2745b44710f6e25a)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <ea489f203e2d52250acb1b9656de6aba8355f3a6.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/cpu_conf.c | 33 +++++++++++++++++++++++++++++++++
src/conf/cpu_conf.h | 6 ++++++
src/libvirt_private.syms | 1 +
3 files changed, 40 insertions(+)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 51e2a83eae..4cccea9981 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -872,6 +872,39 @@ virCPUDefFilterFeatures(virCPUDefPtr cpu,
}
+/**
+ * virCPUDefCheckFeatures:
+ *
+ * Check CPU features for which @filter reports true and store them in a NULL
+ * terminated list returned via @features.
+ *
+ * Returns the number of features matching @filter or -1 on error.
+ */
+int
+virCPUDefCheckFeatures(virCPUDefPtr cpu,
+ virCPUDefFeatureFilter filter,
+ void *opaque,
+ char ***features)
+{
+ VIR_AUTOSTRINGLIST list = NULL;
+ size_t n = 0;
+ size_t i;
+
+ *features = NULL;
+
+ for (i = 0; i < cpu->nfeatures; i++) {
+ if (filter(cpu->features[i].name, opaque)) {
+ if (virStringListAdd(&list, cpu->features[i].name) < 0)
+ return -1;
+ n++;
+ }
+ }
+
+ VIR_STEAL_PTR(*features, list);
+ return n;
+}
+
+
bool
virCPUDefIsEqual(virCPUDefPtr src,
virCPUDefPtr dst,
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index ad25932b9b..cba0ec7c81 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -225,6 +225,12 @@ virCPUDefFilterFeatures(virCPUDefPtr cpu,
virCPUDefFeatureFilter filter,
void *opaque);
+int
+virCPUDefCheckFeatures(virCPUDefPtr cpu,
+ virCPUDefFeatureFilter filter,
+ void *opaque,
+ char ***features);
+
virCPUDefPtr *
virCPUDefListParse(const char **xmlCPUs,
unsigned int ncpus,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 06374deaae..0290f960a0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -72,6 +72,7 @@ virCapabilitiesSetNetPrefix;
virCPUCacheModeTypeFromString;
virCPUCacheModeTypeToString;
virCPUDefAddFeature;
+virCPUDefCheckFeatures;
virCPUDefCopy;
virCPUDefCopyModel;
virCPUDefCopyModelFilter;
--
2.22.0

View File

@ -1,210 +0,0 @@
From cb0d627bf064a14c83f3d34e8b73d77ed1733843 Mon Sep 17 00:00:00 2001
Message-Id: <cb0d627bf064a14c83f3d34e8b73d77ed1733843@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 13 Aug 2018 19:21:54 +0200
Subject: [PATCH] conf: Introduce virDomainDefPostParseMemtune
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Previously we were ignoring "nodeset" attribute for hugepage pages
if there was no guest NUMA topology configured in the domain XML.
Commit <fa6bdf6afa878b8d7c5ed71664ee72be8967cdc5> partially fixed
that issue but it introduced a somehow valid regression.
In case that there is no guest NUMA topology configured and the
"nodeset" attribute is set to "0" it was accepted and was working
properly even though it was not completely valid XML.
This patch introduces a workaround that it will ignore the nodeset="0"
only in case that there is no guest NUMA topology in order not to
hit the validation error.
After this commit the following XML configuration is valid:
<memoryBacking>
<hugepages>
<page size='2048' unit='KiB' nodeset='0'/>
</hugepages>
</memoryBacking>
but this configuration remains invalid:
<memoryBacking>
<hugepages>
<page size='2048' unit='KiB' nodeset='0'/>
<page size='1048576' unit='KiB'/>
</hugepages>
</memoryBacking>
The issue with the second configuration is that it was originally
working, however changing the order of the <page> elements resolved
into using different page size for the guest. The code is written
in a way that it expect only one page configured and always uses only
the first page in case that there is no guest NUMA topology configured.
See qemuBuildMemPathStr() function for details.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1591235
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 0a476f152150f62306f9f8d124aa44e4adb9158c)
Conflicts:
tests/qemuxml2argvdata/hugepages-nodeset.args
- missing upstream commit <caccbba64a>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1615461
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 27 +++++++++++++++++
tests/qemuxml2argvdata/hugepages-nodeset.args | 26 ++++++++++++++++
tests/qemuxml2argvtest.c | 2 +-
.../qemuxml2xmloutdata/hugepages-nodeset.xml | 30 +++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
5 files changed, 85 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/hugepages-nodeset.args
create mode 100644 tests/qemuxml2xmloutdata/hugepages-nodeset.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 98e833c5bb..8a43e607e9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4088,6 +4088,31 @@ virDomainDefPostParseMemory(virDomainDefPtr def,
}
+static void
+virDomainDefPostParseMemtune(virDomainDefPtr def)
+{
+ size_t i;
+
+ if (virDomainNumaGetNodeCount(def->numa) == 0) {
+ /* If guest NUMA is not configured and any hugepage page has nodemask
+ * set to "0" free and clear that nodemas, otherwise we would rise
+ * an error that there is no guest NUMA node configured. */
+ for (i = 0; i < def->mem.nhugepages; i++) {
+ ssize_t nextBit;
+
+ if (!def->mem.hugepages[i].nodemask)
+ continue;
+
+ nextBit = virBitmapNextSetBit(def->mem.hugepages[i].nodemask, 0);
+ if (nextBit < 0) {
+ virBitmapFree(def->mem.hugepages[i].nodemask);
+ def->mem.hugepages[i].nodemask = NULL;
+ }
+ }
+ }
+}
+
+
static int
virDomainDefAddConsoleCompat(virDomainDefPtr def)
{
@@ -5155,6 +5180,8 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
if (virDomainDefPostParseMemory(def, data->parseFlags) < 0)
return -1;
+ virDomainDefPostParseMemtune(def);
+
if (virDomainDefRejectDuplicateControllers(def) < 0)
return -1;
diff --git a/tests/qemuxml2argvdata/hugepages-nodeset.args b/tests/qemuxml2argvdata/hugepages-nodeset.args
new file mode 100644
index 0000000000..d094be1252
--- /dev/null
+++ b/tests/qemuxml2argvdata/hugepages-nodeset.args
@@ -0,0 +1,26 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name SomeDummyHugepagesGuest \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 1024 \
+-mem-prealloc \
+-mem-path /dev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu \
+-smp 2,sockets=2,cores=1,threads=1 \
+-uuid ef1bdff4-27f3-4e85-a807-5fb4d58463cc \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,\
+path=/tmp/lib/domain--1-SomeDummyHugepagesGu/monitor.sock,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index f82bca2637..e6c0120670 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -960,7 +960,7 @@ mymain(void)
DO_TEST("hugepages-default-2M", NONE);
DO_TEST("hugepages-default-system-size", NONE);
DO_TEST_PARSE_ERROR("hugepages-default-1G-nodeset-2M", NONE);
- DO_TEST_PARSE_ERROR("hugepages-nodeset", NONE);
+ DO_TEST("hugepages-nodeset", NONE);
DO_TEST_PARSE_ERROR("hugepages-nodeset-nonexist",
QEMU_CAPS_DEVICE_PC_DIMM,
QEMU_CAPS_OBJECT_MEMORY_FILE,
diff --git a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml b/tests/qemuxml2xmloutdata/hugepages-nodeset.xml
new file mode 100644
index 0000000000..ac219a7800
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hugepages-nodeset.xml
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+ <name>SomeDummyHugepagesGuest</name>
+ <uuid>ef1bdff4-27f3-4e85-a807-5fb4d58463cc</uuid>
+ <memory unit='KiB'>1048576</memory>
+ <currentMemory unit='KiB'>1048576</currentMemory>
+ <memoryBacking>
+ <hugepages>
+ <page size='2048' unit='KiB'/>
+ </hugepages>
+ </memoryBacking>
+ <vcpu placement='static'>2</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index aa543e9e51..b76410b2c1 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -336,6 +336,7 @@ mymain(void)
DO_TEST("hugepages-default", NONE);
DO_TEST("hugepages-default-2M", NONE);
DO_TEST("hugepages-default-system-size", NONE);
+ DO_TEST("hugepages-nodeset", NONE);
DO_TEST("hugepages-numa-default-2M", NONE);
DO_TEST("hugepages-numa-default-dimm", NONE);
DO_TEST("hugepages-numa-nodeset", NONE);
--
2.18.0

View File

@ -1,89 +0,0 @@
From 2f954b30573d57ab0b5d68364afa6168d00ca3e6 Mon Sep 17 00:00:00 2001
Message-Id: <2f954b30573d57ab0b5d68364afa6168d00ca3e6@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Thu, 19 Jul 2018 15:03:52 +0200
Subject: [PATCH] conf: Introduce virDomainDefPostParseVideo helper
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Move the video post parse bits into a separate helper as the logic is
going to be extended in the future.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit 75aa179ad68f5845955128b9f047a43c8e5c9066)
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 45 ++++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 15 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d23b2861ef..db8e17dac4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5097,6 +5097,34 @@ virDomainDefBootOrderPostParse(virDomainDefPtr def)
}
+static int
+virDomainDefPostParseVideo(virDomainDefPtr def,
+ void *opaque)
+{
+ if (def->nvideos == 0)
+ return 0;
+
+ virDomainDeviceDef device = {
+ .type = VIR_DOMAIN_DEVICE_VIDEO,
+ .data.video = def->videos[0],
+ };
+
+ /* Mark the first video as primary. If the user specified
+ * primary="yes", the parser already inserted the device at
+ * def->videos[0]
+ */
+ def->videos[0]->primary = true;
+
+ /* videos[0] might have been added in AddImplicitDevices, after we've
+ * done the per-device post-parse */
+ if (virDomainDefPostParseDeviceIterator(def, &device,
+ NULL, opaque) < 0)
+ return -1;
+
+ return 0;
+}
+
+
static int
virDomainDefPostParseCommon(virDomainDefPtr def,
struct virDomainDefPostParseDeviceIteratorData *data)
@@ -5133,21 +5161,8 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
if (virDomainDefAddImplicitDevices(def) < 0)
return -1;
- if (def->nvideos != 0) {
- virDomainDeviceDef device = {
- .type = VIR_DOMAIN_DEVICE_VIDEO,
- .data.video = def->videos[0],
- };
-
- /* Mark the first video as primary. If the user specified primary="yes",
- * the parser already inserted the device at def->videos[0] */
- def->videos[0]->primary = true;
-
- /* videos[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;
- }
+ if (virDomainDefPostParseVideo(def, data) < 0)
+ return -1;
if (def->nserials != 0) {
virDomainDeviceDef device = {
--
2.18.0

View File

@ -1,105 +0,0 @@
From e6b37b93dd6e7ec133378aec04dd9c96e0ab57cb Mon Sep 17 00:00:00 2001
Message-Id: <e6b37b93dd6e7ec133378aec04dd9c96e0ab57cb@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Thu, 19 Jul 2018 15:04:00 +0200
Subject: [PATCH] conf: Introduce virDomainGraphicsDefHasOpenGL helper
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
A simple helper which will loop through all the graphics elements and
checks whether at least one of them enables OpenGL support, either by
containing <gl enable='yes'/> or being of type 'egl-headless'.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 425329181f1db19f34a8ffffc1da9afa7f323f13)
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 43 ++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 3 +++
src/libvirt_private.syms | 1 +
3 files changed, 47 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fa4dfafcff..08654ab41d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30284,3 +30284,46 @@ virDomainDefHasManagedPR(const virDomainDef *def)
return false;
}
+
+
+/**
+ * virDomainGraphicsDefHasOpenGL:
+ * @def: domain definition
+ *
+ * Returns true if a domain config contains at least one <graphics> element
+ * with OpenGL support enabled, false otherwise.
+ */
+bool
+virDomainGraphicsDefHasOpenGL(const virDomainDef *def)
+{
+ size_t i;
+
+ for (i = 0; i < def->ngraphics; i++) {
+ virDomainGraphicsDefPtr graphics = def->graphics[i];
+
+ /* we only care about OpenGL support for a given type here */
+ switch (graphics->type) {
+ case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
+ case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
+ case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+ continue;
+ case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+ if (graphics->data.sdl.gl == VIR_TRISTATE_BOOL_YES)
+ return true;
+
+ continue;
+ case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+ if (graphics->data.spice.gl == VIR_TRISTATE_BOOL_YES)
+ return true;
+
+ continue;
+ case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
+ return true;
+
+ case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
+ break;
+ }
+ }
+
+ return false;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 26f75b15d0..3deda1d978 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3642,4 +3642,7 @@ virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
bool
virDomainDefHasManagedPR(const virDomainDef *def);
+bool
+virDomainGraphicsDefHasOpenGL(const virDomainDef *def);
+
#endif /* __DOMAIN_CONF_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5bd08d3f67..86846f3b08 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -368,6 +368,7 @@ virDomainGetFilesystemForTarget;
virDomainGraphicsAuthConnectedTypeFromString;
virDomainGraphicsAuthConnectedTypeToString;
virDomainGraphicsDefFree;
+virDomainGraphicsDefHasOpenGL;
virDomainGraphicsGetListen;
virDomainGraphicsListenAppendAddress;
virDomainGraphicsListenAppendSocket;
--
2.18.0

View File

@ -1,84 +0,0 @@
From f60ad6c8636b58d8559963aaf2e445bb4dd3db63 Mon Sep 17 00:00:00 2001
Message-Id: <f60ad6c8636b58d8559963aaf2e445bb4dd3db63@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Thu, 19 Jul 2018 15:03:51 +0200
Subject: [PATCH] conf: Introduce virDomainVideoDefClear helper
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Future patches rely on the ability to reset the contents of the
virDomainVideoDef structure rather than re-allocating it.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit f317b1e5c57291644c841cb620eda86dac8642a1)
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 14 +++++++++++++-
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 1 +
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 70eb45f03a..d23b2861ef 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2538,7 +2538,8 @@ virDomainVideoDefNew(void)
}
-void virDomainVideoDefFree(virDomainVideoDefPtr def)
+void
+virDomainVideoDefClear(virDomainVideoDefPtr def)
{
if (!def)
return;
@@ -2548,6 +2549,17 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
VIR_FREE(def->accel);
VIR_FREE(def->virtio);
VIR_FREE(def->driver);
+
+ memset(def, 0, sizeof(*def));
+}
+
+
+void virDomainVideoDefFree(virDomainVideoDefPtr def)
+{
+ if (!def)
+ return;
+
+ virDomainVideoDefClear(def);
VIR_FREE(def);
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 41d27482fb..1fc1734bcc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2884,6 +2884,7 @@ void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
virDomainVideoDefPtr virDomainVideoDefNew(void);
void virDomainVideoDefFree(virDomainVideoDefPtr def);
+void virDomainVideoDefClear(virDomainVideoDefPtr def);
virDomainHostdevDefPtr virDomainHostdevDefNew(void);
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5499a368c0..5bd08d3f67 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -567,6 +567,7 @@ virDomainTPMModelTypeToString;
virDomainUSBDeviceDefForeach;
virDomainVideoDefaultRAM;
virDomainVideoDefaultType;
+virDomainVideoDefClear;
virDomainVideoDefFree;
virDomainVideoDefNew;
virDomainVideoTypeFromString;
--
2.18.0

View File

@ -1,122 +0,0 @@
From 680d10a61dfab864b5e1bca9e1f197ae06e62d87 Mon Sep 17 00:00:00 2001
Message-Id: <680d10a61dfab864b5e1bca9e1f197ae06e62d87@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Fri, 30 Nov 2018 15:49:26 +0100
Subject: [PATCH] conf: Move VFIO AP validation from post parse to QEMU
validation code
VFIO AP has a limitation on a single device per domain, however, when
commit 11708641 added the support for vfio-ap, check for this limitation
was performed as part of the post parse code. Generally, checks like that
should be performed within the driver's validation callback to eliminate
any slight chance of failing in post parse, which could potentially
result in the domain XML config vanishing.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
(cherry picked from commit 25dde373730545894f60ce5b1497f19d61714c69)
https://bugzilla.redhat.com/show_bug.cgi?id=1508146
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/conf/domain_conf.c | 28 ----------------------------
src/qemu/qemu_domain.c | 28 +++++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 29 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ea7152eb94..e013e9f0c5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4325,31 +4325,6 @@ virDomainDefPostParseGraphics(virDomainDef *def)
}
-static int
-virDomainDefPostParseHostdev(virDomainDefPtr def)
-{
- size_t i;
- bool vfioap_found = false;
-
- /* verify settings of hostdevs vfio-ap */
- for (i = 0; i < def->nhostdevs; i++) {
- virDomainHostdevDefPtr hostdev = def->hostdevs[i];
-
- if (virHostdevIsMdevDevice(hostdev) &&
- hostdev->source.subsys.u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP) {
- if (vfioap_found) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Only one hostdev of model vfio-ap is "
- "supported"));
- return -1;
- }
- vfioap_found = true;
- }
- }
- return 0;
-}
-
-
/**
* virDomainDriveAddressIsUsedByDisk:
* @def: domain definition containing the disks to check
@@ -5262,9 +5237,6 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
virDomainDefPostParseGraphics(def);
- if (virDomainDefPostParseHostdev(def) < 0)
- return -1;
-
if (virDomainDefPostParseCPU(def) < 0)
return -1;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4898d58733..08f479fa1d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4486,6 +4486,32 @@ qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevSubsysMediatedDev *dev,
}
+static int
+qemuDomainMdevDefVFIOAPValidate(const virDomainDef *def)
+{
+ size_t i;
+ bool vfioap_found = false;
+
+ /* VFIO-AP is restricted to a single mediated device only */
+ for (i = 0; i < def->nhostdevs; i++) {
+ virDomainHostdevDefPtr hostdev = def->hostdevs[i];
+
+ if (virHostdevIsMdevDevice(hostdev) &&
+ hostdev->source.subsys.u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP) {
+ if (vfioap_found) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Only one hostdev of model vfio-ap is "
+ "supported"));
+ return -1;
+ }
+ vfioap_found = true;
+ }
+ }
+
+ return 0;
+}
+
+
static int
qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
const virDomainDef *def,
@@ -4495,7 +4521,7 @@ qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
case VIR_MDEV_MODEL_TYPE_VFIO_PCI:
return qemuDomainMdevDefVFIOPCIValidate(mdevsrc, def, qemuCaps);
case VIR_MDEV_MODEL_TYPE_VFIO_AP:
- break;
+ return qemuDomainMdevDefVFIOAPValidate(def);
case VIR_MDEV_MODEL_TYPE_VFIO_CCW:
break;
case VIR_MDEV_MODEL_TYPE_LAST:
--
2.19.2

View File

@ -1,247 +0,0 @@
From d1a499f071b2a223641d2e4f0783eda1ad67d1ae Mon Sep 17 00:00:00 2001
Message-Id: <d1a499f071b2a223641d2e4f0783eda1ad67d1ae@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 13 Aug 2018 19:21:52 +0200
Subject: [PATCH] conf: Move hugepage XML validation check out of qemu_command
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We can safely validate the hugepage nodeset attribute at a define time.
This validation is not done for already existing domains when the daemon
is restarted.
All the changes to the tests are necessary because we move the error
from domain start into XML parse.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 5c93dfb46d9dff623707994f115b6bd7ca4f0682)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1615461
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 32 +++++++++++++++++
src/qemu/qemu_command.c | 34 -------------------
.../seclabel-dynamic-none-relabel.xml | 2 +-
tests/qemuxml2argvtest.c | 18 +++++-----
.../hugepages-default-1G-nodeset-2M.xml | 1 -
.../qemuxml2xmloutdata/hugepages-nodeset.xml | 1 -
.../hugepages-numa-nodeset-nonexist.xml | 1 -
.../seclabel-dynamic-none-relabel.xml | 2 +-
tests/qemuxml2xmltest.c | 3 --
9 files changed, 43 insertions(+), 51 deletions(-)
delete mode 120000 tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml
delete mode 120000 tests/qemuxml2xmloutdata/hugepages-nodeset.xml
delete mode 120000 tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a05aad056d..280bbdf35c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6142,6 +6142,35 @@ virDomainDefLifecycleActionValidate(const virDomainDef *def)
}
+static int
+virDomainDefMemtuneValidate(const virDomainDef *def)
+{
+ const virDomainMemtune *mem = &(def->mem);
+ size_t i;
+ ssize_t pos = virDomainNumaGetNodeCount(def->numa) - 1;
+
+ for (i = 0; i < mem->nhugepages; i++) {
+ ssize_t nextBit;
+
+ if (!mem->hugepages[i].nodemask) {
+ /* This is the master hugepage to use. Skip it as it has no
+ * nodemask anyway. */
+ continue;
+ }
+
+ nextBit = virBitmapNextSetBit(mem->hugepages[i].nodemask, pos);
+ if (nextBit >= 0) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("hugepages: node %zd not found"),
+ nextBit);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
static int
virDomainDefValidateInternal(const virDomainDef *def)
{
@@ -6177,6 +6206,9 @@ virDomainDefValidateInternal(const virDomainDef *def)
if (virDomainDefLifecycleActionValidate(def) < 0)
return -1;
+ if (virDomainDefMemtuneValidate(def) < 0)
+ return -1;
+
return 0;
}
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 954265feb0..f2b64ed720 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7482,16 +7482,6 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg,
if (!def->mem.nhugepages)
return 0;
- if (def->mem.hugepages[0].nodemask) {
- ssize_t next_bit = virBitmapNextSetBit(def->mem.hugepages[0].nodemask, -1);
- if (next_bit >= 0) {
- virReportError(VIR_ERR_XML_DETAIL,
- _("hugepages: node %zd not found"),
- next_bit);
- return -1;
- }
- }
-
/* There is one special case: if user specified "huge"
* pages of regular system pages size.
* And there is nothing to do in this case.
@@ -7624,30 +7614,6 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
if (!virDomainNumatuneNodesetIsAvailable(def->numa, priv->autoNodeset))
goto cleanup;
- for (i = 0; i < def->mem.nhugepages; i++) {
- ssize_t next_bit, pos = 0;
-
- if (!def->mem.hugepages[i].nodemask) {
- /* This is the master hugepage to use. Skip it as it has no
- * nodemask anyway. */
- continue;
- }
-
- if (ncells) {
- /* Fortunately, we allow only guest NUMA nodes to be continuous
- * starting from zero. */
- pos = ncells - 1;
- }
-
- next_bit = virBitmapNextSetBit(def->mem.hugepages[i].nodemask, pos);
- if (next_bit >= 0) {
- virReportError(VIR_ERR_XML_DETAIL,
- _("hugepages: node %zd not found"),
- next_bit);
- goto cleanup;
- }
- }
-
if (VIR_ALLOC_N(nodeBackends, ncells) < 0)
goto cleanup;
diff --git a/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml b/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml
index 47f253b5f7..e954250009 100644
--- a/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml
+++ b/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml
@@ -5,7 +5,7 @@
<currentMemory unit='KiB'>262144</currentMemory>
<memoryBacking>
<hugepages>
- <page size='2048' unit='KiB' nodeset='0'/>
+ <page size='2048' unit='KiB'/>
</hugepages>
</memoryBacking>
<vcpu placement='static'>4</vcpu>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index bd5fdf9412..f82bca2637 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -959,12 +959,12 @@ mymain(void)
DO_TEST("hugepages-default", NONE);
DO_TEST("hugepages-default-2M", NONE);
DO_TEST("hugepages-default-system-size", NONE);
- DO_TEST("hugepages-default-1G-nodeset-2M", NONE);
- DO_TEST_FAILURE("hugepages-nodeset", NONE);
- DO_TEST_FAILURE("hugepages-nodeset-nonexist",
- QEMU_CAPS_DEVICE_PC_DIMM,
- QEMU_CAPS_OBJECT_MEMORY_FILE,
- QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
+ DO_TEST_PARSE_ERROR("hugepages-default-1G-nodeset-2M", NONE);
+ DO_TEST_PARSE_ERROR("hugepages-nodeset", NONE);
+ DO_TEST_PARSE_ERROR("hugepages-nodeset-nonexist",
+ QEMU_CAPS_DEVICE_PC_DIMM,
+ QEMU_CAPS_OBJECT_MEMORY_FILE,
+ QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
DO_TEST("hugepages-numa-default",
QEMU_CAPS_OBJECT_MEMORY_FILE);
DO_TEST("hugepages-numa-default-2M",
@@ -979,9 +979,9 @@ mymain(void)
DO_TEST("hugepages-numa-nodeset-part",
QEMU_CAPS_OBJECT_MEMORY_RAM,
QEMU_CAPS_OBJECT_MEMORY_FILE);
- DO_TEST_FAILURE("hugepages-numa-nodeset-nonexist",
- QEMU_CAPS_OBJECT_MEMORY_RAM,
- QEMU_CAPS_OBJECT_MEMORY_FILE);
+ DO_TEST_PARSE_ERROR("hugepages-numa-nodeset-nonexist",
+ QEMU_CAPS_OBJECT_MEMORY_RAM,
+ QEMU_CAPS_OBJECT_MEMORY_FILE);
DO_TEST("hugepages-shared",
QEMU_CAPS_OBJECT_MEMORY_RAM,
QEMU_CAPS_OBJECT_MEMORY_FILE);
diff --git a/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml b/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml
deleted file mode 120000
index 3d8eb7616e..0000000000
--- a/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml
+++ /dev/null
@@ -1 +0,0 @@
-../qemuxml2argvdata/hugepages-default-1G-nodeset-2M.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml b/tests/qemuxml2xmloutdata/hugepages-nodeset.xml
deleted file mode 120000
index b55838b780..0000000000
--- a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml
+++ /dev/null
@@ -1 +0,0 @@
-../qemuxml2argvdata/hugepages-nodeset.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml b/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml
deleted file mode 120000
index d490edca69..0000000000
--- a/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml
+++ /dev/null
@@ -1 +0,0 @@
-../qemuxml2argvdata/hugepages-numa-nodeset-nonexist.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml b/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml
index 050967b4ee..bfa66b8deb 100644
--- a/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml
+++ b/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml
@@ -5,7 +5,7 @@
<currentMemory unit='KiB'>262144</currentMemory>
<memoryBacking>
<hugepages>
- <page size='2048' unit='KiB' nodeset='0'/>
+ <page size='2048' unit='KiB'/>
</hugepages>
</memoryBacking>
<vcpu placement='static'>4</vcpu>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index acbe2f7133..aa543e9e51 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -336,13 +336,10 @@ mymain(void)
DO_TEST("hugepages-default", NONE);
DO_TEST("hugepages-default-2M", NONE);
DO_TEST("hugepages-default-system-size", NONE);
- DO_TEST("hugepages-default-1G-nodeset-2M", NONE);
- DO_TEST("hugepages-nodeset", NONE);
DO_TEST("hugepages-numa-default-2M", NONE);
DO_TEST("hugepages-numa-default-dimm", NONE);
DO_TEST("hugepages-numa-nodeset", NONE);
DO_TEST("hugepages-numa-nodeset-part", NONE);
- DO_TEST("hugepages-numa-nodeset-nonexist", NONE);
DO_TEST("hugepages-shared", NONE);
DO_TEST("hugepages-memaccess", NONE);
DO_TEST("hugepages-memaccess2", NONE);
--
2.18.0

View File

@ -1,126 +0,0 @@
From a4ddc9b4213809cbab4abce609441975ae433dae Mon Sep 17 00:00:00 2001
Message-Id: <a4ddc9b4213809cbab4abce609441975ae433dae@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 13 Aug 2018 19:21:53 +0200
Subject: [PATCH] conf: Move hugepages validation out of XML parser
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 82327038390bfae117dc6e1d9062e38901cd4c97)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1615461
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 75 ++++++++++++++++++++++--------------------
1 file changed, 40 insertions(+), 35 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 280bbdf35c..98e833c5bb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6149,9 +6149,49 @@ virDomainDefMemtuneValidate(const virDomainDef *def)
size_t i;
ssize_t pos = virDomainNumaGetNodeCount(def->numa) - 1;
+ if (mem->nhugepages == 0)
+ return 0;
+
+ if (mem->allocation == VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("hugepages are not allowed with memory "
+ "allocation ondemand"));
+ return -1;
+ }
+
+ if (mem->source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("hugepages are not allowed with anonymous "
+ "memory source"));
+ return -1;
+ }
+
for (i = 0; i < mem->nhugepages; i++) {
+ size_t j;
ssize_t nextBit;
+ for (j = 0; j < i; j++) {
+ if (mem->hugepages[i].nodemask &&
+ mem->hugepages[j].nodemask &&
+ virBitmapOverlaps(mem->hugepages[i].nodemask,
+ mem->hugepages[j].nodemask)) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("nodeset attribute of hugepages "
+ "of sizes %llu and %llu intersect"),
+ mem->hugepages[i].size,
+ mem->hugepages[j].size);
+ return -1;
+ } else if (!mem->hugepages[i].nodemask &&
+ !mem->hugepages[j].nodemask) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("two master hugepages detected: "
+ "%llu and %llu"),
+ mem->hugepages[i].size,
+ mem->hugepages[j].size);
+ return -1;
+ }
+ }
+
if (!mem->hugepages[i].nodemask) {
/* This is the master hugepage to use. Skip it as it has no
* nodemask anyway. */
@@ -19414,19 +19454,6 @@ virDomainDefParseXML(xmlDocPtr xml,
if (virXPathNode("./memoryBacking/hugepages", ctxt)) {
/* hugepages will be used */
-
- if (def->mem.allocation == VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("hugepages are not allowed with memory allocation ondemand"));
- goto error;
- }
-
- if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("hugepages are not allowed with anonymous memory source"));
- goto error;
- }
-
if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, &nodes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract hugepages nodes"));
@@ -19442,28 +19469,6 @@ virDomainDefParseXML(xmlDocPtr xml,
&def->mem.hugepages[i]) < 0)
goto error;
def->mem.nhugepages++;
-
- for (j = 0; j < i; j++) {
- if (def->mem.hugepages[i].nodemask &&
- def->mem.hugepages[j].nodemask &&
- virBitmapOverlaps(def->mem.hugepages[i].nodemask,
- def->mem.hugepages[j].nodemask)) {
- virReportError(VIR_ERR_XML_DETAIL,
- _("nodeset attribute of hugepages "
- "of sizes %llu and %llu intersect"),
- def->mem.hugepages[i].size,
- def->mem.hugepages[j].size);
- goto error;
- } else if (!def->mem.hugepages[i].nodemask &&
- !def->mem.hugepages[j].nodemask) {
- virReportError(VIR_ERR_XML_DETAIL,
- _("two master hugepages detected: "
- "%llu and %llu"),
- def->mem.hugepages[i].size,
- def->mem.hugepages[j].size);
- goto error;
- }
- }
}
VIR_FREE(nodes);
--
2.18.0

View File

@ -1,152 +0,0 @@
From 742667e7f0a55f3a8042840e2995982a003dc2fc Mon Sep 17 00:00:00 2001
Message-Id: <742667e7f0a55f3a8042840e2995982a003dc2fc@dist-git>
From: Andrea Bolognani <abologna@redhat.com>
Date: Tue, 4 Dec 2018 16:46:19 +0100
Subject: [PATCH] conf: Parse and format nested-hv feature
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit bfa2bd7e38f2777260b63200ef12804e13a7a5c2)
https://bugzilla.redhat.com/show_bug.cgi?id=1647822
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatdomain.html.in | 12 ++++++++++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 4 ++++
src/conf/domain_conf.h | 1 +
src/qemu/qemu_domain.c | 1 +
tests/qemuxml2argvdata/pseries-features.xml | 1 +
tests/qemuxml2xmloutdata/pseries-features.xml | 1 +
7 files changed, 25 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 54eb298414..02d0ac4241 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2191,6 +2191,18 @@
defined, the hypervisor default will be used.
<span class="since">Since 4.6.0</span> (QEMU/KVM only)
</dd>
+ <dt><code>nested-hv</code></dt>
+ <dd>Configure nested HV availability for pSeries guests. This needs to
+ be enabled from the host (L0) in order to be effective; having HV
+ support in the (L1) guest is very desiderable if it's planned to
+ run nested (L2) guests inside it, because it will result in those
+ nested guests having much better performance than they would when
+ using KVM PR or TCG.
+ Possible values for the <code>state</code> attribute are
+ <code>on</code> and <code>off</code>. If the attribute is not
+ defined, the hypervisor default will be used.
+ <span class="since">Since 4.10.0</span> (QEMU/KVM only)
+ </dd>
</dl>
<h3><a id="elementsTime">Time keeping</a></h3>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index e4ce7804b9..70a7767d9c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4925,6 +4925,11 @@
<ref name="featurestate"/>
</element>
</optional>
+ <optional>
+ <element name="nested-hv">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
</interleave>
</element>
</optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e013e9f0c5..660e1523fe 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -153,6 +153,7 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
"hpt",
"vmcoreinfo",
"htm",
+ "nested-hv",
);
VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
@@ -19987,6 +19988,7 @@ virDomainDefParseXML(xmlDocPtr xml,
break;
case VIR_DOMAIN_FEATURE_HTM:
+ case VIR_DOMAIN_FEATURE_NESTED_HV:
if (!(tmp = virXMLPropString(nodes[i], "state"))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("missing state attribute '%s' of feature '%s'"),
@@ -22147,6 +22149,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
case VIR_DOMAIN_FEATURE_SMM:
case VIR_DOMAIN_FEATURE_VMCOREINFO:
case VIR_DOMAIN_FEATURE_HTM:
+ case VIR_DOMAIN_FEATURE_NESTED_HV:
if (src->features[i] != dst->features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of feature '%s' differs: "
@@ -27823,6 +27826,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
case VIR_DOMAIN_FEATURE_PVSPINLOCK:
case VIR_DOMAIN_FEATURE_VMPORT:
case VIR_DOMAIN_FEATURE_HTM:
+ case VIR_DOMAIN_FEATURE_NESTED_HV:
switch ((virTristateSwitch) def->features[i]) {
case VIR_TRISTATE_SWITCH_LAST:
case VIR_TRISTATE_SWITCH_ABSENT:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d32514e7e6..f05fca284f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1775,6 +1775,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_HPT,
VIR_DOMAIN_FEATURE_VMCOREINFO,
VIR_DOMAIN_FEATURE_HTM,
+ VIR_DOMAIN_FEATURE_NESTED_HV,
VIR_DOMAIN_FEATURE_LAST
} virDomainFeature;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4fcca1e05a..0ddc6ef4a7 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3819,6 +3819,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
case VIR_DOMAIN_FEATURE_HPT:
case VIR_DOMAIN_FEATURE_HTM:
+ case VIR_DOMAIN_FEATURE_NESTED_HV:
if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT &&
!qemuDomainIsPSeries(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/tests/qemuxml2argvdata/pseries-features.xml b/tests/qemuxml2argvdata/pseries-features.xml
index 5c842fe87b..6f7d32b065 100644
--- a/tests/qemuxml2argvdata/pseries-features.xml
+++ b/tests/qemuxml2argvdata/pseries-features.xml
@@ -11,6 +11,7 @@
<maxpagesize unit='GiB'>1</maxpagesize>
</hpt>
<htm state='on'/>
+ <nested-hv state='off'/>
</features>
<devices>
<emulator>/usr/bin/qemu-system-ppc64</emulator>
diff --git a/tests/qemuxml2xmloutdata/pseries-features.xml b/tests/qemuxml2xmloutdata/pseries-features.xml
index 55a44c75a0..7e12bc9c03 100644
--- a/tests/qemuxml2xmloutdata/pseries-features.xml
+++ b/tests/qemuxml2xmloutdata/pseries-features.xml
@@ -13,6 +13,7 @@
<maxpagesize unit='KiB'>1048576</maxpagesize>
</hpt>
<htm state='on'/>
+ <nested-hv state='off'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
--
2.20.1

View File

@ -1,194 +0,0 @@
From cb462f891f39ff47179e6fe65437450f9d8c7824 Mon Sep 17 00:00:00 2001
Message-Id: <cb462f891f39ff47179e6fe65437450f9d8c7824@dist-git>
From: Andrea Bolognani <abologna@redhat.com>
Date: Tue, 3 Jul 2018 15:25:16 +0200
Subject: [PATCH] conf: Parse and format the HTM pSeries feature
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit 9f3b9100f33036cb14296aa0a788788743b75a23)
https: //bugzilla.redhat.com/show_bug.cgi?id=1525599
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: David Gibson <dgibson@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
docs/formatdomain.html.in | 8 ++++++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 19 +++++++++++++++++++
src/conf/domain_conf.h | 1 +
src/qemu/qemu_domain.c | 1 +
tests/qemuxml2argvdata/pseries-features.xml | 1 +
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmloutdata/pseries-features.xml | 1 +
tests/qemuxml2xmltest.c | 1 +
9 files changed, 38 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0d68596991..a3afe137bf 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1929,6 +1929,7 @@
&lt;smm state='on'&gt;
&lt;tseg unit='MiB'&gt;48&lt;/tseg&gt;
&lt;/smm&gt;
+ &lt;htm state='on'/&gt;
&lt;/features&gt;
...</pre>
@@ -2162,6 +2163,13 @@
<dd>Enable QEMU vmcoreinfo device to let the guest kernel save debug
details. <span class="since">Since 4.4.0</span> (QEMU only)
</dd>
+ <dt><code>htm</code></dt>
+ <dd>Configure HTM (Hardware Transational Memory) availability for
+ pSeries guests. Possible values for the <code>state</code> attribute
+ are <code>on</code> and <code>off</code>. If the attribute is not
+ defined, the hypervisor default will be used.
+ <span class="since">Since 4.6.0</span> (QEMU/KVM only)
+ </dd>
</dl>
<h3><a id="elementsTime">Time keeping</a></h3>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f46145cf9b..bd687ce9d3 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4907,6 +4907,11 @@
<optional>
<ref name="vmcoreinfo"/>
</optional>
+ <optional>
+ <element name="htm">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
</interleave>
</element>
</optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b8b53450fa..f4e59f6c91 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -152,6 +152,7 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
"ioapic",
"hpt",
"vmcoreinfo",
+ "htm",
);
VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
@@ -19827,6 +19828,22 @@ virDomainDefParseXML(xmlDocPtr xml,
}
break;
+ case VIR_DOMAIN_FEATURE_HTM:
+ if (!(tmp = virXMLPropString(nodes[i], "state"))) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("missing state attribute '%s' of feature '%s'"),
+ tmp, virDomainFeatureTypeToString(val));
+ goto error;
+ }
+ if ((def->features[val] = virTristateSwitchTypeFromString(tmp)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown state attribute '%s' of feature '%s'"),
+ tmp, virDomainFeatureTypeToString(val));
+ goto error;
+ }
+ VIR_FREE(tmp);
+ break;
+
/* coverity[dead_error_begin] */
case VIR_DOMAIN_FEATURE_LAST:
break;
@@ -21961,6 +21978,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
case VIR_DOMAIN_FEATURE_VMPORT:
case VIR_DOMAIN_FEATURE_SMM:
case VIR_DOMAIN_FEATURE_VMCOREINFO:
+ case VIR_DOMAIN_FEATURE_HTM:
if (src->features[i] != dst->features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of feature '%s' differs: "
@@ -27626,6 +27644,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
case VIR_DOMAIN_FEATURE_PMU:
case VIR_DOMAIN_FEATURE_PVSPINLOCK:
case VIR_DOMAIN_FEATURE_VMPORT:
+ case VIR_DOMAIN_FEATURE_HTM:
switch ((virTristateSwitch) def->features[i]) {
case VIR_TRISTATE_SWITCH_LAST:
case VIR_TRISTATE_SWITCH_ABSENT:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 71437dc485..41d27482fb 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1771,6 +1771,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_IOAPIC,
VIR_DOMAIN_FEATURE_HPT,
VIR_DOMAIN_FEATURE_VMCOREINFO,
+ VIR_DOMAIN_FEATURE_HTM,
VIR_DOMAIN_FEATURE_LAST
} virDomainFeature;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4c2a162b85..0eacad1e44 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3865,6 +3865,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
case VIR_DOMAIN_FEATURE_PMU:
case VIR_DOMAIN_FEATURE_VMPORT:
case VIR_DOMAIN_FEATURE_VMCOREINFO:
+ case VIR_DOMAIN_FEATURE_HTM:
case VIR_DOMAIN_FEATURE_LAST:
break;
}
diff --git a/tests/qemuxml2argvdata/pseries-features.xml b/tests/qemuxml2argvdata/pseries-features.xml
index 30cee5b81c..5c842fe87b 100644
--- a/tests/qemuxml2argvdata/pseries-features.xml
+++ b/tests/qemuxml2argvdata/pseries-features.xml
@@ -10,6 +10,7 @@
<hpt resizing='required'>
<maxpagesize unit='GiB'>1</maxpagesize>
</hpt>
+ <htm state='on'/>
</features>
<devices>
<emulator>/usr/bin/qemu-system-ppc64</emulator>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c279ac4975..d6911f9344 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1850,6 +1850,7 @@ mymain(void)
DO_TEST("pseries-features",
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
DO_TEST_FAILURE("pseries-features",
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
diff --git a/tests/qemuxml2xmloutdata/pseries-features.xml b/tests/qemuxml2xmloutdata/pseries-features.xml
index f36705f011..55a44c75a0 100644
--- a/tests/qemuxml2xmloutdata/pseries-features.xml
+++ b/tests/qemuxml2xmloutdata/pseries-features.xml
@@ -12,6 +12,7 @@
<hpt resizing='required'>
<maxpagesize unit='KiB'>1048576</maxpagesize>
</hpt>
+ <htm state='on'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index eac6d5b073..bbb995656e 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -620,6 +620,7 @@ mymain(void)
DO_TEST("pseries-features",
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
+ QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
DO_TEST("pseries-serial-native",
--
2.18.0

View File

@ -1,48 +0,0 @@
From ac3ea7982236832f5f2ae86b631aface267d035c Mon Sep 17 00:00:00 2001
Message-Id: <ac3ea7982236832f5f2ae86b631aface267d035c@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Tue, 21 Aug 2018 14:23:40 +0200
Subject: [PATCH] conf: Parse guestfwd channel device info again
https://bugzilla.redhat.com/show_bug.cgi?id=1610072
Due to historical reasons we were not parsing device info on
guestfwd channel. Sure, it doesn't make much sense to parse
<address/> but it surely makes sense to parse its alias (which
might be an user alias).
This reverts commit 47a3dd46ead20e6fdc30bcdc1b8e707e250d33da
which fixed https://bugzilla.redhat.com/show_bug.cgi?id=1172526.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit cab1843914d9ce5d1ca28477d2b48e5304e9e6f2)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/conf/domain_conf.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8a43e607e9..51a79ad8b1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12760,14 +12760,8 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlopt,
}
}
- if (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
- def->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD) {
- VIR_DEBUG("Ignoring device address for gustfwd channel");
- } else if (virDomainDeviceInfoParseXML(xmlopt, node,
- &def->info, flags) < 0) {
+ if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0)
goto error;
- }
-
if (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
def->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB &&
--
2.18.0

View File

@ -1,175 +0,0 @@
From fd6fae19231031f3feb83c854efdf2f1abfa7847 Mon Sep 17 00:00:00 2001
Message-Id: <fd6fae19231031f3feb83c854efdf2f1abfa7847@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Thu, 19 Jul 2018 15:04:01 +0200
Subject: [PATCH] conf: Replace 'error' with 'cleanup' in
virDomainHostdevDefParseXMLSubsys
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The exit path is the same for both success and failure, so the label
should be called cleanup.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit f1f6f4858260a77416ed5e0c86c4e0614aaf0a5e)
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 08654ab41d..72086f9e86 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7690,18 +7690,18 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown host device source address type '%s'"),
type);
- goto error;
+ goto cleanup;
}
} else {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("missing source address type"));
- goto error;
+ goto cleanup;
}
if (!(sourcenode = virXPathNode("./source", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing <source> element in hostdev device"));
- goto error;
+ goto cleanup;
}
if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB &&
@@ -7709,20 +7709,20 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Setting startupPolicy is only allowed for USB"
" devices"));
- goto error;
+ goto cleanup;
}
if (sgio) {
if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("sgio is only supported for scsi host device"));
- goto error;
+ goto cleanup;
}
if ((scsisrc->sgio = virDomainDeviceSGIOTypeFromString(sgio)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown sgio mode '%s'"), sgio);
- goto error;
+ goto cleanup;
}
}
@@ -7730,14 +7730,14 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("rawio is only supported for scsi host device"));
- goto error;
+ goto cleanup;
}
if ((scsisrc->rawio = virTristateBoolTypeFromString(rawio)) <= 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown hostdev rawio setting '%s'"),
rawio);
- goto error;
+ goto cleanup;
}
}
@@ -7746,28 +7746,28 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
virReportError(VIR_ERR_XML_ERROR, "%s",
_("'model' attribute in <hostdev> is only supported "
"when type='mdev'"));
- goto error;
+ goto cleanup;
}
} else {
if (!model) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing 'model' attribute in mediated device's "
"<hostdev> element"));
- goto error;
+ goto cleanup;
}
if ((mdevsrc->model = virMediatedDeviceModelTypeFromString(model)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown hostdev model '%s'"),
model);
- goto error;
+ goto cleanup;
}
}
switch (def->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, def, flags) < 0)
- goto error;
+ goto cleanup;
backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT;
if ((backendStr = virXPathString("string(./driver/@name)", ctxt)) &&
@@ -7776,7 +7776,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown PCI device <driver name='%s'/> "
"has been specified"), backendStr);
- goto error;
+ goto cleanup;
}
pcisrc->backend = backend;
@@ -7784,32 +7784,32 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
if (virDomainHostdevSubsysUSBDefParseXML(sourcenode, def) < 0)
- goto error;
+ goto cleanup;
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
if (virDomainHostdevSubsysSCSIDefParseXML(sourcenode, scsisrc, ctxt) < 0)
- goto error;
+ goto cleanup;
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
if (virDomainHostdevSubsysSCSIVHostDefParseXML(sourcenode, def) < 0)
- goto error;
+ goto cleanup;
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
if (virDomainHostdevSubsysMediatedDevDefParseXML(def, ctxt) < 0)
- goto error;
+ goto cleanup;
break;
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("address type='%s' not supported in hostdev interfaces"),
virDomainHostdevSubsysTypeToString(def->source.subsys.type));
- goto error;
+ goto cleanup;
}
ret = 0;
- error:
+ cleanup:
VIR_FREE(managed);
VIR_FREE(sgio);
VIR_FREE(rawio);
--
2.18.0

View File

@ -0,0 +1,87 @@
From 2780cb41f7682741be2bbe662d629dd1bd3b4f6e Mon Sep 17 00:00:00 2001
Message-Id: <2780cb41f7682741be2bbe662d629dd1bd3b4f6e@dist-git>
From: Laine Stump <laine@redhat.com>
Date: Sun, 26 Apr 2020 13:04:10 -0400
Subject: [PATCH] conf: add new PCI_CONNECT flag AUTOASSIGN
This new flag will be set for any controller that we decide can have
devices assigned to it automatically during PCI device assignment. In
the past PCI_CONNECT_TYPE_HOTPLUGGABLE was used for this purpose, but
that is overloading that flag, and no longer technically correct; what
we *really* want is to auto-assign devices to any pcie-root-port or
pcie-switch-downstream-port regardless of whether or not that
controller happens to have hotplug enabled.
This patch just adds the flag, but doesn't use it at all. Note that
the numbering of all the other flags was changed in order to insert
the new flag near the beginning of the list; that doesn't cause any
problem because the connect flags aren't stored anywhere between runs
of libvirtd.
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit c296a846ad7de3066a17404f4f407d3e1b6d7935)
https://bugzilla.redhat.com/1802592
Signed-off-by: Laine Stump <laine@redhat.com>
Message-Id: <20200426170415.18328-8-laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/domain_addr.h | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index dcb90618f8..40738ddb72 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -32,26 +32,27 @@ typedef enum {
} virPCIDeviceAddressExtensionFlags;
typedef enum {
- VIR_PCI_CONNECT_HOTPLUGGABLE = 1 << 0, /* is hotplug needed/supported */
-
- /* set for devices that can share a single slot in auto-assignment
- * (by assigning one device to each of the 8 functions on the slot)
- */
- VIR_PCI_CONNECT_AGGREGATE_SLOT = 1 << 1,
-
- /* kinds of devices as a bitmap so they can be combined (some PCI
- * controllers permit connecting multiple types of devices)
- */
- VIR_PCI_CONNECT_TYPE_PCI_DEVICE = 1 << 2,
- VIR_PCI_CONNECT_TYPE_PCIE_DEVICE = 1 << 3,
- VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT = 1 << 4,
- VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT = 1 << 5,
- VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT = 1 << 6,
- VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE = 1 << 7,
- VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS = 1 << 8,
- VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS = 1 << 9,
- VIR_PCI_CONNECT_TYPE_PCI_BRIDGE = 1 << 10,
- VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE = 1 << 11,
+ VIR_PCI_CONNECT_AUTOASSIGN = 1 << 0, /* okay to autoassign a device to this controller */
+ VIR_PCI_CONNECT_HOTPLUGGABLE = 1 << 1, /* is hotplug needed/supported */
+
+ /* set for devices that can share a single slot in auto-assignment
+ * (by assigning one device to each of the 8 functions on the slot)
+ */
+ VIR_PCI_CONNECT_AGGREGATE_SLOT = 1 << 2,
+
+ /* kinds of devices as a bitmap so they can be combined (some PCI
+ * controllers permit connecting multiple types of devices)
+ */
+ VIR_PCI_CONNECT_TYPE_PCI_DEVICE = 1 << 3,
+ VIR_PCI_CONNECT_TYPE_PCIE_DEVICE = 1 << 4,
+ VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT = 1 << 5,
+ VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT = 1 << 6,
+ VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT = 1 << 7,
+ VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE = 1 << 8,
+ VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS = 1 << 9,
+ VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS = 1 << 10,
+ VIR_PCI_CONNECT_TYPE_PCI_BRIDGE = 1 << 11,
+ VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE = 1 << 12,
} virDomainPCIConnectFlags;
/* a combination of all bits that describe the type of connections
--
2.26.2

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,395 @@
From c811bd72130364673dd4a0d2a997a1d8f675eb71 Mon Sep 17 00:00:00 2001
Message-Id: <c811bd72130364673dd4a0d2a997a1d8f675eb71@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Wed, 4 Mar 2020 12:42:42 +0100
Subject: [PATCH] conf: add virtiofs-related elements and attributes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add more elements for tuning the virtiofsd daemon
and the vhost-user-fs device:
<driver type='virtiofs' queue='1024' xattr='on'>
<binary path='/usr/libexec/virtiofsd'>
<cache mode='always'/>
<lock posix='off' flock='off'/>
</binary>
</driver>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 66079339847dc942b9b673e3040b56b055a8d8f5)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
Message-Id: <506d0532c6043a9b8c946bdc42c3d9c5529f6fb8.1583322090.git.jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
docs/formatdomain.html.in | 25 ++++-
docs/schemas/domaincommon.rng | 48 ++++++++
src/conf/domain_conf.c | 104 +++++++++++++++++-
src/conf/domain_conf.h | 15 +++
src/libvirt_private.syms | 1 +
.../vhost-user-fs-fd-memory.xml | 6 +-
.../vhost-user-fs-hugepages.xml | 1 +
7 files changed, 197 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 337ab01316..e9830ab231 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3936,7 +3936,11 @@
&lt;readonly/&gt;
&lt;/filesystem&gt;
&lt;filesystem type='mount' accessmode='passthrough'&gt;
- &lt;driver type='virtiofs'/&gt;
+ &lt;driver type='virtiofs queue='1024'/&gt;
+ &lt;binary path='/usr/libexec/virtiofsd' xattr='on'&gt;
+ &lt;cache mode='always'/&gt;
+ &lt;lock posix='on' flock='on'/&gt;
+ &lt;/binary&gt;
&lt;source dir='/path'/&gt;
&lt;target dir='mount_tag'/&gt;
&lt;/filesystem&gt;
@@ -4063,9 +4067,28 @@
<a href="#elementsVirtio">Virtio-specific options</a> can also be
set. (<span class="since">Since 3.5.0</span>)
</li>
+ <li>
+ For <code>virtiofs</code>, the <code>queue</code> attribute can be used
+ to specify the queue size (i.e. how many requests can the queue fit).
+ (<span class="since">Since 6.2.0</span>)
+ </li>
</ul>
</dd>
+ <dt><code>binary</code></dt>
+ <dd>
+ The optional <code>binary</code> element can tune the options for virtiofsd.
+ All of the following attributes and elements are optional.
+ The attribute <code>path</code> can be used to override the path to the daemon.
+ Attribute <code>xattr</code> enables the use of filesystem extended attributes.
+ Caching can be tuned via the <code>cache</code> element, possible <code>mode</code>
+ values being <code>none</code> and <code>always</code>.
+ Locking can be controlled via the <code>lock</code>
+ element - attributes <code>posix</code> and <code>flock</code> both accepting
+ values <code>on</code> or <code>off</code>.
+ (<span class="since">Since 6.2.0</span>)
+ </dd>
+
<dt><code>source</code></dt>
<dd>
The resource on the host that is being accessed in the guest. The
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5a9291b443..aa70e340b9 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2500,6 +2500,9 @@
<optional>
<ref name="fsDriver"/>
</optional>
+ <optional>
+ <ref name="fsBinary"/>
+ </optional>
<interleave>
<element name="source">
<attribute name="dir">
@@ -2649,12 +2652,57 @@
<attribute name="type">
<value>virtiofs</value>
</attribute>
+ <optional>
+ <attribute name="queue">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
<ref name='virtioOptions'/>
</group>
<empty/>
</choice>
</element>
</define>
+ <define name="fsBinary">
+ <element name="binary">
+ <optional>
+ <attribute name="path">
+ <ref name="absFilePath"/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="xattr">
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
+ <optional>
+ <element name="cache">
+ <optional>
+ <attribute name="mode">
+ <choice>
+ <value>none</value>
+ <value>always</value>
+ </choice>
+ </attribute>
+ </optional>
+ </element>
+ </optional>
+ <optional>
+ <element name="lock">
+ <optional>
+ <attribute name="posix">
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="flock">
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
+ </element>
+ </optional>
+ </element>
+ </define>
<define name="interface-network-attributes">
<attribute name="network">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 31d4828802..3a370e6b90 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -500,6 +500,14 @@ VIR_ENUM_IMPL(virDomainFSModel,
"virtio-non-transitional",
);
+VIR_ENUM_IMPL(virDomainFSCacheMode,
+ VIR_DOMAIN_FS_CACHE_MODE_LAST,
+ "default",
+ "none",
+ "always",
+);
+
+
VIR_ENUM_IMPL(virDomainNet,
VIR_DOMAIN_NET_TYPE_LAST,
"user",
@@ -2322,6 +2330,7 @@ void virDomainFSDefFree(virDomainFSDefPtr def)
virDomainDeviceInfoClear(&def->info);
VIR_FREE(def->virtio);
virObjectUnref(def->privateData);
+ VIR_FREE(def->binary);
VIR_FREE(def);
}
@@ -11293,6 +11302,63 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt,
}
}
+ if (def->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) {
+ g_autofree char *queue_size = virXPathString("string(./driver/@queue)", ctxt);
+ g_autofree char *binary = virXPathString("string(./binary/@path)", ctxt);
+ g_autofree char *xattr = virXPathString("string(./binary/@xattr)", ctxt);
+ g_autofree char *cache = virXPathString("string(./binary/cache/@mode)", ctxt);
+ g_autofree char *posix_lock = virXPathString("string(./binary/lock/@posix)", ctxt);
+ g_autofree char *flock = virXPathString("string(./binary/lock/@flock)", ctxt);
+ int val;
+
+ if (queue_size && virStrToLong_ull(queue_size, NULL, 10, &def->queue_size) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("cannot parse queue size '%s' for virtiofs"),
+ queue_size);
+ goto error;
+ }
+
+ if (binary)
+ def->binary = virFileSanitizePath(binary);
+
+ if (xattr) {
+ if ((val = virTristateSwitchTypeFromString(xattr)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown xattr value '%s'"), xattr);
+ goto error;
+ }
+ def->xattr = val;
+ }
+
+ if (cache) {
+ if ((val = virDomainFSCacheModeTypeFromString(cache)) <= 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("cannot parse cache mode '%s' for virtiofs"),
+ cache);
+ goto error;
+ }
+ def->cache = val;
+ }
+
+ if (posix_lock) {
+ if ((val = virTristateSwitchTypeFromString(posix_lock)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown posix lock value '%s'"), posix_lock);
+ goto error;
+ }
+ def->posix_lock = val;
+ }
+
+ if (flock) {
+ if ((val = virTristateSwitchTypeFromString(flock)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown flock value '%s'"), flock);
+ goto error;
+ }
+ def->flock = val;
+ }
+ }
+
if (format) {
if ((def->format = virStorageFileFormatTypeFromString(format)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -24994,6 +25060,9 @@ virDomainFSDefFormat(virBufferPtr buf,
const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy);
const char *src = def->src->path;
g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) driverBuf = VIR_BUFFER_INIT_CHILD(buf);
+ g_auto(virBuffer) binaryAttrBuf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) binaryBuf = VIR_BUFFER_INIT_CHILD(buf);
if (!type) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -25017,6 +25086,8 @@ virDomainFSDefFormat(virBufferPtr buf,
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
+ virBufferAdjustIndent(&driverBuf, 2);
+ virBufferAdjustIndent(&binaryBuf, 2);
if (def->fsdriver) {
virBufferAsprintf(&driverAttrBuf, " type='%s'", fsdriver);
@@ -25028,11 +25099,42 @@ virDomainFSDefFormat(virBufferPtr buf,
if (def->wrpolicy)
virBufferAsprintf(&driverAttrBuf, " wrpolicy='%s'", wrpolicy);
+ if (def->queue_size)
+ virBufferAsprintf(&driverAttrBuf, " queue='%llu'", def->queue_size);
+
+ }
+
+ if (def->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) {
+ g_auto(virBuffer) lockAttrBuf = VIR_BUFFER_INITIALIZER;
+ virBufferEscapeString(&binaryAttrBuf, " path='%s'", def->binary);
+
+ if (def->xattr != VIR_TRISTATE_SWITCH_ABSENT) {
+ virBufferAsprintf(&binaryAttrBuf, " xattr='%s'",
+ virTristateSwitchTypeToString(def->xattr));
+ }
+
+ if (def->cache != VIR_DOMAIN_FS_CACHE_MODE_DEFAULT) {
+ virBufferAsprintf(&binaryBuf, "<cache mode='%s'/>\n",
+ virDomainFSCacheModeTypeToString(def->cache));
+ }
+
+ if (def->posix_lock != VIR_TRISTATE_SWITCH_ABSENT) {
+ virBufferAsprintf(&lockAttrBuf, " posix='%s'",
+ virTristateSwitchTypeToString(def->posix_lock));
+ }
+
+ if (def->flock != VIR_TRISTATE_SWITCH_ABSENT) {
+ virBufferAsprintf(&lockAttrBuf, " flock='%s'",
+ virTristateSwitchTypeToString(def->flock));
+ }
+
+ virXMLFormatElement(&binaryBuf, "lock", &lockAttrBuf, NULL);
}
virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio);
- virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
+ virXMLFormatElement(buf, "driver", &driverAttrBuf, &driverBuf);
+ virXMLFormatElement(buf, "binary", &binaryAttrBuf, &binaryBuf);
switch (def->type) {
case VIR_DOMAIN_FS_TYPE_MOUNT:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 921cc42a57..2a382ede72 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -802,6 +802,14 @@ typedef enum {
VIR_DOMAIN_FS_MODEL_LAST
} virDomainFSModel;
+typedef enum {
+ VIR_DOMAIN_FS_CACHE_MODE_DEFAULT = 0,
+ VIR_DOMAIN_FS_CACHE_MODE_NONE,
+ VIR_DOMAIN_FS_CACHE_MODE_ALWAYS,
+
+ VIR_DOMAIN_FS_CACHE_MODE_LAST
+} virDomainFSCacheMode;
+
struct _virDomainFSDef {
int type;
int fsdriver; /* enum virDomainFSDriverType */
@@ -817,6 +825,12 @@ struct _virDomainFSDef {
unsigned long long space_hard_limit; /* in bytes */
unsigned long long space_soft_limit; /* in bytes */
bool symlinksResolved;
+ char *binary;
+ unsigned long long queue_size;
+ virTristateSwitch xattr;
+ virDomainFSCacheMode cache;
+ virTristateSwitch posix_lock;
+ virTristateSwitch flock;
virDomainVirtioOptionsPtr virtio;
virObjectPtr privateData;
};
@@ -3437,6 +3451,7 @@ VIR_ENUM_DECL(virDomainFSDriver);
VIR_ENUM_DECL(virDomainFSAccessMode);
VIR_ENUM_DECL(virDomainFSWrpolicy);
VIR_ENUM_DECL(virDomainFSModel);
+VIR_ENUM_DECL(virDomainFSCacheMode);
VIR_ENUM_DECL(virDomainNet);
VIR_ENUM_DECL(virDomainNetBackend);
VIR_ENUM_DECL(virDomainNetVirtioTxMode);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index bc2858fc00..5dc99e03cf 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -389,6 +389,7 @@ virDomainDiskSourceFormat;
virDomainDiskTranslateSourcePool;
virDomainFeatureTypeFromString;
virDomainFeatureTypeToString;
+virDomainFSCacheModeTypeToString;
virDomainFSDefFree;
virDomainFSDefNew;
virDomainFSDriverTypeToString;
diff --git a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml
index a6b6279fb8..f6bb663e97 100644
--- a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml
+++ b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml
@@ -27,7 +27,11 @@
<controller type='usb' index='0' model='none'/>
<controller type='pci' index='0' model='pci-root'/>
<filesystem type='mount' accessmode='passthrough'>
- <driver type='virtiofs'/>
+ <driver type='virtiofs' queue='1024'/>
+ <binary path='/usr/libexec/virtiofsd' xattr='on'>
+ <cache mode='always'/>
+ <lock posix='off' flock='off'/>
+ </binary>
<source dir='/path'/>
<target dir='mount_tag'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
diff --git a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml
index 70df7b890d..96b9774704 100644
--- a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml
+++ b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml
@@ -63,6 +63,7 @@
</controller>
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs'/>
+ <binary path='/usr/libexec/virtiofsd'/>
<source dir='/path'/>
<target dir='mount_tag'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
--
2.25.1

View File

@ -0,0 +1,146 @@
From 100ae962cd0f4dbfd5270bc2d61f05ec1c524c0a Mon Sep 17 00:00:00 2001
Message-Id: <100ae962cd0f4dbfd5270bc2d61f05ec1c524c0a@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 4 Feb 2020 15:07:40 +0100
Subject: [PATCH] conf: backup: Allow configuration of names exported via NBD
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If users wish to use different name for exported disks or bitmaps
the new fields allow to do so. Additionally they also document the
current settings.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 12ccd8d4db12d71a270d903701a8edb83d41f127)
https://bugzilla.redhat.com/show_bug.cgi?id=1207659
Message-Id: <8043f75d8d4b4ae7e7ae3671d71407f733e6a3cf.1580824112.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatbackup.html.in | 9 +++++++++
docs/schemas/domainbackup.rng | 8 ++++++++
src/conf/backup_conf.c | 10 ++++++++++
src/conf/backup_conf.h | 2 ++
tests/domainbackupxml2xmlin/backup-pull-seclabel.xml | 2 +-
tests/domainbackupxml2xmlout/backup-pull-seclabel.xml | 2 +-
6 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/docs/formatbackup.html.in b/docs/formatbackup.html.in
index 1c690901c7..543d913072 100644
--- a/docs/formatbackup.html.in
+++ b/docs/formatbackup.html.in
@@ -85,6 +85,15 @@
<dd>Setting this attribute to <code>yes</code>(default) specifies
that the disk should take part in the backup and using
<code>no</code> excludes the disk from the backup.</dd>
+ <dt><code>exportname</code></dt>
+ <dd>Allows modification of the NBD export name for the given disk.
+ By default equal to disk target.
+ Valid only for pull mode backups.</dd>
+ <dt><code>exportbitmap</code></dt>
+ <dd>Allows modification of the name of the bitmap describing dirty
+ blocks for an incremental backup exported via NBD export name
+ for the given disk.
+ Valid only for pull mode backups.</dd>
<dt><code>type</code></dt>
<dd>A mandatory attribute to describe the type of the
disk, except when <code>backup='no'</code> is
diff --git a/docs/schemas/domainbackup.rng b/docs/schemas/domainbackup.rng
index c1e4d80302..395ea841f9 100644
--- a/docs/schemas/domainbackup.rng
+++ b/docs/schemas/domainbackup.rng
@@ -165,6 +165,14 @@
<attribute name='name'>
<ref name='diskTarget'/>
</attribute>
+ <optional>
+ <attribute name='exportname'>
+ <text/>
+ </attribute>
+ <attribute name='exportbitmap'>
+ <text/>
+ </attribute>
+ </optional>
<choice>
<group>
<attribute name='backup'>
diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
index 61dc8cd4b2..b370b686f1 100644
--- a/src/conf/backup_conf.c
+++ b/src/conf/backup_conf.c
@@ -71,6 +71,8 @@ virDomainBackupDefFree(virDomainBackupDefPtr def)
virDomainBackupDiskDefPtr disk = def->disks + i;
g_free(disk->name);
+ g_free(disk->exportname);
+ g_free(disk->exportbitmap);
virObjectUnref(disk->store);
}
@@ -124,6 +126,11 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
if (def->backup == VIR_TRISTATE_BOOL_NO)
return 0;
+ if (!push) {
+ def->exportname = virXMLPropString(node, "exportname");
+ def->exportbitmap = virXMLPropString(node, "exportbitmap");
+ }
+
if (internal) {
if (!(state = virXMLPropString(node, "state")) ||
(tmp = virDomainBackupDiskStateTypeFromString(state)) < 0) {
@@ -333,6 +340,9 @@ virDomainBackupDiskDefFormat(virBufferPtr buf,
if (disk->backup == VIR_TRISTATE_BOOL_YES) {
virBufferAsprintf(&attrBuf, " type='%s'", virStorageTypeToString(disk->store->type));
+ virBufferEscapeString(&attrBuf, " exportname='%s'", disk->exportname);
+ virBufferEscapeString(&attrBuf, " exportbitmap='%s'", disk->exportbitmap);
+
if (disk->store->format > 0)
virBufferEscapeString(&childBuf, "<driver type='%s'/>\n",
virStorageFileFormatTypeToString(disk->store->format));
diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h
index 7cf44245d4..672fd52ee7 100644
--- a/src/conf/backup_conf.h
+++ b/src/conf/backup_conf.h
@@ -51,6 +51,8 @@ typedef virDomainBackupDiskDef *virDomainBackupDiskDefPtr;
struct _virDomainBackupDiskDef {
char *name; /* name matching the <target dev='...' of the domain */
virTristateBool backup; /* whether backup is requested */
+ char *exportname; /* name of the NBD export for pull mode backup */
+ char *exportbitmap; /* name of the bitmap exposed in NBD for pull mode backup */
/* details of target for push-mode, or of the scratch file for pull-mode */
virStorageSourcePtr store;
diff --git a/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml b/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml
index a00d8758bb..4e6e602c19 100644
--- a/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml
+++ b/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml
@@ -2,7 +2,7 @@
<incremental>1525889631</incremental>
<server transport='tcp' name='localhost' port='10809'/>
<disks>
- <disk name='vda' type='file'>
+ <disk name='vda' type='file' exportname='test-vda' exportbitmap='blah'>
<driver type='qcow2'/>
<scratch file='/path/to/file'>
<seclabel model='dac' relabel='no'/>
diff --git a/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml b/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
index c631c9b979..450f007d3a 100644
--- a/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
+++ b/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
@@ -2,7 +2,7 @@
<incremental>1525889631</incremental>
<server transport='tcp' name='localhost' port='10809'/>
<disks>
- <disk name='vda' backup='yes' type='file'>
+ <disk name='vda' backup='yes' type='file' exportname='test-vda' exportbitmap='blah'>
<driver type='qcow2'/>
<scratch file='/path/to/file'>
<seclabel model='dac' relabel='no'/>
--
2.25.0

View File

@ -0,0 +1,67 @@
From 7f5c44bfd2b6290e142380775b6a6205ccc43840 Mon Sep 17 00:00:00 2001
Message-Id: <7f5c44bfd2b6290e142380775b6a6205ccc43840@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 23 Jun 2020 12:23:37 +0200
Subject: [PATCH] conf: backup: Store incremental backup checkpoint name
per-disk
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In preparation to allow heterogenous backups store the 'incremental'
field per-disk and fill it by default from the per-backup field.
Having this will be important once we'll want to allow incremental
backup working while hotplugging a new disk.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit b8295160c36e555d8bcaef5015d0c1e3ae85fb17)
https://bugzilla.redhat.com/show_bug.cgi?id=1804593
Message-Id: <ee6c31ce5f3400523559793fe40e789656068f7c.1592906423.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/backup_conf.c | 8 ++++++++
src/conf/backup_conf.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
index 64c8f6cc09..58fb3ec759 100644
--- a/src/conf/backup_conf.c
+++ b/src/conf/backup_conf.c
@@ -71,6 +71,7 @@ virDomainBackupDefFree(virDomainBackupDefPtr def)
virDomainBackupDiskDefPtr disk = def->disks + i;
g_free(disk->name);
+ g_free(disk->incremental);
g_free(disk->exportname);
g_free(disk->exportbitmap);
virObjectUnref(disk->store);
@@ -503,5 +504,12 @@ virDomainBackupAlignDisks(virDomainBackupDefPtr def,
}
}
+ for (i = 0; i < def->ndisks; i++) {
+ virDomainBackupDiskDefPtr backupdisk = &def->disks[i];
+
+ if (def->incremental && !backupdisk->incremental)
+ backupdisk->incremental = g_strdup(def->incremental);
+ }
+
return 0;
}
diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h
index 672fd52ee7..7ce7a46ad4 100644
--- a/src/conf/backup_conf.h
+++ b/src/conf/backup_conf.h
@@ -51,6 +51,7 @@ typedef virDomainBackupDiskDef *virDomainBackupDiskDefPtr;
struct _virDomainBackupDiskDef {
char *name; /* name matching the <target dev='...' of the domain */
virTristateBool backup; /* whether backup is requested */
+ char *incremental; /* name of the starting point checkpoint of an incremental backup */
char *exportname; /* name of the NBD export for pull mode backup */
char *exportbitmap; /* name of the bitmap exposed in NBD for pull mode backup */
--
2.27.0

View File

@ -0,0 +1,51 @@
From 28094095fe6e4b05b25e459a34d93d195b7afb62 Mon Sep 17 00:00:00 2001
Message-Id: <28094095fe6e4b05b25e459a34d93d195b7afb62@dist-git>
From: Laine Stump <laine@redhat.com>
Date: Sun, 26 Apr 2020 13:17:02 -0400
Subject: [PATCH] conf: check HOTPLUGGABLE connect flag when validating a PCI
address
The HOTPLUGGABLE flag is set for appropriates buses in a PCI address
set, and thnis patch updates virDomainPCIAddressFlagsCompatible() to
check the HOTPLUGGABLE flag when searching for a suitable bus/slot for
a device. No devices request HOTPLUGGABLE though (yet), so there is no
observable effect.
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit a283189f8c64882681ea99259ccfc8d1b8e524dd)
https://bugzilla.redhat.com/1802592
Signed-off-by: Laine Stump <laine@redhat.com>
Message-Id: <20200426171703.18808-2-laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/domain_addr.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index cc45a0bbf1..ed41eca114 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -376,6 +376,18 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
return false;
}
+ if ((devFlags & VIR_PCI_CONNECT_HOTPLUGGABLE) &&
+ !(busFlags & VIR_PCI_CONNECT_HOTPLUGGABLE)) {
+ if (reportError) {
+ virReportError(errType,
+ _("The device at PCI address %s requires "
+ "hotplug capability, but the PCI controller "
+ "with index='%d' doesn't support hotplug"),
+ addrStr, addr->bus);
+ }
+ return false;
+ }
+
/* If this bus doesn't allow the type of connection (PCI
* vs. PCIe) required by the device, or if the device requires
* hot-plug and this bus doesn't have it, return false.
--
2.26.2

View File

@ -1,214 +0,0 @@
From b56deb73400af9518bdc86802b8ac8da0670d806 Mon Sep 17 00:00:00 2001
Message-Id: <b56deb73400af9518bdc86802b8ac8da0670d806@dist-git>
From: Laine Stump <laine@laine.org>
Date: Thu, 10 Jan 2019 09:44:45 -0500
Subject: [PATCH] conf: correct false boot order error during domain parse
virDomainDefCollectBootOrder() is called for every item on the list
for each type of device. One of the checks it makes is to gather the
order attributes from the <boot> element of all devices, and assure
that no two devices have been given the same order.
Since (internally to libvirt, *not* in the domain XML) an <interface
type='hostdev'> is on both the list of hostdev devices and the list of
network devices, it will be counted twice, and the code that checks
for multiple devices with the same boot order will give a false
positive.
To remedy this, we make sure to return early for hostdev devices that
have a parent.type != NONE.
This was introduced in commit 5b75a4, which was first in libvirt-4.4.0.
Resolves: https://bugzilla.redhat.com/1630393 (RHEL8)
Resolves: https://bugzilla.redhat.com/1601318 (RHEL7)
Change from upstream: upstream has eliminated QEMU_CAPS_BOOTINDEX and
QEMU_CAPS_PCI_BOOTINDEX so they're no longer necessary in test cases.
Signed-off-by: Laine Stump <laine@laine.org>
(cherry picked from commit 7ea7342996d74591e00bcbf14b1eb3995f77a199)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/conf/domain_conf.c | 8 ++++
.../net-hostdev-bootorder.args | 27 ++++++++++++
.../net-hostdev-bootorder.xml | 36 ++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
.../net-hostdev-bootorder.xml | 42 +++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
6 files changed, 117 insertions(+)
create mode 100644 tests/qemuxml2argvdata/net-hostdev-bootorder.args
create mode 100644 tests/qemuxml2argvdata/net-hostdev-bootorder.xml
create mode 100644 tests/qemuxml2xmloutdata/net-hostdev-bootorder.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 660e1523fe..d431441f62 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5076,6 +5076,14 @@ virDomainDefCollectBootOrder(virDomainDefPtr def ATTRIBUTE_UNUSED,
if (info->bootIndex == 0)
return 0;
+ if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
+ dev->data.hostdev->parent.type != VIR_DOMAIN_DEVICE_NONE) {
+ /* This hostdev is a child of a higher level device
+ * (e.g. interface), and thus already being counted on the
+ * list for the other device type.
+ */
+ return 0;
+ }
if (virAsprintf(&order, "%u", info->bootIndex) < 0)
goto cleanup;
diff --git a/tests/qemuxml2argvdata/net-hostdev-bootorder.args b/tests/qemuxml2argvdata/net-hostdev-bootorder.args
new file mode 100644
index 0000000000..e632d9b195
--- /dev/null
+++ b/tests/qemuxml2argvdata/net-hostdev-bootorder.args
@@ -0,0 +1,27 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
+bootindex=2 \
+-device pci-assign,host=03:07.1,id=hostdev0,bootindex=1,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/net-hostdev-bootorder.xml b/tests/qemuxml2argvdata/net-hostdev-bootorder.xml
new file mode 100644
index 0000000000..cd9f32b2f3
--- /dev/null
+++ b/tests/qemuxml2argvdata/net-hostdev-bootorder.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ <boot order='2'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <interface type='hostdev' managed='yes'>
+ <mac address='00:11:22:33:44:55'/>
+ <source>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/>
+ </source>
+ <boot order='1'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index bd4aa1266d..690a39054e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1324,6 +1324,9 @@ mymain(void)
DO_TEST("net-mcast", NONE);
DO_TEST("net-udp", NONE);
DO_TEST("net-hostdev", NONE);
+ DO_TEST("net-hostdev-bootorder",
+ QEMU_CAPS_BOOTINDEX,
+ QEMU_CAPS_PCI_BOOTINDEX);
DO_TEST("net-hostdev-multidomain", NONE);
DO_TEST("net-hostdev-vfio",
QEMU_CAPS_DEVICE_VFIO_PCI);
diff --git a/tests/qemuxml2xmloutdata/net-hostdev-bootorder.xml b/tests/qemuxml2xmloutdata/net-hostdev-bootorder.xml
new file mode 100644
index 0000000000..d9ecf40cf0
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/net-hostdev-bootorder.xml
@@ -0,0 +1,42 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <boot order='2'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <interface type='hostdev' managed='yes'>
+ <mac address='00:11:22:33:44:55'/>
+ <source>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/>
+ </source>
+ <boot order='1'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index db088fff6b..dbac863239 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -454,6 +454,7 @@ mymain(void)
DO_TEST("net-virtio-network-portgroup", NONE);
DO_TEST("net-virtio-rxtxqueuesize", NONE);
DO_TEST("net-hostdev", NONE);
+ DO_TEST("net-hostdev-bootorder", NONE);
DO_TEST("net-hostdev-vfio", NONE);
DO_TEST("net-midonet", NONE);
DO_TEST("net-openvswitch", NONE);
--
2.20.1

View File

@ -0,0 +1,70 @@
From f9fdeb29a61a98868d1a9f5284a85c57f826d6d1 Mon Sep 17 00:00:00 2001
Message-Id: <f9fdeb29a61a98868d1a9f5284a85c57f826d6d1@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Fri, 13 Mar 2020 13:08:08 +0100
Subject: [PATCH] conf: do not generate machine names ending with a dash
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
As of systemd commit:
commit d65652f1f21a4b0c59711320f34266c635393c89
Author: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
CommitDate: 2018-12-10 09:56:56 +0100
Partially unify hostname_is_valid() and dns_name_is_valid()
Dashes are no longer allowed at the end of machine names.
Trim the trailing dashes from the generated name before passing
it to machined.
Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1790409
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
(cherry picked from commit 45464db8ba502764cf37ec9335770248bdb3d9a8)
Prerequisite for: https://bugzilla.redhat.com/show_bug.cgi?id=1808499
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <ae17f80d69ee7772d32dd5c34c332be6b77e7afb.1584101247.git.mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 3 +++
tests/virsystemdtest.c | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 77e3d25a2d..4b297c96bc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30708,6 +30708,9 @@ virDomainMachineNameAppendValid(virBufferPtr buf,
virBufferAddChar(buf, *name);
}
+
+ /* trailing dashes are not allowed */
+ virBufferTrimChars(buf, "-");
}
#undef HOSTNAME_CHARS
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index 9b95ca6789..26876850b8 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -740,6 +740,10 @@ mymain(void)
"qemu-7-123456789012345678901234567890123456789012345678901234567");
TEST_MACHINE("123456789012345678901234567890123456789012345678901234567890", 8,
"qemu-8-123456789012345678901234567890123456789012345678901234567");
+ TEST_MACHINE("kstest-network-device-default-httpks_(c9eed63e-981e-48ec-acdc-56b3f8c5f678)", 100,
+ "qemu-100-kstest-network-device-default-httpksc9eed63e-981e-48ec");
+ TEST_MACHINE("kstest-network-device-default-httpks_(c9eed63e-981e-48ec--cdc-56b3f8c5f678)", 10,
+ "qemu-10-kstest-network-device-default-httpksc9eed63e-981e-48ec");
# define TESTS_PM_SUPPORT_HELPER(name, function) \
do { \
--
2.25.1

View File

@ -0,0 +1,73 @@
From 04792aa0715be4e779fca81fa8f7e9f2c5c1b71f Mon Sep 17 00:00:00 2001
Message-Id: <04792aa0715be4e779fca81fa8f7e9f2c5c1b71f@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 4 Feb 2020 15:08:00 +0100
Subject: [PATCH] conf: domain: Remove checking of return value of
virHashCreateFull
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This module has last two direct checks whether the value returned by
virHashCreateFull is NULL. Remove them so that static analyzers don't
get the false idea that checking the value is necessary.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 2a5ea0a0c1843c7c43e673b3d2082cc3abdef602)
https://bugzilla.redhat.com/show_bug.cgi?id=1793263
Message-Id: <2e310ad44b341511caba735608bc0bba4b072d6c.1580824112.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_addr.c | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 607ba56efd..f07b3d9725 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1044,28 +1044,22 @@ virDomainPCIAddressSetExtensionAlloc(virDomainPCIAddressSetPtr addrs,
if (VIR_ALLOC(addrs->zpciIds) < 0)
return -1;
- if (!(addrs->zpciIds->uids = virHashCreateFull(10, NULL,
- virZPCIAddrKeyCode,
- virZPCIAddrKeyEqual,
- virZPCIAddrKeyCopy,
- virZPCIAddrKeyPrintHuman,
- virZPCIAddrKeyFree)))
- goto error;
+ addrs->zpciIds->uids = virHashCreateFull(10, NULL,
+ virZPCIAddrKeyCode,
+ virZPCIAddrKeyEqual,
+ virZPCIAddrKeyCopy,
+ virZPCIAddrKeyPrintHuman,
+ virZPCIAddrKeyFree);
- if (!(addrs->zpciIds->fids = virHashCreateFull(10, NULL,
- virZPCIAddrKeyCode,
- virZPCIAddrKeyEqual,
- virZPCIAddrKeyCopy,
- virZPCIAddrKeyPrintHuman,
- virZPCIAddrKeyFree)))
- goto error;
+ addrs->zpciIds->fids = virHashCreateFull(10, NULL,
+ virZPCIAddrKeyCode,
+ virZPCIAddrKeyEqual,
+ virZPCIAddrKeyCopy,
+ virZPCIAddrKeyPrintHuman,
+ virZPCIAddrKeyFree);
}
return 0;
-
- error:
- virDomainPCIAddressSetExtensionFree(addrs);
- return -1;
}
--
2.25.0

View File

@ -0,0 +1,47 @@
From 5ec240811e391f97378d0b6b726e0dee13ae8a40 Mon Sep 17 00:00:00 2001
Message-Id: <5ec240811e391f97378d0b6b726e0dee13ae8a40@dist-git>
From: Laine Stump <laine@redhat.com>
Date: Sun, 26 Apr 2020 13:17:03 -0400
Subject: [PATCH] conf: during PCI hotplug, require that the controller support
hotplug
Before this patch we would simply rely on QEMU failing to attach the
device. Since we have a flag in the address set telling us which
controllers support hotplug, we can fail the operation sooner.
This also assures that when hotplugging with no provided PCI address,
that we skip any controllers with hotplug='off', and attempt to assign
the device to a controller that not only supports hotplug, but also
has it enabled.
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 7118bdee1550b6022e7362402ca8204add4cf80b)
https://bugzilla.redhat.com/1802592
Signed-off-by: Laine Stump <laine@redhat.com>
Message-Id: <20200426171703.18808-3-laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/domain_addr.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index ed41eca114..34ea7bc051 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -936,6 +936,11 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
if (!flags)
return 0;
+ /* This function is only called during hotplug, so we require hotplug
+ * support from the controller.
+ */
+ flags |= VIR_PCI_CONNECT_HOTPLUGGABLE;
+
if (!(addrStr = virPCIDeviceAddressAsString(&dev->addr.pci)))
goto cleanup;
--
2.26.2

View File

@ -0,0 +1,290 @@
From 12892e0376be4dc07dc317b807f2ec86c27a94b2 Mon Sep 17 00:00:00 2001
Message-Id: <12892e0376be4dc07dc317b807f2ec86c27a94b2@dist-git>
From: Laine Stump <laine@redhat.com>
Date: Sun, 26 Apr 2020 13:04:07 -0400
Subject: [PATCH] conf: new attribute "hotplug" for pci controllers
a <controller type='pci'...> element can now have a "hotplug"
attribute in the <target> subelement. This is intended to control
whether or not the slot(s) of the controller support
hotplugging/unplugging a device:
<controller type='pci' model='pcie-root-port'>
<target hotplug='off'/>
</controller>
The default value of hotplug is "on".
Since support for configuring such an option is hypervisor-dependent
(and will vary among different types of PCI controllers even on a
single hypervisor), no validation is done in this patch - that
validation will be done in the patch that wires support for the
setting into the hypervisor.
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 78f4d5e6f188a9f0f8d6da6b1fe78b9f4172d9ad)
https://bugzilla.redhat.com/1802592
Signed-off-by: Laine Stump <laine@redhat.com>
Conflicts/Changes from upstread:
tests/qemuxml2xmloutdata/pcie-root-port-nohotplug.x86_64-latest.xml:
had to be modified to remove reference to the qemu64 CPU type.
Signed-off-by: Laine Stump <laine@redhat.com>
Message-Id: <20200426170415.18328-5-laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
docs/formatdomain.html.in | 11 +++
docs/schemas/domaincommon.rng | 5 ++
src/conf/domain_conf.c | 20 +++++-
src/conf/domain_conf.h | 1 +
.../pcie-root-port-nohotplug.xml | 35 ++++++++++
...pcie-root-port-nohotplug.x86_64-latest.xml | 67 +++++++++++++++++++
tests/qemuxml2xmltest.c | 2 +-
7 files changed, 139 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/pcie-root-port-nohotplug.xml
create mode 100644 tests/qemuxml2xmloutdata/pcie-root-port-nohotplug.x86_64-latest.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 9c588185df..76799f5ffc 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4651,6 +4651,17 @@
which is visible to the virtual machine. If set, port must be
between 0 and 255.
</dd>
+ <dt><code>hotplug</code></dt>
+ <dd>
+ pcie-root-port and pcie-switch-downstream-port controllers can
+ also have a <code>hotplug</code> attribute in
+ the <code>&lt;target&gt;</code> subelement, which is used to
+ disable hotplug/unplug of devices on a particular
+ controller. The default setting of <code>hotplug</code>
+ is <code>on</code>; it should be set to <code>off</code> to
+ disable hotplug/unplug of devices on a particular controller.
+ <span class="since">Since 6.3.0</span>
+ </dd>
<dt><code>busNr</code></dt>
<dd>
pci-expander-bus and pcie-expander-bus controllers can have an
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index dd8f27243a..9fda5f17e0 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2475,6 +2475,11 @@
<ref name='uint8'/>
</attribute>
</optional>
+ <optional>
+ <attribute name='hotplug'>
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
<optional>
<element name='node'>
<ref name='unsignedInt'/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 28160a2967..ed9ca0e9d8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10933,6 +10933,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
g_autofree char *port = NULL;
g_autofree char *busNr = NULL;
g_autofree char *targetIndex = NULL;
+ g_autofree char *hotplug = NULL;
g_autofree char *ioeventfd = NULL;
g_autofree char *portsStr = NULL;
g_autofree char *iothread = NULL;
@@ -11004,6 +11005,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
chassis = virXMLPropString(cur, "chassis");
port = virXMLPropString(cur, "port");
busNr = virXMLPropString(cur, "busNr");
+ hotplug = virXMLPropString(cur, "hotplug");
targetIndex = virXMLPropString(cur, "index");
processedTarget = true;
}
@@ -11240,6 +11242,17 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
}
def->opts.pciopts.numaNode = numaNode;
}
+ if (hotplug) {
+ int val = virTristateSwitchTypeFromString(hotplug);
+
+ if (val <= 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("PCI controller unrecognized hotplug setting '%s'"),
+ hotplug);
+ goto error;
+ }
+ def->opts.pciopts.hotplug = val;
+ }
break;
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: {
g_autofree char *gntframes = virXMLPropString(node, "maxGrantFrames");
@@ -25112,7 +25125,8 @@ virDomainControllerDefFormat(virBufferPtr buf,
def->opts.pciopts.port != -1 ||
def->opts.pciopts.busNr != -1 ||
def->opts.pciopts.targetIndex != -1 ||
- def->opts.pciopts.numaNode != -1) {
+ def->opts.pciopts.numaNode != -1 ||
+ def->opts.pciopts.hotplug != VIR_TRISTATE_SWITCH_ABSENT) {
virBufferAddLit(&childBuf, "<target");
if (def->opts.pciopts.chassisNr != -1)
virBufferAsprintf(&childBuf, " chassisNr='%d'",
@@ -25129,6 +25143,10 @@ virDomainControllerDefFormat(virBufferPtr buf,
if (def->opts.pciopts.targetIndex != -1)
virBufferAsprintf(&childBuf, " index='%d'",
def->opts.pciopts.targetIndex);
+ if (def->opts.pciopts.hotplug != VIR_TRISTATE_SWITCH_ABSENT) {
+ virBufferAsprintf(&childBuf, " hotplug='%s'",
+ virTristateSwitchTypeToString(def->opts.pciopts.hotplug));
+ }
if (def->opts.pciopts.numaNode == -1) {
virBufferAddLit(&childBuf, "/>\n");
} else {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 2a382ede72..118077edaa 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -719,6 +719,7 @@ struct _virDomainPCIControllerOpts {
* item in memory target config) -1 == unspecified
*/
int numaNode;
+ virTristateSwitch hotplug; /* 'off' to prevent hotplug/unplug, default 'on' */
};
struct _virDomainUSBControllerOpts {
diff --git a/tests/qemuxml2argvdata/pcie-root-port-nohotplug.xml b/tests/qemuxml2argvdata/pcie-root-port-nohotplug.xml
new file mode 100644
index 0000000000..8a01494470
--- /dev/null
+++ b/tests/qemuxml2argvdata/pcie-root-port-nohotplug.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+ <name>guest</name>
+ <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
+ <memory unit='KiB'>2097152</memory>
+ <currentMemory unit='KiB'>2097152</currentMemory>
+ <vcpu placement='static'>2</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='pci' index='1' model='pcie-root-port'/>
+ <controller type='pci' index='2' model='pcie-root-port'>
+ <target hotplug='off'/>
+ </controller>
+ <controller type='pci' index='3' model='pcie-root-port'>
+ <model name='ioh3420'/>
+ <target hotplug='off'/>
+ </controller>
+ <controller type='pci' index='4' model='pcie-switch-upstream-port'/>
+ <controller type='pci' index='5' model='pcie-switch-downstream-port'>
+ <target hotplug='off'/>
+ </controller>
+ <controller type='pci' index='6' model='pcie-switch-downstream-port'>
+ <target hotplug='on'/>
+ </controller>
+ <controller type='pci' index='7' model='pcie-switch-downstream-port'/>
+ <controller type='pci' index='8' model='pcie-switch-downstream-port'>
+ <model name='xio3130-downstream'/>
+ <target chassis='30' port='0x27'/>
+ </controller>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/pcie-root-port-nohotplug.x86_64-latest.xml b/tests/qemuxml2xmloutdata/pcie-root-port-nohotplug.x86_64-latest.xml
new file mode 100644
index 0000000000..f7dbaccae9
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/pcie-root-port-nohotplug.x86_64-latest.xml
@@ -0,0 +1,67 @@
+<domain type='qemu'>
+ <name>guest</name>
+ <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
+ <memory unit='KiB'>2097152</memory>
+ <currentMemory unit='KiB'>2097152</currentMemory>
+ <vcpu placement='static'>2</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='pci' index='1' model='pcie-root-port'>
+ <model name='pcie-root-port'/>
+ <target chassis='1' port='0x8'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
+ </controller>
+ <controller type='pci' index='2' model='pcie-root-port'>
+ <model name='pcie-root-port'/>
+ <target chassis='2' port='0x9' hotplug='off'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='3' model='pcie-root-port'>
+ <model name='ioh3420'/>
+ <target chassis='3' port='0xa' hotplug='off'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='4' model='pcie-switch-upstream-port'>
+ <model name='x3130-upstream'/>
+ <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
+ </controller>
+ <controller type='pci' index='5' model='pcie-switch-downstream-port'>
+ <model name='xio3130-downstream'/>
+ <target chassis='5' port='0x0' hotplug='off'/>
+ <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
+ </controller>
+ <controller type='pci' index='6' model='pcie-switch-downstream-port'>
+ <model name='xio3130-downstream'/>
+ <target chassis='6' port='0x1' hotplug='on'/>
+ <address type='pci' domain='0x0000' bus='0x04' slot='0x01' function='0x0'/>
+ </controller>
+ <controller type='pci' index='7' model='pcie-switch-downstream-port'>
+ <model name='xio3130-downstream'/>
+ <target chassis='7' port='0x2'/>
+ <address type='pci' domain='0x0000' bus='0x04' slot='0x02' function='0x0'/>
+ </controller>
+ <controller type='pci' index='8' model='pcie-switch-downstream-port'>
+ <model name='xio3130-downstream'/>
+ <target chassis='30' port='0x27'/>
+ <address type='pci' domain='0x0000' bus='0x04' slot='0x03' function='0x0'/>
+ </controller>
+ <controller type='usb' index='0' model='qemu-xhci'>
+ <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
+ </controller>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
+ </controller>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 15110dd104..c8218e423e 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -953,7 +953,7 @@ mymain(void)
QEMU_CAPS_DEVICE_IOH3420);
DO_TEST("pcie-root-port-model-ioh3420",
QEMU_CAPS_DEVICE_IOH3420);
-
+ DO_TEST_CAPS_LATEST("pcie-root-port-nohotplug");
DO_TEST("pcie-switch-upstream-port",
QEMU_CAPS_DEVICE_IOH3420,
QEMU_CAPS_DEVICE_X3130_UPSTREAM,
--
2.26.2

View File

@ -0,0 +1,468 @@
From 653245c4de76aba4e75131da8d40eed5b15ffd0d Mon Sep 17 00:00:00 2001
Message-Id: <653245c4de76aba4e75131da8d40eed5b15ffd0d@dist-git>
From: Laine Stump <laine@redhat.com>
Date: Thu, 30 Jan 2020 14:12:40 -0500
Subject: [PATCH] conf: parse/format <teaming> subelement of <interface>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The subelement <teaming> of <interface> devices is used to configure a
simple teaming association between two interfaces in a domain. Example:
<interface type='bridge'>
<source bridge='br0'/>
<model type='virtio'/>
<mac address='00:11:22:33:44:55'/>
<alias name='ua-backup0'/>
<teaming type='persistent'/>
</interface>
<interface type='hostdev'>
<source>
<address type='pci' bus='0x02' slot='0x10' function='0x4'/>
</source>
<mac address='00:11:22:33:44:55'/>
<teaming type='transient' persistent='ua-backup0'/>
</interface>
The interface with <teaming type='persistent'/> is assumed to always
be present, while the interface with type='transient' may be be
unplugged and later re-plugged; the persistent='blah' attribute (and
in the one currently available implementation, also the matching MAC
addresses) is what associates the two devices with each other. It is
up to the hypervisor and the guest network drivers to determine what
to do with this information.
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit fb0509d06ac57434c2edbd81ee63deb32a0e598a)
https://bugzilla.redhat.com/1693587
Signed-off-by: Laine Stump <laine@redhat.com>
Message-Id: <20200130191244.24174-3-laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
docs/schemas/domaincommon.rng | 19 ++++++
src/conf/domain_conf.c | 47 +++++++++++++
src/conf/domain_conf.h | 14 ++++
.../net-virtio-teaming-network.xml | 37 +++++++++++
tests/qemuxml2argvdata/net-virtio-teaming.xml | 50 ++++++++++++++
.../net-virtio-teaming-network.xml | 51 ++++++++++++++
.../qemuxml2xmloutdata/net-virtio-teaming.xml | 66 +++++++++++++++++++
tests/qemuxml2xmltest.c | 6 ++
8 files changed, 290 insertions(+)
create mode 100644 tests/qemuxml2argvdata/net-virtio-teaming-network.xml
create mode 100644 tests/qemuxml2argvdata/net-virtio-teaming.xml
create mode 100644 tests/qemuxml2xmloutdata/net-virtio-teaming-network.xml
create mode 100644 tests/qemuxml2xmloutdata/net-virtio-teaming.xml
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 76d94b156f..026e753567 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3158,6 +3158,25 @@
<optional>
<ref name="vlan"/>
</optional>
+ <optional>
+ <element name="teaming">
+ <choice>
+ <group>
+ <attribute name="type">
+ <value>persistent</value>
+ </attribute>
+ </group>
+ <group>
+ <attribute name="type">
+ <value>transient</value>
+ </attribute>
+ <attribute name="persistent">
+ <ref name="aliasName"/>
+ </attribute>
+ </group>
+ </choice>
+ </element>
+ </optional>
</interleave>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0478914c69..58f72b3b0f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -554,6 +554,13 @@ VIR_ENUM_IMPL(virDomainNetVirtioTxMode,
"timer",
);
+VIR_ENUM_IMPL(virDomainNetTeaming,
+ VIR_DOMAIN_NET_TEAMING_TYPE_LAST,
+ "none",
+ "persistent",
+ "transient",
+);
+
VIR_ENUM_IMPL(virDomainNetInterfaceLinkState,
VIR_DOMAIN_NET_INTERFACE_LINK_STATE_LAST,
"default",
@@ -6276,6 +6283,21 @@ virDomainNetDefValidate(const virDomainNetDef *net)
virDomainNetTypeToString(net->type));
return -1;
}
+
+ if (net->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT) {
+ if (!net->teaming.persistent) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("teaming persistent attribute must be set if teaming type is 'transient'"));
+ return -1;
+ }
+ } else {
+ if (net->teaming.persistent) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("teaming persistent attribute not allowed if teaming type is '%s'"),
+ virDomainNetTeamingTypeToString(net->teaming.type));
+ return -1;
+ }
+ }
return 0;
}
@@ -11574,6 +11596,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
g_autofree char *vhostuser_type = NULL;
g_autofree char *trustGuestRxFilters = NULL;
g_autofree char *vhost_path = NULL;
+ g_autofree char *teamingType = NULL;
+ g_autofree char *teamingPersistent = NULL;
const char *prefix = xmlopt ? xmlopt->config.netPrefix : NULL;
if (!(def = virDomainNetDefNew(xmlopt)))
@@ -11775,6 +11799,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
if (!vhost_path && (tmp = virXMLPropString(cur, "vhost")))
vhost_path = virFileSanitizePath(tmp);
VIR_FREE(tmp);
+ } else if (virXMLNodeNameEqual(cur, "teaming") &&
+ !teamingType && !teamingPersistent) {
+ teamingType = virXMLPropString(cur, "type");
+ teamingPersistent = virXMLPropString(cur, "persistent");
}
}
cur = cur->next;
@@ -12296,6 +12324,19 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
}
}
+ if (teamingType) {
+ int tmpTeaming;
+
+ if ((tmpTeaming = virDomainNetTeamingTypeFromString(teamingType)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown teaming type '%s'"),
+ teamingType);
+ goto error;
+ }
+ def->teaming.type = tmpTeaming;
+ }
+ def->teaming.persistent = g_steal_pointer(&teamingPersistent);
+
rv = virXPathULong("string(./tune/sndbuf)", ctxt, &def->tune.sndbuf);
if (rv >= 0) {
def->tune.sndbuf_specified = true;
@@ -25741,6 +25782,12 @@ virDomainNetDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "</tune>\n");
}
+ if (def->teaming.type != VIR_DOMAIN_NET_TEAMING_TYPE_NONE) {
+ virBufferAsprintf(buf, "<teaming type='%s'",
+ virDomainNetTeamingTypeToString(def->teaming.type));
+ virBufferEscapeString(buf, " persistent='%s'", def->teaming.persistent);
+ virBufferAddLit(buf, "/>\n");
+ }
if (def->linkstate) {
virBufferAsprintf(buf, "<link state='%s'/>\n",
virDomainNetInterfaceLinkStateTypeToString(def->linkstate));
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6ae89fa498..ee8eb3ddc0 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -884,6 +884,15 @@ typedef enum {
VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
} virDomainNetVirtioTxModeType;
+/* the type of teaming device */
+typedef enum {
+ VIR_DOMAIN_NET_TEAMING_TYPE_NONE,
+ VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT,
+ VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT,
+
+ VIR_DOMAIN_NET_TEAMING_TYPE_LAST
+} virDomainNetTeamingType;
+
/* link interface states */
typedef enum {
VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT = 0, /* Default link state (up) */
@@ -958,6 +967,10 @@ struct _virDomainNetDef {
char *tap;
char *vhost;
} backend;
+ struct {
+ virDomainNetTeamingType type;
+ char *persistent; /* alias name of persistent device */
+ } teaming;
union {
virDomainChrSourceDefPtr vhostuser;
struct {
@@ -3425,6 +3438,7 @@ VIR_ENUM_DECL(virDomainFSModel);
VIR_ENUM_DECL(virDomainNet);
VIR_ENUM_DECL(virDomainNetBackend);
VIR_ENUM_DECL(virDomainNetVirtioTxMode);
+VIR_ENUM_DECL(virDomainNetTeaming);
VIR_ENUM_DECL(virDomainNetInterfaceLinkState);
VIR_ENUM_DECL(virDomainNetModel);
VIR_ENUM_DECL(virDomainChrDevice);
diff --git a/tests/qemuxml2argvdata/net-virtio-teaming-network.xml b/tests/qemuxml2argvdata/net-virtio-teaming-network.xml
new file mode 100644
index 0000000000..edab52f3a1
--- /dev/null
+++ b/tests/qemuxml2argvdata/net-virtio-teaming-network.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <interface type='network'>
+ <mac address='00:11:22:33:44:55'/>
+ <source network='mybridge'/>
+ <model type='virtio'/>
+ <teaming type='persistent'/>
+ <alias name='ua-backup0'/>
+ </interface>
+ <interface type='network'>
+ <mac address='00:11:22:33:44:55'/>
+ <source network='myhostdevpool'/>
+ <model type='virtio'/>
+ <teaming type='transient' persistent='ua-backup0'/>
+ </interface>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/net-virtio-teaming.xml b/tests/qemuxml2argvdata/net-virtio-teaming.xml
new file mode 100644
index 0000000000..830ce28524
--- /dev/null
+++ b/tests/qemuxml2argvdata/net-virtio-teaming.xml
@@ -0,0 +1,50 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <interface type='user'>
+ <mac address='00:11:22:33:44:55'/>
+ <model type='virtio'/>
+ <teaming type='persistent'/>
+ <alias name='ua-backup0'/>
+ </interface>
+ <interface type='user'>
+ <mac address='66:44:33:22:11:00'/>
+ <model type='virtio'/>
+ <teaming type='persistent'/>
+ <alias name='ua-backup1'/>
+ </interface>
+ <interface type='hostdev' managed='yes'>
+ <mac address='00:11:22:33:44:55'/>
+ <source>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/>
+ </source>
+ <teaming type='transient' persistent='ua-backup0'/>
+ </interface>
+ <interface type='hostdev' managed='yes'>
+ <mac address='66:44:33:22:11:00'/>
+ <source>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x2'/>
+ </source>
+ <teaming type='transient' persistent='ua-backup1'/>
+ </interface>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/net-virtio-teaming-network.xml b/tests/qemuxml2xmloutdata/net-virtio-teaming-network.xml
new file mode 100644
index 0000000000..e0dbeafe02
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/net-virtio-teaming-network.xml
@@ -0,0 +1,51 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <interface type='network'>
+ <mac address='00:11:22:33:44:55'/>
+ <source network='mybridge'/>
+ <model type='virtio'/>
+ <teaming type='persistent'/>
+ <alias name='ua-backup0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <interface type='network'>
+ <mac address='00:11:22:33:44:55'/>
+ <source network='myhostdevpool'/>
+ <model type='virtio'/>
+ <teaming type='transient' persistent='ua-backup0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/net-virtio-teaming.xml b/tests/qemuxml2xmloutdata/net-virtio-teaming.xml
new file mode 100644
index 0000000000..5a5695794a
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/net-virtio-teaming.xml
@@ -0,0 +1,66 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <interface type='user'>
+ <mac address='00:11:22:33:44:55'/>
+ <model type='virtio'/>
+ <teaming type='persistent'/>
+ <alias name='ua-backup0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <interface type='user'>
+ <mac address='66:44:33:22:11:00'/>
+ <model type='virtio'/>
+ <teaming type='persistent'/>
+ <alias name='ua-backup1'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </interface>
+ <interface type='hostdev' managed='yes'>
+ <mac address='00:11:22:33:44:55'/>
+ <source>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/>
+ </source>
+ <teaming type='transient' persistent='ua-backup0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </interface>
+ <interface type='hostdev' managed='yes'>
+ <mac address='66:44:33:22:11:00'/>
+ <source>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x2'/>
+ </source>
+ <teaming type='transient' persistent='ua-backup1'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 3cefc64833..e54c540ef6 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -451,6 +451,12 @@ mymain(void)
DO_TEST("net-eth-unmanaged-tap", NONE);
DO_TEST("net-virtio-network-portgroup", NONE);
DO_TEST("net-virtio-rxtxqueuesize", NONE);
+ DO_TEST("net-virtio-teaming",
+ QEMU_CAPS_VIRTIO_NET_FAILOVER,
+ QEMU_CAPS_DEVICE_VFIO_PCI);
+ DO_TEST("net-virtio-teaming-network",
+ QEMU_CAPS_VIRTIO_NET_FAILOVER,
+ QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST("net-hostdev", NONE);
DO_TEST("net-hostdev-bootorder", NONE);
DO_TEST("net-hostdev-vfio", QEMU_CAPS_DEVICE_VFIO_PCI);
--
2.25.0

View File

@ -1,262 +0,0 @@
From efc0312e1edb3d8196806606fbb639bbbd0bd6d4 Mon Sep 17 00:00:00 2001
Message-Id: <efc0312e1edb3d8196806606fbb639bbbd0bd6d4@dist-git>
From: Vitaly Kuznetsov <vkuznets@redhat.com>
Date: Thu, 9 Aug 2018 15:14:21 +0200
Subject: [PATCH] conf: qemu: add support for Hyper-V PV TLB flush
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Qemu-3.0 supports Hyper-V-style PV TLB flush, Windows guests can benefit
from this feature as KVM knows which vCPUs are not currently scheduled (and
thus don't require any immediate action).
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit f4c39db7366376bd95e1751b0e3ced9c73c14f5b)
https://bugzilla.redhat.com/show_bug.cgi?id=1589702
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatdomain.html.in | 7 +++++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 6 +++++-
src/conf/domain_conf.h | 1 +
src/cpu/cpu_x86.c | 3 +++
src/cpu/cpu_x86_data.h | 1 +
src/qemu/qemu_command.c | 1 +
src/qemu/qemu_parse_command.c | 1 +
src/qemu/qemu_process.c | 1 +
tests/qemuxml2argvdata/hyperv-off.xml | 1 +
tests/qemuxml2argvdata/hyperv.args | 2 +-
tests/qemuxml2argvdata/hyperv.xml | 1 +
tests/qemuxml2xmloutdata/hyperv-off.xml | 1 +
tests/qemuxml2xmloutdata/hyperv.xml | 1 +
14 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 43a1067501..c019b26644 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1917,6 +1917,7 @@
&lt;vendor_id state='on' value='KVM Hv'/&gt;
&lt;frequencies state='on'/&gt;
&lt;reenlightenment state='on'/&gt;
+ &lt;tlbflush state='on'/&gt;
&lt;/hyperv&gt;
&lt;kvm&gt;
&lt;hidden state='on'/&gt;
@@ -2051,6 +2052,12 @@
<td> on, off</td>
<td><span class="since">4.7.0 (QEMU 3.0)</span></td>
</tr>
+ <tr>
+ <td>tlbflush</td>
+ <td>Enable PV TLB flush support</td>
+ <td> on, off</td>
+ <td><span class="since">4.7.0 (QEMU 3.0)</span></td>
+ </tr>
</table>
</dd>
<dt><code>pvspinlock</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ceee7a8efe..1c6f2a295d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5723,6 +5723,11 @@
<ref name="featurestate"/>
</element>
</optional>
+ <optional>
+ <element name="tlbflush">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 18b4d03a61..e013e9f0c5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -171,7 +171,8 @@ VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
"reset",
"vendor_id",
"frequencies",
- "reenlightenment")
+ "reenlightenment",
+ "tlbflush")
VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST,
"hidden")
@@ -20055,6 +20056,7 @@ virDomainDefParseXML(xmlDocPtr xml,
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
+ case VIR_DOMAIN_HYPERV_TLBFLUSH:
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
@@ -22248,6 +22250,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
+ case VIR_DOMAIN_HYPERV_TLBFLUSH:
if (src->hyperv_features[i] != dst->hyperv_features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of HyperV enlightenment "
@@ -27898,6 +27901,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
+ case VIR_DOMAIN_HYPERV_TLBFLUSH:
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e450923019..d32514e7e6 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1793,6 +1793,7 @@ typedef enum {
VIR_DOMAIN_HYPERV_VENDOR_ID,
VIR_DOMAIN_HYPERV_FREQUENCIES,
VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
+ VIR_DOMAIN_HYPERV_TLBFLUSH,
VIR_DOMAIN_HYPERV_LAST
} virDomainHyperv;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 7a48b78eb9..7fa84f6014 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -113,6 +113,8 @@ KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_FREQUENCIES,
0x40000003, 0x00000800);
KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT,
0x40000003, 0x00002000);
+KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_TLBFLUSH,
+ 0x40000004, 0x00000004);
static virCPUx86Feature x86_kvm_features[] =
{
@@ -135,6 +137,7 @@ static virCPUx86Feature x86_kvm_features[] =
KVM_FEATURE(VIR_CPU_x86_KVM_HV_RESET),
KVM_FEATURE(VIR_CPU_x86_KVM_HV_FREQUENCIES),
KVM_FEATURE(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT),
+ KVM_FEATURE(VIR_CPU_x86_KVM_HV_TLBFLUSH),
};
typedef struct _virCPUx86Model virCPUx86Model;
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index a810c64fc9..090a21156f 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -65,6 +65,7 @@ struct _virCPUx86CPUID {
# define VIR_CPU_x86_KVM_HV_RESET "__kvm_hv_reset"
# define VIR_CPU_x86_KVM_HV_FREQUENCIES "__kvm_hv_frequencies"
# define VIR_CPU_x86_KVM_HV_REENLIGHTENMENT "__kvm_hv_reenlightenment"
+# define VIR_CPU_x86_KVM_HV_TLBFLUSH "__kvm_hv_tlbflush"
# define VIR_CPU_X86_DATA_INIT { 0 }
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 48f3b09ec9..a3d605c00f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6921,6 +6921,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
+ case VIR_DOMAIN_HYPERV_TLBFLUSH:
if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
virBufferAsprintf(&buf, ",hv_%s",
virDomainHypervTypeToString(i));
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 1e67a5a8c8..fdc1d34068 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1538,6 +1538,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
+ case VIR_DOMAIN_HYPERV_TLBFLUSH:
if (value) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("HyperV feature '%s' should not "
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 990d4d3046..23958bcbce 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3925,6 +3925,7 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
+ case VIR_DOMAIN_HYPERV_TLBFLUSH:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("host doesn't support hyperv '%s' feature"),
virDomainHypervTypeToString(i));
diff --git a/tests/qemuxml2argvdata/hyperv-off.xml b/tests/qemuxml2argvdata/hyperv-off.xml
index b2e3612df9..dc5777355f 100644
--- a/tests/qemuxml2argvdata/hyperv-off.xml
+++ b/tests/qemuxml2argvdata/hyperv-off.xml
@@ -22,6 +22,7 @@
<vendor_id state='off'/>
<frequencies state='off'/>
<reenlightenment state='off'/>
+ <tlbflush state='off'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2argvdata/hyperv.args b/tests/qemuxml2argvdata/hyperv.args
index 4feafad8e2..6ee6198fb0 100644
--- a/tests/qemuxml2argvdata/hyperv.args
+++ b/tests/qemuxml2argvdata/hyperv.args
@@ -10,7 +10,7 @@ QEMU_AUDIO_DRV=none \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-cpu 'qemu32,hv_relaxed,hv_vapic,hv_spinlocks=0x2fff,hv_vpindex,hv_runtime,\
hv_synic,hv_stimer,hv_reset,hv_vendor_id=KVM Hv,hv_frequencies,\
-hv_reenlightenment' \
+hv_reenlightenment,hv_tlbflush' \
-m 214 \
-smp 6,sockets=6,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxml2argvdata/hyperv.xml b/tests/qemuxml2argvdata/hyperv.xml
index 20fcdba59e..816adf6907 100644
--- a/tests/qemuxml2argvdata/hyperv.xml
+++ b/tests/qemuxml2argvdata/hyperv.xml
@@ -22,6 +22,7 @@
<vendor_id state='on' value='KVM Hv'/>
<frequencies state='on'/>
<reenlightenment state='on'/>
+ <tlbflush state='on'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2xmloutdata/hyperv-off.xml b/tests/qemuxml2xmloutdata/hyperv-off.xml
index 4a41e0c37e..77a8dac810 100644
--- a/tests/qemuxml2xmloutdata/hyperv-off.xml
+++ b/tests/qemuxml2xmloutdata/hyperv-off.xml
@@ -22,6 +22,7 @@
<vendor_id state='off'/>
<frequencies state='off'/>
<reenlightenment state='off'/>
+ <tlbflush state='off'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2xmloutdata/hyperv.xml b/tests/qemuxml2xmloutdata/hyperv.xml
index 183b45980b..fc8c59a557 100644
--- a/tests/qemuxml2xmloutdata/hyperv.xml
+++ b/tests/qemuxml2xmloutdata/hyperv.xml
@@ -22,6 +22,7 @@
<vendor_id state='on' value='KVM Hv'/>
<frequencies state='on'/>
<reenlightenment state='on'/>
+ <tlbflush state='on'/>
</hyperv>
</features>
<clock offset='utc'/>
--
2.19.1

View File

@ -1,262 +0,0 @@
From b4335c3290082dd8aa0915e340b625197d80fdc3 Mon Sep 17 00:00:00 2001
Message-Id: <b4335c3290082dd8aa0915e340b625197d80fdc3@dist-git>
From: Vitaly Kuznetsov <vkuznets@redhat.com>
Date: Thu, 9 Aug 2018 15:14:19 +0200
Subject: [PATCH] conf: qemu: add support for Hyper-V frequency MSRs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Qemu-2.12 gained 'hv-frequencies' cpu flag to enable Hyper-V frequency
MSRs. These MSRs are required (but not sufficient) to make Hyper-V on
KVM pass stable TSC page clocksource to L2 guests.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit 8253bca9615233f670c7dad659c120e4556a748a)
https://bugzilla.redhat.com/show_bug.cgi?id=1589702
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatdomain.html.in | 7 +++++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 6 +++++-
src/conf/domain_conf.h | 1 +
src/cpu/cpu_x86.c | 3 +++
src/cpu/cpu_x86_data.h | 1 +
src/qemu/qemu_command.c | 1 +
src/qemu/qemu_parse_command.c | 1 +
src/qemu/qemu_process.c | 1 +
tests/qemuxml2argvdata/hyperv-off.xml | 1 +
tests/qemuxml2argvdata/hyperv.args | 2 +-
tests/qemuxml2argvdata/hyperv.xml | 1 +
tests/qemuxml2xmloutdata/hyperv-off.xml | 1 +
tests/qemuxml2xmloutdata/hyperv.xml | 1 +
14 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 42acf7a828..3b493a98ac 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1915,6 +1915,7 @@
&lt;synic state='on'/&gt;
&lt;reset state='on'/&gt;
&lt;vendor_id state='on' value='KVM Hv'/&gt;
+ &lt;frequencies state='on'/&gt;
&lt;/hyperv&gt;
&lt;kvm&gt;
&lt;hidden state='on'/&gt;
@@ -2037,6 +2038,12 @@
<td>on, off; value - string, up to 12 characters</td>
<td><span class="since">1.3.3 (QEMU 2.5)</span></td>
</tr>
+ <tr>
+ <td>frequencies</td>
+ <td>Expose frequency MSRs</td>
+ <td> on, off</td>
+ <td><span class="since">4.7.0 (QEMU 2.12)</span></td>
+ </tr>
</table>
</dd>
<dt><code>pvspinlock</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ac04af51a1..f156a6b7c4 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5713,6 +5713,11 @@
</optional>
</element>
</optional>
+ <optional>
+ <element name="frequencies">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 240b33f28c..150dd8acc8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -169,7 +169,8 @@ VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
"synic",
"stimer",
"reset",
- "vendor_id")
+ "vendor_id",
+ "frequencies")
VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST,
"hidden")
@@ -20051,6 +20052,7 @@ virDomainDefParseXML(xmlDocPtr xml,
case VIR_DOMAIN_HYPERV_SYNIC:
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
+ case VIR_DOMAIN_HYPERV_FREQUENCIES:
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
@@ -22242,6 +22244,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
case VIR_DOMAIN_HYPERV_SYNIC:
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
+ case VIR_DOMAIN_HYPERV_FREQUENCIES:
if (src->hyperv_features[i] != dst->hyperv_features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of HyperV enlightenment "
@@ -27890,6 +27893,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
case VIR_DOMAIN_HYPERV_SYNIC:
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
+ case VIR_DOMAIN_HYPERV_FREQUENCIES:
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5e2f21dea3..97d38ff7b9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1791,6 +1791,7 @@ typedef enum {
VIR_DOMAIN_HYPERV_STIMER,
VIR_DOMAIN_HYPERV_RESET,
VIR_DOMAIN_HYPERV_VENDOR_ID,
+ VIR_DOMAIN_HYPERV_FREQUENCIES,
VIR_DOMAIN_HYPERV_LAST
} virDomainHyperv;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 809da94117..a2fbfb577d 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -109,6 +109,8 @@ KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_VPINDEX,
0x40000003, 0x00000040);
KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_RESET,
0x40000003, 0x00000080);
+KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_FREQUENCIES,
+ 0x40000003, 0x00000800);
static virCPUx86Feature x86_kvm_features[] =
{
@@ -129,6 +131,7 @@ static virCPUx86Feature x86_kvm_features[] =
KVM_FEATURE(VIR_CPU_x86_KVM_HV_VAPIC),
KVM_FEATURE(VIR_CPU_x86_KVM_HV_VPINDEX),
KVM_FEATURE(VIR_CPU_x86_KVM_HV_RESET),
+ KVM_FEATURE(VIR_CPU_x86_KVM_HV_FREQUENCIES),
};
typedef struct _virCPUx86Model virCPUx86Model;
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index b89110f16c..c01eb41be5 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -63,6 +63,7 @@ struct _virCPUx86CPUID {
# define VIR_CPU_x86_KVM_HV_VAPIC "__kvm_hv_vapic"
# define VIR_CPU_x86_KVM_HV_VPINDEX "__kvm_hv_vpindex"
# define VIR_CPU_x86_KVM_HV_RESET "__kvm_hv_reset"
+# define VIR_CPU_x86_KVM_HV_FREQUENCIES "__kvm_hv_frequencies"
# define VIR_CPU_X86_DATA_INIT { 0 }
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 028f48310b..82c349819e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6919,6 +6919,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_HYPERV_SYNIC:
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
+ case VIR_DOMAIN_HYPERV_FREQUENCIES:
if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
virBufferAsprintf(&buf, ",hv_%s",
virDomainHypervTypeToString(i));
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 351425fedd..ffea9a26bd 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1536,6 +1536,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
case VIR_DOMAIN_HYPERV_SYNIC:
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
+ case VIR_DOMAIN_HYPERV_FREQUENCIES:
if (value) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("HyperV feature '%s' should not "
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2d51c0fa25..dd92a6c179 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3923,6 +3923,7 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
case VIR_DOMAIN_HYPERV_SYNIC:
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
+ case VIR_DOMAIN_HYPERV_FREQUENCIES:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("host doesn't support hyperv '%s' feature"),
virDomainHypervTypeToString(i));
diff --git a/tests/qemuxml2argvdata/hyperv-off.xml b/tests/qemuxml2argvdata/hyperv-off.xml
index ba9c978848..d3a8455ac3 100644
--- a/tests/qemuxml2argvdata/hyperv-off.xml
+++ b/tests/qemuxml2argvdata/hyperv-off.xml
@@ -20,6 +20,7 @@
<stimer state='off'/>
<reset state='off'/>
<vendor_id state='off'/>
+ <frequencies state='off'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2argvdata/hyperv.args b/tests/qemuxml2argvdata/hyperv.args
index a1acbb63de..53026bb2d5 100644
--- a/tests/qemuxml2argvdata/hyperv.args
+++ b/tests/qemuxml2argvdata/hyperv.args
@@ -9,7 +9,7 @@ QEMU_AUDIO_DRV=none \
-S \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-cpu 'qemu32,hv_relaxed,hv_vapic,hv_spinlocks=0x2fff,hv_vpindex,hv_runtime,\
-hv_synic,hv_stimer,hv_reset,hv_vendor_id=KVM Hv' \
+hv_synic,hv_stimer,hv_reset,hv_vendor_id=KVM Hv,hv_frequencies' \
-m 214 \
-smp 6,sockets=6,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxml2argvdata/hyperv.xml b/tests/qemuxml2argvdata/hyperv.xml
index 09f6d21024..27372d1636 100644
--- a/tests/qemuxml2argvdata/hyperv.xml
+++ b/tests/qemuxml2argvdata/hyperv.xml
@@ -20,6 +20,7 @@
<stimer state='on'/>
<reset state='on'/>
<vendor_id state='on' value='KVM Hv'/>
+ <frequencies state='on'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2xmloutdata/hyperv-off.xml b/tests/qemuxml2xmloutdata/hyperv-off.xml
index 07eaf7219d..3ba0b827c3 100644
--- a/tests/qemuxml2xmloutdata/hyperv-off.xml
+++ b/tests/qemuxml2xmloutdata/hyperv-off.xml
@@ -20,6 +20,7 @@
<stimer state='off'/>
<reset state='off'/>
<vendor_id state='off'/>
+ <frequencies state='off'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2xmloutdata/hyperv.xml b/tests/qemuxml2xmloutdata/hyperv.xml
index f9ae9504de..1e47a946d6 100644
--- a/tests/qemuxml2xmloutdata/hyperv.xml
+++ b/tests/qemuxml2xmloutdata/hyperv.xml
@@ -20,6 +20,7 @@
<stimer state='on'/>
<reset state='on'/>
<vendor_id state='on' value='KVM Hv'/>
+ <frequencies state='on'/>
</hyperv>
</features>
<clock offset='utc'/>
--
2.19.1

View File

@ -1,264 +0,0 @@
From 7b4320c2371e10cf717c7bc28f83485cf176e03d Mon Sep 17 00:00:00 2001
Message-Id: <7b4320c2371e10cf717c7bc28f83485cf176e03d@dist-git>
From: Vitaly Kuznetsov <vkuznets@redhat.com>
Date: Thu, 9 Aug 2018 15:14:20 +0200
Subject: [PATCH] conf: qemu: add support for Hyper-V reenlightenment
notifications
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Qemu-3.0 supports so-called 'Reenlightenment' notifications and this (in
conjunction with 'hv-frequencies') can be used make Hyper-V on KVM pass
stable TSC page clocksource to L2 guests.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit b5d770e155cbb7eec036b3d33ee0d81863ffc9a1)
https://bugzilla.redhat.com/show_bug.cgi?id=1589702
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatdomain.html.in | 7 +++++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 6 +++++-
src/conf/domain_conf.h | 1 +
src/cpu/cpu_x86.c | 3 +++
src/cpu/cpu_x86_data.h | 1 +
src/qemu/qemu_command.c | 1 +
src/qemu/qemu_parse_command.c | 1 +
src/qemu/qemu_process.c | 1 +
tests/qemuxml2argvdata/hyperv-off.xml | 1 +
tests/qemuxml2argvdata/hyperv.args | 3 ++-
tests/qemuxml2argvdata/hyperv.xml | 1 +
tests/qemuxml2xmloutdata/hyperv-off.xml | 1 +
tests/qemuxml2xmloutdata/hyperv.xml | 1 +
14 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3b493a98ac..43a1067501 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1916,6 +1916,7 @@
&lt;reset state='on'/&gt;
&lt;vendor_id state='on' value='KVM Hv'/&gt;
&lt;frequencies state='on'/&gt;
+ &lt;reenlightenment state='on'/&gt;
&lt;/hyperv&gt;
&lt;kvm&gt;
&lt;hidden state='on'/&gt;
@@ -2044,6 +2045,12 @@
<td> on, off</td>
<td><span class="since">4.7.0 (QEMU 2.12)</span></td>
</tr>
+ <tr>
+ <td>reenlightenment</td>
+ <td>Enable re-enlightenment notification on migration</td>
+ <td> on, off</td>
+ <td><span class="since">4.7.0 (QEMU 3.0)</span></td>
+ </tr>
</table>
</dd>
<dt><code>pvspinlock</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f156a6b7c4..ceee7a8efe 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5718,6 +5718,11 @@
<ref name="featurestate"/>
</element>
</optional>
+ <optional>
+ <element name="reenlightenment">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 150dd8acc8..18b4d03a61 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -170,7 +170,8 @@ VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
"stimer",
"reset",
"vendor_id",
- "frequencies")
+ "frequencies",
+ "reenlightenment")
VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST,
"hidden")
@@ -20053,6 +20054,7 @@ virDomainDefParseXML(xmlDocPtr xml,
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
+ case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
@@ -22245,6 +22247,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
+ case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
if (src->hyperv_features[i] != dst->hyperv_features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of HyperV enlightenment "
@@ -27894,6 +27897,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
+ case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 97d38ff7b9..e450923019 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1792,6 +1792,7 @@ typedef enum {
VIR_DOMAIN_HYPERV_RESET,
VIR_DOMAIN_HYPERV_VENDOR_ID,
VIR_DOMAIN_HYPERV_FREQUENCIES,
+ VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
VIR_DOMAIN_HYPERV_LAST
} virDomainHyperv;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index a2fbfb577d..7a48b78eb9 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -111,6 +111,8 @@ KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_RESET,
0x40000003, 0x00000080);
KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_FREQUENCIES,
0x40000003, 0x00000800);
+KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT,
+ 0x40000003, 0x00002000);
static virCPUx86Feature x86_kvm_features[] =
{
@@ -132,6 +134,7 @@ static virCPUx86Feature x86_kvm_features[] =
KVM_FEATURE(VIR_CPU_x86_KVM_HV_VPINDEX),
KVM_FEATURE(VIR_CPU_x86_KVM_HV_RESET),
KVM_FEATURE(VIR_CPU_x86_KVM_HV_FREQUENCIES),
+ KVM_FEATURE(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT),
};
typedef struct _virCPUx86Model virCPUx86Model;
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index c01eb41be5..a810c64fc9 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -64,6 +64,7 @@ struct _virCPUx86CPUID {
# define VIR_CPU_x86_KVM_HV_VPINDEX "__kvm_hv_vpindex"
# define VIR_CPU_x86_KVM_HV_RESET "__kvm_hv_reset"
# define VIR_CPU_x86_KVM_HV_FREQUENCIES "__kvm_hv_frequencies"
+# define VIR_CPU_x86_KVM_HV_REENLIGHTENMENT "__kvm_hv_reenlightenment"
# define VIR_CPU_X86_DATA_INIT { 0 }
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 82c349819e..48f3b09ec9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6920,6 +6920,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
+ case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
virBufferAsprintf(&buf, ",hv_%s",
virDomainHypervTypeToString(i));
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index ffea9a26bd..1e67a5a8c8 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1537,6 +1537,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
+ case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
if (value) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("HyperV feature '%s' should not "
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index dd92a6c179..990d4d3046 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3924,6 +3924,7 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
case VIR_DOMAIN_HYPERV_STIMER:
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
+ case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("host doesn't support hyperv '%s' feature"),
virDomainHypervTypeToString(i));
diff --git a/tests/qemuxml2argvdata/hyperv-off.xml b/tests/qemuxml2argvdata/hyperv-off.xml
index d3a8455ac3..b2e3612df9 100644
--- a/tests/qemuxml2argvdata/hyperv-off.xml
+++ b/tests/qemuxml2argvdata/hyperv-off.xml
@@ -21,6 +21,7 @@
<reset state='off'/>
<vendor_id state='off'/>
<frequencies state='off'/>
+ <reenlightenment state='off'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2argvdata/hyperv.args b/tests/qemuxml2argvdata/hyperv.args
index 53026bb2d5..4feafad8e2 100644
--- a/tests/qemuxml2argvdata/hyperv.args
+++ b/tests/qemuxml2argvdata/hyperv.args
@@ -9,7 +9,8 @@ QEMU_AUDIO_DRV=none \
-S \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-cpu 'qemu32,hv_relaxed,hv_vapic,hv_spinlocks=0x2fff,hv_vpindex,hv_runtime,\
-hv_synic,hv_stimer,hv_reset,hv_vendor_id=KVM Hv,hv_frequencies' \
+hv_synic,hv_stimer,hv_reset,hv_vendor_id=KVM Hv,hv_frequencies,\
+hv_reenlightenment' \
-m 214 \
-smp 6,sockets=6,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxml2argvdata/hyperv.xml b/tests/qemuxml2argvdata/hyperv.xml
index 27372d1636..20fcdba59e 100644
--- a/tests/qemuxml2argvdata/hyperv.xml
+++ b/tests/qemuxml2argvdata/hyperv.xml
@@ -21,6 +21,7 @@
<reset state='on'/>
<vendor_id state='on' value='KVM Hv'/>
<frequencies state='on'/>
+ <reenlightenment state='on'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2xmloutdata/hyperv-off.xml b/tests/qemuxml2xmloutdata/hyperv-off.xml
index 3ba0b827c3..4a41e0c37e 100644
--- a/tests/qemuxml2xmloutdata/hyperv-off.xml
+++ b/tests/qemuxml2xmloutdata/hyperv-off.xml
@@ -21,6 +21,7 @@
<reset state='off'/>
<vendor_id state='off'/>
<frequencies state='off'/>
+ <reenlightenment state='off'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2xmloutdata/hyperv.xml b/tests/qemuxml2xmloutdata/hyperv.xml
index 1e47a946d6..183b45980b 100644
--- a/tests/qemuxml2xmloutdata/hyperv.xml
+++ b/tests/qemuxml2xmloutdata/hyperv.xml
@@ -21,6 +21,7 @@
<reset state='on'/>
<vendor_id state='on' value='KVM Hv'/>
<frequencies state='on'/>
+ <reenlightenment state='on'/>
</hyperv>
</features>
<clock offset='utc'/>
--
2.19.1

View File

@ -0,0 +1,327 @@
From 2fce649fb569ab21c224f387456c996428f8a251 Mon Sep 17 00:00:00 2001
Message-Id: <2fce649fb569ab21c224f387456c996428f8a251@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Wed, 4 Mar 2020 12:42:41 +0100
Subject: [PATCH] conf: qemu: add virtiofs fsdriver type
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Introduce a new 'virtiofs' driver type for filesystem.
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs'/>
<source dir='/path'/>
<target dir='mount_tag'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</filesystem>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit ecc6ad6b90ad674a903c95d2a637f8b1b5833be2)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
Message-Id: <abe26807f06ed14b2be3cbd098461afc307e88e3.1583322090.git.jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
docs/formatdomain.html.in | 12 ++-
docs/schemas/domaincommon.rng | 6 ++
src/conf/domain_conf.c | 1 +
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 4 +
src/qemu/qemu_domain.c | 4 +
src/qemu/qemu_domain_address.c | 4 +
.../vhost-user-fs-fd-memory.xml | 39 ++++++++++
.../vhost-user-fs-hugepages.xml | 74 +++++++++++++++++++
.../vhost-user-fs-fd-memory.x86_64-latest.xml | 1 +
.../vhost-user-fs-hugepages.x86_64-latest.xml | 1 +
tests/qemuxml2xmltest.c | 3 +
12 files changed, 149 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml
create mode 100644 tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml
create mode 120000 tests/qemuxml2xmloutdata/vhost-user-fs-fd-memory.x86_64-latest.xml
create mode 120000 tests/qemuxml2xmloutdata/vhost-user-fs-hugepages.x86_64-latest.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 50914a5207..337ab01316 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3935,6 +3935,11 @@
&lt;target dir='/import/from/host'/&gt;
&lt;readonly/&gt;
&lt;/filesystem&gt;
+ &lt;filesystem type='mount' accessmode='passthrough'&gt;
+ &lt;driver type='virtiofs'/&gt;
+ &lt;source dir='/path'/&gt;
+ &lt;target dir='mount_tag'/&gt;
+ &lt;/filesystem&gt;
...
&lt;/devices&gt;
...</pre>
@@ -3963,6 +3968,9 @@
while the value <code>immediate</code> means that a host writeback
is immediately triggered for all pages touched during a guest file
write operation <span class="since">(since 0.9.10)</span>.
+ <span class="since">Since 6.2.0</span>, <code>type='virtiofs'</code>
+ is also supported. Using virtiofs requires setting up shared memory,
+ see the guide: <a href="kbase/virtiofs.html">Virtio-FS</a>
</dd>
<dt><code>template</code></dt>
<dd>
@@ -3998,7 +4006,9 @@
The filesystem element has an optional attribute <code>accessmode</code>
which specifies the security mode for accessing the source
<span class="since">(since 0.8.5)</span>. Currently this only works
- with <code>type='mount'</code> for the QEMU/KVM driver. The possible
+ with <code>type='mount'</code> for the QEMU/KVM driver.
+ For driver type <code>virtiofs</code>, only <code>passthrough</code> is
+ supported. For other driver types, the possible
values are:
<dl>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index bfd8786ea8..5a9291b443 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2645,6 +2645,12 @@
</optional>
<ref name='virtioOptions'/>
</group>
+ <group>
+ <attribute name="type">
+ <value>virtiofs</value>
+ </attribute>
+ <ref name='virtioOptions'/>
+ </group>
<empty/>
</choice>
</element>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 990c5bcc1e..31d4828802 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -476,6 +476,7 @@ VIR_ENUM_IMPL(virDomainFSDriver,
"loop",
"nbd",
"ploop",
+ "virtiofs",
);
VIR_ENUM_IMPL(virDomainFSAccessMode,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ef2c1b80f7..921cc42a57 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -771,6 +771,7 @@ typedef enum {
VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
VIR_DOMAIN_FS_DRIVER_TYPE_NBD,
VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP,
+ VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS,
VIR_DOMAIN_FS_DRIVER_TYPE_LAST
} virDomainFSDriverType;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 252809a8d7..7fdf58f067 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2695,6 +2695,10 @@ qemuBuildFilesystemCommandLine(virCommandPtr cmd,
return -1;
break;
+ case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
+ /* TODO: vhost-user-fs-pci */
+ break;
+
case VIR_DOMAIN_FS_DRIVER_TYPE_LOOP:
case VIR_DOMAIN_FS_DRIVER_TYPE_NBD:
case VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP:
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ed35260712..402b079b09 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8361,6 +8361,10 @@ qemuDomainDeviceDefValidateFS(virDomainFSDefPtr fs,
_("Filesystem driver type not supported"));
return -1;
+ case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
+ /* TODO: vhost-user-fs-pci */
+ return 0;
+
case VIR_DOMAIN_FS_DRIVER_TYPE_LAST:
default:
virReportEnumRangeError(virDomainFSDriverType, fs->fsdriver);
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 9e3bcc434d..3c6ac62ff5 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -690,6 +690,10 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
}
break;
+ case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
+ /* vhost-user-fs-pci */
+ return virtioFlags;
+
case VIR_DOMAIN_FS_DRIVER_TYPE_LOOP:
case VIR_DOMAIN_FS_DRIVER_TYPE_NBD:
case VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP:
diff --git a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml
new file mode 100644
index 0000000000..a6b6279fb8
--- /dev/null
+++ b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml
@@ -0,0 +1,39 @@
+<domain type='kvm'>
+ <name>guest</name>
+ <uuid>126f2720-6f8e-45ab-a886-ec9277079a67</uuid>
+ <memory unit='KiB'>14680064</memory>
+ <currentMemory unit='KiB'>14680064</currentMemory>
+ <memoryBacking>
+ <source type='file'/>
+ <access mode='shared'/>
+ </memoryBacking>
+ <vcpu placement='static'>2</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ <numa>
+ <cell id='0' cpus='0-1' memory='14680064' unit='KiB' memAccess='shared'/>
+ </numa>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <filesystem type='mount' accessmode='passthrough'>
+ <driver type='virtiofs'/>
+ <source dir='/path'/>
+ <target dir='mount_tag'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </filesystem>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml
new file mode 100644
index 0000000000..70df7b890d
--- /dev/null
+++ b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml
@@ -0,0 +1,74 @@
+<domain type='qemu'>
+ <name>guest</name>
+ <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+ <memory unit='KiB'>4194304</memory>
+ <currentMemory unit='KiB'>4194304</currentMemory>
+ <memoryBacking>
+ <hugepages>
+ <page size='2048' unit='KiB'/>
+ </hugepages>
+ <access mode='shared'/>
+ </memoryBacking>
+ <vcpu placement='static'>2</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ </features>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ <numa>
+ <cell id='0' cpus='0-1' memory='2097152' unit='KiB' memAccess='shared'/>
+ </numa>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='qcow2'/>
+ <source file='/var/lib/libvirt/images/guest.qcow2'/>
+ <target dev='vda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
+ </disk>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='pci' index='1' model='pcie-root-port'>
+ <model name='pcie-root-port'/>
+ <target chassis='1' port='0x8'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
+ </controller>
+ <controller type='pci' index='2' model='pcie-root-port'>
+ <model name='pcie-root-port'/>
+ <target chassis='2' port='0x9'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='3' model='pcie-root-port'>
+ <model name='pcie-root-port'/>
+ <target chassis='3' port='0xa'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='4' model='pcie-root-port'>
+ <model name='pcie-root-port'/>
+ <target chassis='4' port='0xb'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
+ </controller>
+ <filesystem type='mount' accessmode='passthrough'>
+ <driver type='virtiofs'/>
+ <source dir='/path'/>
+ <target dir='mount_tag'/>
+ <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
+ </filesystem>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/vhost-user-fs-fd-memory.x86_64-latest.xml b/tests/qemuxml2xmloutdata/vhost-user-fs-fd-memory.x86_64-latest.xml
new file mode 120000
index 0000000000..fbc552ef94
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/vhost-user-fs-fd-memory.x86_64-latest.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/vhost-user-fs-fd-memory.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/vhost-user-fs-hugepages.x86_64-latest.xml b/tests/qemuxml2xmloutdata/vhost-user-fs-hugepages.x86_64-latest.xml
new file mode 120000
index 0000000000..0c0f05b254
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/vhost-user-fs-hugepages.x86_64-latest.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/vhost-user-fs-hugepages.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index d58259587b..f77f59fa3c 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1428,6 +1428,9 @@ mymain(void)
DO_TEST("vhost-vsock-ccw-auto", QEMU_CAPS_DEVICE_VHOST_VSOCK,
QEMU_CAPS_CCW);
+ DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory");
+ DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages");
+
DO_TEST("riscv64-virt",
QEMU_CAPS_DEVICE_VIRTIO_MMIO);
DO_TEST("riscv64-virt-pci",
--
2.25.1

View File

@ -0,0 +1,161 @@
From 4f2bf4edfb640c38281d63e54145433ce8a78d28 Mon Sep 17 00:00:00 2001
Message-Id: <4f2bf4edfb640c38281d63e54145433ce8a78d28@dist-git>
From: Laine Stump <laine@redhat.com>
Date: Sun, 26 Apr 2020 13:04:11 -0400
Subject: [PATCH] conf/qemu:
s/VIR_PCI_CONNECT_HOTPLUGGABLE/VIR_PCI_CONNECT_AUTOASSIGN/g
When the HOTPLUGGABLE flag was originally added, it was set for all
the PCI controllers that accepted hotplugged devices, and requested
for all devices that were auto-assigned to a controller. While we're
still autoassigning to the same list of controllers, those controllers
may or may not support hotplug, so let's use the flag that fits what
we're actually doing.
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 7c98f5e3652e19e4eb015d290c1eed2f1b58ee72)
https://bugzilla.redhat.com/1802592
Signed-off-by: Laine Stump <laine@redhat.com>
Message-Id: <20200426170415.18328-9-laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/domain_addr.c | 18 +++++++++---------
src/qemu/qemu_domain_address.c | 14 +++++++-------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index e0be655772..53be6cd34b 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -362,8 +362,8 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
* libvirt's assumptions about whether or not hotplug
* capability will be required.
*/
- if (devFlags & VIR_PCI_CONNECT_HOTPLUGGABLE)
- busFlags |= VIR_PCI_CONNECT_HOTPLUGGABLE;
+ if (devFlags & VIR_PCI_CONNECT_AUTOASSIGN)
+ busFlags |= VIR_PCI_CONNECT_AUTOASSIGN;
/* if the device is a pci-bridge, allow manually
* assigning to any bus that would also accept a
* standard PCI device.
@@ -419,8 +419,8 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
addrStr, addr->bus, connectStr);
return false;
}
- if ((devFlags & VIR_PCI_CONNECT_HOTPLUGGABLE) &&
- !(busFlags & VIR_PCI_CONNECT_HOTPLUGGABLE)) {
+ if ((devFlags & VIR_PCI_CONNECT_AUTOASSIGN) &&
+ !(busFlags & VIR_PCI_CONNECT_AUTOASSIGN)) {
if (reportError) {
virReportError(errType,
_("The device at PCI address %s requires "
@@ -509,7 +509,7 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
*/
switch (model) {
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
- bus->flags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
+ bus->flags = (VIR_PCI_CONNECT_AUTOASSIGN |
VIR_PCI_CONNECT_TYPE_PCI_DEVICE |
VIR_PCI_CONNECT_TYPE_PCI_BRIDGE |
VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS);
@@ -517,14 +517,14 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
- bus->flags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
+ bus->flags = (VIR_PCI_CONNECT_AUTOASSIGN |
VIR_PCI_CONNECT_TYPE_PCI_DEVICE |
VIR_PCI_CONNECT_TYPE_PCI_BRIDGE);
bus->minSlot = 1;
bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
- bus->flags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
+ bus->flags = (VIR_PCI_CONNECT_AUTOASSIGN |
VIR_PCI_CONNECT_TYPE_PCI_DEVICE |
VIR_PCI_CONNECT_TYPE_PCI_BRIDGE);
bus->minSlot = 0;
@@ -555,7 +555,7 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE:
/* Same as pci-bridge: 32 hotpluggable traditional PCI slots (0-31),
* the first of which is not usable because of the SHPC */
- bus->flags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
+ bus->flags = (VIR_PCI_CONNECT_AUTOASSIGN |
VIR_PCI_CONNECT_TYPE_PCI_DEVICE |
VIR_PCI_CONNECT_TYPE_PCI_BRIDGE);
bus->minSlot = 1;
@@ -566,7 +566,7 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
/* provides one slot which is pcie, can be used by endpoint
* devices, pcie-switch-upstream-ports or pcie-to-pci-bridges,
* and is hotpluggable */
- bus->flags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
+ bus->flags = (VIR_PCI_CONNECT_AUTOASSIGN |
VIR_PCI_CONNECT_TYPE_PCIE_DEVICE |
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT |
VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE);
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 3c6ac62ff5..e81585bc6c 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -571,7 +571,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
virDomainPCIConnectFlags virtioFlags)
{
virDomainPCIConnectFlags pciFlags = (VIR_PCI_CONNECT_TYPE_PCI_DEVICE |
- VIR_PCI_CONNECT_HOTPLUGGABLE);
+ VIR_PCI_CONNECT_AUTOASSIGN);
switch ((virDomainDeviceType)dev->type) {
case VIR_DOMAIN_DEVICE_CONTROLLER: {
@@ -1063,17 +1063,17 @@ qemuDomainFillDevicePCIConnectFlagsIterInit(virDomainDefPtr def,
if (qemuDomainHasPCIeRoot(def)) {
data->pcieFlags = (VIR_PCI_CONNECT_TYPE_PCIE_DEVICE |
- VIR_PCI_CONNECT_HOTPLUGGABLE);
+ VIR_PCI_CONNECT_AUTOASSIGN);
} else {
data->pcieFlags = (VIR_PCI_CONNECT_TYPE_PCI_DEVICE |
- VIR_PCI_CONNECT_HOTPLUGGABLE);
+ VIR_PCI_CONNECT_AUTOASSIGN);
}
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) {
data->virtioFlags = data->pcieFlags;
} else {
data->virtioFlags = (VIR_PCI_CONNECT_TYPE_PCI_DEVICE |
- VIR_PCI_CONNECT_HOTPLUGGABLE);
+ VIR_PCI_CONNECT_AUTOASSIGN);
}
}
@@ -1729,7 +1729,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
virPCIDeviceAddress tmp_addr;
bool qemuDeviceVideoUsable = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
g_autofree char *addrStr = NULL;
- virDomainPCIConnectFlags flags = (VIR_PCI_CONNECT_HOTPLUGGABLE
+ virDomainPCIConnectFlags flags = (VIR_PCI_CONNECT_AUTOASSIGN
| VIR_PCI_CONNECT_TYPE_PCI_DEVICE);
/* Verify that first IDE and USB controllers (if any) is on the PIIX3, fn 1 */
@@ -2666,7 +2666,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
* domain.
*/
virDomainDeviceInfo info = {
- .pciConnectFlags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
+ .pciConnectFlags = (VIR_PCI_CONNECT_AUTOASSIGN |
VIR_PCI_CONNECT_TYPE_PCI_DEVICE),
.pciAddrExtFlags = VIR_PCI_ADDRESS_EXTENSION_NONE
};
@@ -2707,7 +2707,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
addrs->nbuses > max_idx + 1 &&
qemuDomainHasPCIeRoot(def)) {
virDomainDeviceInfo info = {
- .pciConnectFlags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
+ .pciConnectFlags = (VIR_PCI_CONNECT_AUTOASSIGN |
VIR_PCI_CONNECT_TYPE_PCIE_DEVICE),
.pciAddrExtFlags = VIR_PCI_ADDRESS_EXTENSION_NONE
};
--
2.26.2

View File

@ -0,0 +1,88 @@
From 6ece5388a7fb7fc3c703cd1bc9e214ad411451d8 Mon Sep 17 00:00:00 2001
Message-Id: <6ece5388a7fb7fc3c703cd1bc9e214ad411451d8@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Mon, 3 Feb 2020 18:07:23 +0000
Subject: [PATCH] conf: remove unused virCapabilitiesSetHostCPU method
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 2ce9474c2a6ba3df4977068dcee35d3fa5468749)
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1785207
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1785211
Message-Id: <20200203180726.2203691-3-berrange@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/conf/capabilities.c | 21 ---------------------
src/conf/capabilities.h | 6 ------
src/libvirt_private.syms | 1 -
3 files changed, 28 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 9a39858280..bf1d9936ed 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -368,27 +368,6 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMAPtr caps,
g_ptr_array_add(caps->cells, cell);
}
-
-/**
- * virCapabilitiesSetHostCPU:
- * @caps: capabilities to extend
- * @cpu: CPU definition
- *
- * Sets host CPU specification
- */
-int
-virCapabilitiesSetHostCPU(virCapsPtr caps,
- virCPUDefPtr cpu)
-{
- if (cpu == NULL)
- return -1;
-
- caps->host.cpu = cpu;
-
- return 0;
-}
-
-
/**
* virCapabilitiesAllocMachines:
* @machines: machine variants for emulator ('pc', or 'isapc', etc)
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index f604e7b95e..4a49e94aa5 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -258,12 +258,6 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMAPtr caps,
int npageinfo,
virCapsHostNUMACellPageInfoPtr pageinfo);
-
-int
-virCapabilitiesSetHostCPU(virCapsPtr caps,
- virCPUDefPtr cpu);
-
-
virCapsGuestMachinePtr *
virCapabilitiesAllocMachines(const char *const *names,
int nnames);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b97906b852..afa7d4fcae 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -77,7 +77,6 @@ virCapabilitiesHostSecModelAddBaseLabel;
virCapabilitiesInitCaches;
virCapabilitiesInitPages;
virCapabilitiesNew;
-virCapabilitiesSetHostCPU;
virCapabilitiesSetNetPrefix;
--
2.25.0

View File

@ -0,0 +1,144 @@
From 9b070e02e7b5bb95728a1fcdc8b7dfaaacc5f30a Mon Sep 17 00:00:00 2001
Message-Id: <9b070e02e7b5bb95728a1fcdc8b7dfaaacc5f30a@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 24 Mar 2020 16:25:55 +0100
Subject: [PATCH] conf: rename 'namespace' property of struct
_virStorageSourceNVMeDef
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
While 'namespace' is not a reserved word in C, it is in C++. Our
compilers are happy with it but syntax-hilighting in some editors
hilights is as a keyword. Rename it to prevent confusion.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 5793b8baa75747860f6ba97470969047e60c8579)
https://bugzilla.redhat.com/show_bug.cgi?id=1804617
Message-Id: <bfe6cf10a95868ae56a91f362a1ea50667754027.1585063415.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 12 ++++++------
src/qemu/qemu_block.c | 2 +-
src/util/virhostdev.c | 2 +-
src/util/virstoragefile.c | 4 ++--
src/util/virstoragefile.h | 2 +-
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8aec85e83c..1e8518139c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6054,7 +6054,7 @@ virDomainDiskDefValidate(const virDomainDef *def,
if (disk->src->type == VIR_STORAGE_TYPE_NVME) {
/* NVMe namespaces start from 1 */
- if (disk->src->nvme->namespace == 0) {
+ if (disk->src->nvme->namespc == 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("NVMe namespace can't be zero"));
return -1;
@@ -9433,7 +9433,7 @@ virDomainDiskSourceNVMeParse(xmlNodePtr node,
{
g_autoptr(virStorageSourceNVMeDef) nvme = NULL;
g_autofree char *type = NULL;
- g_autofree char *namespace = NULL;
+ g_autofree char *namespc = NULL;
g_autofree char *managed = NULL;
xmlNodePtr address;
@@ -9452,16 +9452,16 @@ virDomainDiskSourceNVMeParse(xmlNodePtr node,
return -1;
}
- if (!(namespace = virXMLPropString(node, "namespace"))) {
+ if (!(namespc = virXMLPropString(node, "namespace"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing 'namespace' attribute to disk source"));
return -1;
}
- if (virStrToLong_ull(namespace, NULL, 10, &nvme->namespace) < 0) {
+ if (virStrToLong_ull(namespc, NULL, 10, &nvme->namespc) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("malformed namespace '%s'"),
- namespace);
+ namespc);
return -1;
}
@@ -24444,7 +24444,7 @@ virDomainDiskSourceNVMeFormat(virBufferPtr attrBuf,
virBufferAddLit(attrBuf, " type='pci'");
virBufferAsprintf(attrBuf, " managed='%s'",
virTristateBoolTypeToString(nvme->managed));
- virBufferAsprintf(attrBuf, " namespace='%llu'", nvme->namespace);
+ virBufferAsprintf(attrBuf, " namespace='%llu'", nvme->namespc);
virPCIDeviceAddressFormat(childBuf, nvme->pciAddr, false);
}
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 73cb5ba4bc..5697d4fc73 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -1008,7 +1008,7 @@ qemuBlockStorageSourceGetNVMeProps(virStorageSourcePtr src)
ignore_value(virJSONValueObjectCreate(&ret,
"s:driver", "nvme",
"s:device", pciAddr,
- "U:namespace", nvme->namespace,
+ "U:namespace", nvme->namespc,
NULL));
return ret;
}
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 9b4ea30216..9596482146 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -2256,7 +2256,7 @@ virHostdevGetNVMeDeviceList(virNVMeDeviceListPtr nvmeDevices,
continue;
if (!(dev = virNVMeDeviceNew(&srcNVMe->pciAddr,
- srcNVMe->namespace,
+ srcNVMe->namespc,
srcNVMe->managed)))
return -1;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index fa37840532..2e54620139 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2052,7 +2052,7 @@ virStorageSourceNVMeDefCopy(const virStorageSourceNVMeDef *src)
ret = g_new0(virStorageSourceNVMeDef, 1);
- ret->namespace = src->namespace;
+ ret->namespc = src->namespc;
ret->managed = src->managed;
virPCIDeviceAddressCopy(&ret->pciAddr, &src->pciAddr);
return ret;
@@ -2069,7 +2069,7 @@ virStorageSourceNVMeDefIsEqual(const virStorageSourceNVMeDef *a,
if (!a || !b)
return false;
- if (a->namespace != b->namespace ||
+ if (a->namespc != b->namespc ||
a->managed != b->managed ||
!virPCIDeviceAddressEqual(&a->pciAddr, &b->pciAddr))
return false;
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index c1430cadd1..0230f44652 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -246,7 +246,7 @@ struct _virStorageSourceInitiatorDef {
typedef struct _virStorageSourceNVMeDef virStorageSourceNVMeDef;
typedef virStorageSourceNVMeDef *virStorageSourceNVMeDefPtr;
struct _virStorageSourceNVMeDef {
- unsigned long long namespace;
+ unsigned long long namespc;
int managed; /* enum virTristateBool */
virPCIDeviceAddress pciAddr;
--
2.26.0

View File

@ -0,0 +1,83 @@
From f52197675b2babfafb1b89058e3fd01decebd8ab Mon Sep 17 00:00:00 2001
Message-Id: <f52197675b2babfafb1b89058e3fd01decebd8ab@dist-git>
From: Laine Stump <laine@redhat.com>
Date: Sun, 26 Apr 2020 13:04:12 -0400
Subject: [PATCH] conf: simplify logic when checking for AUTOASSIGN PCI
addresses
Old behavior: If the address was manually provided by config, copy
device AUTOASSIGN flag into the bus flag, and then later on in the
function *always* check for a match of the flags (which will always
match if the address came from config, since we just copied it).
New behavior: Don't mess with the bus flags - just directly check if
the AUTOASSIGN flag matches in bus and dev, but only make the check if
the address didn't come from config (i.e. it was auto-assigned by
libvirt).
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit fcdf87d3ef14de9dfb0acaf4b4445e1580dfc629)
https://bugzilla.redhat.com/1802592
Signed-off-by: Laine Stump <laine@redhat.com>
Message-Id: <20200426170415.18328-10-laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/domain_addr.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 53be6cd34b..05f036e3e6 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -358,18 +358,22 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
*/
if (busFlags & VIR_PCI_CONNECT_TYPES_ENDPOINT)
busFlags |= VIR_PCI_CONNECT_TYPES_ENDPOINT;
- /* Also allow manual specification of bus to override
- * libvirt's assumptions about whether or not hotplug
- * capability will be required.
- */
- if (devFlags & VIR_PCI_CONNECT_AUTOASSIGN)
- busFlags |= VIR_PCI_CONNECT_AUTOASSIGN;
/* if the device is a pci-bridge, allow manually
* assigning to any bus that would also accept a
* standard PCI device.
*/
if (devFlags & VIR_PCI_CONNECT_TYPE_PCI_BRIDGE)
devFlags |= VIR_PCI_CONNECT_TYPE_PCI_DEVICE;
+ } else if ((devFlags & VIR_PCI_CONNECT_AUTOASSIGN) &&
+ !(busFlags & VIR_PCI_CONNECT_AUTOASSIGN)) {
+ if (reportError) {
+ virReportError(errType,
+ _("The device at PCI address %s was auto-assigned "
+ "this address, but the PCI controller "
+ "with index='%d' doesn't allow auto-assignment"),
+ addrStr, addr->bus);
+ }
+ return false;
}
/* If this bus doesn't allow the type of connection (PCI
@@ -419,17 +423,6 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
addrStr, addr->bus, connectStr);
return false;
}
- if ((devFlags & VIR_PCI_CONNECT_AUTOASSIGN) &&
- !(busFlags & VIR_PCI_CONNECT_AUTOASSIGN)) {
- if (reportError) {
- virReportError(errType,
- _("The device at PCI address %s requires "
- "hotplug capability, but the PCI controller "
- "with index='%d' doesn't support hotplug"),
- addrStr, addr->bus);
- }
- return false;
- }
return true;
}
--
2.26.2

View File

@ -1,154 +0,0 @@
From 2566a32fae64fa5cc8a3d3c30778d0ea7d8c4faa Mon Sep 17 00:00:00 2001
Message-Id: <2566a32fae64fa5cc8a3d3c30778d0ea7d8c4faa@dist-git>
From: Yi Min Zhao <zyimin@linux.ibm.com>
Date: Mon, 8 Apr 2019 10:57:24 +0200
Subject: [PATCH] conf: use virXMLFormatElement() in
virDomainDeviceInfoFormat()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In order to add zPCI child element for PCI address, we update
virDomainDeviceInfoFormat() to format device info by helper function
virXMLFormatElement(). Then we could simply format zPCI address into
child buffer later.
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 0d6b87335c00451b0923ecc91d617f71e4135bf8)
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20190408085732.28684-8-abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/domain_conf.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e62f78471c..bcb0558bc3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6447,6 +6447,8 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
virDomainDeviceInfoPtr info,
unsigned int flags)
{
+ virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
+
if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) {
virBufferAsprintf(buf, "<boot order='%u'", info->bootIndex);
@@ -6491,13 +6493,13 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
return;
- virBufferAsprintf(buf, "<address type='%s'",
+ virBufferAsprintf(&attrBuf, " type='%s'",
virDomainDeviceAddressTypeToString(info->type));
switch ((virDomainDeviceAddressType) info->type) {
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
if (!virPCIDeviceAddressIsEmpty(&info->addr.pci)) {
- virBufferAsprintf(buf, " domain='0x%.4x' bus='0x%.2x' "
+ virBufferAsprintf(&attrBuf, " domain='0x%.4x' bus='0x%.2x' "
"slot='0x%.2x' function='0x%.1x'",
info->addr.pci.domain,
info->addr.pci.bus,
@@ -6505,13 +6507,13 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
info->addr.pci.function);
}
if (info->addr.pci.multi) {
- virBufferAsprintf(buf, " multifunction='%s'",
- virTristateSwitchTypeToString(info->addr.pci.multi));
+ virBufferAsprintf(&attrBuf, " multifunction='%s'",
+ virTristateSwitchTypeToString(info->addr.pci.multi));
}
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
- virBufferAsprintf(buf, " controller='%d' bus='%d' target='%d' unit='%d'",
+ virBufferAsprintf(&attrBuf, " controller='%d' bus='%d' target='%d' unit='%d'",
info->addr.drive.controller,
info->addr.drive.bus,
info->addr.drive.target,
@@ -6519,34 +6521,34 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL:
- virBufferAsprintf(buf, " controller='%d' bus='%d' port='%d'",
+ virBufferAsprintf(&attrBuf, " controller='%d' bus='%d' port='%d'",
info->addr.vioserial.controller,
info->addr.vioserial.bus,
info->addr.vioserial.port);
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID:
- virBufferAsprintf(buf, " controller='%d' slot='%d'",
+ virBufferAsprintf(&attrBuf, " controller='%d' slot='%d'",
info->addr.ccid.controller,
info->addr.ccid.slot);
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB:
- virBufferAsprintf(buf, " bus='%d'", info->addr.usb.bus);
+ virBufferAsprintf(&attrBuf, " bus='%d'", info->addr.usb.bus);
if (virDomainUSBAddressPortIsValid(info->addr.usb.port)) {
- virBufferAddLit(buf, " port='");
- virDomainUSBAddressPortFormatBuf(buf, info->addr.usb.port);
- virBufferAddLit(buf, "'");
+ virBufferAddLit(&attrBuf, " port='");
+ virDomainUSBAddressPortFormatBuf(&attrBuf, info->addr.usb.port);
+ virBufferAddLit(&attrBuf, "'");
}
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
if (info->addr.spaprvio.has_reg)
- virBufferAsprintf(buf, " reg='0x%llx'", info->addr.spaprvio.reg);
+ virBufferAsprintf(&attrBuf, " reg='0x%llx'", info->addr.spaprvio.reg);
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW:
- virBufferAsprintf(buf, " cssid='0x%x' ssid='0x%x' devno='0x%04x'",
+ virBufferAsprintf(&attrBuf, " cssid='0x%x' ssid='0x%x' devno='0x%04x'",
info->addr.ccw.cssid,
info->addr.ccw.ssid,
info->addr.ccw.devno);
@@ -6557,15 +6559,15 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
if (info->addr.isa.iobase > 0)
- virBufferAsprintf(buf, " iobase='0x%x'", info->addr.isa.iobase);
+ virBufferAsprintf(&attrBuf, " iobase='0x%x'", info->addr.isa.iobase);
if (info->addr.isa.irq > 0)
- virBufferAsprintf(buf, " irq='0x%x'", info->addr.isa.irq);
+ virBufferAsprintf(&attrBuf, " irq='0x%x'", info->addr.isa.irq);
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
- virBufferAsprintf(buf, " slot='%u'", info->addr.dimm.slot);
+ virBufferAsprintf(&attrBuf, " slot='%u'", info->addr.dimm.slot);
if (info->addr.dimm.base)
- virBufferAsprintf(buf, " base='0x%llx'", info->addr.dimm.base);
+ virBufferAsprintf(&attrBuf, " base='0x%llx'", info->addr.dimm.base);
break;
@@ -6575,7 +6577,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
break;
}
- virBufferAddLit(buf, "/>\n");
+ virXMLFormatElement(buf, "address", &attrBuf, NULL);
+
+ virBufferFreeAndReset(&attrBuf);
}
static int
--
2.22.0

View File

@ -0,0 +1,70 @@
From d77f180068dab8747f5e2c098a9c59213ce19108 Mon Sep 17 00:00:00 2001
Message-Id: <d77f180068dab8747f5e2c098a9c59213ce19108@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Wed, 4 Mar 2020 12:42:29 +0100
Subject: [PATCH] conf: use virXMLFormatElement in virDomainFSDefFormat
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use the virXMLFormatElement helper to format the driver element
to simplify adding further sub-elements.
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit 3efdbae5bf054d1a2bdc98fdccff0273abe54c88)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
Message-Id: <966ad0eebcb1ae5f20f59fc6cc84008bbfa6426f.1583322090.git.jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/domain_conf.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8a5f14d6cb..88117187c8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -24991,7 +24991,7 @@ virDomainFSDefFormat(virBufferPtr buf,
const char *fsdriver = virDomainFSDriverTypeToString(def->fsdriver);
const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy);
const char *src = def->src->path;
- g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
if (!type) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -25016,25 +25016,21 @@ virDomainFSDefFormat(virBufferPtr buf,
virBufferAdjustIndent(buf, 2);
if (def->fsdriver) {
- virBufferAsprintf(&driverBuf, " type='%s'", fsdriver);
+ virBufferAsprintf(&driverAttrBuf, " type='%s'", fsdriver);
if (def->format)
- virBufferAsprintf(&driverBuf, " format='%s'",
+ virBufferAsprintf(&driverAttrBuf, " format='%s'",
virStorageFileFormatTypeToString(def->format));
/* Don't generate anything if wrpolicy is set to default */
if (def->wrpolicy)
- virBufferAsprintf(&driverBuf, " wrpolicy='%s'", wrpolicy);
+ virBufferAsprintf(&driverAttrBuf, " wrpolicy='%s'", wrpolicy);
}
- virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
+ virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio);
- if (virBufferUse(&driverBuf)) {
- virBufferAddLit(buf, "<driver");
- virBufferAddBuffer(buf, &driverBuf);
- virBufferAddLit(buf, "/>\n");
- }
+ virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
switch (def->type) {
case VIR_DOMAIN_FS_TYPE_MOUNT:
--
2.25.1

View File

@ -1,110 +0,0 @@
From 5b3cf2163da13ac79129ca2bb85ae1908922644c Mon Sep 17 00:00:00 2001
Message-Id: <5b3cf2163da13ac79129ca2bb85ae1908922644c@dist-git>
From: Laine Stump <laine@laine.org>
Date: Fri, 1 Feb 2019 20:29:27 -0500
Subject: [PATCH] configure: change HAVE_FIREWALLD to WITH_FIREWALLD
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Support for firewalld is a feature that can be selectively enabled or
disabled (using --with-firewalld/--without-firewalld), not merely
something that must be accounted for in the code if it is present with
no exceptions. It is more consistent with other usage in libvirt to
use WITH_FIREWALLD rather than HAVE_FIREWALLD.
Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 4bf0f390ed57307050a213f3f6364061f2717b00)
https://bugzilla.redhat.com/1650320
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
m4/virt-firewalld.m4 | 4 ++--
src/network/bridge_driver.c | 6 +++---
src/nwfilter/nwfilter_driver.c | 6 +++---
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/m4/virt-firewalld.m4 b/m4/virt-firewalld.m4
index 08d2ff83d6..89efa47589 100644
--- a/m4/virt-firewalld.m4
+++ b/m4/virt-firewalld.m4
@@ -32,10 +32,10 @@ AC_DEFUN([LIBVIRT_CHECK_FIREWALLD], [
if test "x$with_dbus" != "xyes" ; then
AC_MSG_ERROR([You must have dbus enabled for firewalld support])
fi
- AC_DEFINE_UNQUOTED([HAVE_FIREWALLD], [1], [whether firewalld support is enabled])
+ AC_DEFINE_UNQUOTED([WITH_FIREWALLD], [1], [whether firewalld support is enabled])
fi
- AM_CONDITIONAL([HAVE_FIREWALLD], [test "x$with_firewalld" != "xno"])
+ AM_CONDITIONAL([WITH_FIREWALLD], [test "x$with_firewalld" != "xno"])
])
AC_DEFUN([LIBVIRT_RESULT_FIREWALLD], [
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 1ad95d524c..d153a8cdb6 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -538,7 +538,7 @@ networkAutostartConfig(virNetworkObjPtr obj,
}
-#if HAVE_FIREWALLD
+#ifdef WITH_FIREWALLD
static DBusHandlerResult
firewalld_dbus_filter_bridge(DBusConnection *connection ATTRIBUTE_UNUSED,
DBusMessage *message,
@@ -659,7 +659,7 @@ networkStateInitialize(bool privileged,
int ret = -1;
char *configdir = NULL;
char *rundir = NULL;
-#ifdef HAVE_FIREWALLD
+#ifdef WITH_FIREWALLD
DBusConnection *sysbus = NULL;
#endif
@@ -757,7 +757,7 @@ networkStateInitialize(bool privileged,
network_driver->networkEventState = virObjectEventStateNew();
-#ifdef HAVE_FIREWALLD
+#ifdef WITH_FIREWALLD
if (!(sysbus = virDBusGetSystemBus())) {
VIR_WARN("DBus not available, disabling firewalld support "
"in bridge_network_driver: %s", virGetLastErrorMessage());
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index ed34586105..a657b750e6 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -79,7 +79,7 @@ static void nwfilterDriverUnlock(void)
virMutexUnlock(&driver->lock);
}
-#if HAVE_FIREWALLD
+#ifdef WITH_FIREWALLD
static DBusHandlerResult
nwfilterFirewalldDBusFilter(DBusConnection *connection ATTRIBUTE_UNUSED,
@@ -148,7 +148,7 @@ nwfilterDriverInstallDBusMatches(DBusConnection *sysbus)
return ret;
}
-#else /* HAVE_FIREWALLD */
+#else /* WITH_FIREWALLD */
static void
nwfilterDriverRemoveDBusMatches(void)
@@ -161,7 +161,7 @@ nwfilterDriverInstallDBusMatches(DBusConnection *sysbus ATTRIBUTE_UNUSED)
return 0;
}
-#endif /* HAVE_FIREWALLD */
+#endif /* WITH_FIREWALLD */
static int
virNWFilterTriggerRebuildImpl(void *opaque)
--
2.20.1

View File

@ -1,280 +0,0 @@
From f89135129d722dca4e5eb7dbcc6845ab757f2e08 Mon Sep 17 00:00:00 2001
Message-Id: <f89135129d722dca4e5eb7dbcc6845ab757f2e08@dist-git>
From: Laine Stump <laine@laine.org>
Date: Fri, 1 Feb 2019 20:29:30 -0500
Subject: [PATCH] configure: selectively install a firewalld 'libvirt' zone
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In the past (when both libvirt and firewalld used iptables), if either
libvirt's rules *OR* firewalld's rules accepted a packet, it would
be accepted. This was because libvirt and firewalld rules were
processed during the same kernel hook, and a single ACCEPT result
would terminate the rule traversal and cause the packet to be
accepted.
But now firewalld can use nftables for its backend, while libvirt's
firewall rules are still using iptables; iptables rules are still
processed, but at a different time during packet processing
(i.e. during a different hook) than the firewalld nftables rules. The
result is that a packet must be accepted by *BOTH* the libvirt
iptables rules *AND* the firewalld nftable rules in order to be
accepted.
This causes pain because
1) libvirt always adds rules to permit DNS and DHCP (and sometimes
TFTP) from guests to the host network's bridge interface. But
libvirt's bridges are in firewalld's "default" zone (which is usually
the zone called "public"). The public zone allows ssh, but doesn't
allow DNS, DHCP, or TFTP. So even though libvirt's rules allow the
DHCP and DNS traffic, the firewalld rules (now processed during a
different hook) dont, thus guests connected to libvirt's bridges can't
acquire an IP address from DHCP, nor can they make DNS queries to the
DNS server libvirt has setup on the host. (This could be solved by
modifying the default firewalld zone to allow DNS and DHCP, but that
would open *all* interfaces in the default zone to those services,
which is most likely not what the host's admin wants.)
2) Even though libvirt adds iptables rules to allow forwarded traffic
to pass the iptables hook, firewalld's higher level "rich rules" don't
yet have the ability to configure the acceptance of forwarded traffic
(traffic that is going somewhere beyond the host), so any traffic that
needs to be forwarded from guests to the network beyond the host is
rejected during the nftables hook by the default zone's "default
reject" policy (which rejects all traffic in the zone not specifically
allowed by the rules in the zone, whether that traffic is destined to
be forwarded or locally received by the host).
libvirt can't send "direct" nftables rules (firewalld only supports
direct/passthrough rules for iptables), so we can't solve this problem
by just sending explicit nftables rules instead of explicit iptables
rules (which, if it could be done, would place libvirt's rules in the
same hook as firewalld's native rules, and thus eliminate the need for
packets to be accepted by both libvirt's and firewalld's own rules).
However, we can take advantage of a quirk in firewalld zones that have
a default policy of "accept" (meaning any packet that doesn't match a
specific rule in the zone will be *accepted*) - this default accept will
also accept forwarded traffic (not just traffic destined for the host).
Of course we don't want to modify firewalld's default zone in that
way, because that would affect the filtering of traffic coming into
the host from other interfaces using that zone. Instead, we will
create a new zone called "libvirt". The libvirt zone will have a
default policy of accept so that forwarded traffic can pass and list
specific services that will be allowed into the host from guests (DNS,
DHCP, SSH, and TFTP).
But the same default accept policy that fixes forwarded traffic also
causes *all* traffic from guest to host to be accepted. To close this
new hole, the libvirt zone can take advantage of a new feature in
firewalld (currently slated for firewalld-0.7.0) - priorities for rich
rules - to add a low priority rule that rejects all local traffic (but
leaves alone all forwarded traffic).
So, our new zone will start with a list of services that are allowed
(dhcp, dns, tftp, and ssh to start, but configurable via any firewalld
management application, or direct editing of the zone file in
/etc/firewalld/zones/libvirt.xml), followed by a low priority
<reject/> rule (to reject all other traffic from guest to host), and
finally with a default policy of accept (to allow forwarded traffic).
This patch only creates the zonefile for the new zone, and implements
a configure.ac option to selectively enable/disable installation of
the new zone. A separate patch contains the necessary code to actually
place bridge interfaces in the libvirt zone.
Why do we need a configure option to disable installation of the new
libvirt zone? It uses a new firewalld attribute that sets the priority
of a rich rule; this feature first appears in firewalld-0.7.0 (unless
it has been backported to am earlier firewalld by a downstream
maintainer). If the file were installed on a system with firewalld
that didn't support rule priorities, firewalld would log an error
every time it restarted, causing confusion and lots of extra bug
reports.
So we add two new configure.ac switches to avoid polluting the system
logs with this error on systems that don't support rule priorities -
"--with-firewalld-zone" and "--without-firewalld-zone". A package
builder can use these to include/exclude the libvirt zone file in the
installation. If firewalld is enabled (--with-firewalld), the default
is --with-firewalld-zone, but it can be disabled during configure
(using --without-firewalld-zone). Targets that are using a firewalld
version too old to support the rule priority setting in the libvirt
zone file can simply add --without-firewalld-zone to their configure
commandline.
These switches only affect whether or not the libvirt zone file is
*installed* in /usr/lib/firewalld/zones, but have no effect on whether
or not libvirt looks for a zone called libvirt and tries to use it.
NB: firewalld zones can only be added to the permanent config of
firewalld, and won't be loaded/enabled until firewalld is restarted,
so at package install/upgrade time we have to restart firewalld. For
rpm-based distros, this is done in the libvirt.spec file by calling
the %firewalld_restart rpm macro, which is a part of the
firewalld-filesystem package. (For distros that don't use rpm
packages, the command "firewalld-cmd --reload" will have the same
effect).
Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 3b71f2e42dc6c5453d09136578bfb868874da088)
https://bugzilla.redhat.com/1650320
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
configure.ac | 3 +++
libvirt.spec.in | 31 +++++++++++++++++++++++++
m4/virt-firewalld-zone.m4 | 45 +++++++++++++++++++++++++++++++++++++
src/network/Makefile.inc.am | 10 ++++++++-
src/network/libvirt.zone | 23 +++++++++++++++++++
5 files changed, 111 insertions(+), 1 deletion(-)
create mode 100644 m4/virt-firewalld-zone.m4
create mode 100644 src/network/libvirt.zone
diff --git a/configure.ac b/configure.ac
index e25bf0a6ec..3da26484d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -247,6 +247,7 @@ LIBVIRT_ARG_CAPNG
LIBVIRT_ARG_CURL
LIBVIRT_ARG_DBUS
LIBVIRT_ARG_FIREWALLD
+LIBVIRT_ARG_FIREWALLD_ZONE
LIBVIRT_ARG_FUSE
LIBVIRT_ARG_GLUSTER
LIBVIRT_ARG_HAL
@@ -286,6 +287,7 @@ LIBVIRT_CHECK_DBUS
LIBVIRT_CHECK_DEVMAPPER
LIBVIRT_CHECK_DLOPEN
LIBVIRT_CHECK_FIREWALLD
+LIBVIRT_CHECK_FIREWALLD_ZONE
LIBVIRT_CHECK_FUSE
LIBVIRT_CHECK_GLUSTER
LIBVIRT_CHECK_GNUTLS
@@ -959,6 +961,7 @@ LIBVIRT_RESULT_CURL
LIBVIRT_RESULT_DBUS
LIBVIRT_RESULT_DLOPEN
LIBVIRT_RESULT_FIREWALLD
+LIBVIRT_RESULT_FIREWALLD_ZONE
LIBVIRT_RESULT_FUSE
LIBVIRT_RESULT_GLUSTER
LIBVIRT_RESULT_GNUTLS
diff --git a/m4/virt-firewalld-zone.m4 b/m4/virt-firewalld-zone.m4
new file mode 100644
index 0000000000..b67d1a0b2f
--- /dev/null
+++ b/m4/virt-firewalld-zone.m4
@@ -0,0 +1,45 @@
+dnl firewalld_zone check - whether or not to install the firewall "libvirt" zone
+dnl
+dnl Copyright (C) 2019 Red Hat, Inc.
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library. If not, see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
+AC_DEFUN([LIBVIRT_ARG_FIREWALLD_ZONE], [
+ LIBVIRT_ARG_WITH([FIREWALLD_ZONE], [Whether to install firewalld libvirt zone], [check])
+])
+
+AC_DEFUN([LIBVIRT_CHECK_FIREWALLD_ZONE], [
+ AC_REQUIRE([LIBVIRT_CHECK_FIREWALLD])
+ AC_MSG_CHECKING([for whether to install firewalld libvirt zone])
+
+ if test "x$with_firewalld_zone" = "xcheck" ; then
+ with_firewalld_zone=$with_firewalld
+ fi
+
+ if test "x$with_firewalld_zone" = "xyes" ; then
+ if test "x$with_firewalld" != "xyes" ; then
+ AC_MSG_ERROR([You must have firewalld support enabled to enable firewalld-zone])
+ fi
+ AC_DEFINE_UNQUOTED([WITH_FIREWALLD_ZONE], [1], [whether firewalld libvirt zone is installed])
+ fi
+
+ AM_CONDITIONAL([WITH_FIREWALLD_ZONE], [test "x$with_firewalld_zone" != "xno"])
+ AC_MSG_RESULT($with_firewalld_zone)
+])
+
+AC_DEFUN([LIBVIRT_RESULT_FIREWALLD_ZONE], [
+ LIBVIRT_RESULT([firewalld-zone], [$with_firewalld_zone])
+])
diff --git a/src/network/Makefile.inc.am b/src/network/Makefile.inc.am
index 508c8c0422..cbaaa7ea68 100644
--- a/src/network/Makefile.inc.am
+++ b/src/network/Makefile.inc.am
@@ -87,6 +87,11 @@ install-data-network:
( cd $(DESTDIR)$(confdir)/qemu/networks/autostart && \
rm -f default.xml && \
$(LN_S) ../default.xml default.xml )
+if WITH_FIREWALLD_ZONE
+ $(MKDIR_P) "$(DESTDIR)$(prefix)/lib/firewalld/zones"
+ $(INSTALL_DATA) $(srcdir)/network/libvirt.zone \
+ $(DESTDIR)$(prefix)/lib/firewalld/zones/libvirt.xml
+endif WITH_FIREWALLD_ZONE
uninstall-data-network:
rm -f $(DESTDIR)$(confdir)/qemu/networks/autostart/default.xml
@@ -95,10 +100,13 @@ uninstall-data-network:
rmdir "$(DESTDIR)$(confdir)/qemu/networks" || :
rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/network" ||:
rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/network" ||:
+if WITH_FIREWALLD_ZONE
+ rm -f $(DESTDIR)$(prefix)/lib/firewalld/zones/libvirt.xml
+endif WITH_FIREWALLD_ZONE
endif WITH_NETWORK
-EXTRA_DIST += network/default.xml
+EXTRA_DIST += network/default.xml network/libvirt.zone
.PHONY: \
install-data-network \
diff --git a/src/network/libvirt.zone b/src/network/libvirt.zone
new file mode 100644
index 0000000000..bf81db1b6e
--- /dev/null
+++ b/src/network/libvirt.zone
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<zone target="ACCEPT">
+ <short>libvirt</short>
+
+ <description>
+ The default policy of "ACCEPT" allows all packets to/from
+ interfaces in the zone to be forwarded, while the (*low priority*)
+ reject rule blocks any traffic destined for the host, except those
+ services explicitly listed (that list can be modified as required
+ by the local admin). This zone is intended to be used only by
+ libvirt virtual networks - libvirt will add the bridge devices for
+ all new virtual networks to this zone by default.
+ </description>
+
+<rule priority='32767'>
+ <reject/>
+</rule>
+<service name='dhcp'/>
+<service name='dhcpv6'/>
+<service name='dns'/>
+<service name='ssh'/>
+<service name='tftp'/>
+</zone>
--
2.20.1

View File

@ -1,202 +0,0 @@
From 41a79702b10fc039aa76524626b77f91dc01edbd Mon Sep 17 00:00:00 2001
Message-Id: <41a79702b10fc039aa76524626b77f91dc01edbd@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Mon, 17 Dec 2018 16:24:32 +0100
Subject: [PATCH] cpu: Add support for "stibp" x86_64 feature
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
QEMU commit v3.1.0-4-g0e89165829
KVM patch: https://lore.kernel.org/lkml/20181205191956.31480-1-ehabkost@redhat.com/
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit eb1b551d21e316c1e80aba0b2af6969fdd849f0c)
Conflicts:
src/cpu_map/x86_features.xml
- cpu_map.xml is still monolithic in RHEL-8
https://bugzilla.redhat.com/show_bug.cgi?id=1655032
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/cpu/cpu_map.xml | 3 +++
tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-disabled.xml | 2 +-
tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-guest.xml | 1 +
tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-host.xml | 1 +
tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-disabled.xml | 2 +-
tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-guest.xml | 1 +
tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-host.xml | 1 +
tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-disabled.xml | 2 +-
tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-guest.xml | 1 +
tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-host.xml | 1 +
tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-disabled.xml | 2 +-
tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-guest.xml | 1 +
tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-host.xml | 1 +
13 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index cdb023e936..095d49a69a 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -328,6 +328,9 @@
<feature name='spec-ctrl'>
<cpuid eax_in='0x07' ecx_in='0x00' edx='0x04000000'/>
</feature>
+ <feature name='stibp'>
+ <cpuid eax_in='0x07' ecx_in='0x00' edx='0x08000000'/>
+ </feature>
<feature name='ssbd'>
<cpuid eax_in='0x07' ecx_in='0x00' edx='0x80000000'/>
</feature>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-disabled.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-disabled.xml
index e033bb141f..5c9cfa9bd6 100644
--- a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-disabled.xml
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-disabled.xml
@@ -1,6 +1,6 @@
<!-- Features disabled by QEMU -->
<cpudata arch='x86'>
<cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x0800c1dc' edx='0xb0600000'/>
- <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x04000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x0c000000'/>
<cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-guest.xml
index 4fa4770208..5d3093cec1 100644
--- a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-guest.xml
@@ -23,6 +23,7 @@
<feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='intel-pt'/>
+ <feature policy='require' name='stibp'/>
<feature policy='require' name='xsaveopt'/>
<feature policy='require' name='pdpe1gb'/>
<feature policy='require' name='abm'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-host.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-host.xml
index 25690c099c..a534d2dec5 100644
--- a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-host.xml
+++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-ibrs-host.xml
@@ -24,6 +24,7 @@
<feature name='arat'/>
<feature name='tsc_adjust'/>
<feature name='intel-pt'/>
+ <feature name='stibp'/>
<feature name='xsaveopt'/>
<feature name='pdpe1gb'/>
<feature name='abm'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-disabled.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-disabled.xml
index aacc7a2b14..ec299652f7 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-disabled.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-disabled.xml
@@ -1,6 +1,6 @@
<!-- Features disabled by QEMU -->
<cpudata arch='x86'>
<cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x0804c1fc' edx='0xb0600000'/>
- <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x00001000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x00001000' ecx='0x00000000' edx='0x08000000'/>
<cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-guest.xml
index a66c7a5644..d8aaaad29d 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-guest.xml
@@ -24,6 +24,7 @@
<feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='cmt'/>
+ <feature policy='require' name='stibp'/>
<feature policy='require' name='xsaveopt'/>
<feature policy='require' name='pdpe1gb'/>
<feature policy='require' name='abm'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-host.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-host.xml
index 624d71db20..9bac4b4648 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-host.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2609-v3-host.xml
@@ -25,6 +25,7 @@
<feature name='arat'/>
<feature name='tsc_adjust'/>
<feature name='cmt'/>
+ <feature name='stibp'/>
<feature name='xsaveopt'/>
<feature name='pdpe1gb'/>
<feature name='abm'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-disabled.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-disabled.xml
index d904808cec..85369d755c 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-disabled.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-disabled.xml
@@ -1,7 +1,7 @@
<!-- Features disabled by QEMU -->
<cpudata arch='x86'>
<cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x0804c1fc' edx='0xb0600000'/>
- <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x00001000' ecx='0x00000000' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x00001000' ecx='0x00000000' edx='0x08000000'/>
<cpuid eax_in='0x0000000f' ecx_in='0x01' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000006'/>
<cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
</cpudata>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-guest.xml
index 7b93df3f1b..7718d7ca59 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-guest.xml
@@ -21,6 +21,7 @@
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='cmt'/>
<feature policy='require' name='intel-pt'/>
+ <feature policy='require' name='stibp'/>
<feature policy='require' name='mbm_total'/>
<feature policy='require' name='mbm_local'/>
<feature policy='require' name='pdpe1gb'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-host.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-host.xml
index 5078420c7a..43a0b93ab4 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-host.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2623-v4-host.xml
@@ -26,6 +26,7 @@
<feature name='tsc_adjust'/>
<feature name='cmt'/>
<feature name='intel-pt'/>
+ <feature name='stibp'/>
<feature name='xsaveopt'/>
<feature name='mbm_total'/>
<feature name='mbm_local'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-disabled.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-disabled.xml
index b5c70a9dc4..a5b85a15c2 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-disabled.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-disabled.xml
@@ -1,7 +1,7 @@
<!-- Features disabled by QEMU -->
<cpudata arch='x86'>
<cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x0804c1fc' edx='0xb0600000'/>
- <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x00001000' ecx='0x00000008' edx='0x00000000'/>
+ <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x00001000' ecx='0x00000008' edx='0x08000000'/>
<cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x00000008' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
<cpuid eax_in='0x0000000f' ecx_in='0x01' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000006'/>
<cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-guest.xml
index 480127f341..8f014f6e28 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-guest.xml
@@ -23,6 +23,7 @@
<feature policy='require' name='clflushopt'/>
<feature policy='require' name='intel-pt'/>
<feature policy='require' name='pku'/>
+ <feature policy='require' name='stibp'/>
<feature policy='require' name='xsaves'/>
<feature policy='require' name='mbm_total'/>
<feature policy='require' name='mbm_local'/>
diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-host.xml b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-host.xml
index 680b10acef..9de76fd640 100644
--- a/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-host.xml
+++ b/tests/cputestdata/x86_64-cpuid-Xeon-Gold-5115-host.xml
@@ -24,6 +24,7 @@
<feature name='clflushopt'/>
<feature name='intel-pt'/>
<feature name='pku'/>
+ <feature name='stibp'/>
<feature name='xsaves'/>
<feature name='mbm_total'/>
<feature name='mbm_local'/>
--
2.20.1

View File

@ -0,0 +1,53 @@
From 2145d7b6f4370dfcd7dadae7daf544767cde0392 Mon Sep 17 00:00:00 2001
Message-Id: <2145d7b6f4370dfcd7dadae7daf544767cde0392@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 26 May 2020 10:58:51 +0200
Subject: [PATCH] cpu: Change control flow in virCPUUpdateLive
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The updateLive CPU sub-driver function is supposed to be called only for
a subset of CPU definitions. Let's make it more obvious by turning a
negative test and return into a positive check.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 68c0b85ecb07c8cefcf4f4a2ffc28e123baa9e8c)
https://bugzilla.redhat.com/show_bug.cgi?id=1839999
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <2633727669ca50970bd10abe9b045e24b76028d1.1590483392.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index ae3a0acc10..1cb2dd04f4 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -647,13 +647,14 @@ virCPUUpdateLive(virArch arch,
if (!driver->updateLive)
return 1;
- if (cpu->mode != VIR_CPU_MODE_CUSTOM)
- return 1;
+ if (cpu->mode == VIR_CPU_MODE_CUSTOM) {
+ if (driver->updateLive(cpu, dataEnabled, dataDisabled) < 0)
+ return -1;
- if (driver->updateLive(cpu, dataEnabled, dataDisabled) < 0)
- return -1;
+ return 0;
+ }
- return 0;
+ return 1;
}
--
2.26.2

View File

@ -1,59 +0,0 @@
From b339a54e493d97a5616be8883d1a0b4ebcd149d3 Mon Sep 17 00:00:00 2001
Message-Id: <b339a54e493d97a5616be8883d1a0b4ebcd149d3@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 21 Jun 2019 09:25:18 +0200
Subject: [PATCH] cpu: Don't access invalid memory in virCPUx86Translate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem is that if there are no signatures for a CPU, then we
still allocate cpu->signatures (even though with size 0). Later,
we access cpu->signatures[0] if cpu->signatures is not NULL.
Invalid read of size 4
at 0x5F439D7: virCPUx86Translate (cpu_x86.c:2930)
by 0x5F3C239: virCPUTranslate (cpu.c:927)
by 0x57CE7A1: qemuProcessUpdateGuestCPU (qemu_process.c:5870)
...
Address 0xf752d40 is 0 bytes after a block of size 0 alloc'd
at 0x4C30EC6: calloc (vg_replace_malloc.c:711)
by 0x5DBDE4E: virAllocN (viralloc.c:190)
by 0x5F3E4FA: x86ModelCopySignatures (cpu_x86.c:990)
by 0x5F3E60F: x86ModelCopy (cpu_x86.c:1008)
by 0x5F3E7CB: x86ModelFromCPU (cpu_x86.c:1068)
by 0x5F4397E: virCPUx86Translate (cpu_x86.c:2922)
by 0x5F3C239: virCPUTranslate (cpu.c:927)
by 0x57CE7A1: qemuProcessUpdateGuestCPU (qemu_process.c:5870)
...
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 62cb9c335c43a722e81ac0a1ed6e1111ba1d428b)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <b36b22d237a7044a473e9b72de9763b2c603198c.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 24569a90f3..66aa5a612c 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -985,6 +985,9 @@ x86ModelCopySignatures(virCPUx86ModelPtr dst,
{
size_t i;
+ if (src->nsignatures == 0)
+ return 0;
+
if (VIR_ALLOC_N(dst->signatures, src->nsignatures) < 0)
return -1;
--
2.22.0

View File

@ -0,0 +1,100 @@
From 781e82d0330afe60ab1c366e43dfe8292fcf68eb Mon Sep 17 00:00:00 2001
Message-Id: <781e82d0330afe60ab1c366e43dfe8292fcf68eb@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 26 May 2020 10:58:53 +0200
Subject: [PATCH] cpu: Honor check='full' for host-passthrough CPUs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The check attribute was completely ignored for host-passthrough CPUs
even if they explicitly requested some features to be enabled. For
example, a domain with the following CPU definition
<cpu mode='host-passthrough' check='full'>
<feature policy='require' name='svm'/>
</cpu>
would happily start even when 'svm' cannot be enabled.
Let's call virCPUArchUpdateLive for host-passthrough CPUs with
VIR_CPU_CHECK_FULL to make sure the architecture specific code can
validate the provided virtual CPU against the desired definition.
https://bugzilla.redhat.com/show_bug.cgi?id=1515677
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit ac36a824641862dcac057c6403b27ab1e91874f5)
https://bugzilla.redhat.com/show_bug.cgi?id=1839999
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <b8d30055a0df31c423d6c1832ca0bfbf3eafd222.1590483392.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu.c | 3 ++-
src/cpu/cpu_x86.c | 10 +++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 1cb2dd04f4..f2a0f560f6 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -647,7 +647,8 @@ virCPUUpdateLive(virArch arch,
if (!driver->updateLive)
return 1;
- if (cpu->mode == VIR_CPU_MODE_CUSTOM) {
+ if (cpu->mode == VIR_CPU_MODE_CUSTOM ||
+ cpu->check == VIR_CPU_CHECK_FULL) {
if (driver->updateLive(cpu, dataEnabled, dataDisabled) < 0)
return -1;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 9e686a86d2..8c865bdaa4 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3009,8 +3009,10 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
virCPUDataPtr dataEnabled,
virCPUDataPtr dataDisabled)
{
+ bool hostPassthrough = cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH;
virCPUx86MapPtr map;
virCPUx86ModelPtr model = NULL;
+ virCPUx86ModelPtr modelDisabled = NULL;
virCPUx86Data enabled = VIR_CPU_X86_DATA_INIT;
virCPUx86Data disabled = VIR_CPU_X86_DATA_INIT;
virBuffer bufAdded = VIR_BUFFER_INITIALIZER;
@@ -3026,6 +3028,10 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
if (!(model = x86ModelFromCPU(cpu, map, -1)))
goto cleanup;
+ if (hostPassthrough &&
+ !(modelDisabled = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_DISABLE)))
+ goto cleanup;
+
if (dataEnabled &&
x86DataCopy(&enabled, &dataEnabled->data.x86) < 0)
goto cleanup;
@@ -3040,7 +3046,8 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
if (x86DataIsSubset(&model->data, &feature->data))
expected = VIR_CPU_FEATURE_REQUIRE;
- else
+ else if (!hostPassthrough ||
+ x86DataIsSubset(&modelDisabled->data, &feature->data))
expected = VIR_CPU_FEATURE_DISABLE;
if (expected == VIR_CPU_FEATURE_DISABLE &&
@@ -3101,6 +3108,7 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
cleanup:
x86ModelFree(model);
+ x86ModelFree(modelDisabled);
virCPUx86DataClear(&enabled);
virCPUx86DataClear(&disabled);
VIR_FREE(added);
--
2.26.2

View File

@ -1,176 +0,0 @@
From 992af2f6564b899142a2be5f342e0cdbdd13eadc Mon Sep 17 00:00:00 2001
Message-Id: <992af2f6564b899142a2be5f342e0cdbdd13eadc@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:59 +0200
Subject: [PATCH] cpu: Introduce virCPUDataAddFeature
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is a generic replacement for the former virCPUx86DataAddFeature,
which worked on the generic virCPUDataPtr anyway.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit df73078c612a70e48aa76e889a7026e2daa47b16)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Conflicts:
src/cpu/cpu_x86.h
- downstream did not switch to #pragma once
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <4e946f702092fe5eb4c8235dbb98402b30876a5f.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu.c | 33 +++++++++++++++++++++++++++++++++
src/cpu/cpu.h | 9 +++++++++
src/cpu/cpu_x86.c | 3 ++-
src/cpu/cpu_x86.h | 3 ---
src/libvirt_private.syms | 2 +-
src/qemu/qemu_capabilities.c | 2 +-
6 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index cc93c49418..a2d143c94a 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -1078,3 +1078,36 @@ virCPUValidateFeatures(virArch arch,
else
return 0;
}
+
+
+/**
+ * virCPUDataAddFeature:
+ *
+ * @cpuData: CPU data
+ * @name: feature to be added to @cpuData
+ *
+ * Adds a feature called @name to @cpuData.
+ *
+ * Returns 0 on success, -1 on error.
+ */
+int
+virCPUDataAddFeature(virCPUDataPtr cpuData,
+ const char *name)
+{
+ struct cpuArchDriver *driver;
+
+ VIR_DEBUG("arch=%s, cpuData=%p, name=%s",
+ virArchToString(cpuData->arch), cpuData, name);
+
+ if (!(driver = cpuGetSubDriver(cpuData->arch)))
+ return -1;
+
+ if (!driver->dataAddFeature) {
+ virReportError(VIR_ERR_NO_SUPPORT,
+ _("cannot add guest CPU feature for %s architecture"),
+ virArchToString(cpuData->arch));
+ return -1;
+ }
+
+ return driver->dataAddFeature(cpuData, name);
+}
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
index 81119b6aeb..e5fae31e30 100644
--- a/src/cpu/cpu.h
+++ b/src/cpu/cpu.h
@@ -121,6 +121,10 @@ typedef virCPUDefPtr
typedef int
(*virCPUArchValidateFeatures)(virCPUDefPtr cpu);
+typedef int
+(*virCPUArchDataAddFeature)(virCPUDataPtr cpuData,
+ const char *name);
+
struct cpuArchDriver {
const char *name;
const virArch *arch;
@@ -143,6 +147,7 @@ struct cpuArchDriver {
virCPUArchExpandFeatures expandFeatures;
virCPUArchCopyMigratable copyMigratable;
virCPUArchValidateFeatures validateFeatures;
+ virCPUArchDataAddFeature dataAddFeature;
};
@@ -260,6 +265,10 @@ virCPUValidateFeatures(virArch arch,
virCPUDefPtr cpu)
ATTRIBUTE_NONNULL(2);
+int
+virCPUDataAddFeature(virCPUDataPtr cpuData,
+ const char *name);
+
/* 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 3c1bd623db..ead962ae06 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3316,7 +3316,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData,
}
-int
+static int
virCPUx86DataAddFeature(virCPUDataPtr cpuData,
const char *name)
{
@@ -3361,4 +3361,5 @@ struct cpuArchDriver cpuDriverX86 = {
.expandFeatures = virCPUx86ExpandFeatures,
.copyMigratable = virCPUx86CopyMigratable,
.validateFeatures = virCPUx86ValidateFeatures,
+ .dataAddFeature = virCPUx86DataAddFeature,
};
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
index 8b51cef9c1..519024b7c0 100644
--- a/src/cpu/cpu_x86.h
+++ b/src/cpu/cpu_x86.h
@@ -45,7 +45,4 @@ uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData,
int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
const char *vendor);
-int virCPUx86DataAddFeature(virCPUDataPtr cpuData,
- const char *name);
-
#endif /* __VIR_CPU_X86_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 57508de0c1..a20e0593f0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1187,6 +1187,7 @@ virCPUCompare;
virCPUCompareXML;
virCPUConvertLegacy;
virCPUCopyMigratable;
+virCPUDataAddFeature;
virCPUDataCheckFeature;
virCPUDataFormat;
virCPUDataFree;
@@ -1205,7 +1206,6 @@ virCPUValidateFeatures;
# cpu/cpu_x86.h
virCPUx86DataAdd;
-virCPUx86DataAddFeature;
virCPUx86DataGetSignature;
virCPUx86DataSetSignature;
virCPUx86DataSetVendor;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 78be2d35f4..4be0ec305f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2916,7 +2916,7 @@ virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
continue;
- if (virCPUx86DataAddFeature(data, name) < 0)
+ if (virCPUDataAddFeature(data, name) < 0)
goto cleanup;
break;
--
2.22.0

View File

@ -1,159 +0,0 @@
From 6438640b53fef3e889c21a2ed016638b91c5ac80 Mon Sep 17 00:00:00 2001
Message-Id: <6438640b53fef3e889c21a2ed016638b91c5ac80@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Fri, 21 Jun 2019 09:24:44 +0200
Subject: [PATCH] cpu: allow include files for CPU definition
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Allow for syntax
<include filename="subdir/fooo.xml"/>
to reference other files in the CPU database directory
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit eda5f575f2a7530fc7f6471f88496778a9bc9fcb)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <800e5ebbc30502fd780a3ef84fe524f1dc0ffd67.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_map.c | 92 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 89 insertions(+), 3 deletions(-)
diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
index d263eb8cdd..333c7ef24f 100644
--- a/src/cpu/cpu_map.c
+++ b/src/cpu/cpu_map.c
@@ -1,7 +1,7 @@
/*
* cpu_map.c: internal functions for handling CPU mapping configuration
*
- * Copyright (C) 2009-2010 Red Hat, Inc.
+ * Copyright (C) 2009-2018 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
@@ -70,6 +70,89 @@ static int load(xmlXPathContextPtr ctxt,
return ret;
}
+static int
+cpuMapLoadInclude(const char *filename,
+ cpuMapLoadCallback cb,
+ void *data)
+{
+ xmlDocPtr xml = NULL;
+ xmlXPathContextPtr ctxt = NULL;
+ int ret = -1;
+ int element;
+ char *mapfile;
+
+ if (!(mapfile = virFileFindResource(filename,
+ abs_topsrcdir "/src/cpu",
+ PKGDATADIR)))
+ return -1;
+
+ VIR_DEBUG("Loading CPU map include from %s", mapfile);
+
+ if (!(xml = virXMLParseFileCtxt(mapfile, &ctxt)))
+ goto cleanup;
+
+ ctxt->node = xmlDocGetRootElement(xml);
+
+ for (element = 0; element < CPU_MAP_ELEMENT_LAST; element++) {
+ if (load(ctxt, element, cb, data) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot parse CPU map '%s'"), mapfile);
+ goto cleanup;
+ }
+ }
+
+ ret = 0;
+
+ cleanup:
+ xmlXPathFreeContext(ctxt);
+ xmlFreeDoc(xml);
+ VIR_FREE(mapfile);
+
+ return ret;
+}
+
+
+static int
+loadIncludes(xmlXPathContextPtr ctxt,
+ cpuMapLoadCallback callback,
+ void *data)
+{
+ int ret = -1;
+ xmlNodePtr ctxt_node;
+ xmlNodePtr *nodes = NULL;
+ int n;
+ size_t i;
+
+ ctxt_node = ctxt->node;
+
+ n = virXPathNodeSet("include", ctxt, &nodes);
+ if (n < 0)
+ goto cleanup;
+
+ for (i = 0; i < n; i++) {
+ char *filename = virXMLPropString(nodes[i], "filename");
+ if (!filename) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Missing 'filename' in CPU map include"));
+ goto cleanup;
+ }
+ VIR_DEBUG("Finding CPU map include '%s'", filename);
+ if (cpuMapLoadInclude(filename, callback, data) < 0) {
+ VIR_FREE(filename);
+ goto cleanup;
+ }
+ VIR_FREE(filename);
+ }
+
+ ret = 0;
+
+ cleanup:
+ ctxt->node = ctxt_node;
+ VIR_FREE(nodes);
+
+ return ret;
+}
+
int cpuMapLoad(const char *arch,
cpuMapLoadCallback cb,
@@ -88,7 +171,7 @@ int cpuMapLoad(const char *arch,
PKGDATADIR)))
return -1;
- VIR_DEBUG("Loading CPU map from %s", mapfile);
+ VIR_DEBUG("Loading '%s' CPU map from %s", NULLSTR(arch), mapfile);
if (arch == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -122,11 +205,14 @@ int cpuMapLoad(const char *arch,
for (element = 0; element < CPU_MAP_ELEMENT_LAST; element++) {
if (load(ctxt, element, cb, data) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse CPU map for %s architecture"), arch);
+ _("cannot parse CPU map '%s'"), mapfile);
goto cleanup;
}
}
+ if (loadIncludes(ctxt, cb, data) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
--
2.22.0

View File

@ -1,51 +0,0 @@
From 612913a764992dc1a9ae63762749ecee447427d7 Mon Sep 17 00:00:00 2001
Message-Id: <612913a764992dc1a9ae63762749ecee447427d7@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Fri, 21 Jun 2019 09:24:45 +0200
Subject: [PATCH] cpu: fix cleanup when signature parsing fails
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Two pieces of code accidentally jumped to the wrong label when they
failed causing incorrect cleanup, returning a partially initialized
CPU model struct.
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 118fcdd480ad38a3e8477f466f6a876dce7e9fa6)
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <5e9aedc6fd4f4570322a7d13626863bec0449283.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 89baf94d7d..124aa5fd5e 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1250,7 +1250,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid CPU signature family in model %s"),
model->name);
- goto cleanup;
+ goto error;
}
rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
@@ -1258,7 +1258,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid CPU signature model in model %s"),
model->name);
- goto cleanup;
+ goto error;
}
model->signature = x86MakeSignature(sigFamily, sigModel, 0);
--
2.22.0

Some files were not shown because too many files have changed in this diff Show More