summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* target/nios2: Prevent writes to read-only or reserved control fieldsRichard Henderson2022-04-264-28/+168
| | | | | | | | | | Create an array of masks which detail the writable and readonly bits for each control register. Apply them when writing to control registers, including the write to status during eret. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20220421151735.31996-38-richard.henderson@linaro.org>
* target/nios2: Clean up handling of tlbmisc in do_exceptionRichard Henderson2022-04-262-37/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The 4 lower bits, D, PERM, BAD, DBL, are unconditionally set on any exception with EH=0, or so says Table 42 (Processor Status After Taking Exception). We currently do not set PERM or BAD at all, and only set/clear DBL for tlb miss, and do not clear DBL for any other exception. It is a bit confusing to set D in tlb_fill and the rest during do_interrupt, so move the setting of D to do_interrupt as well. To do this, split EXP_TLBD into two cases, EXCP_TLB_X and EXCP_TLB_D, which allows us to distinguish them during do_interrupt. Choose a value for EXCP_TLB_D such that when truncated it produces the correct value for exception.CAUSE. Rename EXCP_TLB[RWX] to EXCP_PERM_[RWX], to emphasize that the exception is permissions related. Rename EXCP_SUPER[AD] to EXCP_SUPERA_[DX] to emphasize that they are both "supervisor address" exceptions, data and execute. Retain the setting of tlbmisc.WE for the fast-tlb-miss path, as it is being relied upon, but remove it from the permission path. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-37-richard.henderson@linaro.org>
* target/nios2: Cleanup set of CR_EXCEPTION for do_interruptRichard Henderson2022-04-261-3/+4
| | | | | | | | | | | | The register is entirely read-only for software, and we do not implement ECC, so we need not deposit the cause into an existing value; just create a new value from scratch. Furthermore, exception.CAUSE is not written for break exceptions. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-36-richard.henderson@linaro.org>
* target/nios2: Handle EXCP_UNALIGN and EXCP_UNALIGNDRichard Henderson2022-04-261-0/+8
| | | | | | | | | | While some of the plumbing for misaligned data is present, in the form of nios2_cpu_do_unaligned_access, the hook will not be called because TARGET_ALIGNED_ONLY is not set in configs/targets/nios2-softmmu.mak. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20220421151735.31996-35-richard.henderson@linaro.org>
* target/nios2: Hoist CPU_LOG_INT loggingRichard Henderson2022-04-261-11/+47
| | | | | | | | | Performing this early means that we can merge more cases within the non-logging switch statement. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-34-richard.henderson@linaro.org>
* target/nios2: Clean up nios2_cpu_do_interruptRichard Henderson2022-04-261-97/+44Star
| | | | | | | | | | | | | | | | | | Split out do_exception and do_iic_irq to handle bulk of the interrupt and exception processing. Parameterize the changes required to cpu state. The status.EH bit, which protects some data against double-faults, is only present with the MMU. Several exception cases did not check for status.EH being set, as required. The status.IH bit, which had been set by EXCP_IRQ, is exclusive to the external interrupt controller, which we do not yet implement. The internal interrupt controller, when the MMU is also present, sets the status.EH bit. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-33-richard.henderson@linaro.org>
* target/nios2: Create EXCP_SEMIHOST for semi-hostingRichard Henderson2022-04-263-9/+23
| | | | | | | | | Decode 'break 1' during translation, rather than doing it again during exception processing. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-32-richard.henderson@linaro.org>
* target/nios2: Move R_FOO and CR_BAR into enumerationsRichard Henderson2022-04-261-37/+35Star
| | | | | | | | These symbols become available to the debugger. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-31-richard.henderson@linaro.org>
* target/nios2: Use hw/registerfields.h for CR_TLBMISC fieldsRichard Henderson2022-04-264-34/+39
| | | | | | | | | Use FIELD_EX32 and FIELD_DP32 instead of managing the masking by hand. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-30-richard.henderson@linaro.org>
* target/nios2: Rename CR_TLBMISC_WR to CR_TLBMISC_WERichard Henderson2022-04-263-5/+5
| | | | | | | | WE is the architectural name of the field, not WR. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-29-richard.henderson@linaro.org>
* target/nios2: Use hw/registerfields.h for CR_TLBACC fieldsRichard Henderson2022-04-262-16/+23
| | | | | | | | | | | | | | Retain the helper macros for single bit fields as aliases to the longer R_*_MASK names. Use FIELD_EX32 and FIELD_DP32 instead of manually manipulating the fields. Since we're rewriting the references to CR_TLBACC_IGN_* anyway, we correct the name of this field to IG, which is its name in the official CPU documentation. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-28-richard.henderson@linaro.org>
* target/nios2: Use hw/registerfields.h for CR_TLBADDR fieldsRichard Henderson2022-04-264-15/+16
| | | | | | | | | Use FIELD_EX32 and FIELD_DP32 instead of manual manipulation of the fields. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-27-richard.henderson@linaro.org>
* target/nios2: Use hw/registerfields.h for CR_EXCEPTION fieldsRichard Henderson2022-04-262-15/+26
| | | | | | | | Use FIELD_DP32 instead of manual shifting and masking. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-26-richard.henderson@linaro.org>
* target/nios2: Use hw/registerfields.h for CR_STATUS fieldsRichard Henderson2022-04-261-9/+19
| | | | | | | | | Add all fields; retain the helper macros for single bit fields. So far there are no uses of the multi-bit status fields. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-25-richard.henderson@linaro.org>
* target/nios2: Clean up nios2_cpu_dump_stateRichard Henderson2022-04-261-10/+9Star
| | | | | | | | | | Do not print control registers for user-only mode. Rename reserved control registers to "resN", where N is the control register index. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-24-richard.henderson@linaro.org>
* target/nios2: Split control registers away from general registersRichard Henderson2022-04-266-113/+118
| | | | | | | | Place the control registers into their own array, env->ctrl[]. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-23-richard.henderson@linaro.org>
* target/nios2: Remove cpu_interrupts_enabledRichard Henderson2022-04-261-5/+0Star
| | | | | | | | | This function is unused. The real computation of this value is located in nios2_cpu_exec_interrupt. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-22-richard.henderson@linaro.org>
* linux-user/nios2: Only initialize SP and PC in target_cpu_copy_regsRichard Henderson2022-04-262-23/+0Star
| | | | | | | | | | | | | | Drop the set of estatus in init_thread; it was clearly intended to be setting the value of CR_STATUS for the application, but we never actually performed that copy. However, the proper value is set in nios2_cpu_reset so we don't need to do anything here. We only initialize SP and EA in init_thread, there's no value in copying other uninitialized data into ENV. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-21-richard.henderson@linaro.org>
* target/nios2: Do not create TCGv for control registersRichard Henderson2022-04-261-7/+26
| | | | | | | | | We don't need to reference them often, and when we do it is just as easy to load/store from cpu_env directly. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-20-richard.henderson@linaro.org>
* target/nios2: Fix BRET instructionRichard Henderson2022-04-261-3/+13
| | | | | | | | | | | | | | We had failed to copy BSTATUS back to STATUS, and diagnose supervisor-only. The spec is light on the specifics of the implementation of bret, but it is an easy assumption that the restore into STATUS should work the same as eret. Therefore, reuse the existing helper_eret. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-19-richard.henderson@linaro.org>
* target/nios2: Split out helper for eret instructionAmir Gonnen2022-04-263-4/+16
| | | | | | | | | | | | | | The implementation of eret will become much more complex with the introduction of shadow registers. [rth: Split out of a larger patch for shadow register sets. Directly exit to the cpu loop from the helper.] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Amir Gonnen <amir.gonnen@neuroblade.ai> Message-Id: <20220303153906.2024748-3-amir.gonnen@neuroblade.ai> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-18-richard.henderson@linaro.org>
* target/nios2: Split PC out of env->regs[]Richard Henderson2022-04-267-65/+58Star
| | | | | | | | It is cleaner to have a separate name for this variable. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-17-richard.henderson@linaro.org>
* target/nios2: Add NUM_GP_REGS and NUM_CP_REGSAmir Gonnen2022-04-261-2/+4
| | | | | | | | | | | Split NUM_CORE_REGS into components that can be used elsewhere. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Amir Gonnen <amir.gonnen@neuroblade.ai> Message-Id: <20220303153906.2024748-3-amir.gonnen@neuroblade.ai> [rth: Split out of a larger patch for shadow register sets.] Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-16-richard.henderson@linaro.org>
* target/nios2: Stop generating code if gen_check_supervisor failsRichard Henderson2022-04-261-5/+15
| | | | | | | | | | | Whether the cpu is in user-mode or not is something that we know at translation-time. We do not need to generate code after having raised an exception. Suggested-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-15-richard.henderson@linaro.org>
* target/nios2: Check supervisor on eretAmir Gonnen2022-04-261-0/+2
| | | | | | | | | | | eret instruction is only allowed in supervisor mode. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Amir Gonnen <amir.gonnen@neuroblade.ai> Message-Id: <20220303153906.2024748-2-amir.gonnen@neuroblade.ai> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-14-richard.henderson@linaro.org>
* linux-user/nios2: Use force_sig_fault for EXCP_DEBUGRichard Henderson2022-04-261-5/+1Star
| | | | | | | | | Use the simpler signal interface, which forces us to supply the missing PC value to si_addr. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20220421151735.31996-13-richard.henderson@linaro.org>
* target/nios2: Build helper.c for system onlyRichard Henderson2022-04-262-4/+6
| | | | | | | | | Remove the #ifdef !defined(CONFIG_USER_ONLY) that surrounds the whole file, and move helper.c to nios2_softmmu_ss. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20220421151735.31996-12-richard.henderson@linaro.org>
* target/nios2: Remove nios2_cpu_record_sigsegvRichard Henderson2022-04-264-31/+3Star
| | | | | | | | | Since f5ef0e518d0, we have a real page mapped for kuser, which means the special casing for SIGSEGV can go away. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20220421151735.31996-11-richard.henderson@linaro.org>
* target/nios2: Remove user-only nios2_cpu_do_interruptRichard Henderson2022-04-261-8/+0Star
| | | | | | | | | Since 78271684719, this function is unused for user-only, when the TCGCPUOps.do_interrupt hook itself became system-only. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20220421151735.31996-10-richard.henderson@linaro.org>
* tests/tcg/nios2: Re-enable linux-user testsRichard Henderson2022-04-261-11/+0Star
| | | | | | | | Now that threads and signals have been fixed, re-enable tests. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-9-richard.henderson@linaro.org>
* linux-user/nios2: Use QEMU_ESIGRETURN from do_rt_sigreturnRichard Henderson2022-04-261-8/+4Star
| | | | | | | | | Drop the kernel-specific "pr2" code structure and use the qemu-specific error return value. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-8-richard.henderson@linaro.org>
* linux-user/nios2: Remove do_sigreturnRichard Henderson2022-04-261-7/+0Star
| | | | | | | | | There is no sigreturn syscall, only rt_sigreturn. This function is unused. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-7-richard.henderson@linaro.org>
* linux-user/nios2: Handle special qemu syscall return valuesRichard Henderson2022-04-261-0/+8
| | | | | | | | Honor QEMU_ESIGRETURN and QEMU_ERESTARTSYS. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-6-richard.henderson@linaro.org>
* linux-user/nios2: Adjust error returnRichard Henderson2022-04-261-2/+7
| | | | | | | | | Follow the kernel assembly, which considers all negative return values to be errors. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-5-richard.henderson@linaro.org>
* linux-user/nios2: Drop syscall 0 "workaround"Richard Henderson2022-04-261-4/+0Star
| | | | | | | | | | Syscall 0 is __NR_io_setup for this target; there is nothing to work around. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Fixes: a0a839b65b6 ("nios2: Add usermode binaries emulation") Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-4-richard.henderson@linaro.org>
* linux-user/nios2: Fix clone child returnRichard Henderson2022-04-261-0/+1
| | | | | | | | | The child side of clone needs to set the secondary syscall return value, r7, to indicate syscall success. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-3-richard.henderson@linaro.org>
* linux-user/nios2: Hoist pc advance to the top of EXCP_TRAPRichard Henderson2022-04-261-2/+8
| | | | | | | | | | | | | | Note that this advance *should* be done by the translator, as that's the pc value that's supposed to be generated by hardware. However, that's a much larger change across sysemu as well. In the meantime, produce the correct PC for any signals raised by the trap instruction. Note the special case of TRAP_BRKPT, which itself is special cased within the kernel. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-2-richard.henderson@linaro.org>
* Merge tag 'pull-block-2022-04-25' of https://gitlab.com/hreitz/qemu into stagingRichard Henderson2022-04-2528-188/+231
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Block patches: - New @force parameter for blockdev-change-medium - Improvements to the iotests to help with debugging - Fix iotest 108 on systems without user_allow_other in fuse.conf # -----BEGIN PGP SIGNATURE----- # # iQJGBAABCAAwFiEEy2LXoO44KeRfAE00ofpA0JgBnN8FAmJmqyISHGhyZWl0ekBy # ZWRoYXQuY29tAAoJEKH6QNCYAZzf7uEP/RKNblyIuFjHkPgaMzWqdGUjHpbRzKBi # NFgO+ISRCSx/KXYBaanJP94qKLfpACJ1JHDUD3hipeO3kmVGmtF93cKypTQS4qhL # bGmX+h38AK1omSR2iWRhu4ue4VAPeu9gLoHNYJ5vZlylWD3eHdppN7K2KFf7Aeo5 # /BnhwHiU2IQ7WkLlo5Pdb96+LqZfmCGYJGWO6eWx123+j+bpjLfpmV9+Kjzb1pDc # FN60OFlp8RozXHKpqh4ZoThtJ+t3sYdlo6yvg1K18Y5JcXTx5d4D24HGo1ZIRxqz # XgJbi+bSr8hnxCjvdUZlr3IpbjAE5DVbCjtDxyjGnim6vjIwhxCSWM7Bvzw2tm60 # TYNl2zxyIe5831v6Xv/YfYJFqtos/orZf87TSqx/uWrfinbxZ1nN/8zi5z9lC8tg # S6IlNpKPK0wv33BmLVHcsnMABLY2YiJPx/Ngl0CvAEGvkQdaHzgcYGbmeEMrZTv7 # hVpBb1t+AKmnXYYZdCh4ulfJLUg3R9mXf0oI3otbcpNMwExB6hqcVI23VYC00Ct5 # m3Tb6bddIkBih25l9B7i6FPWfXG+0zu6Q4kIQiXmfNkqKseQ96aDY1aAU/GWoTZH # MOOPqIhmLRgyYpJ3+am9AseczaMybC4DIfx1VXzjwS/X3YwHvHEbZ7iPR6C0630Z # yslJbuH4ERl7 # =url0 # -----END PGP SIGNATURE----- # gpg: Signature made Mon 25 Apr 2022 07:07:30 AM PDT # gpg: using RSA key CB62D7A0EE3829E45F004D34A1FA40D098019CDF # gpg: issuer "hreitz@redhat.com" # gpg: Good signature from "Hanna Reitz <hreitz@redhat.com>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: CB62 D7A0 EE38 29E4 5F00 4D34 A1FA 40D0 9801 9CDF * tag 'pull-block-2022-04-25' of https://gitlab.com/hreitz/qemu: iotests/108: Fix when missing user_allow_other iotests: make qemu_io_log() check return codes by default iotests: remove qemu_io_silent() and qemu_io_silent_check(). iotests: remove qemu_io_pipe_and_status() iotests/image-fleecing: switch to qemu_io() iotests/migration-permissions: use assertRaises() for qemu_io() negative test iotests: rebase qemu_io() on top of qemu_tool() iotests: create generic qemu_tool() function iotests/040: Fix TestCommitWithFilters test iotests/040: Don't check image pattern on zero-length image iotests: Don't check qemu_io() output for specific error strings iotests/163: Fix broken qemu-io invocation iotests: replace calls to log(qemu_io(...)) with qemu_io_log() block: add 'force' parameter to 'blockdev-change-medium' command Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
| * iotests/108: Fix when missing user_allow_otherHanna Reitz2022-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FUSE exports' allow-other option defaults to "auto", which means that it will try passing allow_other as a mount option, and fall back to not using it when an error occurs. We make no effort to hide fusermount's error message (because it would be difficult, and because users might want to know about the fallback occurring), and so when allow_other does not work (primarily when /etc/fuse.conf does not contain user_allow_other), this error message will appear and break the reference output. We do not need allow_other here, though, so we can just pass allow-other=off to fix that. Reported-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220421142435.569600-1-hreitz@redhat.com> Tested-by: Markus Armbruster <armbru@redhat.com> Tested-by: Eric Blake <eblake@redhat.com>
| * iotests: make qemu_io_log() check return codes by defaultJohn Snow2022-04-252-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Just like qemu_img_log(), upgrade qemu_io_log() to enforce a return code of zero by default. Tests that use qemu_io_log(): 242 245 255 274 303 307 nbd-reconnect-on-open Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220418211504.943969-13-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
| * iotests: remove qemu_io_silent() and qemu_io_silent_check().John Snow2022-04-2510-59/+38Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like qemu-img, qemu-io returning 0 should be the norm and not the exception. Remove all calls to qemu_io_silent that just assert the return code is zero (That's every last call, as it turns out), and replace them with a normal qemu_io() call. qemu_io_silent_check() appeared to have been unused already. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220418211504.943969-12-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
| * iotests: remove qemu_io_pipe_and_status()John Snow2022-04-251-3/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | I know we just added it, sorry. This is done in favor of qemu_io() which *also* returns the console output and status, but with more robust error handling on failure. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220418211504.943969-11-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
| * iotests/image-fleecing: switch to qemu_io()John Snow2022-04-251-9/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | This test expects failure ... but only sometimes. When? Why? It's for reads of a region not defined by a bitmap. Adjust the test to be more explicit about what it expects to fail and why. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220418211504.943969-10-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
| * iotests/migration-permissions: use assertRaises() for qemu_io() negative testJohn Snow2022-04-251-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modify this test to use assertRaises for its negative testing of qemu_io. If the exception raised does not match the one we tell it to expect, we get *that* exception unhandled. If we get no exception, we get a unittest assertion failure and the provided emsg printed to screen. If we get the CalledProcessError exception but the output is not what we expect, we re-raise the original CalledProcessError. Tidy. (Note: Yes, you can reference "with" objects after that block ends; it just means that ctx.__exit__(...) will have been called on it. It does not *actually* go out of scope. unittests expects you to want to inspect the Exception object, so they leave it defined post-exit.) Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220418211504.943969-9-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
| * iotests: rebase qemu_io() on top of qemu_tool()John Snow2022-04-256-54/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework qemu_io() to be analogous to qemu_img(); a function that requires a return code of zero by default unless disabled explicitly. Tests that use qemu_io(): 030 040 041 044 055 056 093 124 129 132 136 148 149 151 152 163 165 205 209 219 236 245 248 254 255 257 260 264 280 298 300 302 304 image-fleecing migrate-bitmaps-postcopy-test migrate-bitmaps-test migrate-during-backup migration-permissions Test that use qemu_io_log(): 242 245 255 274 303 307 nbd-reconnect-on-open Copy-pastables for testing/verification: ./check -qcow2 030 040 041 044 055 056 124 129 132 151 152 163 165 209 \ 219 236 242 245 248 254 255 257 260 264 274 \ 280 298 300 302 303 304 307 image-fleecing \ migrate-bitmaps-postcopy-test migrate-bitmaps-test \ migrate-during-backup nbd-reconnect-on-open ./check -raw 093 136 148 migration-permissions ./check -nbd 205 # ./configure configure --disable-gnutls --enable-gcrypt # this ALSO requires passwordless sudo. ./check -luks 149 # Just the tests that were edited in this commit: ./check -qcow2 030 040 242 245 ./check -raw migration-permissions ./check -nbd 205 ./check -luks 149 Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20220418211504.943969-8-jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
| * iotests: create generic qemu_tool() functionJohn Snow2022-04-251-11/+21
| | | | | | | | | | | | | | | | | | | | | | reimplement qemu_img() in terms of qemu_tool() in preparation for doing the same with qemu_io(). Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220418211504.943969-7-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
| * iotests/040: Fix TestCommitWithFilters testJohn Snow2022-04-251-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this change, asserting that qemu_io always returns 0 causes this test to fail in a way we happened not to be catching previously: qemu.utils.VerboseProcessError: Command '('/home/jsnow/src/qemu/bin/git/tests/qemu-iotests/../../qemu-io', '--cache', 'writeback', '--aio', 'threads', '-f', 'qcow2', '-c', 'read -P 4 3M 1M', '/home/jsnow/src/qemu/bin/git/tests/qemu-iotests/scratch/3.img')' returned non-zero exit status 1. ┏━ output ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ┃ qemu-io: can't open device ┃ /home/jsnow/src/qemu/bin/git/tests/qemu-iotests/scratch/3.img: ┃ Could not open backing file: Could not open backing file: Throttle ┃ group 'tg' does not exist ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ The commit jobs changes the backing file string stored in the image file header belonging to the node above the commit’s top node to point to the commit target (the base node). QEMU tries to be as accurate as possible, and so in these test cases will include the filter that is part of the block graph in that backing file string (by virtue of making it a json:{} description of the post-commit subgraph). This makes little sense outside of QEMU, though: Specifically, the throttle node in that subgraph will dearly miss its supposedly associated throttle group object. When starting the commit job, we can specify a custom backing file string to write into said image file, so let’s use that feature to write the plain filename of the backing chain’s next actual image file there. Explicitly provide the backing file so that opening the file outside of QEMU (Where we will not have throttle groups) will succeed. Signed-off-by: Hanna Reitz <hreitz@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20220418211504.943969-6-jsnow@redhat.com>
| * iotests/040: Don't check image pattern on zero-length imageJohn Snow2022-04-251-2/+12
| | | | | | | | | | | | | | | | | | | | | | qemu-io fails on read/write beyond end-of-file on raw images, so skip these invocations when running the zero-length image tests. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220418211504.943969-5-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
| * iotests: Don't check qemu_io() output for specific error stringsJohn Snow2022-04-252-18/+17Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A forthcoming commit updates qemu_io() to raise an exception on non-zero return by default, and changes its return type. In preparation, simplify some calls to qemu_io() that assert that specific error message strings do not appear in qemu-io's output. Asserting that all of these calls return a status code of zero will be a more robust way to guard against failure. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220418211504.943969-4-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
| * iotests/163: Fix broken qemu-io invocationJohn Snow2022-04-251-4/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'read' commands to qemu-io were malformed, and this invocation only worked by coincidence because the error messages were identical. Oops. There's no point in checking the patterning of the reference image, so just check the empty image by itself instead. (Note: as of this commit, nothing actually enforces that this command completes successfully, but a forthcoming commit in this series will enforce that qemu_io() must have a zero status code.) Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220418211504.943969-3-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>