Backport patches from upstream

Signed-off-by: jiang jiacheng <jiangjiacheng@huawei.com>
This commit is contained in:
jiang jiacheng 2023-01-04 12:02:07 +08:00
parent 3e5cb55b1a
commit adddc503d8
35 changed files with 2521 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From 0e6fcb0eb5e3eb499a3cc7232fa1b7bf9f1813a2 Mon Sep 17 00:00:00 2001
From: jiangdawei15 <jiangdawei15@huawei.com>
Date: Thu, 11 Aug 2022 21:24:35 +0800
Subject: [PATCH 06/22] conf: validate serial port model in ABI checks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The serial port model cannot be allowed to
change across migration as it affects ABI.
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dawei Jiang jiangdawei15@huawei.com
---
src/conf/domain_conf.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1689d92c51..2d1726af8f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23058,6 +23058,14 @@ virDomainSerialDefCheckABIStability(virDomainChrDefPtr src,
return false;
}
+ if (src->targetModel != dst->targetModel) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target serial model %s does not match source %s"),
+ virDomainChrSerialTargetModelTypeToString(dst->targetModel),
+ virDomainChrSerialTargetModelTypeToString(src->targetModel));
+ return false;
+ }
+
if (src->target.port != dst->target.port) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target serial port %d does not match source %d"),
--
2.33.0

View File

@ -0,0 +1,125 @@
From 04c5fee85547da11323b66b2fb79fb590e8307a1 Mon Sep 17 00:00:00 2001
From: jiangdawei15 <jiangdawei15@huawei.com>
Date: Thu, 18 Aug 2022 20:15:54 +0800
Subject: [PATCH 22/22] enum: Add helpers for converting virTristate* to a
plain bool
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The helpers will update the passed boolean if the tristate's value is
not _ABSENT.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/libvirt_private.syms | 2 ++
src/util/virenum.c | 54 ++++++++++++++++++++++++++++++++++++++++
src/util/virenum.h | 2 ++
3 files changed, 58 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f30eb7ffb5..a00e354859 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1965,9 +1965,11 @@ ebtablesRemoveForwardAllowIn;
virEnumFromString;
virEnumToString;
virTristateBoolFromBool;
+virTristateBoolToBool;
virTristateBoolTypeFromString;
virTristateBoolTypeToString;
virTristateSwitchFromBool;
+virTristateSwitchToBool;
virTristateSwitchTypeFromString;
virTristateSwitchTypeToString;
diff --git a/src/util/virenum.c b/src/util/virenum.c
index 26093bd795..dfedc28ba7 100644
--- a/src/util/virenum.c
+++ b/src/util/virenum.c
@@ -47,6 +47,33 @@ virTristateBoolFromBool(bool val)
}
+/**
+ * virTristateBoolToBool: The value pointed to by @b is
+ * updated if the tristate value @t is not absent.
+ *
+ * @t: a virTristateBool value
+ * @b: pointer to a boolean to be updated according to the value of @t
+ */
+void
+virTristateBoolToBool(virTristateBool t,
+ bool *b)
+{
+ switch (t) {
+ case VIR_TRISTATE_BOOL_YES:
+ *b = true;
+ break;
+
+ case VIR_TRISTATE_BOOL_NO:
+ *b = false;
+ break;
+
+ case VIR_TRISTATE_BOOL_ABSENT:
+ case VIR_TRISTATE_BOOL_LAST:
+ break;
+ }
+}
+
+
virTristateSwitch
virTristateSwitchFromBool(bool val)
{
@@ -57,6 +84,33 @@ virTristateSwitchFromBool(bool val)
}
+/**
+ * virTristateSwitchToBool: The value pointed to by @b
+ * is updated if the tristate value @t is not absent.
+ *
+ * @t: a virTristateSwitch value
+ * @b: pointer to a boolean to be updated according to the value of @t
+ */
+void
+virTristateSwitchToBool(virTristateSwitch t,
+ bool *b)
+{
+ switch (t) {
+ case VIR_TRISTATE_SWITCH_ON:
+ *b = true;
+ break;
+
+ case VIR_TRISTATE_SWITCH_OFF:
+ *b = false;
+ break;
+
+ case VIR_TRISTATE_SWITCH_ABSENT:
+ case VIR_TRISTATE_SWITCH_LAST:
+ break;
+ }
+}
+
+
int
virEnumFromString(const char * const *types,
unsigned int ntypes,
diff --git a/src/util/virenum.h b/src/util/virenum.h
index d74af35530..98f01d574d 100644
--- a/src/util/virenum.h
+++ b/src/util/virenum.h
@@ -68,7 +68,9 @@ VIR_ENUM_DECL(virTristateBool);
VIR_ENUM_DECL(virTristateSwitch);
virTristateBool virTristateBoolFromBool(bool val);
+void virTristateBoolToBool(virTristateBool t, bool *b);
virTristateSwitch virTristateSwitchFromBool(bool val);
+void virTristateSwitchToBool(virTristateSwitch t, bool *b);
/* the two enums must be in sync to be able to use helpers interchangeably in
* some special cases */
--
2.33.0

View File

@ -101,7 +101,7 @@
Summary: Library providing a simple virtualization API Summary: Library providing a simple virtualization API
Name: libvirt Name: libvirt
Version: 6.2.0 Version: 6.2.0
Release: 49 Release: 50
License: LGPLv2+ License: LGPLv2+
URL: https://libvirt.org/ URL: https://libvirt.org/
@ -432,6 +432,40 @@ Patch0319: migration-migration-pin-add-migrationpin-for-migrati.patch
Patch0320: migration-migration-pin-add-domainMigrationPid-for-q.patch Patch0320: migration-migration-pin-add-domainMigrationPid-for-q.patch
Patch0321: migration-multifd-pin-add-qemu-monitor-callback-func.patch Patch0321: migration-multifd-pin-add-qemu-monitor-callback-func.patch
Patch0322: migration-multifd-pin-support-migration-multifd-thre.patch Patch0322: migration-multifd-pin-support-migration-multifd-thre.patch
Patch0323: virInterfaceDefDevFormat-Add-missing-error-handling.patch
Patch0324: tests-Report-expected-monitor-command-for-simulated-.patch
Patch0325: testutils-Terminate-usage-string-with-a-new-line.patch
Patch0326: qemuxml2-argv-xml-data-x86-kvm-32-on-64-Add-machine-.patch
Patch0327: qemuDomainPinIOThread-Update-live-definition-after-p.patch
Patch0328: qemu-Log-which-API-is-trying-to-acquire-a-job.patch
Patch0329: qemuxml2argvtest-disk-vhostuser-Add-invocation-for-q.patch
Patch0330: qemuDomainAttachHostPCIDevice-Fix-coding-style.patch
Patch0331: test_driver-Don-t-leak-group_name.patch
Patch0332: virnwfilterbindingobj-Fix-virNWFilterBindingObjNew.patch
Patch0333: conf-validate-serial-port-model-in-ABI-checks.patch
Patch0334: qemu-Validate-domain-definition-even-on-migration.patch
Patch0335: enum-Add-helpers-for-converting-virTristate-to-a-pla.patch
Patch0336: qemu-fix-formatting-of-pflash-readonly-attribute.patch
Patch0337: qemu-do-crash-safe-creation-of-NVRAM-file.patch
Patch0338: virNetDevOpenvswitchUpdateVlan-fix-vlan-tag-update-e.patch
Patch0339: virNetDevOpenvswitchUpdateVlan-Use-space-for-indenta.patch
Patch0340: virbuftest-Increase-coverage.patch
Patch0341: tests-add-test-case-for-NVRAM-with-template.patch
Patch0342: tests-add-explicit-test-case-for-pflash-loader-lacki.patch
Patch0343: tests-Update-IPv4-in-IPv6-addresses.patch
Patch0344: sockettest-Check-for-IPv4-in-IPv6-parsing-and-format.patch
Patch0345: vircgroupmock-Be-wiser-about-detecting-fakerootdir-c.patch
Patch0346: tests-Allow-expansion-of-mocked-stat-symbols.patch
Patch0347: virsh-fflush-stdout-after-fputs.patch
Patch0348: qemu_cgroup-Drop-ENOENT-special-case-for-RNG-devices.patch
Patch0349: virConnectDomainEventRegisterAny-correct-docs.patch
Patch0350: virsh-Fix-integer-overflow-in-allocpages.patch
Patch0351: virNWFilterObjListFree-Prevent-null-pointer-derefern.patch
Patch0352: qemu-fix-one-more-race-on-undefining-and-create.patch
Patch0353: remote_daemon-Don-t-run-virStateCleanup-if-virStateR.patch
Patch0354: virDomainInputDefValidate-Validate-model.patch
Patch0355: virsh-Check-whether-enough-arguments-was-passed-to-i.patch
Patch0356: virNetDevSaveNetConfig-Pass-mode-to-virFileWriteStr.patch
Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon = %{version}-%{release}
Requires: libvirt-daemon-config-network = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release}
@ -2166,6 +2200,9 @@ exit 0
%changelog %changelog
* Wed Jan 04 2023 jiangjiacheng <jiangjiacheng@huawei.com> - 6.2.0-50
- backport patches from upstream
* Sat Dec 17 2022 zhengchuan <zhengchuan@huawei.com> - 6.2.0-49 * Sat Dec 17 2022 zhengchuan <zhengchuan@huawei.com> - 6.2.0-49
- add function of set migration thread affinity during migration - add function of set migration thread affinity during migration

View File

@ -0,0 +1,53 @@
From 6c3639df31680a03e03ad1e0f1ad489db595c02d Mon Sep 17 00:00:00 2001
From: Bihong Yu <yubihong@huawei.com>
Date: Tue, 11 Jan 2022 10:28:43 +0100
Subject: [PATCH 02/22] qemu: Log which API is trying to acquire a job
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Log which API is trying to acquire a job.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Bihong Yu <yubihong@huawei.com>
---
src/qemu/qemu_domain.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b7fb4eb9f9..bf09ad517b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9811,9 +9811,11 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
unsigned long long duration = 0;
unsigned long long agentDuration = 0;
unsigned long long asyncDuration = 0;
+ const char *currentAPI = virThreadJobGet();
- VIR_DEBUG("Starting job: job=%s agentJob=%s asyncJob=%s "
+ VIR_DEBUG("Starting job: API=%s job=%s agentJob=%s asyncJob=%s "
"(vm=%p name=%s, current job=%s agentJob=%s async=%s)",
+ NULLSTR(currentAPI),
qemuDomainJobTypeToString(job),
qemuDomainAgentJobTypeToString(agentJob),
qemuDomainAsyncJobTypeToString(asyncJob),
@@ -9916,13 +9918,14 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
if (priv->job.asyncJob && priv->job.asyncStarted)
asyncDuration = now - priv->job.asyncStarted;
- VIR_WARN("Cannot start job (%s, %s, %s) for domain %s; "
+ VIR_WARN("Cannot start job (%s, %s, %s) in API %s for domain %s; "
"current job is (%s, %s, %s) "
"owned by (%llu %s, %llu %s, %llu %s (flags=0x%lx)) "
"for (%llus, %llus, %llus)",
qemuDomainJobTypeToString(job),
qemuDomainAgentJobTypeToString(agentJob),
qemuDomainAsyncJobTypeToString(asyncJob),
+ NULLSTR(currentAPI),
obj->def->name,
qemuDomainJobTypeToString(priv->job.active),
qemuDomainAgentJobTypeToString(priv->job.agentActive),
--
2.33.0

View File

@ -0,0 +1,68 @@
From 3fbf29d9a7f89c7fc627c11c4ec65a2e10fd391a Mon Sep 17 00:00:00 2001
From: jiangdawei15 <jiangdawei15@huawei.com>
Date: Thu, 11 Aug 2022 21:20:29 +0800
Subject: [PATCH 07/22] qemu: Validate domain definition even on migration
When we are about to spawn QEMU, we validate the domain
definition against qemuCaps. Except when domain is/was already
running before (i.e. on incoming migration, snapshots, resume
from a file). However, especially on incoming migration it may
happen that the destination QEMU is different to the source
QEMU, e.g. the destination QEMU may have some devices disabled.
And we have a function that validates devices/features requested
in domain XML against the desired QEMU capabilities (aka
qemuCaps) - it's virDomainDefValidate() which calls
qemuValidateDomainDef() and qemuValidateDomainDeviceDef()
subsequently.
But the problem here is that the validation function is
explicitly skipped over in specific scenarios (like incoming
migration, restore from a snapshot or previously saved file).
This in turn means that we may spawn QEMU and request
device/features it doesn't support. When that happens QEMU fails
to load migration stream:
qemu-kvm: ... 'virtio-mem-pci' is not a valid device model name
(NB, while the example shows one particular device, the problem
is paramount)
This problem is easier to run into since we are slowly moving
validation from qemu_command.c into said validation functions.
The solution is simple: do the validation in all cases. And while
it may happen that users would be unable to migrate/restore a
guest due to a bug in our validator, spawning QEMU without
validation is worse (especially when you consider that users can
supply their own XMLs for migrate/restore operations - these were
never validated).
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2048435
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
---
src/qemu/qemu_process.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 0f3e651630..b240149f7a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5685,11 +5685,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
}
- /* Checks below should not be executed when starting a qemu process for a
- * VM that was running before (migration, snapshots, save). It's more
- * important to start such VM than keep the configuration clean */
- if ((flags & VIR_QEMU_PROCESS_START_NEW) &&
- virDomainDefValidate(vm->def, 0, driver->xmlopt) < 0)
+ if (virDomainDefValidate(vm->def, 0, driver->xmlopt) < 0)
return -1;
if (qemuProcessStartValidateGraphics(vm) < 0)
--
2.33.0

View File

@ -0,0 +1,89 @@
From c96afef6693dfbf783abf5dfa3b60c588920e201 Mon Sep 17 00:00:00 2001
From: jiangdawei15 <jiangdawei15@huawei.com>
Date: Thu, 11 Aug 2022 20:57:49 +0800
Subject: [PATCH 08/22] qemu: do crash safe creation of NVRAM file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If we crash part way through writing the NVRAM file we end up with an
unusable NVRAM on file. To avoid this we need to write to a temporary
file and fsync(2) at the end, then rename to the real NVRAM file path.
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
src/qemu/qemu_process.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b240149f7a..48d39ba97c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4697,7 +4697,8 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
bool created = false;
const char *master_nvram_path;
ssize_t r;
-
+ g_autofree char *tmp_dst_path = NULL;
+
if (!loader || !loader->nvram || virFileExists(loader->nvram))
return 0;
@@ -4726,7 +4727,9 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
master_nvram_path);
goto cleanup;
}
- if ((dstFD = virFileOpenAs(loader->nvram,
+
+ tmp_dst_path = g_strdup_printf("%s.tmp", loader->nvram);
+ if ((dstFD = virFileOpenAs(tmp_dst_path,
O_WRONLY | O_CREAT | O_EXCL,
S_IRUSR | S_IWUSR,
cfg->user, cfg->group, 0)) < 0) {
@@ -4750,7 +4753,7 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
if (safewrite(dstFD, buf, r) < 0) {
virReportSystemError(errno,
_("Unable to write to file '%s'"),
- loader->nvram);
+ tmp_dst_path);
goto cleanup;
}
} while (r);
@@ -4761,9 +4764,24 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
master_nvram_path);
goto cleanup;
}
+
+ if (g_fsync(dstFD) < 0) {
+ virReportSystemError(errno,
+ _("cannot sync file '%s'"),
+ tmp_dst_path);
+ goto cleanup;
+ }
+
if (VIR_CLOSE(dstFD) < 0) {
virReportSystemError(errno,
_("Unable to close file '%s'"),
+ tmp_dst_path);
+ goto cleanup;
+ }
+
+ if (rename(tmp_dst_path, loader->nvram) < 0) {
+ virReportSystemError(errno,
+ _("Unable to replace '%s'"),
loader->nvram);
goto cleanup;
}
@@ -4774,7 +4792,7 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
* copy the file content. Roll back. */
if (ret < 0) {
if (created)
- unlink(loader->nvram);
+ unlink(tmp_dst_path);
}
VIR_FORCE_CLOSE(srcFD);
--
2.33.0

View File

@ -0,0 +1,48 @@
From 678c5195c496ee02d46554f0e80216b20928358e Mon Sep 17 00:00:00 2001
From: jiangdawei15 <jiangdawei15@huawei.com>
Date: Thu, 18 Aug 2022 20:43:49 +0800
Subject: [PATCH 09/22] qemu: fix formatting of pflash readonly attribute
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When the <loader> had an explicit readonly='no' attribute we
accidentally still marked the plfash as readonly due to the
bad conversion from virTristateBool to bool. This was missed
because the test cases run with no capabilities set and thus
are validated the -drive approach for pflash configuration,
not the -blockdev approach.
This affected the following config:
<os>
<loader readonly='no' type='pflash'>/var/lib/libvirt/qemu/nvram/test-bios.fd</loader>
</os>
for the sake of completeness, we also add a test XML config
with no readonly attribute at all, to demonstrate that the
default for pflash is intended to be r/w.
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
src/qemu/qemu_domain.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index bf09ad517b..c4c3bb57ac 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -17166,7 +17166,8 @@ qemuDomainInitializePflashStorageSource(virDomainObjPtr vm)
pflash0->type = VIR_STORAGE_TYPE_FILE;
pflash0->format = VIR_STORAGE_FILE_RAW;
pflash0->path = g_strdup(def->os.loader->path);
- pflash0->readonly = def->os.loader->readonly;
+ pflash0->readonly = false;
+ virTristateBoolToBool(def->os.loader->readonly, &pflash0->readonly);
pflash0->nodeformat = g_strdup("libvirt-pflash0-format");
pflash0->nodestorage = g_strdup("libvirt-pflash0-storage");
--
2.33.0

View File

@ -0,0 +1,55 @@
From 046ca6d0b6c80dc233e530c31156a808ae63893a Mon Sep 17 00:00:00 2001
From: huangkai <huangkai101@huawei.com>
Date: Mon, 15 Aug 2022 09:32:36 +0800
Subject: [PATCH 17/22] qemu: fix one more race on undefining and create
[1] closes gap in virDomainObjListRemove so that concurrent thread can
not step in and obtain the domain while domain is temporary unlocked. But
there is another gap exist:
thread B - executes create API
thread C - executes undefine API
- thread A executes some job on domain
- threads B and C obtains domain from list and wait for job condition
- thread A finishes its job and C grabs job condition, removes domain
from list and finishes
- thread B grabs job condition and start the domain, unfortunately
is not in the list already
[1] commit c7d1c139ca3402e875002753952e80ce8054374e
Author: Martin Kletzander <mkletzan@redhat.com>
Date: Thu Dec 11 11:14:08 2014 +0100
qemu: avoid rare race when undefining domain
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@openvz.org>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
---
src/qemu/qemu_domain.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c4c3bb57ac..70835e4efd 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9860,6 +9860,16 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
if (!nested && !qemuDomainNestedJobAllowed(priv, job))
goto retry;
+ if (obj->removing) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ virUUIDFormat(obj->def->uuid, uuidstr);
+ virReportError(VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s' (%s)"),
+ uuidstr, obj->def->name);
+ goto cleanup;
+ }
+
ignore_value(virTimeMillisNow(&now));
if (job) {
--
2.33.0

View File

@ -0,0 +1,34 @@
From 80f671d083a7508a2b3cabdf3d6c102137ee0616 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Tue, 25 Jan 2022 10:48:36 +0100
Subject: [PATCH 04/22] qemuDomainAttachHostPCIDevice: Fix coding style
Our coding style requires that a body of an if() longer than two
lines is wrapped in a curly braces. There's one offender in
qemuDomainAttachHostPCIDevice(). Fortunately, there was no
functional problem because one of the lines is a comment.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
src/qemu/qemu_hotplug.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index cb571c3161..e13879cde3 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1619,9 +1619,10 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
if (qemuAssignDeviceHostdevAlias(vm->def, &info->alias, -1) < 0)
goto error;
- if (qemuDomainIsPSeries(vm->def))
+ if (qemuDomainIsPSeries(vm->def)) {
/* Isolation groups are only relevant for pSeries guests */
qemuDomainFillDeviceIsolationGroup(vm->def, &dev);
+ }
if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0)
goto error;
--
2.33.0

View File

@ -0,0 +1,52 @@
From f98761b13ec88aa506987f3d112a9f41f14d6dfb Mon Sep 17 00:00:00 2001
From: Bihong Yu <yubihong@huawei.com>
Date: Tue, 18 Jan 2022 10:08:03 +0100
Subject: [PATCH 03/22] qemuDomainPinIOThread: Update live definition after
process pinning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Update live definition after process pinning, Otherwise we'll
keep using the new pinning value even if it can't be applied to
the thread.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2040555
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Bihong Yu <yubihong@huawei.com>
---
src/qemu/qemu_driver.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8b19be46f1..32b3ef3cf1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5719,10 +5719,6 @@ qemuDomainPinIOThread(virDomainPtr dom,
if (!(cpumask = virBitmapNewData(cpumap, maplen)))
goto endjob;
- virBitmapFree(iothrid->cpumask);
- iothrid->cpumask = cpumask;
- iothrid->autofill = false;
-
/* Configure the corresponding cpuset cgroup before set affinity. */
if (virCgroupHasController(priv->cgroup,
VIR_CGROUP_CONTROLLER_CPUSET)) {
@@ -5740,6 +5736,10 @@ qemuDomainPinIOThread(virDomainPtr dom,
if (virProcessSetAffinity(iothrid->thread_id, pcpumap) < 0)
goto endjob;
+ virBitmapFree(iothrid->cpumask);
+ iothrid->cpumask = cpumask;
+ iothrid->autofill = false;
+
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
goto endjob;
--
2.33.0

View File

@ -0,0 +1,44 @@
From fccb7c2ccec7fe9a831be04e589b5fb56a048828 Mon Sep 17 00:00:00 2001
From: xuyinghao <xuyinghao2@huawei.com>
Date: Tue, 9 Aug 2022 18:58:05 +0800
Subject: [PATCH 13/22] qemu_cgroup: Drop ENOENT special case for RNG devices
Description: When allowing or denying RNG device in CGroups there's a special check if the backend device exists (errno == ENOENT) in which case success is returned to caller. This is in contrast with the rest of the functions and in fact wrong too - if the backend device doesn't exist then QEMU will fail opening it. Might as well signal error here.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
---
src/qemu/qemu_cgroup.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index aa721df100..c30ede7394 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -667,9 +667,9 @@ qemuSetupRNGCgroup(virDomainObjPtr vm,
virDomainAuditCgroupPath(vm, priv->cgroup, "allow",
rng->source.file,
"rw", rv);
- if (rv < 0 &&
- !virLastErrorIsSystemErrno(ENOENT))
+ if (rv < 0) {
return -1;
+ }
}
return 0;
@@ -694,9 +694,9 @@ qemuTeardownRNGCgroup(virDomainObjPtr vm,
virDomainAuditCgroupPath(vm, priv->cgroup, "deny",
rng->source.file,
"rw", rv);
- if (rv < 0 &&
- !virLastErrorIsSystemErrno(ENOENT))
+ if (rv < 0) {
return -1;
+ }
}
return 0;
--
2.33.0

View File

@ -0,0 +1,36 @@
From 4821323a523c8a5b34aab61c913ed7b13deada27 Mon Sep 17 00:00:00 2001
From: Bihong Yu <yubihong@huawei.com>
Date: Thu, 13 Jan 2022 16:14:42 +0100
Subject: [PATCH 02/13] qemuxml2(argv|xml)data: x86-kvm-32-on-64: Add machine
type
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The machine type doesn't change the test result and prevents tests being
changed every time we are about to update real capabilities to a new
qemu.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Bihong Yu <yubihong@huawei.com>
---
tests/qemuxml2argvdata/x86-kvm-32-on-64.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/qemuxml2argvdata/x86-kvm-32-on-64.xml b/tests/qemuxml2argvdata/x86-kvm-32-on-64.xml
index 37f53bf2af..35ddbd0630 100644
--- a/tests/qemuxml2argvdata/x86-kvm-32-on-64.xml
+++ b/tests/qemuxml2argvdata/x86-kvm-32-on-64.xml
@@ -3,7 +3,7 @@
<uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid>
<memory unit='KiB'>4194304</memory>
<os>
- <type arch='i686'>hvm</type>
+ <type arch='i686' machine='pc'>hvm</type>
</os>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
--
2.33.0

View File

@ -0,0 +1,187 @@
From d8e9a553365a70a7f3ed2286aa847064e6a77542 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Thu, 13 Jan 2022 12:47:17 +0100
Subject: [PATCH] qemuxml2argvtest: disk-vhostuser: Add invocation for qemu-4.2
With qemu versions prior to qemu-5.0 we'll format 'scsi=off' for
virtio-blk disks, but also for vhost-user-blk. This is a bug as it's not
supported.
Add a test case to show that wrong configuration is generated by adding
running 'disk-vhostuser' test case on capabilities from qemu-4.2.
For this to be possible it's required to enable shared memory via NUMA
configuration as old QEMU's don't allow configuration of the default
memory backend. This is achieved by adding a copy of the
'disk-vhostuser' XML with NUMA enabled.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
.../disk-vhostuser-numa.x86_64-4.2.0.args | 39 +++++++++++++++++++
.../disk-vhostuser-numa.x86_64-latest.args | 39 +++++++++++++++++++
.../qemuxml2argvdata/disk-vhostuser-numa.xml | 32 +++++++++++++++
.../disk-vhostuser.x86_64-latest.args | 3 +-
tests/qemuxml2argvtest.c | 2 +
5 files changed, 113 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args
create mode 100644 tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-vhostuser-numa.xml
diff --git a/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args b/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args
new file mode 100644
index 0000000000..cf1a0fb53e
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args
@@ -0,0 +1,39 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine pc-i440fx-4.2,usb=off,dump-guest-core=off \
+-accel tcg \
+-cpu qemu64 \
+-m 14336 \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node0,share=yes,size=15032385536 \
+-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-chardev socket,id=chr-vu-virtio-disk0,path=/tmp/vhost1.sock \
+-device vhost-user-blk-pci,bus=pci.0,addr=0x2,chardev=chr-vu-virtio-disk0,id=virtio-disk0,bootindex=1 \
+-chardev socket,id=chr-vu-virtio-disk1,path=/tmp/vhost1.sock,reconnect=10 \
+-device vhost-user-blk-pci,bus=pci.0,addr=0x3,chardev=chr-vu-virtio-disk1,id=virtio-disk1 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-latest.args b/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-latest.args
new file mode 100644
index 0000000000..1bbc4250ca
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-latest.args
@@ -0,0 +1,39 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine pc,usb=off,dump-guest-core=off \
+-accel tcg \
+-cpu qemu64 \
+-m 14336 \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node0,share=yes,size=15032385536 \
+-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-chardev socket,id=chr-vu-virtio-disk0,path=/tmp/vhost1.sock \
+-device vhost-user-blk-pci,bus=pci.0,addr=0x2,chardev=chr-vu-virtio-disk0,id=virtio-disk0,bootindex=1 \
+-chardev socket,id=chr-vu-virtio-disk1,path=/tmp/vhost1.sock,reconnect=10 \
+-device vhost-user-blk-pci,bus=pci.0,addr=0x3,chardev=chr-vu-virtio-disk1,id=virtio-disk1 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/disk-vhostuser-numa.xml b/tests/qemuxml2argvdata/disk-vhostuser-numa.xml
new file mode 100644
index 0000000000..56f2f1be85
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-vhostuser-numa.xml
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ <numa>
+ <cell id='0' cpus='0' memory='14680064' unit='KiB' memAccess='shared'/>
+ </numa>
+ </cpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <disk type='vhostuser' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source type='unix' path='/tmp/vhost1.sock'/>
+ <target dev='vda' bus='virtio'/>
+ <boot order='1'/>
+ </disk>
+ <disk type='vhostuser' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source type='unix' path='/tmp/vhost1.sock'>
+ <reconnect enabled='yes' timeout='10'/>
+ </source>
+ <target dev='vdb' bus='virtio'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/disk-vhostuser.x86_64-latest.args b/tests/qemuxml2argvdata/disk-vhostuser.x86_64-latest.args
index a143b7cdc6..11e8a05d99 100644
--- a/tests/qemuxml2argvdata/disk-vhostuser.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-vhostuser.x86_64-latest.args
@@ -33,8 +33,7 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-device vhost-user-blk-pci,bus=pci.0,addr=0x2,chardev=chr-vu-virtio-disk0,\
id=virtio-disk0,bootindex=1 \
-chardev socket,id=chr-vu-virtio-disk1,path=/tmp/vhost1.sock,reconnect=10 \
--device vhost-user-blk-pci,bus=pci.0,addr=0x3,chardev=chr-vu-virtio-disk1,\
-id=virtio-disk1 \
+-device vhost-user-blk-pci,bus=pci.0,addr=0x3,chardev=chr-vu-virtio-disk1,id=virtio-disk1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7b117f5984..d37969d065 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1209,6 +1209,8 @@ mymain(void)
VIR_FREE(driver.config->vxhsTLSx509certdir);
DO_TEST("disk-no-boot", NONE);
DO_TEST_CAPS_LATEST("disk-nvme");
+ DO_TEST_CAPS_VER("disk-vhostuser-numa", "4.2.0");
+ DO_TEST_CAPS_LATEST("disk-vhostuser-numa");
DO_TEST_CAPS_LATEST("disk-vhostuser");
DO_TEST_PARSE_ERROR("disk-device-lun-type-invalid",
QEMU_CAPS_VIRTIO_SCSI);
--
2.33.0

View File

@ -0,0 +1,81 @@
From ffaa244c76d7baeccab1846b1cae8ca057718f03 Mon Sep 17 00:00:00 2001
From: huangkai <huangkai101@huawei.com>
Date: Sun, 14 Aug 2022 17:32:00 +0800
Subject: [PATCH 18/22] remote_daemon: Don't run virStateCleanup() if
virStateReload() is still running
When a SIGHUP is received a thread is spawned that runs
virStateReload(). However, if SIGINT is received while the former
thread is still running then we may get into problematic
situation: the cleanup code in main() sees drivers initialized
and thus calls virStateCleanup(). So now we have two threads, one
running virStateReload() the other virStateCleanup(). In this
situation it's very likely that a race condition occurs and
either of threads causes SIGSEGV.
To fix this, unmark drivers as initialized in the
virStateReload() thread for the time the function runs.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2075837
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
---
src/remote/remote_daemon.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index a1552800e9..cb93e39413 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -77,7 +77,7 @@ virNetSASLContextPtr saslCtxt = NULL;
virNetServerProgramPtr remoteProgram = NULL;
virNetServerProgramPtr qemuProgram = NULL;
-volatile bool driversInitialized = false;
+volatile gint driversInitialized = 0;
static void daemonErrorHandler(void *opaque G_GNUC_UNUSED,
virErrorPtr err G_GNUC_UNUSED)
@@ -469,7 +469,7 @@ static void daemonReloadHandler(virNetDaemonPtr dmn G_GNUC_UNUSED,
{
virThread thr;
- if (!driversInitialized) {
+ if (!g_atomic_int_compare_and_exchange(&driversInitialized, 1, 0)) {
VIR_WARN("Drivers are not initialized, reload ignored");
return;
}
@@ -480,6 +480,9 @@ static void daemonReloadHandler(virNetDaemonPtr dmn G_GNUC_UNUSED,
* Not much we can do on error here except log it.
*/
VIR_ERROR(_("Failed to create thread to handle daemon restart"));
+ /* Drivers were initialized at the beginning, otherwise we wouldn't
+ * even get here. */
+ g_atomic_int_set(&driversInitialized, 1);
}
}
@@ -606,7 +609,7 @@ static void daemonRunStateInit(void *opaque)
goto cleanup;
}
- driversInitialized = true;
+ g_atomic_int_set(&driversInitialized, 1);
#ifdef WITH_DBUS
/* Tie the non-privileged daemons to the session/shutdown lifecycle */
@@ -1206,10 +1209,9 @@ int main(int argc, char **argv) {
virNetlinkEventServiceStopAll();
- if (driversInitialized) {
+ if (g_atomic_int_compare_and_exchange(&driversInitialized, 1, 0)) {
/* NB: Possible issue with timing window between driversInitialized
* setting if virNetlinkEventServerStart fails */
- driversInitialized = false;
virStateCleanup();
}
--
2.33.0

View File

@ -0,0 +1,41 @@
From 8dfa48d0b5b64ab8bbc78aabfea8252db38215c5 Mon Sep 17 00:00:00 2001
From: xuyinghao <xuyinghao2@huawei.com>
Date: Tue, 16 Aug 2022 19:36:03 +0800
Subject: [PATCH 03/13] sockettest: Check for IPv4-in-IPv6 parsing and
formatting
There are two standards how IPv4 address in IPv6 can be expressed:
::10.1.2.3
::ffff:10.1.2.3
The former is obsolete and the latter should be used instead [1]. Add test cases to our sockettest to exercise parsing/formatting of the valid address format.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com
---
tests/sockettest.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/sockettest.c b/tests/sockettest.c
index 29a565de40..b30bf0008f 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -373,12 +373,14 @@ mymain(void)
DO_TEST_PARSE_AND_CHECK_FORMAT("127.2", "127.2.0.0", AF_INET, false);
DO_TEST_PARSE_AND_CHECK_FORMAT("1.2.3", "1.2.0.3", AF_INET, true);
DO_TEST_PARSE_AND_CHECK_FORMAT("1.2.3", "1.2.3.0", AF_INET, false);
+ DO_TEST_PARSE_AND_CHECK_FORMAT("::ffff:a01:203", "::ffff:10.1.2.3", AF_INET6, true);
DO_TEST_PARSE_AND_FORMAT("::1", AF_UNSPEC, true);
DO_TEST_PARSE_AND_FORMAT("::1", AF_INET, false);
DO_TEST_PARSE_AND_FORMAT("::1", AF_INET6, true);
DO_TEST_PARSE_AND_FORMAT("::1", AF_UNIX, false);
DO_TEST_PARSE_AND_FORMAT("::fffe:0:0", AF_UNSPEC, true);
+ DO_TEST_PARSE_AND_FORMAT("::ffff:10.1.2.3", AF_UNSPEC, true);
/* tests that specify a network that should contain the range */
DO_TEST_RANGE("192.168.122.1", "192.168.122.1", "192.168.122.1", 24, 1, true);
--
2.33.0

View File

@ -0,0 +1,32 @@
From 05a25f4c74e0e5c93703302a36b55a63b754d995 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Mon, 31 Jan 2022 13:52:25 +0100
Subject: [PATCH 04/13] test_driver: Don't leak @group_name
In testDomainSetBlockIoTune() the info.group_name is strdup()-ed
and just after the whole @info structure is passed to
virDomainDiskSetBlockIOTune() the @group_name member is set to
NULL. This creates a memleak, because
virDomainDiskSetBlockIOTune() creates its own copy of the string.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
---
src/test/test_driver.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 33f1792177..e0d9c4fa0b 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3845,7 +3845,6 @@ testDomainSetBlockIoTune(virDomainPtr dom,
if (virDomainDiskSetBlockIOTune(conf_disk, &info) < 0)
goto cleanup;
- info.group_name = NULL;
ret = 0;
cleanup:
--
2.33.0

View File

@ -0,0 +1,41 @@
From 9f6e5e5fe12e9cb4bb42918f597ba0268e57064b Mon Sep 17 00:00:00 2001
From: xuyinghao <xuyinghao2@huawei.com>
Date: Tue, 16 Aug 2022 19:08:45 +0800
Subject: [PATCH 08/13] tests: Allow expansion of mocked stat symbols
When libc uses a define to rewrite stat64 to stat our mocks do not work if they
are chained because the symbol that we are looking up is being stringified and
therefore preventing the stat64->stat expansion per C-preprocessor rules. One
stringification macro is just enough to make it work.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/virmock.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/virmock.h b/tests/virmock.h
index 95feeb0d92..188f0cf55b 100644
--- a/tests/virmock.h
+++ b/tests/virmock.h
@@ -57,6 +57,7 @@
#define VIR_MOCK_GET_ARG20(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) z(a, b), z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n), z(o, p), z(q, r), z(s, t)
#define VIR_MOCK_GET_ARG21(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) z(a, b), z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n), z(o, p), z(q, r), z(s, t)
+#define VIR_MOCK_STRINGIFY_SYMBOL(name) #name
#define VIR_MOCK_ARGNAMES_EXPAND(a, b, ...) VIR_MOCK_ARG_PASTE(a, b, __VA_ARGS__)
#define VIR_MOCK_ARGNAMES(...) \
@@ -283,7 +284,7 @@
do { \
if (real_##name == NULL && \
!(real_##name = dlsym(RTLD_NEXT, \
- #name))) { \
+ VIR_MOCK_STRINGIFY_SYMBOL(name)))) { \
fprintf(stderr, "Missing symbol '" #name "'\n"); \
abort(); \
} \
--
2.33.0

View File

@ -0,0 +1,42 @@
From 31a4a7ecceeeaccfc016d28aa80f8a668c203ce0 Mon Sep 17 00:00:00 2001
From: Bihong Yu <yubihong@huawei.com>
Date: Tue, 30 Nov 2021 18:16:32 +0100
Subject: [PATCH 09/13] tests: Report expected monitor command for simulated
commands
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
There are two tests currently that simulate QMP talk:
qemucapabilitiestest and qemuhotplugtest. In both cases they
check whether currently executed command is the one for which
reply was provided. If not an error message is reported. However,
the error message contains only the actual command and not the
expected one. This makes it harder to navigate through .replies
files.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Bihong Yu <yubihong@huawei.com>
---
tests/qemumonitortestutils.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 159b1b909e..78d52028de 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -637,7 +637,8 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPtr test,
ret = qemuMonitorTestAddResponse(test, data->response);
} else {
if (data->cmderr) {
- errmsg = g_strdup_printf("%s: %s", data->cmderr, cmdstr);
+ errmsg = g_strdup_printf("%s: %s expected %s",
+ data->cmderr, cmdstr, data->command_name);
ret = qemuMonitorTestAddErrorResponse(test, errmsg);
} else {
--
2.33.0

View File

@ -0,0 +1,607 @@
From 339c987367faf9bf758633d7a54b4bbcbf54d300 Mon Sep 17 00:00:00 2001
From: xuyinghao <xuyinghao2@huawei.com>
Date: Tue, 16 Aug 2022 19:33:07 +0800
Subject: [PATCH 13/13] tests: Update IPv4-in-IPv6 addresses
We have couple of tests where the obsolete IPv4-in-IPv6 notation is used (::10.1.2.3). Change them to the correct format (::ffff:10.1.2.3).
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/nwfilterxml2firewalldata/ah-ipv6-linux.args | 6 +++---
tests/nwfilterxml2firewalldata/ah-ipv6.xml | 2 +-
tests/nwfilterxml2firewalldata/all-ipv6-linux.args | 6 +++---
tests/nwfilterxml2firewalldata/all-ipv6.xml | 2 +-
tests/nwfilterxml2firewalldata/comment-linux.args | 4 ++--
tests/nwfilterxml2firewalldata/comment.xml | 4 ++--
tests/nwfilterxml2firewalldata/esp-ipv6-linux.args | 6 +++---
tests/nwfilterxml2firewalldata/esp-ipv6.xml | 2 +-
tests/nwfilterxml2firewalldata/hex-data-linux.args | 4 ++--
tests/nwfilterxml2firewalldata/hex-data.xml | 4 ++--
tests/nwfilterxml2firewalldata/icmpv6-linux.args | 2 +-
tests/nwfilterxml2firewalldata/icmpv6.xml | 2 +-
tests/nwfilterxml2firewalldata/ipv6-linux.args | 4 ++--
tests/nwfilterxml2firewalldata/ipv6.xml | 4 ++--
tests/nwfilterxml2firewalldata/sctp-ipv6-linux.args | 6 +++---
tests/nwfilterxml2firewalldata/sctp-ipv6.xml | 2 +-
tests/nwfilterxml2firewalldata/tcp-ipv6-linux.args | 6 +++---
tests/nwfilterxml2firewalldata/tcp-ipv6.xml | 2 +-
tests/nwfilterxml2firewalldata/udp-ipv6-linux.args | 6 +++---
tests/nwfilterxml2firewalldata/udp-ipv6.xml | 2 +-
tests/nwfilterxml2firewalldata/udplite-ipv6-linux.args | 6 +++---
tests/nwfilterxml2firewalldata/udplite-ipv6.xml | 2 +-
tests/nwfilterxml2xmlout/ah-ipv6-test.xml | 2 +-
tests/nwfilterxml2xmlout/all-ipv6-test.xml | 2 +-
tests/nwfilterxml2xmlout/comment-test.xml | 2 +-
tests/nwfilterxml2xmlout/esp-ipv6-test.xml | 2 +-
tests/nwfilterxml2xmlout/hex-data-test.xml | 2 +-
tests/nwfilterxml2xmlout/icmpv6-test.xml | 2 +-
tests/nwfilterxml2xmlout/ipv6-test.xml | 2 +-
tests/nwfilterxml2xmlout/sctp-ipv6-test.xml | 2 +-
tests/nwfilterxml2xmlout/tcp-ipv6-test.xml | 2 +-
tests/nwfilterxml2xmlout/udp-ipv6-test.xml | 2 +-
tests/nwfilterxml2xmlout/udplite-ipv6-test.xml | 2 +-
33 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/tests/nwfilterxml2firewalldata/ah-ipv6-linux.args b/tests/nwfilterxml2firewalldata/ah-ipv6-linux.args
index 35c9de38b8..74e26f962f 100644
--- a/tests/nwfilterxml2firewalldata/ah-ipv6-linux.args
+++ b/tests/nwfilterxml2firewalldata/ah-ipv6-linux.args
@@ -64,7 +64,7 @@ ip6tables \
ip6tables \
-A FJ-vnet0 \
-p ah \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
@@ -75,7 +75,7 @@ ip6tables \
-p ah \
-m mac \
--mac-source 01:02:03:04:05:06 \
---source ::10.1.2.3/128 \
+--source ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
@@ -84,7 +84,7 @@ ip6tables \
ip6tables \
-A HJ-vnet0 \
-p ah \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
diff --git a/tests/nwfilterxml2firewalldata/ah-ipv6.xml b/tests/nwfilterxml2firewalldata/ah-ipv6.xml
index 95ebbc9e09..b664c0dfa6 100644
--- a/tests/nwfilterxml2firewalldata/ah-ipv6.xml
+++ b/tests/nwfilterxml2firewalldata/ah-ipv6.xml
@@ -13,7 +13,7 @@
</rule>
<rule action='accept' direction='in'>
<ah-ipv6 srcmacaddr='1:2:3:4:5:6'
- srcipaddr='::10.1.2.3' srcipmask='128'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='128'
dscp='33'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2firewalldata/all-ipv6-linux.args b/tests/nwfilterxml2firewalldata/all-ipv6-linux.args
index 2f84c1bfea..47c459a0f9 100644
--- a/tests/nwfilterxml2firewalldata/all-ipv6-linux.args
+++ b/tests/nwfilterxml2firewalldata/all-ipv6-linux.args
@@ -64,7 +64,7 @@ ip6tables \
ip6tables \
-A FJ-vnet0 \
-p all \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
@@ -75,7 +75,7 @@ ip6tables \
-p all \
-m mac \
--mac-source 01:02:03:04:05:06 \
---source ::10.1.2.3/128 \
+--source ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
@@ -84,7 +84,7 @@ ip6tables \
ip6tables \
-A HJ-vnet0 \
-p all \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
diff --git a/tests/nwfilterxml2firewalldata/all-ipv6.xml b/tests/nwfilterxml2firewalldata/all-ipv6.xml
index 5cf3519437..5132e9bdd6 100644
--- a/tests/nwfilterxml2firewalldata/all-ipv6.xml
+++ b/tests/nwfilterxml2firewalldata/all-ipv6.xml
@@ -13,7 +13,7 @@
</rule>
<rule action='accept' direction='in'>
<all-ipv6 srcmacaddr='1:2:3:4:5:6'
- srcipaddr='::10.1.2.3' srcipmask='128'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='128'
dscp='33'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2firewalldata/comment-linux.args b/tests/nwfilterxml2firewalldata/comment-linux.args
index 462b2e2177..815d4f1a79 100644
--- a/tests/nwfilterxml2firewalldata/comment-linux.args
+++ b/tests/nwfilterxml2firewalldata/comment-linux.args
@@ -22,8 +22,8 @@ ebtables \
-s 01:02:03:04:05:06/ff:ff:ff:ff:ff:fe \
-d aa:bb:cc:dd:ee:ff/ff:ff:ff:ff:ff:80 \
-p ipv6 \
---ip6-source ::10.1.2.3/22 \
---ip6-destination ::10.1.2.3/113 \
+--ip6-source ::ffff:10.1.2.3/22 \
+--ip6-destination ::ffff:10.1.2.3/113 \
--ip6-protocol 6 \
--ip6-source-port 273:400 \
--ip6-destination-port 13107:65535 \
diff --git a/tests/nwfilterxml2firewalldata/comment.xml b/tests/nwfilterxml2firewalldata/comment.xml
index a154a17c14..f1d2af1908 100644
--- a/tests/nwfilterxml2firewalldata/comment.xml
+++ b/tests/nwfilterxml2firewalldata/comment.xml
@@ -19,8 +19,8 @@
<rule action='accept' direction='out'>
<ipv6 srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:fe'
dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80'
- srcipaddr='::10.1.2.3' srcipmask='22'
- dstipaddr='::10.1.2.3'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='22'
+ dstipaddr='::ffff:10.1.2.3'
dstipmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:8000'
protocol='tcp'
srcportstart='0x111' srcportend='400'
diff --git a/tests/nwfilterxml2firewalldata/esp-ipv6-linux.args b/tests/nwfilterxml2firewalldata/esp-ipv6-linux.args
index 51cf74815b..98cd0984b6 100644
--- a/tests/nwfilterxml2firewalldata/esp-ipv6-linux.args
+++ b/tests/nwfilterxml2firewalldata/esp-ipv6-linux.args
@@ -64,7 +64,7 @@ ip6tables \
ip6tables \
-A FJ-vnet0 \
-p esp \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
@@ -75,7 +75,7 @@ ip6tables \
-p esp \
-m mac \
--mac-source 01:02:03:04:05:06 \
---source ::10.1.2.3/128 \
+--source ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
@@ -84,7 +84,7 @@ ip6tables \
ip6tables \
-A HJ-vnet0 \
-p esp \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
diff --git a/tests/nwfilterxml2firewalldata/esp-ipv6.xml b/tests/nwfilterxml2firewalldata/esp-ipv6.xml
index 295d0f9b3b..d411366c1c 100644
--- a/tests/nwfilterxml2firewalldata/esp-ipv6.xml
+++ b/tests/nwfilterxml2firewalldata/esp-ipv6.xml
@@ -13,7 +13,7 @@
</rule>
<rule action='accept' direction='in'>
<esp-ipv6 srcmacaddr='1:2:3:4:5:6'
- srcipaddr='::10.1.2.3' srcipmask='128'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='128'
dscp='33'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2firewalldata/hex-data-linux.args b/tests/nwfilterxml2firewalldata/hex-data-linux.args
index f1a1f588f2..3d22f4ed69 100644
--- a/tests/nwfilterxml2firewalldata/hex-data-linux.args
+++ b/tests/nwfilterxml2firewalldata/hex-data-linux.args
@@ -22,8 +22,8 @@ ebtables \
-s 01:02:03:04:05:06/ff:ff:ff:ff:ff:fe \
-d aa:bb:cc:dd:ee:ff/ff:ff:ff:ff:ff:80 \
-p ipv6 \
---ip6-source ::10.1.2.3/22 \
---ip6-destination ::10.1.2.3/113 \
+--ip6-source ::ffff:10.1.2.3/22 \
+--ip6-destination ::ffff:10.1.2.3/113 \
--ip6-protocol 6 \
--ip6-source-port 273:400 \
--ip6-destination-port 13107:65535 \
diff --git a/tests/nwfilterxml2firewalldata/hex-data.xml b/tests/nwfilterxml2firewalldata/hex-data.xml
index 45df45129b..ee93bbccda 100644
--- a/tests/nwfilterxml2firewalldata/hex-data.xml
+++ b/tests/nwfilterxml2firewalldata/hex-data.xml
@@ -19,8 +19,8 @@
<rule action='accept' direction='out'>
<ipv6 srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:fe'
dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80'
- srcipaddr='::10.1.2.3' srcipmask='22'
- dstipaddr='::10.1.2.3'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='22'
+ dstipaddr='::ffff:10.1.2.3'
dstipmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:8000'
protocol='tcp'
srcportstart='0x111' srcportend='400'
diff --git a/tests/nwfilterxml2firewalldata/icmpv6-linux.args b/tests/nwfilterxml2firewalldata/icmpv6-linux.args
index 92190eb311..2462468ab4 100644
--- a/tests/nwfilterxml2firewalldata/icmpv6-linux.args
+++ b/tests/nwfilterxml2firewalldata/icmpv6-linux.args
@@ -41,7 +41,7 @@ ip6tables \
-p icmpv6 \
-m mac \
--mac-source 01:02:03:04:05:06 \
---source ::10.1.2.3/128 \
+--source ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
--icmpv6-type 255/255 \
diff --git a/tests/nwfilterxml2firewalldata/icmpv6.xml b/tests/nwfilterxml2firewalldata/icmpv6.xml
index 9d248266fe..52b3a7cada 100644
--- a/tests/nwfilterxml2firewalldata/icmpv6.xml
+++ b/tests/nwfilterxml2firewalldata/icmpv6.xml
@@ -13,7 +13,7 @@
</rule>
<rule action='accept' direction='in'>
<icmpv6 srcmacaddr='1:2:3:4:5:6'
- srcipaddr='::10.1.2.3' srcipmask='128'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='128'
dscp='33' type='255' code='255'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2firewalldata/ipv6-linux.args b/tests/nwfilterxml2firewalldata/ipv6-linux.args
index 6fba19f2eb..44b84f0916 100644
--- a/tests/nwfilterxml2firewalldata/ipv6-linux.args
+++ b/tests/nwfilterxml2firewalldata/ipv6-linux.args
@@ -4,8 +4,8 @@ ebtables \
-s 01:02:03:04:05:06/ff:ff:ff:ff:ff:fe \
-d aa:bb:cc:dd:ee:ff/ff:ff:ff:ff:ff:80 \
-p ipv6 \
---ip6-source ::10.1.2.3/22 \
---ip6-destination ::10.1.2.3/113 \
+--ip6-source ::ffff:10.1.2.3/22 \
+--ip6-destination ::ffff:10.1.2.3/113 \
--ip6-protocol 17 \
--ip6-source-port 20:22 \
--ip6-destination-port 100:101 \
diff --git a/tests/nwfilterxml2firewalldata/ipv6.xml b/tests/nwfilterxml2firewalldata/ipv6.xml
index 2400958030..0351bca01a 100644
--- a/tests/nwfilterxml2firewalldata/ipv6.xml
+++ b/tests/nwfilterxml2firewalldata/ipv6.xml
@@ -3,8 +3,8 @@
<rule action='accept' direction='out'>
<ipv6 srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:fe'
dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80'
- srcipaddr='::10.1.2.3' srcipmask='22'
- dstipaddr='::10.1.2.3'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='22'
+ dstipaddr='::ffff:10.1.2.3'
dstipmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:8000'
protocol='udp'
srcportstart='20' srcportend='22'
diff --git a/tests/nwfilterxml2firewalldata/sctp-ipv6-linux.args b/tests/nwfilterxml2firewalldata/sctp-ipv6-linux.args
index 959c4e8e0f..b39d3314b3 100644
--- a/tests/nwfilterxml2firewalldata/sctp-ipv6-linux.args
+++ b/tests/nwfilterxml2firewalldata/sctp-ipv6-linux.args
@@ -67,7 +67,7 @@ ip6tables \
ip6tables \
-A FJ-vnet0 \
-p sctp \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 63 \
--dport 255:256 \
@@ -80,7 +80,7 @@ ip6tables \
-p sctp \
-m mac \
--mac-source 01:02:03:04:05:06 \
---source ::10.1.2.3/128 \
+--source ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 63 \
--sport 255:256 \
@@ -91,7 +91,7 @@ ip6tables \
ip6tables \
-A HJ-vnet0 \
-p sctp \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 63 \
--dport 255:256 \
diff --git a/tests/nwfilterxml2firewalldata/sctp-ipv6.xml b/tests/nwfilterxml2firewalldata/sctp-ipv6.xml
index d1a57b8f93..1b870ce5d8 100644
--- a/tests/nwfilterxml2firewalldata/sctp-ipv6.xml
+++ b/tests/nwfilterxml2firewalldata/sctp-ipv6.xml
@@ -14,7 +14,7 @@
</rule>
<rule action='accept' direction='in'>
<sctp-ipv6 srcmacaddr='1:2:3:4:5:6'
- srcipaddr='::10.1.2.3' srcipmask='128'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='128'
dscp='63'
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65535'/>
diff --git a/tests/nwfilterxml2firewalldata/tcp-ipv6-linux.args b/tests/nwfilterxml2firewalldata/tcp-ipv6-linux.args
index e6f8de3fca..6d59ac31b8 100644
--- a/tests/nwfilterxml2firewalldata/tcp-ipv6-linux.args
+++ b/tests/nwfilterxml2firewalldata/tcp-ipv6-linux.args
@@ -67,7 +67,7 @@ ip6tables \
ip6tables \
-A FJ-vnet0 \
-p tcp \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 63 \
--dport 255:256 \
@@ -80,7 +80,7 @@ ip6tables \
-p tcp \
-m mac \
--mac-source 01:02:03:04:05:06 \
---source ::10.1.2.3/128 \
+--source ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 63 \
--sport 255:256 \
@@ -91,7 +91,7 @@ ip6tables \
ip6tables \
-A HJ-vnet0 \
-p tcp \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 63 \
--dport 255:256 \
diff --git a/tests/nwfilterxml2firewalldata/tcp-ipv6.xml b/tests/nwfilterxml2firewalldata/tcp-ipv6.xml
index d4f24f44de..2f41b227b3 100644
--- a/tests/nwfilterxml2firewalldata/tcp-ipv6.xml
+++ b/tests/nwfilterxml2firewalldata/tcp-ipv6.xml
@@ -14,7 +14,7 @@
</rule>
<rule action='accept' direction='in'>
<tcp-ipv6 srcmacaddr='1:2:3:4:5:6'
- srcipaddr='::10.1.2.3' srcipmask='128'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='128'
dscp='63'
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65535'/>
diff --git a/tests/nwfilterxml2firewalldata/udp-ipv6-linux.args b/tests/nwfilterxml2firewalldata/udp-ipv6-linux.args
index 9183c08753..808c44e051 100644
--- a/tests/nwfilterxml2firewalldata/udp-ipv6-linux.args
+++ b/tests/nwfilterxml2firewalldata/udp-ipv6-linux.args
@@ -67,7 +67,7 @@ ip6tables \
ip6tables \
-A FJ-vnet0 \
-p udp \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 63 \
--dport 255:256 \
@@ -80,7 +80,7 @@ ip6tables \
-p udp \
-m mac \
--mac-source 01:02:03:04:05:06 \
---source ::10.1.2.3/128 \
+--source ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 63 \
--sport 255:256 \
@@ -91,7 +91,7 @@ ip6tables \
ip6tables \
-A HJ-vnet0 \
-p udp \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 63 \
--dport 255:256 \
diff --git a/tests/nwfilterxml2firewalldata/udp-ipv6.xml b/tests/nwfilterxml2firewalldata/udp-ipv6.xml
index fd4f135a4b..7c0be8404e 100644
--- a/tests/nwfilterxml2firewalldata/udp-ipv6.xml
+++ b/tests/nwfilterxml2firewalldata/udp-ipv6.xml
@@ -14,7 +14,7 @@
</rule>
<rule action='accept' direction='in'>
<udp-ipv6 srcmacaddr='1:2:3:4:5:6'
- srcipaddr='::10.1.2.3' srcipmask='128'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='128'
dscp='63'
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65535'/>
diff --git a/tests/nwfilterxml2firewalldata/udplite-ipv6-linux.args b/tests/nwfilterxml2firewalldata/udplite-ipv6-linux.args
index 9eb38d7e6d..f2267996f6 100644
--- a/tests/nwfilterxml2firewalldata/udplite-ipv6-linux.args
+++ b/tests/nwfilterxml2firewalldata/udplite-ipv6-linux.args
@@ -64,7 +64,7 @@ ip6tables \
ip6tables \
-A FJ-vnet0 \
-p udplite \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
@@ -75,7 +75,7 @@ ip6tables \
-p udplite \
-m mac \
--mac-source 01:02:03:04:05:06 \
---source ::10.1.2.3/128 \
+--source ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
@@ -84,7 +84,7 @@ ip6tables \
ip6tables \
-A HJ-vnet0 \
-p udplite \
---destination ::10.1.2.3/128 \
+--destination ::ffff:10.1.2.3/128 \
-m dscp \
--dscp 33 \
-m state \
diff --git a/tests/nwfilterxml2firewalldata/udplite-ipv6.xml b/tests/nwfilterxml2firewalldata/udplite-ipv6.xml
index 5b941a2465..1b006e1d42 100644
--- a/tests/nwfilterxml2firewalldata/udplite-ipv6.xml
+++ b/tests/nwfilterxml2firewalldata/udplite-ipv6.xml
@@ -13,7 +13,7 @@
</rule>
<rule action='accept' direction='in'>
<udplite-ipv6 srcmacaddr='1:2:3:4:5:6'
- srcipaddr='::10.1.2.3' srcipmask='128'
+ srcipaddr='::ffff:10.1.2.3' srcipmask='128'
dscp='33'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2xmlout/ah-ipv6-test.xml b/tests/nwfilterxml2xmlout/ah-ipv6-test.xml
index 6d65b3de57..2c4b9c97af 100644
--- a/tests/nwfilterxml2xmlout/ah-ipv6-test.xml
+++ b/tests/nwfilterxml2xmlout/ah-ipv6-test.xml
@@ -7,6 +7,6 @@
<ah-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
- <ah-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='33'/>
+ <ah-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::ffff:10.1.2.3' dscp='33'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2xmlout/all-ipv6-test.xml b/tests/nwfilterxml2xmlout/all-ipv6-test.xml
index 263a679966..226e86bead 100644
--- a/tests/nwfilterxml2xmlout/all-ipv6-test.xml
+++ b/tests/nwfilterxml2xmlout/all-ipv6-test.xml
@@ -7,6 +7,6 @@
<all-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
- <all-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='33'/>
+ <all-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::ffff:10.1.2.3' dscp='33'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2xmlout/comment-test.xml b/tests/nwfilterxml2xmlout/comment-test.xml
index 1d95af1c27..70779bcb23 100644
--- a/tests/nwfilterxml2xmlout/comment-test.xml
+++ b/tests/nwfilterxml2xmlout/comment-test.xml
@@ -7,7 +7,7 @@
<ip srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' srcipaddr='10.1.2.3' srcipmask='32' dstipaddr='10.1.2.3' dstipmask='32' protocol='udp' srcportstart='0x123' srcportend='0x234' dstportstart='0x3456' dstportend='0x4567' dscp='0x32' comment='ip rule'/>
</rule>
<rule action='accept' direction='out' priority='500'>
- <ipv6 srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:fe' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80' srcipaddr='::10.1.2.3' srcipmask='22' dstipaddr='::10.1.2.3' dstipmask='113' protocol='tcp' srcportstart='0x111' srcportend='400' dstportstart='0x3333' dstportend='65535' comment='ipv6 rule'/>
+ <ipv6 srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:fe' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80' srcipaddr='::ffff:10.1.2.3' srcipmask='22' dstipaddr='::10.1.2.3' dstipmask='113' protocol='tcp' srcportstart='0x111' srcportend='400' dstportstart='0x3333' dstportend='65535' comment='ipv6 rule'/>
</rule>
<rule action='accept' direction='out' priority='500'>
<arp srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' hwtype='0x12' protocoltype='0x56' opcode='Request' arpsrcmacaddr='01:02:03:04:05:06' arpdstmacaddr='0a:0b:0c:0d:0e:0f' comment='arp rule'/>
diff --git a/tests/nwfilterxml2xmlout/esp-ipv6-test.xml b/tests/nwfilterxml2xmlout/esp-ipv6-test.xml
index 3852aaca47..c8744b86d8 100644
--- a/tests/nwfilterxml2xmlout/esp-ipv6-test.xml
+++ b/tests/nwfilterxml2xmlout/esp-ipv6-test.xml
@@ -7,6 +7,6 @@
<esp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
- <esp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='33'/>
+ <esp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::ffff:10.1.2.3' dscp='33'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2xmlout/hex-data-test.xml b/tests/nwfilterxml2xmlout/hex-data-test.xml
index 35a125b600..98eeac7152 100644
--- a/tests/nwfilterxml2xmlout/hex-data-test.xml
+++ b/tests/nwfilterxml2xmlout/hex-data-test.xml
@@ -7,7 +7,7 @@
<ip srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' srcipaddr='10.1.2.3' srcipmask='32' dstipaddr='10.1.2.3' dstipmask='32' protocol='udp' srcportstart='0x123' srcportend='0x234' dstportstart='0x3456' dstportend='0x4567' dscp='0x32'/>
</rule>
<rule action='accept' direction='out' priority='500'>
- <ipv6 srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:fe' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80' srcipaddr='::10.1.2.3' srcipmask='22' dstipaddr='::10.1.2.3' dstipmask='113' protocol='tcp' srcportstart='0x111' srcportend='400' dstportstart='0x3333' dstportend='65535'/>
+ <ipv6 srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:fe' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80' srcipaddr='::ffff:10.1.2.3' srcipmask='22' dstipaddr='::10.1.2.3' dstipmask='113' protocol='tcp' srcportstart='0x111' srcportend='400' dstportstart='0x3333' dstportend='65535'/>
</rule>
<rule action='accept' direction='out' priority='500'>
<arp srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' hwtype='0x12' protocoltype='0x56' opcode='Request' arpsrcmacaddr='01:02:03:04:05:06' arpdstmacaddr='0a:0b:0c:0d:0e:0f'/>
diff --git a/tests/nwfilterxml2xmlout/icmpv6-test.xml b/tests/nwfilterxml2xmlout/icmpv6-test.xml
index 3334038a84..314aad2137 100644
--- a/tests/nwfilterxml2xmlout/icmpv6-test.xml
+++ b/tests/nwfilterxml2xmlout/icmpv6-test.xml
@@ -7,6 +7,6 @@
<icmpv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33' type='255' code='255'/>
</rule>
<rule action='accept' direction='in' priority='500'>
- <icmpv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='33'/>
+ <icmpv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::ffff:10.1.2.3' dscp='33'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2xmlout/ipv6-test.xml b/tests/nwfilterxml2xmlout/ipv6-test.xml
index ce9dd06233..3c5799590a 100644
--- a/tests/nwfilterxml2xmlout/ipv6-test.xml
+++ b/tests/nwfilterxml2xmlout/ipv6-test.xml
@@ -1,7 +1,7 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
- <ipv6 srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:fe' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80' srcipaddr='::10.1.2.3' srcipmask='22' dstipaddr='::10.1.2.3' dstipmask='113' protocol='udp' srcportstart='20' srcportend='22' dstportstart='100' dstportend='101'/>
+ <ipv6 srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:fe' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80' srcipaddr='::ffff:10.1.2.3' srcipmask='22' dstipaddr='::10.1.2.3' dstipmask='113' protocol='udp' srcportstart='20' srcportend='22' dstportstart='100' dstportend='101'/>
</rule>
<rule action='accept' direction='inout' priority='500'>
<ipv6 srcipaddr='1::2' srcipmask='128' dstipaddr='a:b:c::' dstipmask='65' protocol='tcp' srcportstart='20' srcportend='22' dstportstart='100' dstportend='101'/>
diff --git a/tests/nwfilterxml2xmlout/sctp-ipv6-test.xml b/tests/nwfilterxml2xmlout/sctp-ipv6-test.xml
index 3ef8589a00..87c8487257 100644
--- a/tests/nwfilterxml2xmlout/sctp-ipv6-test.xml
+++ b/tests/nwfilterxml2xmlout/sctp-ipv6-test.xml
@@ -7,6 +7,6 @@
<sctp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33' srcportstart='20' srcportend='21' dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in' priority='500'>
- <sctp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
+ <sctp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::ffff:10.1.2.3' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2xmlout/tcp-ipv6-test.xml b/tests/nwfilterxml2xmlout/tcp-ipv6-test.xml
index fcbe7a4a0f..0755c1b75f 100644
--- a/tests/nwfilterxml2xmlout/tcp-ipv6-test.xml
+++ b/tests/nwfilterxml2xmlout/tcp-ipv6-test.xml
@@ -7,6 +7,6 @@
<tcp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33' srcportstart='20' srcportend='21' dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in' priority='500'>
- <tcp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
+ <tcp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::ffff:10.1.2.3' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2xmlout/udp-ipv6-test.xml b/tests/nwfilterxml2xmlout/udp-ipv6-test.xml
index abcf698169..28b1a93f4d 100644
--- a/tests/nwfilterxml2xmlout/udp-ipv6-test.xml
+++ b/tests/nwfilterxml2xmlout/udp-ipv6-test.xml
@@ -7,6 +7,6 @@
<udp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipmask='128' dscp='33' srcportstart='20' srcportend='21' dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in' priority='500'>
- <udp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
+ <udp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::ffff:10.1.2.3' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
</filter>
diff --git a/tests/nwfilterxml2xmlout/udplite-ipv6-test.xml b/tests/nwfilterxml2xmlout/udplite-ipv6-test.xml
index 9f41181535..308fb98e6f 100644
--- a/tests/nwfilterxml2xmlout/udplite-ipv6-test.xml
+++ b/tests/nwfilterxml2xmlout/udplite-ipv6-test.xml
@@ -7,6 +7,6 @@
<udplite-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
- <udplite-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='33'/>
+ <udplite-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::ffff:10.1.2.3' dscp='33'/>
</rule>
</filter>
--
2.33.0

View File

@ -0,0 +1,76 @@
From d72b85480695e15f1ffdd7cd91ddecc4608467c6 Mon Sep 17 00:00:00 2001
From: liumengqiu <liumengqiu1@huawei.com>
Date: Thu, 25 Aug 2022 20:22:02 +0800
Subject: [PATCH 05/13] tests: add explicit test case for pflash loader lacking
path
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The following is expected to raise an error:
<os>
<loader readonly='yes' type='pflash'/>
</os>
because no path to the pflash loader is given and there is
no default built-in.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: liumengqiu <liumengqiu1@huawei.com>
---
tests/qemuxml2argvdata/bios-nvram-no-path.err | 1 +
tests/qemuxml2argvdata/bios-nvram-no-path.xml | 19 +++++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
3 files changed, 21 insertions(+)
create mode 100644 tests/qemuxml2argvdata/bios-nvram-no-path.err
create mode 100644 tests/qemuxml2argvdata/bios-nvram-no-path.xml
diff --git a/tests/qemuxml2argvdata/bios-nvram-no-path.err b/tests/qemuxml2argvdata/bios-nvram-no-path.err
new file mode 100644
index 0000000000..795386008c
--- /dev/null
+++ b/tests/qemuxml2argvdata/bios-nvram-no-path.err
@@ -0,0 +1 @@
+no loader path specified and firmware auto selection disabled
diff --git a/tests/qemuxml2argvdata/bios-nvram-no-path.xml b/tests/qemuxml2argvdata/bios-nvram-no-path.xml
new file mode 100644
index 0000000000..bf97f0bdd6
--- /dev/null
+++ b/tests/qemuxml2argvdata/bios-nvram-no-path.xml
@@ -0,0 +1,19 @@
+<domain type='qemu'>
+ <name>test-bios</name>
+ <uuid>362d1fc1-df7d-193e-5c18-49a71bd1da66</uuid>
+ <memory unit='KiB'>1048576</memory>
+ <currentMemory unit='KiB'>1048576</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <loader readonly='yes' type='pflash'/>
+ <boot dev='hd'/>
+ <bootmenu enable='yes'/>
+ </os>
+ <features>
+ <acpi/>
+ </features>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d37969d065..e3ecd37c2b 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -990,6 +990,7 @@ mymain(void)
QEMU_CAPS_DEVICE_ISA_SERIAL,
QEMU_CAPS_SGA);
DO_TEST("bios-nvram", NONE);
+ DO_TEST_PARSE_ERROR("bios-nvram-no-path", NONE);
DO_TEST("bios-nvram-secure",
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
QEMU_CAPS_DEVICE_PCI_BRIDGE,
--
2.33.0

View File

@ -0,0 +1,114 @@
From 29348ffca334863dccc462d8337d9bedea3d511f Mon Sep 17 00:00:00 2001
From: liumengqiu <liumengqiu1@huawei.com>
Date: Wed, 24 Aug 2022 16:33:34 +0800
Subject: [PATCH] tests: add test case for NVRAM with template
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This demonstrates that
<os>
<loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
<nvram template="/usr/share/OVMF/OVMF_VARS.fd"/>
</os>
gets expanded to give a per-VM NVRAM path.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: liumengqiu <liumengqiu1@huawei.com>
---
.../bios-nvram-template.x86_64-latest.args | 36 +++++++++++++++++++
.../qemuxml2argvdata/bios-nvram-template.xml | 21 +++++++++++
tests/qemuxml2argvtest.c | 3 +-
3 files changed, 59 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/bios-nvram-template.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/bios-nvram-template.xml
diff --git a/tests/qemuxml2argvdata/bios-nvram-template.x86_64-latest.args b/tests/qemuxml2argvdata/bios-nvram-template.x86_64-latest.args
new file mode 100644
index 0000000000..bd612d1001
--- /dev/null
+++ b/tests/qemuxml2argvdata/bios-nvram-template.x86_64-latest.args
@@ -0,0 +1,36 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-test-bios \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-test-bios/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-test-bios/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-test-bios/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name guest=test-bios,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-test-bios/master-key.aes \
+-blockdev '{"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}' \
+-blockdev '{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/test-bios_VARS.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}' \
+-machine pc,usb=off,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format \
+-accel tcg \
+-cpu qemu64 \
+-m 1024 \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid 362d1fc1-df7d-193e-5c18-49a71bd1da66 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot menu=on,strict=on \
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/bios-nvram-template.xml b/tests/qemuxml2argvdata/bios-nvram-template.xml
new file mode 100644
index 0000000000..1bbe4314b5
--- /dev/null
+++ b/tests/qemuxml2argvdata/bios-nvram-template.xml
@@ -0,0 +1,21 @@
+<domain type='qemu'>
+ <name>test-bios</name>
+ <uuid>362d1fc1-df7d-193e-5c18-49a71bd1da66</uuid>
+ <memory unit='KiB'>1048576</memory>
+ <currentMemory unit='KiB'>1048576</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
+ <nvram template="/usr/share/OVMF/OVMF_VARS.fd"/>
+ <boot dev='hd'/>
+ <bootmenu enable='yes'/>
+ </os>
+ <features>
+ <acpi/>
+ </features>
+ <clock offset='utc'/>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d37969d065..dacaf0bca3 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -997,7 +997,8 @@ mymain(void)
QEMU_CAPS_ICH9_AHCI,
QEMU_CAPS_MACHINE_SMM_OPT,
QEMU_CAPS_VIRTIO_SCSI);
-
+ DO_TEST_CAPS_LATEST("bios-nvram-template");
+
/* Make sure all combinations of ACPI and UEFI behave as expected */
DO_TEST("q35-acpi-uefi", NONE);
DO_TEST_PARSE_ERROR("q35-noacpi-uefi", NONE);
--
2.33.0

View File

@ -0,0 +1,34 @@
From 51e4c7c4c88b424b13cddbc5d1e3804d34d88df0 Mon Sep 17 00:00:00 2001
From: Bihong Yu <yubihong@huawei.com>
Date: Mon, 17 Jan 2022 16:46:46 +0100
Subject: [PATCH 10/13] testutils: Terminate usage string with a new line
If a test binary is executed with an argument then usage
information is printed out (that no arguments are accepted and
what environment variables affect execution). The string is
printed onto stderr but it is not terminated with a newline
character producing not so nice output.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Bihong Yu <yubihong@huawei.com>
---
tests/testutils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/testutils.c b/tests/testutils.c
index 2aeaee3306..a2cb6666c2 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -804,7 +804,7 @@ int virTestMain(int argc,
fprintf(stderr, "Usage: %s\n", argv[0]);
fputs("effective environment variables:\n"
"VIR_TEST_VERBOSE set to show names of individual tests\n"
- "VIR_TEST_DEBUG set to show information for debugging failures",
+ "VIR_TEST_DEBUG set to show information for debugging failures\n",
stderr);
return EXIT_FAILURE;
}
--
2.33.0

View File

@ -0,0 +1,30 @@
From 3a68d932c30efd54bbf2833f932adcfdc8a99876 Mon Sep 17 00:00:00 2001
From: huangkai <huangkai101@huawei.com>
Date: Tue, 2 Aug 2022 16:16:57 +0800
Subject: [PATCH 14/22] virConnectDomainEventRegisterAny: correct docs
The callback ID can be zero, not necessarily positive; correct the
comment to reflect this.
Signed-off-by: John Levon <levon@movementarian.org>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/libvirt-domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 0ff99c94b6..6ce4a6715c 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -9281,7 +9281,7 @@ virDomainMigrateStartPostCopy(virDomainPtr domain,
* The reference can be released once the object is no longer required
* by calling virDomainFree().
*
- * The return value from this method is a positive integer identifier
+ * The return value from this method is a non-negative integer identifier
* for the callback. To unregister a callback, this callback ID should
* be passed to the virConnectDomainEventDeregisterAny() method.
*
--
2.33.0

View File

@ -0,0 +1,50 @@
From 5d17ae66252024451c1e9f30f348f5e223b26c72 Mon Sep 17 00:00:00 2001
From: chenyuhui <chenyuhui5@huawei.com>
Date: Tue, 2 Aug 2022 10:51:59 +0800
Subject: [PATCH 19/22] virDomainInputDefValidate: Validate model
If input device has one of virtio* models set then it has to go
onto virtio bus. Introduce such check into the validator.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2081981
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
---
src/conf/domain_conf.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2d1726af8f..b8cf1adb98 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6834,6 +6834,27 @@ virDomainInputDefValidate(const virDomainInputDef *input)
return -1;
}
+ switch ((virDomainInputModel)input->model) {
+ case VIR_DOMAIN_INPUT_MODEL_VIRTIO:
+ case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL:
+ case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL:
+ if (input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("only bus 'virtio' is supported for input model '%s'"),
+ virDomainInputModelTypeToString(input->model));
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_INPUT_MODEL_DEFAULT:
+ break;
+
+ case VIR_DOMAIN_INPUT_MODEL_LAST:
+ default:
+ virReportEnumRangeError(virDomainInputModel, input->model);
+ return -1;
+ }
+
return 0;
}
--
2.33.0

View File

@ -0,0 +1,41 @@
From 1a6d497e64f668d16e7e431bd93efc5436d48a07 Mon Sep 17 00:00:00 2001
From: Bihong Yu <yubihong@huawei.com>
Date: Wed, 12 Jan 2022 12:17:39 +0100
Subject: [PATCH 01/22] virInterfaceDefDevFormat: Add missing error handling
Add missing error handling for virInterfaceDefDevFormat.
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Bihong Yu <yubihong@huawei.com>
---
src/conf/interface_conf.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index d1732621b5..c0744c3899 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -1110,13 +1110,16 @@ virInterfaceDefDevFormat(virBufferPtr buf,
virBufferAsprintf(buf, "<mac address='%s'/>\n", def->mac);
break;
case VIR_INTERFACE_TYPE_BRIDGE:
- virInterfaceBridgeDefFormat(buf, def);
+ if (virInterfaceBridgeDefFormat(buf, def) < 0)
+ return -1;
break;
case VIR_INTERFACE_TYPE_BOND:
- virInterfaceBondDefFormat(buf, def);
+ if (virInterfaceBondDefFormat(buf, def) < 0)
+ return -1;
break;
case VIR_INTERFACE_TYPE_VLAN:
- virInterfaceVlanDefFormat(buf, def);
+ if (virInterfaceVlanDefFormat(buf, def) < 0)
+ return -1;
break;
}
--
2.33.0

View File

@ -0,0 +1,35 @@
From 2153e7eb25d0ffd2b4af0776df8e089e7c503687 Mon Sep 17 00:00:00 2001
From: huangkai <huangkai101@huawei.com>
Date: Tue, 2 Aug 2022 16:26:13 +0800
Subject: [PATCH 16/22] virNWFilterObjListFree: Prevent null pointer derefernce
Allow virNWFilterObjListFree to be called with a NULL argument.
This enables a later patch to use virNWFilterObjListFree as a
cleanup function safely, as it is a no-op if virNWFilterObj was
not yet initialized.
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/virnwfilterobj.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index c9e224061d..cc59c0ea9d 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -108,6 +108,11 @@ void
virNWFilterObjListFree(virNWFilterObjListPtr nwfilters)
{
size_t i;
+
+ if (!nwfilters) {
+ return;
+ }
+
for (i = 0; i < nwfilters->count; i++)
virNWFilterObjFree(nwfilters->objs[i]);
VIR_FREE(nwfilters->objs);
--
2.33.0

View File

@ -0,0 +1,36 @@
From 4bb06dc8104d886e7fa5bfdb7e32825e6cb50966 Mon Sep 17 00:00:00 2001
From: liumengqiu <liumengqiu1@huawei.com>
Date: Thu, 11 Aug 2022 21:19:22 +0800
Subject: [PATCH 11/22] virNetDevOpenvswitchUpdateVlan: Use space for
indentation
Breaks syntax-check:
TAB_in_indentation
/home/pipo/libvirt/src/util/virnetdevopenvswitch.c:610: if (virtVlan && virtVlan->nTags > 0)
/home/pipo/libvirt/src/util/virnetdevopenvswitch.c:611: virCommandAddArgList(cmd, "--", "--if-exists", "set", "Port", ifname, NULL);
make: Leaving directory '/home/pipo/build/libvirt/gcc/build-aux'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
src/util/virnetdevopenvswitch.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 5de8c7f5cf..52feff7468 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -549,8 +549,8 @@ int virNetDevOpenvswitchUpdateVlan(const char *ifname,
"--", "--if-exists", "clear", "Port", ifname, "trunk",
"--", "--if-exists", "clear", "Port", ifname, "vlan_mode", NULL);
- if (virtVlan && virtVlan->nTags > 0)
- virCommandAddArgList(cmd, "--", "--if-exists", "set", "Port", ifname, NULL);
+ if (virtVlan && virtVlan->nTags > 0)
+ virCommandAddArgList(cmd, "--", "--if-exists", "set", "Port", ifname, NULL);
if (virNetDevOpenvswitchConstructVlans(cmd, virtVlan) < 0)
return -1;
--
2.33.0

View File

@ -0,0 +1,68 @@
From 3b5a24866bf5fae387de70be8cb65e29b31a3a6d Mon Sep 17 00:00:00 2001
From: liumengqiu <liumengqiu1@huawei.com>
Date: Thu, 11 Aug 2022 20:04:09 +0800
Subject: [PATCH 10/22] virNetDevOpenvswitchUpdateVlan: fix vlan tag update
error
We try to update vlan tag by running virsh update-device command,
libvirtd will report ovs-vsctl arguments error. Vlan tag update
funtion does't consider the xml with no vlan configured circumstances.
The steps to reproduce the problem:
1 define and start domain with its vlan configured as:
<interface type='bridge'>
<mac address='52:54:00:9e:bb:ac'/>
<source bridge='ovs-br0'/>
<vlan>
<tag id='10'/>
</vlan>
<virtualport type='openvswitch'>
</virtualport>
<target dev='vnet4.0'/>
<model type='virtio'/>
<driver name='vhost'/>
</interface>
2 define and run virsh update-device command with no vlan configured as:
<interface type='bridge'>
<mac address='52:54:00:9e:bb:ac'/>
<source bridge='ovs-br0'/>
<virtualport type='openvswitch'>
</virtualport>
<target dev='vnet4.0'/>
<model type='virtio'/>
<driver name='vhost'/>
</interface>
#virsh update-device dom-id novlan.xml
3 virsh command returned error, and we got an error in libvirtd.log:
error : virCommandWait:2584 : internal error: exit status 1: ovs-vsctl: 'set' command requires at least 3 arguments
. Child process (ovs-vsctl --timeout=5 -- --if-exists clear Port vnet4.0 tag -- --if-exists clear Port vnet4.0 trunk
-- --if-exists clear Port vnet4.0 vlan_mode -- --if-exists set Port vnet4.0) unexpected
error : virNetDevOpenvswitchUpdateVlan:540 : internal error: Unable to set vlan configuration on port vnet4.0
Signed-off-by: Tu Qiang <tu.qiang35@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
src/util/virnetdevopenvswitch.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index f961777411..5de8c7f5cf 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -547,8 +547,10 @@ int virNetDevOpenvswitchUpdateVlan(const char *ifname,
virCommandAddArgList(cmd,
"--", "--if-exists", "clear", "Port", ifname, "tag",
"--", "--if-exists", "clear", "Port", ifname, "trunk",
- "--", "--if-exists", "clear", "Port", ifname, "vlan_mode",
- "--", "--if-exists", "set", "Port", ifname, NULL);
+ "--", "--if-exists", "clear", "Port", ifname, "vlan_mode", NULL);
+
+ if (virtVlan && virtVlan->nTags > 0)
+ virCommandAddArgList(cmd, "--", "--if-exists", "set", "Port", ifname, NULL);
if (virNetDevOpenvswitchConstructVlans(cmd, virtVlan) < 0)
return -1;
--
2.33.0

View File

@ -0,0 +1,38 @@
From 2aefb506e491e0ddf1abb6a7cbb2c4137e01e47e Mon Sep 17 00:00:00 2001
From: chenyuhui <chenyuhui5@huawei.com>
Date: Mon, 1 Aug 2022 19:32:29 +0800
Subject: [PATCH 21/22] virNetDevSaveNetConfig: Pass mode to virFileWriteStr()
For some types of SRIOV interfaces we create a temporary file
where the state of the interface is saved before we start
modifying it. The file is used then to restore the original
configuration when the interface is no longer associated with any
guest. For writing the file virFileWriteStr() is used. However,
it's given wrong argument: the last argument is supposed to be
mode to create the file with but virNetDevSaveNetConfig() passes
open(2) flags (O_CREAT|O_TRUNC|O_WRONLY). We need the file to be
writable and readable by root only (0600). Therefore, pass that
mode instead of gibberish.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
---
src/util/virnetdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 950844b110..518eaea820 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1916,7 +1916,7 @@ virNetDevSaveNetConfig(const char *linkdev, int vf,
if (!(fileStr = virJSONValueToString(configJSON, true)))
goto cleanup;
- if (virFileWriteStr(filePath, fileStr, O_CREAT|O_TRUNC|O_WRONLY) < 0) {
+ if (virFileWriteStr(filePath, fileStr, 0600) < 0) { /* 0600: writable and readable by root */
virReportSystemError(errno, _("Unable to preserve mac/vlan tag "
"for device = %s, vf = %d"), linkdev, vf);
goto cleanup;
--
2.33.0

View File

@ -0,0 +1,45 @@
From 23f96f11539b13cee88563d8c670036b4868787b Mon Sep 17 00:00:00 2001
From: liumengqiu <liumengqiu1@huawei.com>
Date: Wed, 24 Aug 2022 16:22:15 +0800
Subject: [PATCH 11/13] virbuftest: Increase coverage
Test the behavior of virBufferEscapeShell for different types of
quotes as well as the empty string.
Signed-off-by: Andrea Bolognani abologna@redhat.com
Reviewed-by: Michal Privoznik mprivozn@redhat.com
Signed-off-by: liumengqiu <liumengqiu1@huawei.com>
---
tests/virbuftest.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
index f9d19ff1a1..26e344feab 100644
--- a/tests/virbuftest.c
+++ b/tests/virbuftest.c
@@ -20,7 +20,8 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
virBuffer bufinit = VIR_BUFFER_INITIALIZER;
virBufferPtr buf = &bufinit;
const char expected[] =
- " 1\n 2\n 3\n 4\n 5\n 6\n 7\n &amp;\n 8\n 9\n 10\n ' 11'\n";
+ " 1\n 2\n 3\n 4\n 5\n 6\n 7\n &amp;\n 8\n 9\n 10\n"
+ " ' 11'\n ''\\''12'\n '\"13'\n ''\n";
g_autofree char *result = NULL;
int ret = 0;
@@ -85,6 +86,12 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
virBufferAddChar(buf, '\n');
virBufferEscapeShell(buf, " 11");
virBufferAddChar(buf, '\n');
+ virBufferEscapeShell(buf, "'12");
+ virBufferAddChar(buf, '\n');
+ virBufferEscapeShell(buf, "\"13");
+ virBufferAddChar(buf, '\n');
+ virBufferEscapeShell(buf, "");
+ virBufferAddChar(buf, '\n');
result = virBufferContentAndReset(buf);
if (!result || STRNEQ(result, expected)) {
--
2.33.0

View File

@ -0,0 +1,35 @@
From 6ce9382804a5598150d4d357adfef2fd2d09c48b Mon Sep 17 00:00:00 2001
From: xuyinghao <xuyinghao2@huawei.com>
Date: Tue, 16 Aug 2022 19:38:53 +0800
Subject: [PATCH 12/13] vircgroupmock: Be wiser about detecting fakerootdir
change
The way that vircgroupmock works is that the vircgrouptest creates a temporary directory and sets LIBVIRT_FAKE_ROOT_DIR env variable which is then checked by the mock at the beginning of basically every function it overrides (access(), stat in all its flavours, mkdir(), etc.). The mock then creates a CGroup dir structure. But the test is allowed to change the directory, to accommodate environment for the particular test case. This is done by changing the environment variable which is then detected by the mock and the whole process repeats.
However, the way the mock detect changes is buggy. After it got the environment variable it compares it to the last known value (global variable @fakerootdir) and if they don't match the last known value is set to point to the new value. Problem is that the result of getenv() is assigned to the @fakerootdir directly.Therefore, @fakerootdir points somewhere into the buffer of environment variables. In turn, when the test sets new value (via g_setenv()) it may be placed at the very same position in the env var buffer and thus the mock fails to detect the change.
The solution is to keep our private copy of the value (by g_strdup()) which makes the variable not rely on getenv()/setenv() placing values at random positions.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/vircgroupmock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c
index 66b8c01852..4acadb8686 100644
--- a/tests/vircgroupmock.c
+++ b/tests/vircgroupmock.c
@@ -352,7 +352,8 @@ static void init_sysfs(void)
if (fakerootdir && STREQ(fakerootdir, newfakerootdir))
return;
- fakerootdir = newfakerootdir;
+ VIR_FREE(fakerootdir);
+ fakerootdir = g_strdup(newfakerootdir);
mock = getenv("VIR_CGROUP_MOCK_MODE");
if (mock) {
--
2.33.0

View File

@ -0,0 +1,51 @@
From cb72ee4b8e09b2a4246fc85235ae2a73cff4cb73 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Tue, 1 Feb 2022 10:21:02 +0100
Subject: [PATCH 05/22] virnwfilterbindingobj: Fix virNWFilterBindingObjNew()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The idea behind virNWFilterBindingObjNew() is to create and
return an object of virNWFilterBindingObjClass class. The class
is virObjectLockable (and the corresponding
_virNWFilterBindingObj structure has virObjectLockable parent).
But for some reason plain virObjectNew() is called. This is wrong
because the mutex in the parent is left uninitialized.
Next, the returned object is not locked. This is wrong because in
some cases the returned object is added onto a list of bindings
and then passed to virNWFilterBindingObjEndAPI() which unlocks it
right away. This is potentially dangerous because we might just
have unlocked the object for another thread.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/virnwfilterbindingobj.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/conf/virnwfilterbindingobj.c b/src/conf/virnwfilterbindingobj.c
index 7cfc2e9efa..656398ed8b 100644
--- a/src/conf/virnwfilterbindingobj.c
+++ b/src/conf/virnwfilterbindingobj.c
@@ -57,10 +57,15 @@ VIR_ONCE_GLOBAL_INIT(virNWFilterBindingObj);
virNWFilterBindingObjPtr
virNWFilterBindingObjNew(void)
{
+ virNWFilterBindingObj *ret;
if (virNWFilterBindingObjInitialize() < 0)
return NULL;
- return virObjectNew(virNWFilterBindingObjClass);
+ if (!(ret = virObjectLockableNew(virNWFilterBindingObjClass)))
+ return NULL;
+
+ virObjectLock(ret);
+ return ret;
}
--
2.33.0

View File

@ -0,0 +1,42 @@
From 6999dc861ad3cf77802f76cda028802355c4ee6d Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Wed, 8 Jun 2022 15:01:00 +0200
Subject: [PATCH 20/22] virsh: Check whether enough arguments was passed to
iothreadset
Virsh has iothreadset command which allows setting various
attributes of IOThreads. However, when the command is called
without any arguments (besides domain and IOThread IDs), then
@params stays NULL and is passed to virDomainSetIOThreadParams()
which produces rather user unfriendly error message:
error: params in virDomainSetIOThreadParams must not be NULL
Introduce a check and produce better error message.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
---
tools/virsh-domain.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 6dd56168e3..0d58775289 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7981,6 +7981,11 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd)
#undef VSH_IOTHREAD_SET_UINT_PARAMS
+ if (nparams == 0) {
+ vshError(ctl, _("Not enough arguments passed, nothing to set"));
+ goto cleanup;
+ }
+
if (virDomainSetIOThreadParams(dom, id, params, nparams, flags) < 0)
goto cleanup;
--
2.33.0

View File

@ -0,0 +1,57 @@
From e24d9516a286735716f388dcb403e2cf84841f25 Mon Sep 17 00:00:00 2001
From: huangkai <huangkai101@huawei.com>
Date: Tue, 2 Aug 2022 16:21:38 +0800
Subject: [PATCH 15/22] virsh: Fix integer overflow in allocpages
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
I've came across an aarch64 system which supports hugepages up to
16GiB of size. However, I was unable to allocate them using
virsh allocpages. This is because cmdAllocpages() uses
vshCommandOptScaledInt(), which scales passed value into bytes,
but since the virNodeAllocPages() expects size in KiB the
variable holding bytes is then divided by 1024. However, the
limit for the biggest value passed to vshCommandOptScaledInt() is
UINT_MAX which is now obviously wrong, as it needs to be UINT_MAX
* 1024.
The same bug is in completer. But here, let's use ULLONG_MAX so
that we don't have to care about it anymore.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tools/virsh-completer-host.c | 2 +-
tools/virsh-host.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c
index 8893888ec2..7d2ef01be1 100644
--- a/tools/virsh-completer-host.c
+++ b/tools/virsh-completer-host.c
@@ -41,7 +41,7 @@ virshPagesizeNodeToString(xmlNodePtr node)
unit = virXMLPropString(node, "unit");
if (virStrToLong_ull(pagesize, NULL, 10, &byteval) < 0)
return NULL;
- if (virScaleInteger(&byteval, unit, 1024, UINT_MAX) < 0)
+ if (virScaleInteger(&byteval, unit, 1024, ULLONG_MAX) < 0)
return NULL;
size = vshPrettyCapacity(byteval, &suffix);
ret = g_strdup_printf("%.0f%s", size, suffix);
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 0fd77cbae5..67d5466be2 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -519,7 +519,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
if (cellno && vshCommandOptInt(ctl, cmd, "cellno", &startCell) < 0)
return false;
- if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &tmp, 1024, UINT_MAX) < 0)
+ if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &tmp, 1024, UINT_MAX * 1024ULL) < 0)
return false;
pageSizes[0] = VIR_DIV_UP(tmp, 1024);
--
2.33.0

View File

@ -0,0 +1,55 @@
From b50bad542e62e13c55f5b9057f7ca869f818c3e9 Mon Sep 17 00:00:00 2001
From: xuyinghao <xuyinghao2@huawei.com>
Date: Tue, 9 Aug 2022 18:59:08 +0800
Subject: [PATCH 12/22] virsh: fflush(stdout) after fputs()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Description: We are not guaranteed that the string we are printing onto stdout contains '\n' and thus that the stdout is flushed. Flush stdout after all fputs()-s which do not flush stdout.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tools/vsh.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/vsh.c b/tools/vsh.c
index 9bb4ff043a..3646f37cea 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -1829,6 +1829,7 @@ vshDebug(vshControl *ctl, int level, const char *format, ...)
str = g_strdup_vprintf(format, ap);
va_end(ap);
fputs(str, stdout);
+ fflush(stdout);
VIR_FREE(str);
}
@@ -1845,6 +1846,7 @@ vshPrintExtra(vshControl *ctl, const char *format, ...)
str = g_strdup_vprintf(format, ap);
va_end(ap);
fputs(str, stdout);
+ fflush(stdout);
VIR_FREE(str);
}
@@ -1859,6 +1861,7 @@ vshPrint(vshControl *ctl G_GNUC_UNUSED, const char *format, ...)
str = g_strdup_vprintf(format, ap);
va_end(ap);
fputs(str, stdout);
+ fflush(stdout);
VIR_FREE(str);
}
@@ -2950,6 +2953,7 @@ vshReadline(vshControl *ctl G_GNUC_UNUSED,
int len;
fputs(prompt, stdout);
+ fflush(stdout);
r = fgets(line, sizeof(line), stdin);
if (r == NULL) return NULL; /* EOF */
--
2.33.0