diff --git a/conf-validate-serial-port-model-in-ABI-checks.patch b/conf-validate-serial-port-model-in-ABI-checks.patch new file mode 100644 index 0000000000000000000000000000000000000000..926e02ff7a6cca269a81318300cf94fcb86f6844 --- /dev/null +++ b/conf-validate-serial-port-model-in-ABI-checks.patch @@ -0,0 +1,41 @@ +From 0e6fcb0eb5e3eb499a3cc7232fa1b7bf9f1813a2 Mon Sep 17 00:00:00 2001 +From: jiangdawei15 +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 + +Signed-off-by: Daniel P. Berrangé +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 + diff --git a/enum-Add-helpers-for-converting-virTristate-to-a-pla.patch b/enum-Add-helpers-for-converting-virTristate-to-a-pla.patch new file mode 100644 index 0000000000000000000000000000000000000000..78c611b96b2ef9fca983766f8559fdef67e0449e --- /dev/null +++ b/enum-Add-helpers-for-converting-virTristate-to-a-pla.patch @@ -0,0 +1,125 @@ +From 04c5fee85547da11323b66b2fb79fb590e8307a1 Mon Sep 17 00:00:00 2001 +From: jiangdawei15 +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 +Reviewed-by: Ján Tomko +--- + 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 + diff --git a/libvirt.spec b/libvirt.spec index c934d07197fddcdd55ef96439172dc8c71f131fc..13473067129217e2cb79b4fbf038b5ecab4c978d 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -101,7 +101,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 6.2.0 -Release: 49 +Release: 50 License: LGPLv2+ 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 Patch0321: migration-multifd-pin-add-qemu-monitor-callback-func.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-config-network = %{version}-%{release} @@ -2166,6 +2200,9 @@ exit 0 %changelog +* Wed Jan 04 2023 jiangjiacheng - 6.2.0-50 +- backport patches from upstream + * Sat Dec 17 2022 zhengchuan - 6.2.0-49 - add function of set migration thread affinity during migration diff --git a/qemu-Log-which-API-is-trying-to-acquire-a-job.patch b/qemu-Log-which-API-is-trying-to-acquire-a-job.patch new file mode 100644 index 0000000000000000000000000000000000000000..48da1302331439f6942ba73f2408ebb3b5a1d608 --- /dev/null +++ b/qemu-Log-which-API-is-trying-to-acquire-a-job.patch @@ -0,0 +1,53 @@ +From 6c3639df31680a03e03ad1e0f1ad489db595c02d Mon Sep 17 00:00:00 2001 +From: Bihong Yu +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 +Reviewed-by: Ján Tomko +Signed-off-by: Bihong Yu +--- + 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 + diff --git a/qemu-Validate-domain-definition-even-on-migration.patch b/qemu-Validate-domain-definition-even-on-migration.patch new file mode 100644 index 0000000000000000000000000000000000000000..e272d7d7cc08e845fabeb0ed36f772b0a8f70f52 --- /dev/null +++ b/qemu-Validate-domain-definition-even-on-migration.patch @@ -0,0 +1,68 @@ +From 3fbf29d9a7f89c7fc627c11c4ec65a2e10fd391a Mon Sep 17 00:00:00 2001 +From: jiangdawei15 +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 +Reviewed-by: Peter Krempa +--- + 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 + diff --git a/qemu-do-crash-safe-creation-of-NVRAM-file.patch b/qemu-do-crash-safe-creation-of-NVRAM-file.patch new file mode 100644 index 0000000000000000000000000000000000000000..fcf0311e94933b3b366070283cf69707e02cab30 --- /dev/null +++ b/qemu-do-crash-safe-creation-of-NVRAM-file.patch @@ -0,0 +1,89 @@ +From c96afef6693dfbf783abf5dfa3b60c588920e201 Mon Sep 17 00:00:00 2001 +From: jiangdawei15 +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 +Signed-off-by: Daniel P. Berrangé +--- + 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 + diff --git a/qemu-fix-formatting-of-pflash-readonly-attribute.patch b/qemu-fix-formatting-of-pflash-readonly-attribute.patch new file mode 100644 index 0000000000000000000000000000000000000000..4769b95e31a3a700e4d3a803358647a53825bdaa --- /dev/null +++ b/qemu-fix-formatting-of-pflash-readonly-attribute.patch @@ -0,0 +1,48 @@ +From 678c5195c496ee02d46554f0e80216b20928358e Mon Sep 17 00:00:00 2001 +From: jiangdawei15 +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 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: + + + /var/lib/libvirt/qemu/nvram/test-bios.fd + + +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 +Signed-off-by: Daniel P. Berrangé +--- + 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 + diff --git a/qemu-fix-one-more-race-on-undefining-and-create.patch b/qemu-fix-one-more-race-on-undefining-and-create.patch new file mode 100644 index 0000000000000000000000000000000000000000..bd12cdbb63844368606f661aaf76a7e84704e4fc --- /dev/null +++ b/qemu-fix-one-more-race-on-undefining-and-create.patch @@ -0,0 +1,55 @@ +From 046ca6d0b6c80dc233e530c31156a808ae63893a Mon Sep 17 00:00:00 2001 +From: huangkai +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 +Date: Thu Dec 11 11:14:08 2014 +0100 + + qemu: avoid rare race when undefining domain + +Signed-off-by: Nikolay Shirokovskiy +Reviewed-by: Martin Kletzander +--- + 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 + diff --git a/qemuDomainAttachHostPCIDevice-Fix-coding-style.patch b/qemuDomainAttachHostPCIDevice-Fix-coding-style.patch new file mode 100644 index 0000000000000000000000000000000000000000..1d3f4e445ff8badc2735e71c109a86e365c7d34b --- /dev/null +++ b/qemuDomainAttachHostPCIDevice-Fix-coding-style.patch @@ -0,0 +1,34 @@ +From 80f671d083a7508a2b3cabdf3d6c102137ee0616 Mon Sep 17 00:00:00 2001 +From: Michal Privoznik +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 +--- + 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 + diff --git a/qemuDomainPinIOThread-Update-live-definition-after-p.patch b/qemuDomainPinIOThread-Update-live-definition-after-p.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9d6bb8aef60349015b79d559e1d7b7417b988b9 --- /dev/null +++ b/qemuDomainPinIOThread-Update-live-definition-after-p.patch @@ -0,0 +1,52 @@ +From f98761b13ec88aa506987f3d112a9f41f14d6dfb Mon Sep 17 00:00:00 2001 +From: Bihong Yu +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 +Reviewed-by: Ján Tomko +Reviewed-by: Pavel Hrdina +Signed-off-by: Bihong Yu +--- + 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 + diff --git a/qemu_cgroup-Drop-ENOENT-special-case-for-RNG-devices.patch b/qemu_cgroup-Drop-ENOENT-special-case-for-RNG-devices.patch new file mode 100644 index 0000000000000000000000000000000000000000..7901bc107c70603068a1429a062fe9e8d900f45d --- /dev/null +++ b/qemu_cgroup-Drop-ENOENT-special-case-for-RNG-devices.patch @@ -0,0 +1,44 @@ +From fccb7c2ccec7fe9a831be04e589b5fb56a048828 Mon Sep 17 00:00:00 2001 +From: xuyinghao +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 +Reviewed-by: Pavel Hrdina +--- + 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 + diff --git a/qemuxml2-argv-xml-data-x86-kvm-32-on-64-Add-machine-.patch b/qemuxml2-argv-xml-data-x86-kvm-32-on-64-Add-machine-.patch new file mode 100644 index 0000000000000000000000000000000000000000..c7d19da13a50ee9f71d450d384256b3adaf7e144 --- /dev/null +++ b/qemuxml2-argv-xml-data-x86-kvm-32-on-64-Add-machine-.patch @@ -0,0 +1,36 @@ +From 4821323a523c8a5b34aab61c913ed7b13deada27 Mon Sep 17 00:00:00 2001 +From: Bihong Yu +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 +Reviewed-by: Ján Tomko +Signed-off-by: Bihong Yu +--- + 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 @@ + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + +- hvm ++ hvm + + + /usr/bin/qemu-system-x86_64 +-- +2.33.0 + diff --git a/qemuxml2argvtest-disk-vhostuser-Add-invocation-for-q.patch b/qemuxml2argvtest-disk-vhostuser-Add-invocation-for-q.patch new file mode 100644 index 0000000000000000000000000000000000000000..6da1901b17893843e3018c6f3696a6bf152d2d87 --- /dev/null +++ b/qemuxml2argvtest-disk-vhostuser-Add-invocation-for-q.patch @@ -0,0 +1,187 @@ +From d8e9a553365a70a7f3ed2286aa847064e6a77542 Mon Sep 17 00:00:00 2001 +From: Peter Krempa +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 +--- + .../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 @@ ++ ++ QEMUGuest1 ++ c7a5fdbd-edaf-9455-926a-d65c16db1809 ++ 219136 ++ 219136 ++ 1 ++ ++ qemu64 ++ ++ ++ ++ ++ ++ hvm ++ ++ ++ /usr/bin/qemu-system-x86_64 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +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 + diff --git a/remote_daemon-Don-t-run-virStateCleanup-if-virStateR.patch b/remote_daemon-Don-t-run-virStateCleanup-if-virStateR.patch new file mode 100644 index 0000000000000000000000000000000000000000..65a8c246c8edb0feb262ee380b67a421221c2262 --- /dev/null +++ b/remote_daemon-Don-t-run-virStateCleanup-if-virStateR.patch @@ -0,0 +1,81 @@ +From ffaa244c76d7baeccab1846b1cae8ca057718f03 Mon Sep 17 00:00:00 2001 +From: huangkai +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 +Reviewed-by: Martin Kletzander +--- + 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 + diff --git a/sockettest-Check-for-IPv4-in-IPv6-parsing-and-format.patch b/sockettest-Check-for-IPv4-in-IPv6-parsing-and-format.patch new file mode 100644 index 0000000000000000000000000000000000000000..d8fe44f9a833d9e8ec08b06586d8f25e532811c7 --- /dev/null +++ b/sockettest-Check-for-IPv4-in-IPv6-parsing-and-format.patch @@ -0,0 +1,41 @@ +From 8dfa48d0b5b64ab8bbc78aabfea8252db38215c5 Mon Sep 17 00:00:00 2001 +From: xuyinghao +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 +Reviewed-by: Ján Tomko +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 +Reviewed-by: Erik Skultety +--- + 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 + diff --git a/tests-Allow-expansion-of-mocked-stat-symbols.patch b/tests-Allow-expansion-of-mocked-stat-symbols.patch new file mode 100644 index 0000000000000000000000000000000000000000..67e08113ca86fc69f700361db84839ae80380df7 --- /dev/null +++ b/tests-Allow-expansion-of-mocked-stat-symbols.patch @@ -0,0 +1,41 @@ +From 9f6e5e5fe12e9cb4bb42918f597ba0268e57064b Mon Sep 17 00:00:00 2001 +From: xuyinghao +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 +Reviewed-by: Michal Privoznik +Reviewed-by: Ján Tomko +--- + 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 + diff --git a/tests-Report-expected-monitor-command-for-simulated-.patch b/tests-Report-expected-monitor-command-for-simulated-.patch new file mode 100644 index 0000000000000000000000000000000000000000..3b4b9fd1be21c17d4e1c25c7eaaee72e7a4e4986 --- /dev/null +++ b/tests-Report-expected-monitor-command-for-simulated-.patch @@ -0,0 +1,42 @@ +From 31a4a7ecceeeaccfc016d28aa80f8a668c203ce0 Mon Sep 17 00:00:00 2001 +From: Bihong Yu +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 +Reviewed-by: Ján Tomko +Signed-off-by: Bihong Yu +--- + 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 + diff --git a/tests-Update-IPv4-in-IPv6-addresses.patch b/tests-Update-IPv4-in-IPv6-addresses.patch new file mode 100644 index 0000000000000000000000000000000000000000..6dddd356037fc362b9e59f3d0fcb652d149e678d --- /dev/null +++ b/tests-Update-IPv4-in-IPv6-addresses.patch @@ -0,0 +1,607 @@ +From 339c987367faf9bf758633d7a54b4bbcbf54d300 Mon Sep 17 00:00:00 2001 +From: xuyinghao +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 +Reviewed-by: Ján Tomko +--- + 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 @@ + + + + + +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 @@ + + + + + +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 @@ + + + + + + +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 @@ + + + + + + +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 @@ + + + + +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 @@ + + + +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 @@ + + + +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 @@ + + + + + +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 @@ + + + +- ++ + + +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 @@ + + + +- ++ + + +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 @@ + + + +- ++ + + + +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 @@ + + + +- ++ + + +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 @@ + + + +- ++ + + + +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 @@ + + + +- ++ + + +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 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + +- ++ + + + +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 @@ + + + +- ++ + + +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 @@ + + + +- ++ + + +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 @@ + + + +- ++ + + +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 @@ + + + +- ++ + + +-- +2.33.0 + diff --git a/tests-add-explicit-test-case-for-pflash-loader-lacki.patch b/tests-add-explicit-test-case-for-pflash-loader-lacki.patch new file mode 100644 index 0000000000000000000000000000000000000000..5916b5a9eddeaf8e0af9ea5bc467565fc1f6d529 --- /dev/null +++ b/tests-add-explicit-test-case-for-pflash-loader-lacki.patch @@ -0,0 +1,76 @@ +From d72b85480695e15f1ffdd7cd91ddecc4608467c6 Mon Sep 17 00:00:00 2001 +From: liumengqiu +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: + + + + + +because no path to the pflash loader is given and there is +no default built-in. + +Reviewed-by: Michal Privoznik +Signed-off-by: Daniel P. Berrangé +Signed-off-by: liumengqiu +--- + 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 @@ ++ ++ test-bios ++ 362d1fc1-df7d-193e-5c18-49a71bd1da66 ++ 1048576 ++ 1048576 ++ 1 ++ ++ hvm ++ ++ ++ ++ ++ ++ ++ ++ ++ /usr/bin/qemu-system-x86_64 ++ ++ +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 + diff --git a/tests-add-test-case-for-NVRAM-with-template.patch b/tests-add-test-case-for-NVRAM-with-template.patch new file mode 100644 index 0000000000000000000000000000000000000000..a6428cad93570a17509774d92226dce3626984df --- /dev/null +++ b/tests-add-test-case-for-NVRAM-with-template.patch @@ -0,0 +1,114 @@ +From 29348ffca334863dccc462d8337d9bedea3d511f Mon Sep 17 00:00:00 2001 +From: liumengqiu +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 + + + /usr/share/OVMF/OVMF_CODE.fd + + + +gets expanded to give a per-VM NVRAM path. + +Reviewed-by: Michal Privoznik +Signed-off-by: Daniel P. Berrangé +Signed-off-by: liumengqiu +--- + .../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 @@ ++ ++ test-bios ++ 362d1fc1-df7d-193e-5c18-49a71bd1da66 ++ 1048576 ++ 1048576 ++ 1 ++ ++ hvm ++ /usr/share/OVMF/OVMF_CODE.fd ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ /usr/bin/qemu-system-x86_64 ++ ++ +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 + diff --git a/testutils-Terminate-usage-string-with-a-new-line.patch b/testutils-Terminate-usage-string-with-a-new-line.patch new file mode 100644 index 0000000000000000000000000000000000000000..4c5fdd21f6ba96a8ed9bb0047cbf7d5988950819 --- /dev/null +++ b/testutils-Terminate-usage-string-with-a-new-line.patch @@ -0,0 +1,34 @@ +From 51e4c7c4c88b424b13cddbc5d1e3804d34d88df0 Mon Sep 17 00:00:00 2001 +From: Bihong Yu +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 +Signed-off-by: Bihong Yu +--- + 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 + diff --git a/virConnectDomainEventRegisterAny-correct-docs.patch b/virConnectDomainEventRegisterAny-correct-docs.patch new file mode 100644 index 0000000000000000000000000000000000000000..e324fa94bc27f02b380d003b68de123dc20fcb67 --- /dev/null +++ b/virConnectDomainEventRegisterAny-correct-docs.patch @@ -0,0 +1,30 @@ +From 3a68d932c30efd54bbf2833f932adcfdc8a99876 Mon Sep 17 00:00:00 2001 +From: huangkai +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 +Reviewed-by: Michal Privoznik +--- + 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 + diff --git a/virDomainInputDefValidate-Validate-model.patch b/virDomainInputDefValidate-Validate-model.patch new file mode 100644 index 0000000000000000000000000000000000000000..52a62d74da95c1ba0d983366b04285fe86f010d0 --- /dev/null +++ b/virDomainInputDefValidate-Validate-model.patch @@ -0,0 +1,50 @@ +From 5d17ae66252024451c1e9f30f348f5e223b26c72 Mon Sep 17 00:00:00 2001 +From: chenyuhui +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 +Reviewed-by: Martin Kletzander +--- + 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 + diff --git a/virInterfaceDefDevFormat-Add-missing-error-handling.patch b/virInterfaceDefDevFormat-Add-missing-error-handling.patch new file mode 100644 index 0000000000000000000000000000000000000000..55c1e17c94f85b7fdde2fc9ef0be1332818470f4 --- /dev/null +++ b/virInterfaceDefDevFormat-Add-missing-error-handling.patch @@ -0,0 +1,41 @@ +From 1a6d497e64f668d16e7e431bd93efc5436d48a07 Mon Sep 17 00:00:00 2001 +From: Bihong Yu +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 +Reviewed-by: Michal Privoznik +Signed-off-by: Bihong Yu +--- + 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, "\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 + diff --git a/virNWFilterObjListFree-Prevent-null-pointer-derefern.patch b/virNWFilterObjListFree-Prevent-null-pointer-derefern.patch new file mode 100644 index 0000000000000000000000000000000000000000..b26a1716b2c32b46a31cd61e92ef780f78caf343 --- /dev/null +++ b/virNWFilterObjListFree-Prevent-null-pointer-derefern.patch @@ -0,0 +1,35 @@ +From 2153e7eb25d0ffd2b4af0776df8e089e7c503687 Mon Sep 17 00:00:00 2001 +From: huangkai +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 +Reviewed-by: Michal Privoznik +--- + 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 + diff --git a/virNetDevOpenvswitchUpdateVlan-Use-space-for-indenta.patch b/virNetDevOpenvswitchUpdateVlan-Use-space-for-indenta.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9eea1d2869a0ae56d77c1a0fa6225bdaf548e93 --- /dev/null +++ b/virNetDevOpenvswitchUpdateVlan-Use-space-for-indenta.patch @@ -0,0 +1,36 @@ +From 4bb06dc8104d886e7fa5bfdb7e32825e6cb50966 Mon Sep 17 00:00:00 2001 +From: liumengqiu +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 +--- + 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 + diff --git a/virNetDevOpenvswitchUpdateVlan-fix-vlan-tag-update-e.patch b/virNetDevOpenvswitchUpdateVlan-fix-vlan-tag-update-e.patch new file mode 100644 index 0000000000000000000000000000000000000000..a688ce4364ef755d4d5fab436b2860a4f75bf966 --- /dev/null +++ b/virNetDevOpenvswitchUpdateVlan-fix-vlan-tag-update-e.patch @@ -0,0 +1,68 @@ +From 3b5a24866bf5fae387de70be8cb65e29b31a3a6d Mon Sep 17 00:00:00 2001 +From: liumengqiu +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: + + + + + + + + + + + + +2 define and run virsh update-device command with no vlan configured as: + + + + + + + + + + #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 +Signed-off-by: Yi Wang +Reviewed-by: Michal Privoznik +--- + 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 + diff --git a/virNetDevSaveNetConfig-Pass-mode-to-virFileWriteStr.patch b/virNetDevSaveNetConfig-Pass-mode-to-virFileWriteStr.patch new file mode 100644 index 0000000000000000000000000000000000000000..b761eeba4975cd4fd9b0809ba12be63c520be30e --- /dev/null +++ b/virNetDevSaveNetConfig-Pass-mode-to-virFileWriteStr.patch @@ -0,0 +1,38 @@ +From 2aefb506e491e0ddf1abb6a7cbb2c4137e01e47e Mon Sep 17 00:00:00 2001 +From: chenyuhui +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 +Reviewed-by: Peter Krempa +--- + 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 + diff --git a/virbuftest-Increase-coverage.patch b/virbuftest-Increase-coverage.patch new file mode 100644 index 0000000000000000000000000000000000000000..e99e6e768fca7343b0997ddee8fc01f9f4d0abf1 --- /dev/null +++ b/virbuftest-Increase-coverage.patch @@ -0,0 +1,45 @@ +From 23f96f11539b13cee88563d8c670036b4868787b Mon Sep 17 00:00:00 2001 +From: liumengqiu +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 +--- + 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 &\n 8\n 9\n 10\n ' 11'\n"; ++ " 1\n 2\n 3\n 4\n 5\n 6\n 7\n &\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 + diff --git a/vircgroupmock-Be-wiser-about-detecting-fakerootdir-c.patch b/vircgroupmock-Be-wiser-about-detecting-fakerootdir-c.patch new file mode 100644 index 0000000000000000000000000000000000000000..7027f86fa52c295ac761bc3749d23a12aafb9e0e --- /dev/null +++ b/vircgroupmock-Be-wiser-about-detecting-fakerootdir-c.patch @@ -0,0 +1,35 @@ +From 6ce9382804a5598150d4d357adfef2fd2d09c48b Mon Sep 17 00:00:00 2001 +From: xuyinghao +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 +Reviewed-by: Ján Tomko +--- + 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 + diff --git a/virnwfilterbindingobj-Fix-virNWFilterBindingObjNew.patch b/virnwfilterbindingobj-Fix-virNWFilterBindingObjNew.patch new file mode 100644 index 0000000000000000000000000000000000000000..ac5273a622e403a4c842dc18827332f877fca528 --- /dev/null +++ b/virnwfilterbindingobj-Fix-virNWFilterBindingObjNew.patch @@ -0,0 +1,51 @@ +From cb72ee4b8e09b2a4246fc85235ae2a73cff4cb73 Mon Sep 17 00:00:00 2001 +From: Michal Privoznik +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 +Reviewed-by: Ján Tomko +--- + 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 + diff --git a/virsh-Check-whether-enough-arguments-was-passed-to-i.patch b/virsh-Check-whether-enough-arguments-was-passed-to-i.patch new file mode 100644 index 0000000000000000000000000000000000000000..8aef9f55e8650f84a669c7f03d7480511725bfbc --- /dev/null +++ b/virsh-Check-whether-enough-arguments-was-passed-to-i.patch @@ -0,0 +1,42 @@ +From 6999dc861ad3cf77802f76cda028802355c4ee6d Mon Sep 17 00:00:00 2001 +From: Michal Privoznik +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 +Reviewed-by: Peter Krempa +Reviewed-by: Claudio Fontana +--- + 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 + diff --git a/virsh-Fix-integer-overflow-in-allocpages.patch b/virsh-Fix-integer-overflow-in-allocpages.patch new file mode 100644 index 0000000000000000000000000000000000000000..b7b7e89fd4855e1e7552ea896e5dfe0dcdbcc8f8 --- /dev/null +++ b/virsh-Fix-integer-overflow-in-allocpages.patch @@ -0,0 +1,57 @@ +From e24d9516a286735716f388dcb403e2cf84841f25 Mon Sep 17 00:00:00 2001 +From: huangkai +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 +Reviewed-by: Ján Tomko +--- + 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 + diff --git a/virsh-fflush-stdout-after-fputs.patch b/virsh-fflush-stdout-after-fputs.patch new file mode 100644 index 0000000000000000000000000000000000000000..49a0c9fcd8ff4cc0183df2b10ba9079df2ae2275 --- /dev/null +++ b/virsh-fflush-stdout-after-fputs.patch @@ -0,0 +1,55 @@ +From b50bad542e62e13c55f5b9057f7ca869f818c3e9 Mon Sep 17 00:00:00 2001 +From: xuyinghao +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 +Reviewed-by: Ján Tomko +--- + 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 +