diff options
-rw-r--r-- | MAINTAINERS | 21 | ||||
-rw-r--r-- | block.c | 60 | ||||
-rw-r--r-- | block/block-backend.c | 8 | ||||
-rw-r--r-- | block/bochs.c | 17 | ||||
-rw-r--r-- | block/cloop.c | 16 | ||||
-rw-r--r-- | block/curl.c | 8 | ||||
-rw-r--r-- | block/dmg.c | 16 | ||||
-rw-r--r-- | block/file-posix.c | 19 | ||||
-rw-r--r-- | block/gluster.c | 12 | ||||
-rw-r--r-- | block/iscsi.c | 8 | ||||
-rw-r--r-- | block/nbd-client.c | 10 | ||||
-rw-r--r-- | block/qcow.c | 18 | ||||
-rw-r--r-- | block/qcow2-bitmap.c | 24 | ||||
-rw-r--r-- | block/qcow2.c | 66 | ||||
-rw-r--r-- | block/quorum.c | 45 | ||||
-rw-r--r-- | block/rbd.c | 14 | ||||
-rw-r--r-- | block/vdi.c | 68 | ||||
-rw-r--r-- | block/vhdx-endian.c | 118 | ||||
-rw-r--r-- | block/vhdx-log.c | 4 | ||||
-rw-r--r-- | block/vhdx.c | 18 | ||||
-rw-r--r-- | block/vhdx.h | 12 | ||||
-rw-r--r-- | block/vpc.c | 2 | ||||
-rw-r--r-- | block/vvfat.c | 15 | ||||
-rw-r--r-- | blockdev.c | 3 | ||||
-rw-r--r-- | chardev/char.c | 2 | ||||
-rwxr-xr-x | configure | 57 | ||||
-rw-r--r-- | crypto/block-qcow.c | 2 | ||||
-rw-r--r-- | docs/specs/pci-testdev.txt | 15 | ||||
-rw-r--r-- | hw/arm/exynos4210.c | 2 | ||||
-rw-r--r-- | hw/block/vhost-user-blk.c | 25 | ||||
-rw-r--r-- | hw/block/virtio-blk.c | 4 | ||||
-rw-r--r-- | hw/i386/acpi-build.c | 31 | ||||
-rw-r--r-- | hw/i386/amd_iommu.c | 414 | ||||
-rw-r--r-- | hw/i386/amd_iommu.h | 96 | ||||
-rw-r--r-- | hw/i386/intel_iommu.c | 127 | ||||
-rw-r--r-- | hw/i386/trace-events | 14 | ||||
-rw-r--r-- | hw/i386/x86-iommu.c | 33 | ||||
-rw-r--r-- | hw/lm32/milkymist.c | 5 | ||||
-rw-r--r-- | hw/misc/pci-testdev.c | 19 | ||||
-rw-r--r-- | hw/pci-bridge/ioh3420.c | 2 | ||||
-rw-r--r-- | hw/pci-bridge/ioh3420.h | 6 | ||||
-rw-r--r-- | hw/pci-bridge/xio3130_downstream.c | 28 | ||||
-rw-r--r-- | hw/pci-bridge/xio3130_downstream.h | 11 | ||||
-rw-r--r-- | hw/pci-bridge/xio3130_upstream.c | 24 | ||||
-rw-r--r-- | hw/pci-bridge/xio3130_upstream.h | 10 | ||||
-rw-r--r-- | hw/pci-host/piix.c | 34 | ||||
-rw-r--r-- | hw/pci-host/q35.c | 17 | ||||
-rw-r--r-- | hw/pci/pci_bridge.c | 2 | ||||
-rw-r--r-- | hw/scsi/vhost-scsi.c | 2 | ||||
-rw-r--r-- | hw/vfio/ap.c | 2 | ||||
-rw-r--r-- | include/block/block.h | 5 | ||||
-rw-r--r-- | include/fpu/softfloat-macros.h | 4 | ||||
-rw-r--r-- | include/hw/i386/intel_iommu.h | 59 | ||||
-rw-r--r-- | include/hw/i386/x86-iommu.h | 66 | ||||
-rw-r--r-- | include/hw/pci/pci_bus.h | 2 | ||||
-rw-r--r-- | include/qemu/option.h | 2 | ||||
-rw-r--r-- | include/qemu/units.h | 18 | ||||
-rw-r--r-- | include/sysemu/block-backend.h | 6 | ||||
-rw-r--r-- | qapi/block-core.json | 7 | ||||
-rw-r--r-- | qdev-monitor.c | 13 | ||||
-rw-r--r-- | qemu-img.c | 4 | ||||
-rw-r--r-- | qemu-io-cmds.c | 4 | ||||
-rw-r--r-- | target/arm/helper.c | 14 | ||||
-rw-r--r-- | target/arm/translate-a64.c | 8 | ||||
-rw-r--r-- | tests/bios-tables-test.c | 18 | ||||
-rw-r--r-- | tests/data/acpi/pc/APIC (renamed from tests/acpi-test-data/pc/APIC) | bin | 120 -> 120 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/APIC.cphp (renamed from tests/acpi-test-data/pc/APIC.cphp) | bin | 160 -> 160 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/APIC.dimmpxm (renamed from tests/acpi-test-data/pc/APIC.dimmpxm) | bin | 144 -> 144 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/DSDT (renamed from tests/acpi-test-data/pc/DSDT) | bin | 5131 -> 5131 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/DSDT.bridge (renamed from tests/acpi-test-data/pc/DSDT.bridge) | bin | 6990 -> 6990 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/DSDT.cphp (renamed from tests/acpi-test-data/pc/DSDT.cphp) | bin | 5594 -> 5594 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/DSDT.dimmpxm (renamed from tests/acpi-test-data/pc/DSDT.dimmpxm) | bin | 6790 -> 6790 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/DSDT.ipmikcs (renamed from tests/acpi-test-data/pc/DSDT.ipmikcs) | bin | 5203 -> 5203 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/DSDT.memhp (renamed from tests/acpi-test-data/pc/DSDT.memhp) | bin | 6496 -> 6496 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/DSDT.numamem (renamed from tests/acpi-test-data/pc/DSDT.numamem) | bin | 5137 -> 5137 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/FACP (renamed from tests/acpi-test-data/pc/FACP) | bin | 116 -> 116 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/FACS (renamed from tests/acpi-test-data/pc/FACS) | bin | 64 -> 64 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/HPET (renamed from tests/acpi-test-data/pc/HPET) | bin | 56 -> 56 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/NFIT.dimmpxm (renamed from tests/acpi-test-data/pc/NFIT.dimmpxm) | bin | 240 -> 240 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/SLIT.cphp (renamed from tests/acpi-test-data/pc/SLIT.cphp) | bin | 48 -> 48 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/SLIT.memhp (renamed from tests/acpi-test-data/pc/SLIT.memhp) | bin | 48 -> 48 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/SRAT.cphp (renamed from tests/acpi-test-data/pc/SRAT.cphp) | bin | 304 -> 304 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/SRAT.dimmpxm (renamed from tests/acpi-test-data/pc/SRAT.dimmpxm) | bin | 392 -> 392 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/SRAT.memhp (renamed from tests/acpi-test-data/pc/SRAT.memhp) | bin | 264 -> 264 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/SRAT.numamem (renamed from tests/acpi-test-data/pc/SRAT.numamem) | bin | 224 -> 224 bytes | |||
-rw-r--r-- | tests/data/acpi/pc/SSDT.dimmpxm (renamed from tests/acpi-test-data/pc/SSDT.dimmpxm) | bin | 685 -> 685 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/APIC (renamed from tests/acpi-test-data/q35/APIC) | bin | 120 -> 120 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/APIC.cphp (renamed from tests/acpi-test-data/q35/APIC.cphp) | bin | 160 -> 160 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/APIC.dimmpxm (renamed from tests/acpi-test-data/q35/APIC.dimmpxm) | bin | 144 -> 144 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT (renamed from tests/acpi-test-data/q35/DSDT) | bin | 7815 -> 7815 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.bridge (renamed from tests/acpi-test-data/q35/DSDT.bridge) | bin | 7832 -> 7832 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.cphp (renamed from tests/acpi-test-data/q35/DSDT.cphp) | bin | 8278 -> 8278 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.dimmpxm (renamed from tests/acpi-test-data/q35/DSDT.dimmpxm) | bin | 9474 -> 9474 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.ipmibt (renamed from tests/acpi-test-data/q35/DSDT.ipmibt) | bin | 7890 -> 7890 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.memhp (renamed from tests/acpi-test-data/q35/DSDT.memhp) | bin | 9180 -> 9180 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.mmio64 | bin | 0 -> 8947 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.numamem (renamed from tests/acpi-test-data/q35/DSDT.numamem) | bin | 7821 -> 7821 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/FACP (renamed from tests/acpi-test-data/q35/FACP) | bin | 244 -> 244 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/FACS (renamed from tests/acpi-test-data/q35/FACS) | bin | 64 -> 64 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/HPET (renamed from tests/acpi-test-data/q35/HPET) | bin | 56 -> 56 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/MCFG (renamed from tests/acpi-test-data/q35/MCFG) | bin | 60 -> 60 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/NFIT.dimmpxm (renamed from tests/acpi-test-data/q35/NFIT.dimmpxm) | bin | 240 -> 240 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/SLIT.cphp (renamed from tests/acpi-test-data/q35/SLIT.cphp) | bin | 48 -> 48 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/SLIT.memhp (renamed from tests/acpi-test-data/q35/SLIT.memhp) | bin | 48 -> 48 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/SRAT.cphp (renamed from tests/acpi-test-data/q35/SRAT.cphp) | bin | 304 -> 304 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/SRAT.dimmpxm (renamed from tests/acpi-test-data/q35/SRAT.dimmpxm) | bin | 392 -> 392 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/SRAT.memhp (renamed from tests/acpi-test-data/q35/SRAT.memhp) | bin | 264 -> 264 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/SRAT.mmio64 | bin | 0 -> 224 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/SRAT.numamem (renamed from tests/acpi-test-data/q35/SRAT.numamem) | bin | 224 -> 224 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/SSDT.dimmpxm (renamed from tests/acpi-test-data/q35/SSDT.dimmpxm) | bin | 685 -> 685 bytes | |||
-rwxr-xr-x | tests/data/acpi/rebuild-expected-aml.sh (renamed from tests/acpi-test-data/rebuild-expected-aml.sh) | 2 | ||||
-rw-r--r-- | tests/data/hex-loader/test.hex (renamed from tests/hex-loader-check-data/test.hex) | 0 | ||||
-rw-r--r-- | tests/hexloader-test.c | 2 | ||||
-rwxr-xr-x | tests/qemu-iotests/081 | 116 | ||||
-rw-r--r-- | tests/qemu-iotests/081.out | 70 | ||||
-rw-r--r-- | tests/qemu-iotests/082.out | 956 | ||||
-rwxr-xr-x | tests/qemu-iotests/083 | 2 | ||||
-rwxr-xr-x | tests/qemu-iotests/232 | 147 | ||||
-rw-r--r-- | tests/qemu-iotests/232.out | 59 | ||||
-rw-r--r-- | tests/qemu-iotests/group | 1 | ||||
-rw-r--r-- | util/oslib-posix.c | 15 | ||||
-rw-r--r-- | util/qemu-option.c | 32 | ||||
-rw-r--r-- | vl.c | 15 |
123 files changed, 2145 insertions, 1088 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 98a1856afc..0499e11593 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -253,7 +253,6 @@ F: disas/riscv.c S390 M: Richard Henderson <rth@twiddle.net> -M: Alexander Graf <agraf@suse.de> M: David Hildenbrand <david@redhat.com> S: Maintained F: target/s390x/ @@ -349,7 +348,6 @@ F: target/ppc/kvm.c S390 M: Christian Borntraeger <borntraeger@de.ibm.com> M: Cornelia Huck <cohuck@redhat.com> -M: Alexander Graf <agraf@suse.de> S: Maintained F: target/s390x/kvm.c F: target/s390x/kvm_s390x.h @@ -934,7 +932,6 @@ S390 Machines S390 Virtio-ccw M: Cornelia Huck <cohuck@redhat.com> M: Christian Borntraeger <borntraeger@de.ibm.com> -M: Alexander Graf <agraf@suse.de> S: Supported F: hw/char/sclp*.[hc] F: hw/char/terminal3270.c @@ -947,15 +944,22 @@ T: git git://github.com/cohuck/qemu.git s390-next T: git git://github.com/borntraeger/qemu.git s390-next L: qemu-s390x@nongnu.org -S390-ccw Bios +S390-ccw boot M: Christian Borntraeger <borntraeger@de.ibm.com> M: Thomas Huth <thuth@redhat.com> S: Supported +F: hw/s390x/ipl.* F: pc-bios/s390-ccw/ F: pc-bios/s390-ccw.img T: git git://github.com/borntraeger/qemu.git s390-next L: qemu-s390x@nongnu.org +S390 PCI +M: Collin Walling <walling@linux.ibm.com> +S: Supported +F: hw/s390x/s390-pci* +L: qemu-s390x@nongnu.org + UniCore32 Machines ------------- PKUnity-3 SoC initramfs-with-busybox @@ -1116,6 +1120,8 @@ F: hw/i386/acpi-build.[hc] F: hw/arm/virt-acpi-build.c F: tests/bios-tables-test.c F: tests/acpi-utils.[hc] +F: tests/acpi-test-data/* +F: tests/acpi-test-data/*/* ppc4xx M: Alexander Graf <agraf@suse.de> @@ -1205,6 +1211,8 @@ F: include/hw/vfio/ vfio-ccw M: Cornelia Huck <cohuck@redhat.com> +M: Eric Farman <farman@linux.ibm.com> +M: Farhan Ali <alifm@linux.ibm.com> S: Supported F: hw/vfio/ccw.c F: hw/s390x/s390-ccw.c @@ -1261,7 +1269,7 @@ T: git git://github.com/stefanha/qemu.git block virtio-ccw M: Cornelia Huck <cohuck@redhat.com> -M: Christian Borntraeger <borntraeger@de.ibm.com> +M: Halil Pasic <pasic@linux.ibm.com> S: Supported F: hw/s390x/virtio-ccw*.[hc] F: hw/s390x/vhost-vsock-ccw.c @@ -1370,7 +1378,7 @@ Intel Hexadecimal Object File Loader M: Su Hang <suhang16@mails.ucas.ac.cn> S: Maintained F: tests/hexloader-test.c -F: tests/hex-loader-check-data/test.hex +F: tests/data/hex-loader/test.hex CHRP NVRAM M: Thomas Huth <thuth@redhat.com> @@ -1990,7 +1998,6 @@ F: tcg/ppc/ F: disas/ppc.c S390 target -M: Alexander Graf <agraf@suse.de> M: Richard Henderson <rth@twiddle.net> S: Maintained F: tcg/s390/ @@ -266,22 +266,41 @@ int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, return 0; } -/* TODO Remove (deprecated since 2.11) - * Block drivers are not supposed to automatically change bs->read_only. - * Instead, they should just check whether they can provide what the user - * explicitly requested and error out if read-write is requested, but they can - * only provide read-only access. */ -int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) +/* + * Called by a driver that can only provide a read-only image. + * + * Returns 0 if the node is already read-only or it could switch the node to + * read-only because BDRV_O_AUTO_RDONLY is set. + * + * Returns -EACCES if the node is read-write and BDRV_O_AUTO_RDONLY is not set + * or bdrv_can_set_read_only() forbids making the node read-only. If @errmsg + * is not NULL, it is used as the error message for the Error object. + */ +int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg, + Error **errp) { int ret = 0; - ret = bdrv_can_set_read_only(bs, read_only, false, errp); + if (!(bs->open_flags & BDRV_O_RDWR)) { + return 0; + } + if (!(bs->open_flags & BDRV_O_AUTO_RDONLY)) { + goto fail; + } + + ret = bdrv_can_set_read_only(bs, true, false, NULL); if (ret < 0) { - return ret; + goto fail; } - bs->read_only = read_only; + bs->read_only = true; + bs->open_flags &= ~BDRV_O_RDWR; + return 0; + +fail: + error_setg(errp, "%s", errmsg ?: "Image is read-only"); + return -EACCES; } void bdrv_get_full_backing_filename_from_filename(const char *backed, @@ -923,6 +942,7 @@ static void bdrv_inherited_options(int *child_flags, QDict *child_options, /* Inherit the read-only option from the parent if it's not set */ qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY); + qdict_copy_default(child_options, parent_options, BDRV_OPT_AUTO_READ_ONLY); /* Our block drivers take care to send flushes and respect unmap policy, * so we can default to enable both on lower layers regardless of the @@ -1046,6 +1066,7 @@ static void bdrv_backing_options(int *child_flags, QDict *child_options, /* backing files always opened read-only */ qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on"); + qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off"); flags &= ~BDRV_O_COPY_ON_READ; /* snapshot=on is handled on the top layer */ @@ -1135,6 +1156,10 @@ static void update_flags_from_options(int *flags, QemuOpts *opts) *flags |= BDRV_O_RDWR; } + assert(qemu_opt_find(opts, BDRV_OPT_AUTO_READ_ONLY)); + if (qemu_opt_get_bool_del(opts, BDRV_OPT_AUTO_READ_ONLY, false)) { + *flags |= BDRV_O_AUTO_RDONLY; + } } static void update_options_from_flags(QDict *options, int flags) @@ -1149,6 +1174,10 @@ static void update_options_from_flags(QDict *options, int flags) if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) { qdict_put_bool(options, BDRV_OPT_READ_ONLY, !(flags & BDRV_O_RDWR)); } + if (!qdict_haskey(options, BDRV_OPT_AUTO_READ_ONLY)) { + qdict_put_bool(options, BDRV_OPT_AUTO_READ_ONLY, + flags & BDRV_O_AUTO_RDONLY); + } } static void bdrv_assign_node_name(BlockDriverState *bs, @@ -1322,12 +1351,17 @@ QemuOptsList bdrv_runtime_opts = { .help = "Node is opened in read-only mode", }, { + .name = BDRV_OPT_AUTO_READ_ONLY, + .type = QEMU_OPT_BOOL, + .help = "Node can become read-only if opening read-write fails", + }, + { .name = "detect-zeroes", .type = QEMU_OPT_STRING, .help = "try to optimize zero writes (off, on, unmap)", }, { - .name = "discard", + .name = BDRV_OPT_DISCARD, .type = QEMU_OPT_STRING, .help = "discard operation (ignore/off, unmap/on)", }, @@ -1432,7 +1466,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file, } } - discard = qemu_opt_get(opts, "discard"); + discard = qemu_opt_get(opts, BDRV_OPT_DISCARD); if (discard != NULL) { if (bdrv_parse_discard_flags(discard, &bs->open_flags) != 0) { error_setg(errp, "Invalid discard option"); @@ -2479,6 +2513,8 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp) qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off"); qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off"); qdict_set_default_str(qdict, BDRV_OPT_READ_ONLY, "off"); + qdict_set_default_str(qdict, BDRV_OPT_AUTO_READ_ONLY, "off"); + } bs = bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, errp); @@ -3186,7 +3222,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, update_flags_from_options(&reopen_state->flags, opts); - discard = qemu_opt_get_del(opts, "discard"); + discard = qemu_opt_get_del(opts, BDRV_OPT_DISCARD); if (discard != NULL) { if (bdrv_parse_discard_flags(discard, &reopen_state->flags) != 0) { error_setg(errp, "Invalid discard option"); diff --git a/block/block-backend.c b/block/block-backend.c index dc0cd57724..2a8f3b55f8 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1708,7 +1708,7 @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action, } } -int blk_is_read_only(BlockBackend *blk) +bool blk_is_read_only(BlockBackend *blk) { BlockDriverState *bs = blk_bs(blk); @@ -1719,18 +1719,18 @@ int blk_is_read_only(BlockBackend *blk) } } -int blk_is_sg(BlockBackend *blk) +bool blk_is_sg(BlockBackend *blk) { BlockDriverState *bs = blk_bs(blk); if (!bs) { - return 0; + return false; } return bdrv_is_sg(bs); } -int blk_enable_write_cache(BlockBackend *blk) +bool blk_enable_write_cache(BlockBackend *blk) { return blk->enable_write_cache; } diff --git a/block/bochs.c b/block/bochs.c index 50c630047b..22e7d44211 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -105,23 +105,18 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags, struct bochs_header bochs; int ret; + /* No write support yet */ + ret = bdrv_apply_auto_read_only(bs, NULL, errp); + if (ret < 0) { + return ret; + } + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, errp); if (!bs->file) { return -EINVAL; } - if (!bdrv_is_read_only(bs)) { - error_report("Opening bochs images without an explicit read-only=on " - "option is deprecated. Future versions will refuse to " - "open the image instead of automatically marking the " - "image read-only."); - ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */ - if (ret < 0) { - return ret; - } - } - ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); if (ret < 0) { return ret; diff --git a/block/cloop.c b/block/cloop.c index 2be68987bd..df2b85f723 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -67,23 +67,17 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, uint32_t offsets_size, max_compressed_block_size = 1, i; int ret; + ret = bdrv_apply_auto_read_only(bs, NULL, errp); + if (ret < 0) { + return ret; + } + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, errp); if (!bs->file) { return -EINVAL; } - if (!bdrv_is_read_only(bs)) { - error_report("Opening cloop images without an explicit read-only=on " - "option is deprecated. Future versions will refuse to " - "open the image instead of automatically marking the " - "image read-only."); - ret = bdrv_set_read_only(bs, true, errp); - if (ret < 0) { - return ret; - } - } - /* read header */ ret = bdrv_pread(bs->file, 128, &s->block_size, 4); if (ret < 0) { diff --git a/block/curl.c b/block/curl.c index fabb2b4da7..db5d2bd8ef 100644 --- a/block/curl.c +++ b/block/curl.c @@ -684,10 +684,10 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, const char *protocol_delimiter; int ret; - - if (flags & BDRV_O_RDWR) { - error_setg(errp, "curl block device does not support writes"); - return -EROFS; + ret = bdrv_apply_auto_read_only(bs, "curl driver does not support writes", + errp); + if (ret < 0) { + return ret; } if (!libcurl_initialized) { diff --git a/block/dmg.c b/block/dmg.c index c9b3c519c4..1d9283ba2f 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -413,23 +413,17 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, int64_t offset; int ret; + ret = bdrv_apply_auto_read_only(bs, NULL, errp); + if (ret < 0) { + return ret; + } + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, errp); if (!bs->file) { return -EINVAL; } - if (!bdrv_is_read_only(bs)) { - error_report("Opening dmg images without an explicit read-only=on " - "option is deprecated. Future versions will refuse to " - "open the image instead of automatically marking the " - "image read-only."); - ret = bdrv_set_read_only(bs, true, errp); - if (ret < 0) { - return ret; - } - } - block_module_load_one("dmg-bz2"); s->n_chunks = 0; diff --git a/block/file-posix.c b/block/file-posix.c index 2da3a76355..0c1b81ce4b 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -527,9 +527,22 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, s->fd = -1; fd = qemu_open(filename, s->open_flags, 0644); - if (fd < 0) { - ret = -errno; - error_setg_errno(errp, errno, "Could not open '%s'", filename); + ret = fd < 0 ? -errno : 0; + + if (ret == -EACCES || ret == -EROFS) { + /* Try to degrade to read-only, but if it doesn't work, still use the + * normal error message. */ + if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) { + bdrv_flags &= ~BDRV_O_RDWR; + raw_parse_flags(bdrv_flags, &s->open_flags); + assert(!(s->open_flags & O_CREAT)); + fd = qemu_open(filename, s->open_flags); + ret = fd < 0 ? -errno : 0; + } + } + + if (ret < 0) { + error_setg_errno(errp, -ret, "Could not open '%s'", filename); if (ret == -EROFS) { ret = -EACCES; } diff --git a/block/gluster.c b/block/gluster.c index 4fd55a9cc5..5e300c96c8 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -849,8 +849,16 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options, qemu_gluster_parse_flags(bdrv_flags, &open_flags); s->fd = glfs_open(s->glfs, gconf->path, open_flags); - if (!s->fd) { - ret = -errno; + ret = s->fd ? 0 : -errno; + + if (ret == -EACCES || ret == -EROFS) { + /* Try to degrade to read-only, but if it doesn't work, still use the + * normal error message. */ + if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) { + open_flags = (open_flags & ~O_RDWR) | O_RDONLY; + s->fd = glfs_open(s->glfs, gconf->path, open_flags); + ret = s->fd ? 0 : -errno; + } } s->supports_seek_data = qemu_gluster_test_seek(s->fd); diff --git a/block/iscsi.c b/block/iscsi.c index 73998c2860..727dee50bf 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1878,9 +1878,11 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, /* Check the write protect flag of the LUN if we want to write */ if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) && iscsilun->write_protected) { - error_setg(errp, "Cannot open a write protected LUN as read-write"); - ret = -EACCES; - goto out; + ret = bdrv_apply_auto_read_only(bs, "LUN is write protected", errp); + if (ret < 0) { + goto out; + } + flags &= ~BDRV_O_RDWR; } iscsi_readcapacity_sync(iscsilun, &local_err); diff --git a/block/nbd-client.c b/block/nbd-client.c index 9686ecbd5e..76e9ca3abe 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -992,11 +992,11 @@ int nbd_client_init(BlockDriverState *bs, logout("Failed to negotiate with the NBD server\n"); return ret; } - if (client->info.flags & NBD_FLAG_READ_ONLY && - !bdrv_is_read_only(bs)) { - error_setg(errp, - "request for write access conflicts with read-only export"); - return -EACCES; + if (client->info.flags & NBD_FLAG_READ_ONLY) { + ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp); + if (ret < 0) { + return ret; + } } if (client->info.flags & NBD_FLAG_SEND_FUA) { bs->supported_write_flags = BDRV_REQ_FUA; diff --git a/block/qcow.c b/block/qcow.c index 385d935258..4518cb4c35 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -140,14 +140,14 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, if (ret < 0) { goto fail; } - be32_to_cpus(&header.magic); - be32_to_cpus(&header.version); - be64_to_cpus(&header.backing_file_offset); - be32_to_cpus(&header.backing_file_size); - be32_to_cpus(&header.mtime); - be64_to_cpus(&header.size); - be32_to_cpus(&header.crypt_method); - be64_to_cpus(&header.l1_table_offset); + header.magic = be32_to_cpu(header.magic); + header.version = be32_to_cpu(header.version); + header.backing_file_offset = be64_to_cpu(header.backing_file_offset); + header.backing_file_size = be32_to_cpu(header.backing_file_size); + header.mtime = be32_to_cpu(header.mtime); + header.size = be64_to_cpu(header.size); + header.crypt_method = be32_to_cpu(header.crypt_method); + header.l1_table_offset = be64_to_cpu(header.l1_table_offset); if (header.magic != QCOW_MAGIC) { error_setg(errp, "Image not in qcow format"); @@ -270,7 +270,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, } for(i = 0;i < s->l1_size; i++) { - be64_to_cpus(&s->l1_table[i]); + s->l1_table[i] = be64_to_cpu(s->l1_table[i]); } /* alloc L2 cache (max. 64k * 16 * 8 = 8 MB) */ diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index b5f1b3563d..accebef4cf 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -118,7 +118,7 @@ static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size) size_t i; for (i = 0; i < size; ++i) { - cpu_to_be64s(&bitmap_table[i]); + bitmap_table[i] = cpu_to_be64(bitmap_table[i]); } } @@ -231,7 +231,7 @@ static int bitmap_table_load(BlockDriverState *bs, Qcow2BitmapTable *tb, } for (i = 0; i < tb->size; ++i) { - be64_to_cpus(&table[i]); + table[i] = be64_to_cpu(table[i]); ret = check_table_entry(table[i], s->cluster_size); if (ret < 0) { goto fail; @@ -394,20 +394,20 @@ fail: static inline void bitmap_dir_entry_to_cpu(Qcow2BitmapDirEntry *entry) { - be64_to_cpus(&entry->bitmap_table_offset); - be32_to_cpus(&entry->bitmap_table_size); - be32_to_cpus(&entry->flags); - be16_to_cpus(&entry->name_size); - be32_to_cpus(&entry->extra_data_size); + entry->bitmap_table_offset = be64_to_cpu(entry->bitmap_table_offset); + entry->bitmap_table_size = be32_to_cpu(entry->bitmap_table_size); + entry->flags = be32_to_cpu(entry->flags); + entry->name_size = be16_to_cpu(entry->name_size); + entry->extra_data_size = be32_to_cpu(entry->extra_data_size); } static inline void bitmap_dir_entry_to_be(Qcow2BitmapDirEntry *entry) { - cpu_to_be64s(&entry->bitmap_table_offset); - cpu_to_be32s(&entry->bitmap_table_size); - cpu_to_be32s(&entry->flags); - cpu_to_be16s(&entry->name_size); - cpu_to_be32s(&entry->extra_data_size); + entry->bitmap_table_offset = cpu_to_be64(entry->bitmap_table_offset); + entry->bitmap_table_size = cpu_to_be32(entry->bitmap_table_size); + entry->flags = cpu_to_be32(entry->flags); + entry->name_size = cpu_to_be16(entry->name_size); + entry->extra_data_size = cpu_to_be32(entry->extra_data_size); } static inline int calc_dir_entry_size(size_t name_size, size_t extra_data_size) diff --git a/block/qcow2.c b/block/qcow2.c index 30689b7688..991d6ac91b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -210,8 +210,8 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, "pread fail from offset %" PRIu64, offset); return 1; } - be32_to_cpus(&ext.magic); - be32_to_cpus(&ext.len); + ext.magic = be32_to_cpu(ext.magic); + ext.len = be32_to_cpu(ext.len); offset += sizeof(ext); #ifdef DEBUG_EXT printf("ext.magic = 0x%x\n", ext.magic); @@ -279,8 +279,8 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, "Unable to read CRYPTO header extension"); return ret; } - be64_to_cpus(&s->crypto_header.offset); - be64_to_cpus(&s->crypto_header.length); + s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset); + s->crypto_header.length = be64_to_cpu(s->crypto_header.length); if ((s->crypto_header.offset % s->cluster_size) != 0) { error_setg(errp, "Encryption header offset '%" PRIu64 "' is " @@ -342,9 +342,11 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, return -EINVAL; } - be32_to_cpus(&bitmaps_ext.nb_bitmaps); - be64_to_cpus(&bitmaps_ext.bitmap_directory_size); - be64_to_cpus(&bitmaps_ext.bitmap_directory_offset); + bitmaps_ext.nb_bitmaps = be32_to_cpu(bitmaps_ext.nb_bitmaps); + bitmaps_ext.bitmap_directory_size = + be64_to_cpu(bitmaps_ext.bitmap_directory_size); + bitmaps_ext.bitmap_directory_offset = + be64_to_cpu(bitmaps_ext.bitmap_directory_offset); if (bitmaps_ext.nb_bitmaps > QCOW2_MAX_BITMAPS) { error_setg(errp, @@ -1159,19 +1161,20 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, error_setg_errno(errp, -ret, "Could not read qcow2 header"); goto fail; } - be32_to_cpus(&header.magic); - be32_to_cpus(&header.version); - be64_to_cpus(&header.backing_file_offset); - be32_to_cpus(&header.backing_file_size); - be64_to_cpus(&header.size); - be32_to_cpus(&header.cluster_bits); - be32_to_cpus(&header.crypt_method); - be64_to_cpus(&header.l1_table_offset); - be32_to_cpus(&header.l1_size); - be64_to_cpus(&header.refcount_table_offset); - be32_to_cpus(&header.refcount_table_clusters); - be64_to_cpus(&header.snapshots_offset); - be32_to_cpus(&header.nb_snapshots); + header.magic = be32_to_cpu(header.magic); + header.version = be32_to_cpu(header.version); + header.backing_file_offset = be64_to_cpu(header.backing_file_offset); + header.backing_file_size = be32_to_cpu(header.backing_file_size); + header.size = be64_to_cpu(header.size); + header.cluster_bits = be32_to_cpu(header.cluster_bits); + header.crypt_method = be32_to_cpu(header.crypt_method); + header.l1_table_offset = be64_to_cpu(header.l1_table_offset); + header.l1_size = be32_to_cpu(header.l1_size); + header.refcount_table_offset = be64_to_cpu(header.refcount_table_offset); + header.refcount_table_clusters = + be32_to_cpu(header.refcount_table_clusters); + header.snapshots_offset = be64_to_cpu(header.snapshots_offset); + header.nb_snapshots = be32_to_cpu(header.nb_snapshots); if (header.magic != QCOW_MAGIC) { error_setg(errp, "Image is not in qcow2 format"); @@ -1207,11 +1210,12 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, header.refcount_order = 4; header.header_length = 72; } else { - be64_to_cpus(&header.incompatible_features); - be64_to_cpus(&header.compatible_features); - be64_to_cpus(&header.autoclear_features); - be32_to_cpus(&header.refcount_order); - be32_to_cpus(&header.header_length); + header.incompatible_features = + be64_to_cpu(header.incompatible_features); + header.compatible_features = be64_to_cpu(header.compatible_features); + header.autoclear_features = be64_to_cpu(header.autoclear_features); + header.refcount_order = be32_to_cpu(header.refcount_order); + header.header_length = be32_to_cpu(header.header_length); if (header.header_length < 104) { error_setg(errp, "qcow2 header too short"); @@ -1400,7 +1404,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, goto fail; } for(i = 0;i < s->l1_size; i++) { - be64_to_cpus(&s->l1_table[i]); + s->l1_table[i] = be64_to_cpu(s->l1_table[i]); } } @@ -1673,7 +1677,7 @@ static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp) if (bs->encrypted) { /* Encryption works on a sector granularity */ - bs->bl.request_alignment = BDRV_SECTOR_SIZE; + bs->bl.request_alignment = qcrypto_block_get_sector_size(s->crypto); } bs->bl.pwrite_zeroes_alignment = s->cluster_size; bs->bl.pdiscard_alignment = s->cluster_size; @@ -2392,13 +2396,13 @@ int qcow2_update_header(BlockDriverState *bs) /* Full disk encryption header pointer extension */ if (s->crypto_header.offset != 0) { - cpu_to_be64s(&s->crypto_header.offset); - cpu_to_be64s(&s->crypto_header.length); + s->crypto_header.offset = cpu_to_be64(s->crypto_header.offset); + s->crypto_header.length = cpu_to_be64(s->crypto_header.length); ret = header_ext_add(buf, QCOW2_EXT_MAGIC_CRYPTO_HEADER, &s->crypto_header, sizeof(s->crypto_header), buflen); - be64_to_cpus(&s->crypto_header.offset); - be64_to_cpus(&s->crypto_header.length); + s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset); + s->crypto_header.length = be64_to_cpu(s->crypto_header.length); if (ret < 0) { goto fail; } diff --git a/block/quorum.c b/block/quorum.c index eb526cc0f1..16b3c8067c 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -437,23 +437,7 @@ static bool quorum_iovec_compare(QEMUIOVector *a, QEMUIOVector *b) return true; } -static void GCC_FMT_ATTR(2, 3) quorum_err(QuorumAIOCB *acb, - const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 " ", - acb->offset, acb->bytes); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - exit(1); -} - -static bool quorum_compare(QuorumAIOCB *acb, - QEMUIOVector *a, - QEMUIOVector *b) +static bool quorum_compare(QuorumAIOCB *acb, QEMUIOVector *a, QEMUIOVector *b) { BDRVQuorumState *s = acb->bs->opaque; ssize_t offset; @@ -462,8 +446,10 @@ static bool quorum_compare(QuorumAIOCB *acb, if (s->is_blkverify) { offset = qemu_iovec_compare(a, b); if (offset != -1) { - quorum_err(acb, "contents mismatch at offset %" PRIu64, - acb->offset + offset); + fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 + " contents mismatch at offset %" PRIu64 "\n", + acb->offset, acb->bytes, acb->offset + offset); + exit(1); } return true; } @@ -926,13 +912,12 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, s->read_pattern = ret; if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) { - /* is the driver in blkverify mode */ - if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) && - s->num_children == 2 && s->threshold == 2) { - s->is_blkverify = true; - } else if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false)) { - fprintf(stderr, "blkverify mode is set by setting blkverify=on " - "and using two files with vote_threshold=2\n"); + s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false); + if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) { + error_setg(&local_err, "blkverify=on can only be set if there are " + "exactly two files and vote-threshold is 2"); + ret = -EINVAL; + goto exit; } s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE, @@ -1007,6 +992,11 @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs, char indexstr[32]; int ret; + if (s->is_blkverify) { + error_setg(errp, "Cannot add a child to a quorum in blkverify mode"); + return; + } + assert(s->num_children <= INT_MAX / sizeof(BdrvChild *)); if (s->num_children == INT_MAX / sizeof(BdrvChild *) || s->next_child_index == UINT_MAX) { @@ -1061,6 +1051,9 @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child, return; } + /* We know now that num_children > threshold, so blkverify must be false */ + assert(!s->is_blkverify); + bdrv_drained_begin(bs); /* We can safely remove this child now */ diff --git a/block/rbd.c b/block/rbd.c index e5bf5a146f..8a1a9f4b6e 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -780,16 +780,10 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, /* If we are using an rbd snapshot, we must be r/o, otherwise * leave as-is */ if (s->snap != NULL) { - if (!bdrv_is_read_only(bs)) { - error_report("Opening rbd snapshots without an explicit " - "read-only=on option is deprecated. Future versions " - "will refuse to open the image instead of " - "automatically marking the image read-only."); - r = bdrv_set_read_only(bs, true, &local_err); - if (r < 0) { - error_propagate(errp, local_err); - goto failed_open; - } + r = bdrv_apply_auto_read_only(bs, "rbd snapshots are read-only", errp); + if (r < 0) { + rbd_close(s->image); + goto failed_open; } } diff --git a/block/vdi.c b/block/vdi.c index 6555cffb88..2380daa583 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -85,7 +85,7 @@ #define BLOCK_OPT_STATIC "static" #define SECTOR_SIZE 512 -#define DEFAULT_CLUSTER_SIZE (1 * MiB) +#define DEFAULT_CLUSTER_SIZE S_1MiB #if defined(CONFIG_VDI_DEBUG) #define VDI_DEBUG 1 @@ -187,22 +187,22 @@ typedef struct { static void vdi_header_to_cpu(VdiHeader *header) { - le32_to_cpus(&header->signature); - le32_to_cpus(&header->version); - le32_to_cpus(&header->header_size); - le32_to_cpus(&header->image_type); - le32_to_cpus(&header->image_flags); - le32_to_cpus(&header->offset_bmap); - le32_to_cpus(&header->offset_data); - le32_to_cpus(&header->cylinders); - le32_to_cpus(&header->heads); - le32_to_cpus(&header->sectors); - le32_to_cpus(&header->sector_size); - le64_to_cpus(&header->disk_size); - le32_to_cpus(&header->block_size); - le32_to_cpus(&header->block_extra); - le32_to_cpus(&header->blocks_in_image); - le32_to_cpus(&header->blocks_allocated); + header->signature = le32_to_cpu(header->signature); + header->version = le32_to_cpu(header->version); + header->header_size = le32_to_cpu(header->header_size); + header->image_type = le32_to_cpu(header->image_type); + header->image_flags = le32_to_cpu(header->image_flags); + header->offset_bmap = le32_to_cpu(header->offset_bmap); + header->offset_data = le32_to_cpu(header->offset_data); + header->cylinders = le32_to_cpu(header->cylinders); + header->heads = le32_to_cpu(header->heads); + header->sectors = le32_to_cpu(header->sectors); + header->sector_size = le32_to_cpu(header->sector_size); + header->disk_size = le64_to_cpu(header->disk_size); + header->block_size = le32_to_cpu(header->block_size); + header->block_extra = le32_to_cpu(header->block_extra); + header->blocks_in_image = le32_to_cpu(header->blocks_in_image); + header->blocks_allocated = le32_to_cpu(header->blocks_allocated); qemu_uuid_bswap(&header->uuid_image); qemu_uuid_bswap(&header->uuid_last_snap); qemu_uuid_bswap(&header->uuid_link); @@ -211,22 +211,22 @@ static void vdi_header_to_cpu(VdiHeader *header) static void vdi_header_to_le(VdiHeader *header) { - cpu_to_le32s(&header->signature); - cpu_to_le32s(&header->version); - cpu_to_le32s(&header->header_size); - cpu_to_le32s(&header->image_type); - cpu_to_le32s(&header->image_flags); - cpu_to_le32s(&header->offset_bmap); - cpu_to_le32s(&header->offset_data); - cpu_to_le32s(&header->cylinders); - cpu_to_le32s(&header->heads); - cpu_to_le32s(&header->sectors); - cpu_to_le32s(&header->sector_size); - cpu_to_le64s(&header->disk_size); - cpu_to_le32s(&header->block_size); - cpu_to_le32s(&header->block_extra); - cpu_to_le32s(&header->blocks_in_image); - cpu_to_le32s(&header->blocks_allocated); + header->signature = cpu_to_le32(header->signature); + header->version = cpu_to_le32(header->version); + header->header_size = cpu_to_le32(header->header_size); + header->image_type = cpu_to_le32(header->image_type); + header->image_flags = cpu_to_le32(header->image_flags); + header->offset_bmap = cpu_to_le32(header->offset_bmap); + header->offset_data = cpu_to_le32(header->offset_data); + header->cylinders = cpu_to_le32(header->cylinders); + header->heads = cpu_to_le32(header->heads); + header->sectors = cpu_to_le32(header->sectors); + header->sector_size = cpu_to_le32(header->sector_size); + header->disk_size = cpu_to_le64(header->disk_size); + header->block_size = cpu_to_le32(header->block_size); + header->block_extra = cpu_to_le32(header->block_extra); + header->blocks_in_image = cpu_to_le32(header->blocks_in_image); + header->blocks_allocated = cpu_to_le32(header->blocks_allocated); qemu_uuid_bswap(&header->uuid_image); qemu_uuid_bswap(&header->uuid_last_snap); qemu_uuid_bswap(&header->uuid_link); @@ -432,7 +432,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } else if (header.block_size != DEFAULT_CLUSTER_SIZE) { error_setg(errp, "unsupported VDI image (block size %" PRIu32 - " is not %" PRIu64 ")", + " is not %" PRIu32 ")", header.block_size, DEFAULT_CLUSTER_SIZE); ret = -ENOTSUP; goto fail; diff --git a/block/vhdx-endian.c b/block/vhdx-endian.c index 41fbdd2b8f..ebfa33cb8a 100644 --- a/block/vhdx-endian.c +++ b/block/vhdx-endian.c @@ -35,18 +35,18 @@ void vhdx_header_le_import(VHDXHeader *h) { assert(h != NULL); - le32_to_cpus(&h->signature); - le32_to_cpus(&h->checksum); - le64_to_cpus(&h->sequence_number); + h->signature = le32_to_cpu(h->signature); + h->checksum = le32_to_cpu(h->checksum); + h->sequence_number = le64_to_cpu(h->sequence_number); leguid_to_cpus(&h->file_write_guid); leguid_to_cpus(&h->data_write_guid); leguid_to_cpus(&h->log_guid); - le16_to_cpus(&h->log_version); - le16_to_cpus(&h->version); - le32_to_cpus(&h->log_length); - le64_to_cpus(&h->log_offset); + h->log_version = le16_to_cpu(h->log_version); + h->version = le16_to_cpu(h->version); + h->log_length = le32_to_cpu(h->log_length); + h->log_offset = le64_to_cpu(h->log_offset); } void vhdx_header_le_export(VHDXHeader *orig_h, VHDXHeader *new_h) @@ -80,68 +80,68 @@ void vhdx_log_desc_le_import(VHDXLogDescriptor *d) { assert(d != NULL); - le32_to_cpus(&d->signature); - le64_to_cpus(&d->file_offset); - le64_to_cpus(&d->sequence_number); + d->signature = le32_to_cpu(d->signature); + d->file_offset = le64_to_cpu(d->file_offset); + d->sequence_number = le64_to_cpu(d->sequence_number); } void vhdx_log_desc_le_export(VHDXLogDescriptor *d) { assert(d != NULL); - cpu_to_le32s(&d->signature); - cpu_to_le32s(&d->trailing_bytes); - cpu_to_le64s(&d->leading_bytes); - cpu_to_le64s(&d->file_offset); - cpu_to_le64s(&d->sequence_number); + d->signature = cpu_to_le32(d->signature); + d->trailing_bytes = cpu_to_le32(d->trailing_bytes); + d->leading_bytes = cpu_to_le64(d->leading_bytes); + d->file_offset = cpu_to_le64(d->file_offset); + d->sequence_number = cpu_to_le64(d->sequence_number); } void vhdx_log_data_le_import(VHDXLogDataSector *d) { assert(d != NULL); - le32_to_cpus(&d->data_signature); - le32_to_cpus(&d->sequence_high); - le32_to_cpus(&d->sequence_low); + d->data_signature = le32_to_cpu(d->data_signature); + d->sequence_high = le32_to_cpu(d->sequence_high); + d->sequence_low = le32_to_cpu(d->sequence_low); } void vhdx_log_data_le_export(VHDXLogDataSector *d) { assert(d != NULL); - cpu_to_le32s(&d->data_signature); - cpu_to_le32s(&d->sequence_high); - cpu_to_le32s(&d->sequence_low); + d->data_signature = cpu_to_le32(d->data_signature); + d->sequence_high = cpu_to_le32(d->sequence_high); + d->sequence_low = cpu_to_le32(d->sequence_low); } void vhdx_log_entry_hdr_le_import(VHDXLogEntryHeader *hdr) { assert(hdr != NULL); - le32_to_cpus(&hdr->signature); - le32_to_cpus(&hdr->checksum); - le32_to_cpus(&hdr->entry_length); - le32_to_cpus(&hdr->tail); - le64_to_cpus(&hdr->sequence_number); - le32_to_cpus(&hdr->descriptor_count); + hdr->signature = le32_to_cpu(hdr->signature); + hdr->checksum = le32_to_cpu(hdr->checksum); + hdr->entry_length = le32_to_cpu(hdr->entry_length); + hdr->tail = le32_to_cpu(hdr->tail); + hdr->sequence_number = le64_to_cpu(hdr->sequence_number); + hdr->descriptor_count = le32_to_cpu(hdr->descriptor_count); leguid_to_cpus(&hdr->log_guid); - le64_to_cpus(&hdr->flushed_file_offset); - le64_to_cpus(&hdr->last_file_offset); + hdr->flushed_file_offset = le64_to_cpu(hdr->flushed_file_offset); + hdr->last_file_offset = le64_to_cpu(hdr->last_file_offset); } void vhdx_log_entry_hdr_le_export(VHDXLogEntryHeader *hdr) { assert(hdr != NULL); - cpu_to_le32s(&hdr->signature); - cpu_to_le32s(&hdr->checksum); - cpu_to_le32s(&hdr->entry_length); - cpu_to_le32s(&hdr->tail); - cpu_to_le64s(&hdr->sequence_number); - cpu_to_le32s(&hdr->descriptor_count); + hdr->signature = cpu_to_le32(hdr->signature); + hdr->checksum = cpu_to_le32(hdr->checksum); + hdr->entry_length = cpu_to_le32(hdr->entry_length); + hdr->tail = cpu_to_le32(hdr->tail); + hdr->sequence_number = cpu_to_le64(hdr->sequence_number); + hdr->descriptor_count = cpu_to_le32(hdr->descriptor_count); cpu_to_leguids(&hdr->log_guid); - cpu_to_le64s(&hdr->flushed_file_offset); - cpu_to_le64s(&hdr->last_file_offset); + hdr->flushed_file_offset = cpu_to_le64(hdr->flushed_file_offset); + hdr->last_file_offset = cpu_to_le64(hdr->last_file_offset); } @@ -150,18 +150,18 @@ void vhdx_region_header_le_import(VHDXRegionTableHeader *hdr) { assert(hdr != NULL); - le32_to_cpus(&hdr->signature); - le32_to_cpus(&hdr->checksum); - le32_to_cpus(&hdr->entry_count); + hdr->signature = le32_to_cpu(hdr->signature); + hdr->checksum = le32_to_cpu(hdr->checksum); + hdr->entry_count = le32_to_cpu(hdr->entry_count); } void vhdx_region_header_le_export(VHDXRegionTableHeader *hdr) { assert(hdr != NULL); - cpu_to_le32s(&hdr->signature); - cpu_to_le32s(&hdr->checksum); - cpu_to_le32s(&hdr->entry_count); + hdr->signature = cpu_to_le32(hdr->signature); + hdr->checksum = cpu_to_le32(hdr->checksum); + hdr->entry_count = cpu_to_le32(hdr->entry_count); } void vhdx_region_entry_le_import(VHDXRegionTableEntry *e) @@ -169,9 +169,9 @@ void vhdx_region_entry_le_import(VHDXRegionTableEntry *e) assert(e != NULL); leguid_to_cpus(&e->guid); - le64_to_cpus(&e->file_offset); - le32_to_cpus(&e->length); - le32_to_cpus(&e->data_bits); + e->file_offset = le64_to_cpu(e->file_offset); + e->length = le32_to_cpu(e->length); + e->data_bits = le32_to_cpu(e->data_bits); } void vhdx_region_entry_le_export(VHDXRegionTableEntry *e) @@ -179,9 +179,9 @@ void vhdx_region_entry_le_export(VHDXRegionTableEntry *e) assert(e != NULL); cpu_to_leguids(&e->guid); - cpu_to_le64s(&e->file_offset); - cpu_to_le32s(&e->length); - cpu_to_le32s(&e->data_bits); + e->file_offset = cpu_to_le64(e->file_offset); + e->length = cpu_to_le32(e->length); + e->data_bits = cpu_to_le32(e->data_bits); } @@ -190,16 +190,16 @@ void vhdx_metadata_header_le_import(VHDXMetadataTableHeader *hdr) { assert(hdr != NULL); - le64_to_cpus(&hdr->signature); - le16_to_cpus(&hdr->entry_count); + hdr->signature = le64_to_cpu(hdr->signature); + hdr->entry_count = le16_to_cpu(hdr->entry_count); } void vhdx_metadata_header_le_export(VHDXMetadataTableHeader *hdr) { assert(hdr != NULL); - cpu_to_le64s(&hdr->signature); - cpu_to_le16s(&hdr->entry_count); + hdr->signature = cpu_to_le64(hdr->signature); + hdr->entry_count = cpu_to_le16(hdr->entry_count); } void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e) @@ -207,16 +207,16 @@ void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e) assert(e != NULL); leguid_to_cpus(&e->item_id); - le32_to_cpus(&e->offset); - le32_to_cpus(&e->length); - le32_to_cpus(&e->data_bits); + e->offset = le32_to_cpu(e->offset); + e->length = le32_to_cpu(e->length); + e->data_bits = le32_to_cpu(e->data_bits); } void vhdx_metadata_entry_le_export(VHDXMetadataTableEntry *e) { assert(e != NULL); cpu_to_leguids(&e->item_id); - cpu_to_le32s(&e->offset); - cpu_to_le32s(&e->length); - cpu_to_le32s(&e->data_bits); + e->offset = cpu_to_le32(e->offset); + e->length = cpu_to_le32(e->length); + e->data_bits = cpu_to_le32(e->data_bits); } diff --git a/block/vhdx-log.c b/block/vhdx-log.c index d2f1b98199..ecd64266c5 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -835,11 +835,11 @@ static void vhdx_log_raw_to_le_sector(VHDXLogDescriptor *desc, /* 8 + 4084 + 4 = 4096, 1 log sector */ memcpy(&desc->leading_bytes, data, 8); data += 8; - cpu_to_le64s(&desc->leading_bytes); + desc->leading_bytes = cpu_to_le64(desc->leading_bytes); memcpy(sector->data, data, 4084); data += 4084; memcpy(&desc->trailing_bytes, data, 4); - cpu_to_le32s(&desc->trailing_bytes); + desc->trailing_bytes = cpu_to_le32(desc->trailing_bytes); data += 4; sector->sequence_high = (uint32_t) (seq >> 32); diff --git a/block/vhdx.c b/block/vhdx.c index 0795ca1985..b785aef4b7 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -156,7 +156,7 @@ uint32_t vhdx_update_checksum(uint8_t *buf, size_t size, int crc_offset) memset(buf + crc_offset, 0, sizeof(crc)); crc = crc32c(0xffffffff, buf, size); - cpu_to_le32s(&crc); + crc = cpu_to_le32(crc); memcpy(buf + crc_offset, &crc, sizeof(crc)); return crc; @@ -753,8 +753,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) goto exit; } - le32_to_cpus(&s->params.block_size); - le32_to_cpus(&s->params.data_bits); + s->params.block_size = le32_to_cpu(s->params.block_size); + s->params.data_bits = le32_to_cpu(s->params.data_bits); /* We now have the file parameters, so we can tell if this is a @@ -803,9 +803,9 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) goto exit; } - le64_to_cpus(&s->virtual_disk_size); - le32_to_cpus(&s->logical_sector_size); - le32_to_cpus(&s->physical_sector_size); + s->virtual_disk_size = le64_to_cpu(s->virtual_disk_size); + s->logical_sector_size = le32_to_cpu(s->logical_sector_size); + s->physical_sector_size = le32_to_cpu(s->physical_sector_size); if (s->params.block_size < VHDX_BLOCK_SIZE_MIN || s->params.block_size > VHDX_BLOCK_SIZE_MAX) { @@ -985,7 +985,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, /* endian convert, and verify populated BAT field file offsets against * region table and log entries */ for (i = 0; i < s->bat_entries; i++) { - le64_to_cpus(&s->bat[i]); + s->bat[i] = le64_to_cpu(s->bat[i]); if (payblocks--) { /* payload bat entries */ if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) == @@ -1509,7 +1509,7 @@ static int vhdx_create_new_metadata(BlockBackend *blk, mt_file_params->block_size = cpu_to_le32(block_size); if (type == VHDX_TYPE_FIXED) { mt_file_params->data_bits |= VHDX_PARAMS_LEAVE_BLOCKS_ALLOCED; - cpu_to_le32s(&mt_file_params->data_bits); + mt_file_params->data_bits = cpu_to_le32(mt_file_params->data_bits); } vhdx_guid_generate(&mt_page83->page_83_data); @@ -1656,7 +1656,7 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, sinfo.file_offset = ROUND_UP(sinfo.file_offset, MiB); vhdx_update_bat_table_entry(blk_bs(blk), s, &sinfo, &unused, &unused, block_state); - cpu_to_le64s(&s->bat[sinfo.bat_idx]); + s->bat[sinfo.bat_idx] = cpu_to_le64(s->bat[sinfo.bat_idx]); sector_num += s->sectors_per_block; } ret = blk_pwrite(blk, file_offset, s->bat, length, 0); diff --git a/block/vhdx.h b/block/vhdx.h index 7003ab7a79..3a5f5293ad 100644 --- a/block/vhdx.h +++ b/block/vhdx.h @@ -420,16 +420,16 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s, static inline void leguid_to_cpus(MSGUID *guid) { - le32_to_cpus(&guid->data1); - le16_to_cpus(&guid->data2); - le16_to_cpus(&guid->data3); + guid->data1 = le32_to_cpu(guid->data1); + guid->data2 = le16_to_cpu(guid->data2); + guid->data3 = le16_to_cpu(guid->data3); } static inline void cpu_to_leguids(MSGUID *guid) { - cpu_to_le32s(&guid->data1); - cpu_to_le16s(&guid->data2); - cpu_to_le16s(&guid->data3); + guid->data1 = cpu_to_le32(guid->data1); + guid->data2 = cpu_to_le16(guid->data2); + guid->data3 = cpu_to_le16(guid->data3); } void vhdx_header_le_import(VHDXHeader *h); diff --git a/block/vpc.c b/block/vpc.c index 984187cadd..80c5b2b197 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -456,10 +456,12 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, } qemu_co_mutex_init(&s->lock); + qemu_opts_del(opts); return 0; fail: + qemu_opts_del(opts); qemu_vfree(s->pagetable); #ifdef CACHE g_free(s->pageentry_u8); diff --git a/block/vvfat.c b/block/vvfat.c index fc41841a5c..e4df255d58 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -973,10 +973,10 @@ static int init_directories(BDRVVVFATState* s, mapping = array_get(&(s->mapping), i); if (mapping->mode & MODE_DIRECTORY) { + char *path = mapping->path; mapping->begin = cluster; if(read_directory(s, i)) { - error_setg(errp, "Could not read directory %s", - mapping->path); + error_setg(errp, "Could not read directory %s", path); return -1; } mapping = array_get(&(s->mapping), i); @@ -1262,15 +1262,9 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, "Unable to set VVFAT to 'rw' when drive is read-only"); goto fail; } - } else if (!bdrv_is_read_only(bs)) { - error_report("Opening non-rw vvfat images without an explicit " - "read-only=on option is deprecated. Future versions " - "will refuse to open the image instead of " - "automatically marking the image read-only."); - /* read only is the default for safety */ - ret = bdrv_set_read_only(bs, true, &local_err); + } else { + ret = bdrv_apply_auto_read_only(bs, NULL, errp); if (ret < 0) { - error_propagate(errp, local_err); goto fail; } } @@ -3130,6 +3124,7 @@ static void vvfat_qcow_options(int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options) { qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "off"); + qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off"); qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on"); } diff --git a/blockdev.c b/blockdev.c index c30495d035..e5b5eb46e2 100644 --- a/blockdev.c +++ b/blockdev.c @@ -590,6 +590,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off"); qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY, read_only ? "on" : "off"); + qdict_set_default_str(bs_opts, BDRV_OPT_AUTO_READ_ONLY, "on"); assert((bdrv_flags & BDRV_O_CACHE_MASK) == 0); if (runstate_check(RUN_STATE_INMIGRATE)) { @@ -2651,7 +2652,7 @@ void qmp_blockdev_change_medium(bool has_device, const char *device, bdrv_flags = blk_get_open_flags_from_root_state(blk); bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | - BDRV_O_PROTOCOL); + BDRV_O_PROTOCOL | BDRV_O_AUTO_RDONLY); if (!has_read_only) { read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; diff --git a/chardev/char.c b/chardev/char.c index 79b05fb7b7..152dde5327 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -572,7 +572,7 @@ help_string_append(const char *name, void *opaque) { GString *str = opaque; - g_string_append_printf(str, "\n%s", name); + g_string_append_printf(str, "\n %s", name); } static const char *chardev_alias_translate(const char *name) @@ -7392,22 +7392,33 @@ if test "$ccache_cpp2" = "yes"; then echo "export CCACHE_CPP2=y" >> $config_host_mak fi -# build tree in object directory in case the source is not in the current directory +# If we're using a separate build tree, set it up now. +# DIRS are directories which we simply mkdir in the build tree; +# LINKS are things to symlink back into the source tree +# (these can be both files and directories). +# Caution: do not add files or directories here using wildcards. This +# will result in problems later if a new file matching the wildcard is +# added to the source tree -- nothing will cause configure to be rerun +# so the build tree will be missing the link back to the new file, and +# tests might fail. Prefer to keep the relevant files in their own +# directory and symlink the directory instead. DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm" DIRS="$DIRS tests/fp" DIRS="$DIRS docs docs/interop fsdev scsi" DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw" DIRS="$DIRS roms/seabios roms/vgabios" -FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" -FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" -FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile" -FILES="$FILES tests/fp/Makefile" -FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps" -FILES="$FILES pc-bios/spapr-rtas/Makefile" -FILES="$FILES pc-bios/s390-ccw/Makefile" -FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile" -FILES="$FILES pc-bios/qemu-icon.bmp" -FILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit +LINKS="Makefile tests/tcg/Makefile qdict-test-data.txt" +LINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" +LINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile" +LINKS="$LINKS tests/fp/Makefile" +LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps" +LINKS="$LINKS pc-bios/spapr-rtas/Makefile" +LINKS="$LINKS pc-bios/s390-ccw/Makefile" +LINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile" +LINKS="$LINKS pc-bios/qemu-icon.bmp" +LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit +LINKS="$LINKS tests/acceptance tests/data" +LINKS="$LINKS tests/qemu-iotests/check" for bios_file in \ $source_path/pc-bios/*.bin \ $source_path/pc-bios/*.lid \ @@ -7419,18 +7430,10 @@ for bios_file in \ $source_path/pc-bios/u-boot.* \ $source_path/pc-bios/palcode-* do - FILES="$FILES pc-bios/$(basename $bios_file)" -done -for test_file in $(find $source_path/tests/acpi-test-data -type f) -do - FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')" -done -for test_file in $(find $source_path/tests/hex-loader-check-data -type f) -do - FILES="$FILES tests/hex-loader-check-data$(echo $test_file | sed -e 's/.*hex-loader-check-data//')" + LINKS="$LINKS pc-bios/$(basename $bios_file)" done mkdir -p $DIRS -for f in $FILES ; do +for f in $LINKS ; do if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then symlink "$source_path/$f" "$f" fi @@ -7452,25 +7455,13 @@ for rom in seabios vgabios ; do echo "RANLIB=$ranlib" >> $config_mak done -# set up tests data directory -for tests_subdir in acceptance data; do - if [ ! -e tests/$tests_subdir ]; then - symlink "$source_path/tests/$tests_subdir" tests/$tests_subdir - fi -done - # set up qemu-iotests in this build directory iotests_common_env="tests/qemu-iotests/common.env" -iotests_check="tests/qemu-iotests/check" echo "# Automatically generated by configure - do not modify" > "$iotests_common_env" echo >> "$iotests_common_env" echo "export PYTHON='$python'" >> "$iotests_common_env" -if [ ! -e "$iotests_check" ]; then - symlink "$source_path/$iotests_check" "$iotests_check" -fi - # Save the configure command line for later reuse. cat <<EOD >config.status #!/bin/sh diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c index 4284e05167..7606231e79 100644 --- a/crypto/block-qcow.c +++ b/crypto/block-qcow.c @@ -102,6 +102,8 @@ qcrypto_block_qcow_open(QCryptoBlock *block, Error **errp) { if (flags & QCRYPTO_BLOCK_OPEN_NO_IO) { + block->sector_size = QCRYPTO_BLOCK_QCOW_SECTOR_SIZE; + block->payload_offset = 0; return 0; } else { if (!options->u.qcow.key_secret) { diff --git a/docs/specs/pci-testdev.txt b/docs/specs/pci-testdev.txt index 128ae222ef..4280a1e73c 100644 --- a/docs/specs/pci-testdev.txt +++ b/docs/specs/pci-testdev.txt @@ -1,11 +1,11 @@ pci-test is a device used for testing low level IO -device implements up to two BARs: BAR0 and BAR1. -Each BAR can be memory or IO. Guests must detect -BAR type and act accordingly. +device implements up to three BARs: BAR0, BAR1 and BAR2. +Each of BAR 0+1 can be memory or IO. Guests must detect +BAR types and act accordingly. -Each BAR size is up to 4K bytes. -Each BAR starts with the following header: +BAR 0+1 size is up to 4K bytes each. +BAR 0+1 starts with the following header: typedef struct PCITestDevHdr { uint8_t test; <- write-only, starts a given test number @@ -24,3 +24,8 @@ All registers are little endian. device is expected to always implement tests 0 to N on each BAR, and to add new tests with higher numbers. In this way a guest can scan test numbers until it detects an access type that it does not support on this BAR, then stop. + +BAR2 is a 64bit memory bar, without backing storage. It is disabled +by default and can be enabled using the membar=<size> property. This +can be used to test whether guests handle pci bars of a specific +(possibly quite large) size correctly. diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c index 827318a003..af82e95542 100644 --- a/hw/arm/exynos4210.c +++ b/hw/arm/exynos4210.c @@ -162,7 +162,7 @@ static uint64_t exynos4210_calc_affinity(int cpu) Exynos4210State *exynos4210_init(MemoryRegion *system_mem) { - Exynos4210State *s = g_new(Exynos4210State, 1); + Exynos4210State *s = g_new0(Exynos4210State, 1); qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; SysBusDevice *busdev; DeviceState *dev; diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index d755223643..1451940845 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -217,7 +217,32 @@ static uint64_t vhost_user_blk_get_features(VirtIODevice *vdev, static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) { + VHostUserBlk *s = VHOST_USER_BLK(vdev); + int i; + + if (!(virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) && + !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1))) { + return; + } + + if (s->dev.started) { + return; + } + + /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start + * vhost here instead of waiting for .set_status(). + */ + vhost_user_blk_start(vdev); + /* Kick right away to begin processing requests already in vring */ + for (i = 0; i < s->dev.nvqs; i++) { + VirtQueue *kick_vq = virtio_get_queue(vdev, i); + + if (!virtio_queue_get_desc_addr(vdev, i)) { + continue; + } + event_notifier_set(virtio_queue_get_host_notifier(kick_vq)); + } } static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 225fe44b7a..83cf5c01f9 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -97,8 +97,8 @@ static void virtio_blk_rw_complete(void *opaque, int ret) if (req->qiov.nalloc != -1) { /* If nalloc is != 1 req->qiov is a local copy of the original - * external iovec. It was allocated in submit_merged_requests - * to be able to merge requests. */ + * external iovec. It was allocated in submit_requests to be + * able to merge requests. */ qemu_iovec_destroy(&req->qiov); } diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 1599caa7c5..236a20eaa8 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2467,9 +2467,12 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linker) * IVRS table as specified in AMD IOMMU Specification v2.62, Section 5.2 * accessible here http://support.amd.com/TechDocs/48882_IOMMU.pdf */ +#define IOAPIC_SB_DEVID (uint64_t)PCI_BUILD_BDF(0, PCI_DEVFN(0x14, 0)) + static void build_amd_iommu(GArray *table_data, BIOSLinker *linker) { + int ivhd_table_len = 28; int iommu_start = table_data->len; AMDVIState *s = AMD_IOMMU_DEVICE(x86_iommu_get_default()); @@ -2491,8 +2494,16 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker) (1UL << 6) | /* PrefSup */ (1UL << 7), /* PPRSup */ 1); + + /* + * When interrupt remapping is supported, we add a special IVHD device + * for type IO-APIC. + */ + if (x86_iommu_get_default()->intr_supported) { + ivhd_table_len += 8; + } /* IVHD length */ - build_append_int_noprefix(table_data, 28, 2); + build_append_int_noprefix(table_data, ivhd_table_len, 2); /* DeviceID */ build_append_int_noprefix(table_data, s->devid, 2); /* Capability offset */ @@ -2507,7 +2518,8 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker) build_append_int_noprefix(table_data, (48UL << 30) | /* HATS */ (48UL << 28) | /* GATS */ - (1UL << 2), /* GTSup */ + (1UL << 2) | /* GTSup */ + (1UL << 6), /* GASup */ 4); /* * Type 1 device entry reporting all devices @@ -2516,6 +2528,21 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker) */ build_append_int_noprefix(table_data, 0x0000001, 4); + /* + * Add a special IVHD device type. + * Refer to spec - Table 95: IVHD device entry type codes + * + * Linux IOMMU driver checks for the special IVHD device (type IO-APIC). + * See Linux kernel commit 'c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059' + */ + if (x86_iommu_get_default()->intr_supported) { + build_append_int_noprefix(table_data, + (0x1ull << 56) | /* type IOAPIC */ + (IOAPIC_SB_DEVID << 40) | /* IOAPIC devid */ + 0x48, /* special device */ + 8); + } + build_header(linker, table_data, (void *)(table_data->data + iommu_start), "IVRS", table_data->len - iommu_start, 1, NULL, NULL); } diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 1fd669fef8..353a810e6b 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -26,7 +26,9 @@ #include "amd_iommu.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "hw/i386/apic_internal.h" #include "trace.h" +#include "hw/i386/apic-msidef.h" /* used AMD-Vi MMIO registers */ const char *amdvi_mmio_low[] = { @@ -55,6 +57,7 @@ struct AMDVIAddressSpace { uint8_t bus_num; /* bus number */ uint8_t devfn; /* device function */ AMDVIState *iommu_state; /* AMDVI - one per machine */ + MemoryRegion root; /* AMDVI Root memory map region */ IOMMUMemoryRegion iommu; /* Device's address translation region */ MemoryRegion iommu_ir; /* Device's interrupt remapping region */ AddressSpace as; /* device's corresponding address space */ @@ -605,6 +608,7 @@ static void amdvi_handle_control_write(AMDVIState *s) s->completion_wait_intr = !!(control & AMDVI_MMIO_CONTROL_COMWAITINTEN); s->cmdbuf_enabled = s->enabled && !!(control & AMDVI_MMIO_CONTROL_CMDBUFLEN); + s->ga_enabled = !!(control & AMDVI_MMIO_CONTROL_GAEN); /* update the flags depending on the control register */ if (s->cmdbuf_enabled) { @@ -807,7 +811,7 @@ static inline uint64_t amdvi_get_perms(uint64_t entry) AMDVI_DEV_PERM_SHIFT; } -/* a valid entry should have V = 1 and reserved bits honoured */ +/* validate that reserved bits are honoured */ static bool amdvi_validate_dte(AMDVIState *s, uint16_t devid, uint64_t *dte) { @@ -820,7 +824,7 @@ static bool amdvi_validate_dte(AMDVIState *s, uint16_t devid, return false; } - return dte[0] & AMDVI_DEV_VALID; + return true; } /* get a device table entry given the devid */ @@ -966,8 +970,12 @@ static void amdvi_do_translate(AMDVIAddressSpace *as, hwaddr addr, return; } - /* devices with V = 0 are not translated */ if (!amdvi_get_dte(s, devid, entry)) { + return; + } + + /* devices with V = 0 are not translated */ + if (!(entry[0] & AMDVI_DEV_VALID)) { goto out; } @@ -1026,10 +1034,366 @@ static IOMMUTLBEntry amdvi_translate(IOMMUMemoryRegion *iommu, hwaddr addr, return ret; } +static int amdvi_get_irte(AMDVIState *s, MSIMessage *origin, uint64_t *dte, + union irte *irte, uint16_t devid) +{ + uint64_t irte_root, offset; + + irte_root = dte[2] & AMDVI_IR_PHYS_ADDR_MASK; + offset = (origin->data & AMDVI_IRTE_OFFSET) << 2; + + trace_amdvi_ir_irte(irte_root, offset); + + if (dma_memory_read(&address_space_memory, irte_root + offset, + irte, sizeof(*irte))) { + trace_amdvi_ir_err("failed to get irte"); + return -AMDVI_IR_GET_IRTE; + } + + trace_amdvi_ir_irte_val(irte->val); + + return 0; +} + +static int amdvi_int_remap_legacy(AMDVIState *iommu, + MSIMessage *origin, + MSIMessage *translated, + uint64_t *dte, + X86IOMMUIrq *irq, + uint16_t sid) +{ + int ret; + union irte irte; + + /* get interrupt remapping table */ + ret = amdvi_get_irte(iommu, origin, dte, &irte, sid); + if (ret < 0) { + return ret; + } + + if (!irte.fields.valid) { + trace_amdvi_ir_target_abort("RemapEn is disabled"); + return -AMDVI_IR_TARGET_ABORT; + } + + if (irte.fields.guest_mode) { + error_report_once("guest mode is not zero"); + return -AMDVI_IR_ERR; + } + + if (irte.fields.int_type > AMDVI_IOAPIC_INT_TYPE_ARBITRATED) { + error_report_once("reserved int_type"); + return -AMDVI_IR_ERR; + } + + irq->delivery_mode = irte.fields.int_type; + irq->vector = irte.fields.vector; + irq->dest_mode = irte.fields.dm; + irq->redir_hint = irte.fields.rq_eoi; + irq->dest = irte.fields.destination; + + return 0; +} + +static int amdvi_get_irte_ga(AMDVIState *s, MSIMessage *origin, uint64_t *dte, + struct irte_ga *irte, uint16_t devid) +{ + uint64_t irte_root, offset; + + irte_root = dte[2] & AMDVI_IR_PHYS_ADDR_MASK; + offset = (origin->data & AMDVI_IRTE_OFFSET) << 4; + trace_amdvi_ir_irte(irte_root, offset); + + if (dma_memory_read(&address_space_memory, irte_root + offset, + irte, sizeof(*irte))) { + trace_amdvi_ir_err("failed to get irte_ga"); + return -AMDVI_IR_GET_IRTE; + } + + trace_amdvi_ir_irte_ga_val(irte->hi.val, irte->lo.val); + return 0; +} + +static int amdvi_int_remap_ga(AMDVIState *iommu, + MSIMessage *origin, + MSIMessage *translated, + uint64_t *dte, + X86IOMMUIrq *irq, + uint16_t sid) +{ + int ret; + struct irte_ga irte; + + /* get interrupt remapping table */ + ret = amdvi_get_irte_ga(iommu, origin, dte, &irte, sid); + if (ret < 0) { + return ret; + } + + if (!irte.lo.fields_remap.valid) { + trace_amdvi_ir_target_abort("RemapEn is disabled"); + return -AMDVI_IR_TARGET_ABORT; + } + + if (irte.lo.fields_remap.guest_mode) { + error_report_once("guest mode is not zero"); + return -AMDVI_IR_ERR; + } + + if (irte.lo.fields_remap.int_type > AMDVI_IOAPIC_INT_TYPE_ARBITRATED) { + error_report_once("reserved int_type is set"); + return -AMDVI_IR_ERR; + } + + irq->delivery_mode = irte.lo.fields_remap.int_type; + irq->vector = irte.hi.fields.vector; + irq->dest_mode = irte.lo.fields_remap.dm; + irq->redir_hint = irte.lo.fields_remap.rq_eoi; + irq->dest = irte.lo.fields_remap.destination; + + return 0; +} + +static int __amdvi_int_remap_msi(AMDVIState *iommu, + MSIMessage *origin, + MSIMessage *translated, + uint64_t *dte, + X86IOMMUIrq *irq, + uint16_t sid) +{ + int ret; + uint8_t int_ctl; + + int_ctl = (dte[2] >> AMDVI_IR_INTCTL_SHIFT) & 3; + trace_amdvi_ir_intctl(int_ctl); + + switch (int_ctl) { + case AMDVI_IR_INTCTL_PASS: + memcpy(translated, origin, sizeof(*origin)); + return 0; + case AMDVI_IR_INTCTL_REMAP: + break; + case AMDVI_IR_INTCTL_ABORT: + trace_amdvi_ir_target_abort("int_ctl abort"); + return -AMDVI_IR_TARGET_ABORT; + default: + trace_amdvi_ir_err("int_ctl reserved"); + return -AMDVI_IR_ERR; + } + + if (iommu->ga_enabled) { + ret = amdvi_int_remap_ga(iommu, origin, translated, dte, irq, sid); + } else { + ret = amdvi_int_remap_legacy(iommu, origin, translated, dte, irq, sid); + } + + return ret; +} + +/* Interrupt remapping for MSI/MSI-X entry */ +static int amdvi_int_remap_msi(AMDVIState *iommu, + MSIMessage *origin, + MSIMessage *translated, + uint16_t sid) +{ + int ret = 0; + uint64_t pass = 0; + uint64_t dte[4] = { 0 }; + X86IOMMUIrq irq = { 0 }; + uint8_t dest_mode, delivery_mode; + + assert(origin && translated); + + /* + * When IOMMU is enabled, interrupt remap request will come either from + * IO-APIC or PCI device. If interrupt is from PCI device then it will + * have a valid requester id but if the interrupt is from IO-APIC + * then requester id will be invalid. + */ + if (sid == X86_IOMMU_SID_INVALID) { + sid = AMDVI_IOAPIC_SB_DEVID; + } + + trace_amdvi_ir_remap_msi_req(origin->address, origin->data, sid); + + /* check if device table entry is set before we go further. */ + if (!iommu || !iommu->devtab_len) { + memcpy(translated, origin, sizeof(*origin)); + goto out; + } + + if (!amdvi_get_dte(iommu, sid, dte)) { + return -AMDVI_IR_ERR; + } + + /* Check if IR is enabled in DTE */ + if (!(dte[2] & AMDVI_IR_REMAP_ENABLE)) { + memcpy(translated, origin, sizeof(*origin)); + goto out; + } + + /* validate that we are configure with intremap=on */ + if (!X86_IOMMU_DEVICE(iommu)->intr_supported) { + trace_amdvi_err("Interrupt remapping is enabled in the guest but " + "not in the host. Use intremap=on to enable interrupt " + "remapping in amd-iommu."); + return -AMDVI_IR_ERR; + } + + if (origin->address & AMDVI_MSI_ADDR_HI_MASK) { + trace_amdvi_err("MSI address high 32 bits non-zero when " + "Interrupt Remapping enabled."); + return -AMDVI_IR_ERR; + } + + if ((origin->address & AMDVI_MSI_ADDR_LO_MASK) != APIC_DEFAULT_ADDRESS) { + trace_amdvi_err("MSI is not from IOAPIC."); + return -AMDVI_IR_ERR; + } + + /* + * The MSI data register [10:8] are used to get the upstream interrupt type. + * + * See MSI/MSI-X format: + * https://pdfs.semanticscholar.org/presentation/9420/c279e942eca568157711ef5c92b800c40a79.pdf + * (page 5) + */ + delivery_mode = (origin->data >> MSI_DATA_DELIVERY_MODE_SHIFT) & 7; + + switch (delivery_mode) { + case AMDVI_IOAPIC_INT_TYPE_FIXED: + case AMDVI_IOAPIC_INT_TYPE_ARBITRATED: + trace_amdvi_ir_delivery_mode("fixed/arbitrated"); + ret = __amdvi_int_remap_msi(iommu, origin, translated, dte, &irq, sid); + if (ret < 0) { + goto remap_fail; + } else { + /* Translate IRQ to MSI messages */ + x86_iommu_irq_to_msi_message(&irq, translated); + goto out; + } + break; + case AMDVI_IOAPIC_INT_TYPE_SMI: + error_report("SMI is not supported!"); + ret = -AMDVI_IR_ERR; + break; + case AMDVI_IOAPIC_INT_TYPE_NMI: + pass = dte[3] & AMDVI_DEV_NMI_PASS_MASK; + trace_amdvi_ir_delivery_mode("nmi"); + break; + case AMDVI_IOAPIC_INT_TYPE_INIT: + pass = dte[3] & AMDVI_DEV_INT_PASS_MASK; + trace_amdvi_ir_delivery_mode("init"); + break; + case AMDVI_IOAPIC_INT_TYPE_EINT: + pass = dte[3] & AMDVI_DEV_EINT_PASS_MASK; + trace_amdvi_ir_delivery_mode("eint"); + break; + default: + trace_amdvi_ir_delivery_mode("unsupported delivery_mode"); + ret = -AMDVI_IR_ERR; + break; + } + + if (ret < 0) { + goto remap_fail; + } + + /* + * The MSI address register bit[2] is used to get the destination + * mode. The dest_mode 1 is valid for fixed and arbitrated interrupts + * only. + */ + dest_mode = (origin->address >> MSI_ADDR_DEST_MODE_SHIFT) & 1; + if (dest_mode) { + trace_amdvi_ir_err("invalid dest_mode"); + ret = -AMDVI_IR_ERR; + goto remap_fail; + } + + if (pass) { + memcpy(translated, origin, sizeof(*origin)); + } else { + trace_amdvi_ir_err("passthrough is not enabled"); + ret = -AMDVI_IR_ERR; + goto remap_fail; + } + +out: + trace_amdvi_ir_remap_msi(origin->address, origin->data, + translated->address, translated->data); + return 0; + +remap_fail: + return ret; +} + +static int amdvi_int_remap(X86IOMMUState *iommu, + MSIMessage *origin, + MSIMessage *translated, + uint16_t sid) +{ + return amdvi_int_remap_msi(AMD_IOMMU_DEVICE(iommu), origin, + translated, sid); +} + +static MemTxResult amdvi_mem_ir_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + int ret; + MSIMessage from = { 0, 0 }, to = { 0, 0 }; + uint16_t sid = AMDVI_IOAPIC_SB_DEVID; + + from.address = (uint64_t) addr + AMDVI_INT_ADDR_FIRST; + from.data = (uint32_t) value; + + trace_amdvi_mem_ir_write_req(addr, value, size); + + if (!attrs.unspecified) { + /* We have explicit Source ID */ + sid = attrs.requester_id; + } + + ret = amdvi_int_remap_msi(opaque, &from, &to, sid); + if (ret < 0) { + /* TODO: log the event using IOMMU log event interface */ + error_report_once("failed to remap interrupt from devid 0x%x", sid); + return MEMTX_ERROR; + } + + apic_get_class()->send_msi(&to); + + trace_amdvi_mem_ir_write(to.address, to.data); + return MEMTX_OK; +} + +static MemTxResult amdvi_mem_ir_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + return MEMTX_OK; +} + +static const MemoryRegionOps amdvi_ir_ops = { + .read_with_attrs = amdvi_mem_ir_read, + .write_with_attrs = amdvi_mem_ir_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + } +}; + static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) { + char name[128]; AMDVIState *s = opaque; - AMDVIAddressSpace **iommu_as; + AMDVIAddressSpace **iommu_as, *amdvi_dev_as; int bus_num = pci_bus_num(bus); iommu_as = s->address_spaces[bus_num]; @@ -1042,19 +1406,45 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) /* set up AMD-Vi region */ if (!iommu_as[devfn]) { + snprintf(name, sizeof(name), "amd_iommu_devfn_%d", devfn); + iommu_as[devfn] = g_malloc0(sizeof(AMDVIAddressSpace)); iommu_as[devfn]->bus_num = (uint8_t)bus_num; iommu_as[devfn]->devfn = (uint8_t)devfn; iommu_as[devfn]->iommu_state = s; - memory_region_init_iommu(&iommu_as[devfn]->iommu, - sizeof(iommu_as[devfn]->iommu), + amdvi_dev_as = iommu_as[devfn]; + + /* + * Memory region relationships looks like (Address range shows + * only lower 32 bits to make it short in length...): + * + * |-----------------+-------------------+----------| + * | Name | Address range | Priority | + * |-----------------+-------------------+----------+ + * | amdvi_root | 00000000-ffffffff | 0 | + * | amdvi_iommu | 00000000-ffffffff | 1 | + * | amdvi_iommu_ir | fee00000-feefffff | 64 | + * |-----------------+-------------------+----------| + */ + memory_region_init_iommu(&amdvi_dev_as->iommu, + sizeof(amdvi_dev_as->iommu), TYPE_AMD_IOMMU_MEMORY_REGION, OBJECT(s), - "amd-iommu", UINT64_MAX); - address_space_init(&iommu_as[devfn]->as, - MEMORY_REGION(&iommu_as[devfn]->iommu), - "amd-iommu"); + "amd_iommu", UINT64_MAX); + memory_region_init(&amdvi_dev_as->root, OBJECT(s), + "amdvi_root", UINT64_MAX); + address_space_init(&amdvi_dev_as->as, &amdvi_dev_as->root, name); + memory_region_init_io(&amdvi_dev_as->iommu_ir, OBJECT(s), + &amdvi_ir_ops, s, "amd_iommu_ir", + AMDVI_INT_ADDR_SIZE); + memory_region_add_subregion_overlap(&amdvi_dev_as->root, + AMDVI_INT_ADDR_FIRST, + &amdvi_dev_as->iommu_ir, + 64); + memory_region_add_subregion_overlap(&amdvi_dev_as->root, 0, + MEMORY_REGION(&amdvi_dev_as->iommu), + 1); } return &iommu_as[devfn]->as; } @@ -1172,6 +1562,9 @@ static void amdvi_realize(DeviceState *dev, Error **err) return; } + /* Pseudo address space under root PCI bus. */ + pcms->ioapic_as = amdvi_host_dma_iommu(bus, s, AMDVI_IOAPIC_SB_DEVID); + /* set up MMIO */ memory_region_init_io(&s->mmio, OBJECT(s), &mmio_mem_ops, s, "amdvi-mmio", AMDVI_MMIO_SIZE); @@ -1205,6 +1598,7 @@ static void amdvi_class_init(ObjectClass *klass, void* data) dc->vmsd = &vmstate_amdvi; dc->hotpluggable = false; dc_class->realize = amdvi_realize; + dc_class->int_remap = amdvi_int_remap; /* Supported by the pc-q35-* machine types */ dc->user_creatable = true; } diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 874030582d..c52886f3ed 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -103,6 +103,7 @@ #define AMDVI_MMIO_CONTROL_EVENTINTEN (1ULL << 3) #define AMDVI_MMIO_CONTROL_COMWAITINTEN (1ULL << 4) #define AMDVI_MMIO_CONTROL_CMDBUFLEN (1ULL << 12) +#define AMDVI_MMIO_CONTROL_GAEN (1ULL << 17) /* MMIO status register bits */ #define AMDVI_MMIO_STATUS_CMDBUF_RUN (1 << 4) @@ -175,7 +176,7 @@ /* extended feature support */ #define AMDVI_EXT_FEATURES (AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_PPR | \ AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | AMDVI_FEATURE_HE | \ - AMDVI_GATS_MODE | AMDVI_HATS_MODE) + AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA) /* capabilities header */ #define AMDVI_CAPAB_FEATURES (AMDVI_CAPAB_FLAT_EXT | \ @@ -206,8 +207,94 @@ #define AMDVI_COMMAND_SIZE 16 -#define AMDVI_INT_ADDR_FIRST 0xfee00000 -#define AMDVI_INT_ADDR_LAST 0xfeefffff +#define AMDVI_INT_ADDR_FIRST 0xfee00000 +#define AMDVI_INT_ADDR_LAST 0xfeefffff +#define AMDVI_INT_ADDR_SIZE (AMDVI_INT_ADDR_LAST - AMDVI_INT_ADDR_FIRST + 1) +#define AMDVI_MSI_ADDR_HI_MASK (0xffffffff00000000ULL) +#define AMDVI_MSI_ADDR_LO_MASK (0x00000000ffffffffULL) + +/* SB IOAPIC is always on this device in AMD systems */ +#define AMDVI_IOAPIC_SB_DEVID PCI_BUILD_BDF(0, PCI_DEVFN(0x14, 0)) + +/* Interrupt remapping errors */ +#define AMDVI_IR_ERR 0x1 +#define AMDVI_IR_GET_IRTE 0x2 +#define AMDVI_IR_TARGET_ABORT 0x3 + +/* Interrupt remapping */ +#define AMDVI_IR_REMAP_ENABLE 1ULL +#define AMDVI_IR_INTCTL_SHIFT 60 +#define AMDVI_IR_INTCTL_ABORT 0 +#define AMDVI_IR_INTCTL_PASS 1 +#define AMDVI_IR_INTCTL_REMAP 2 + +#define AMDVI_IR_PHYS_ADDR_MASK (((1ULL << 45) - 1) << 6) + +/* MSI data 10:0 bits (section 2.2.5.1 Fig 14) */ +#define AMDVI_IRTE_OFFSET 0x7ff + +/* Delivery mode of MSI data (same as IOAPIC deilver mode encoding) */ +#define AMDVI_IOAPIC_INT_TYPE_FIXED 0x0 +#define AMDVI_IOAPIC_INT_TYPE_ARBITRATED 0x1 +#define AMDVI_IOAPIC_INT_TYPE_SMI 0x2 +#define AMDVI_IOAPIC_INT_TYPE_NMI 0x4 +#define AMDVI_IOAPIC_INT_TYPE_INIT 0x5 +#define AMDVI_IOAPIC_INT_TYPE_EINT 0x7 + +/* Pass through interrupt */ +#define AMDVI_DEV_INT_PASS_MASK (1ULL << 56) +#define AMDVI_DEV_EINT_PASS_MASK (1ULL << 57) +#define AMDVI_DEV_NMI_PASS_MASK (1ULL << 58) +#define AMDVI_DEV_LINT0_PASS_MASK (1ULL << 62) +#define AMDVI_DEV_LINT1_PASS_MASK (1ULL << 63) + +/* Interrupt remapping table fields (Guest VAPIC not enabled) */ +union irte { + uint32_t val; + struct { + uint32_t valid:1, + no_fault:1, + int_type:3, + rq_eoi:1, + dm:1, + guest_mode:1, + destination:8, + vector:8, + rsvd:8; + } fields; +}; + +/* Interrupt remapping table fields (Guest VAPIC is enabled) */ +union irte_ga_lo { + uint64_t val; + + /* For int remapping */ + struct { + uint64_t valid:1, + no_fault:1, + /* ------ */ + int_type:3, + rq_eoi:1, + dm:1, + /* ------ */ + guest_mode:1, + destination:8, + rsvd_1:48; + } fields_remap; +}; + +union irte_ga_hi { + uint64_t val; + struct { + uint64_t vector:8, + rsvd_2:56; + } fields; +}; + +struct irte_ga { + union irte_ga_lo lo; + union irte_ga_hi hi; +}; #define TYPE_AMD_IOMMU_DEVICE "amd-iommu" #define AMD_IOMMU_DEVICE(obj)\ @@ -278,6 +365,9 @@ typedef struct AMDVIState { /* IOTLB */ GHashTable *iotlb; + + /* Interrupt remapping */ + bool ga_enabled; } AMDVIState; #endif diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 3dfada19a6..d97bcbc2f7 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -37,6 +37,9 @@ #include "kvm_i386.h" #include "trace.h" +static void vtd_address_space_refresh_all(IntelIOMMUState *s); +static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n); + static void vtd_define_quad(IntelIOMMUState *s, hwaddr addr, uint64_t val, uint64_t wmask, uint64_t w1cmask) { @@ -227,6 +230,14 @@ static void vtd_reset_iotlb(IntelIOMMUState *s) vtd_iommu_unlock(s); } +static void vtd_reset_caches(IntelIOMMUState *s) +{ + vtd_iommu_lock(s); + vtd_reset_iotlb_locked(s); + vtd_reset_context_cache_locked(s); + vtd_iommu_unlock(s); +} + static uint64_t vtd_get_iotlb_key(uint64_t gfn, uint16_t source_id, uint32_t level) { @@ -1035,7 +1046,6 @@ static int vtd_sync_shadow_page_hook(IOMMUTLBEntry *entry, return 0; } -/* If context entry is NULL, we'll try to fetch it on our own. */ static int vtd_sync_shadow_page_table_range(VTDAddressSpace *vtd_as, VTDContextEntry *ce, hwaddr addr, hwaddr size) @@ -1047,39 +1057,41 @@ static int vtd_sync_shadow_page_table_range(VTDAddressSpace *vtd_as, .notify_unmap = true, .aw = s->aw_bits, .as = vtd_as, + .domain_id = VTD_CONTEXT_ENTRY_DID(ce->hi), }; - VTDContextEntry ce_cache; + + return vtd_page_walk(ce, addr, addr + size, &info); +} + +static int vtd_sync_shadow_page_table(VTDAddressSpace *vtd_as) +{ int ret; + VTDContextEntry ce; + IOMMUNotifier *n; - if (ce) { - /* If the caller provided context entry, use it */ - ce_cache = *ce; - } else { - /* If the caller didn't provide ce, try to fetch */ - ret = vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), - vtd_as->devfn, &ce_cache); - if (ret) { + ret = vtd_dev_to_context_entry(vtd_as->iommu_state, + pci_bus_num(vtd_as->bus), + vtd_as->devfn, &ce); + if (ret) { + if (ret == -VTD_FR_CONTEXT_ENTRY_P) { /* - * This should not really happen, but in case it happens, - * we just skip the sync for this time. After all we even - * don't have the root table pointer! + * It's a valid scenario to have a context entry that is + * not present. For example, when a device is removed + * from an existing domain then the context entry will be + * zeroed by the guest before it was put into another + * domain. When this happens, instead of synchronizing + * the shadow pages we should invalidate all existing + * mappings and notify the backends. */ - error_report_once("%s: invalid context entry for bus 0x%x" - " devfn 0x%x", - __func__, pci_bus_num(vtd_as->bus), - vtd_as->devfn); - return 0; + IOMMU_NOTIFIER_FOREACH(n, &vtd_as->iommu) { + vtd_address_space_unmap(vtd_as, n); + } + ret = 0; } + return ret; } - info.domain_id = VTD_CONTEXT_ENTRY_DID(ce_cache.hi); - - return vtd_page_walk(&ce_cache, addr, addr + size, &info); -} - -static int vtd_sync_shadow_page_table(VTDAddressSpace *vtd_as) -{ - return vtd_sync_shadow_page_table_range(vtd_as, NULL, 0, UINT64_MAX); + return vtd_sync_shadow_page_table_range(vtd_as, &ce, 0, UINT64_MAX); } /* @@ -1428,7 +1440,7 @@ static void vtd_context_global_invalidate(IntelIOMMUState *s) vtd_reset_context_cache_locked(s); } vtd_iommu_unlock(s); - vtd_switch_address_space_all(s); + vtd_address_space_refresh_all(s); /* * From VT-d spec 6.5.2.1, a global context entry invalidation * should be followed by a IOTLB global invalidation, so we should @@ -1719,6 +1731,8 @@ static void vtd_handle_gcmd_srtp(IntelIOMMUState *s) vtd_root_table_setup(s); /* Ok - report back to driver */ vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_RTPS); + vtd_reset_caches(s); + vtd_address_space_refresh_all(s); } /* Set Interrupt Remap Table Pointer */ @@ -1751,7 +1765,8 @@ static void vtd_handle_gcmd_te(IntelIOMMUState *s, bool en) vtd_set_clear_mask_long(s, DMAR_GSTS_REG, VTD_GSTS_TES, 0); } - vtd_switch_address_space_all(s); + vtd_reset_caches(s); + vtd_address_space_refresh_all(s); } /* Handle Interrupt Remap Enable/Disable */ @@ -2701,7 +2716,7 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index, /* Fetch IRQ information of specific IR index */ static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index, - VTDIrq *irq, uint16_t sid) + X86IOMMUIrq *irq, uint16_t sid) { VTD_IR_TableEntry irte = {}; int ret = 0; @@ -2730,30 +2745,6 @@ static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index, return 0; } -/* Generate one MSI message from VTDIrq info */ -static void vtd_generate_msi_message(VTDIrq *irq, MSIMessage *msg_out) -{ - VTD_MSIMessage msg = {}; - - /* Generate address bits */ - msg.dest_mode = irq->dest_mode; - msg.redir_hint = irq->redir_hint; - msg.dest = irq->dest; - msg.__addr_hi = irq->dest & 0xffffff00; - msg.__addr_head = cpu_to_le32(0xfee); - /* Keep this from original MSI address bits */ - msg.__not_used = irq->msi_addr_last_bits; - - /* Generate data bits */ - msg.vector = irq->vector; - msg.delivery_mode = irq->delivery_mode; - msg.level = 1; - msg.trigger_mode = irq->trigger_mode; - - msg_out->address = msg.msi_addr; - msg_out->data = msg.msi_data; -} - /* Interrupt remapping for MSI/MSI-X entry */ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu, MSIMessage *origin, @@ -2763,7 +2754,7 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu, int ret = 0; VTD_IR_MSIAddress addr; uint16_t index; - VTDIrq irq = {}; + X86IOMMUIrq irq = {}; assert(origin && translated); @@ -2842,8 +2833,8 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu, */ irq.msi_addr_last_bits = addr.addr.__not_care; - /* Translate VTDIrq to MSI message */ - vtd_generate_msi_message(&irq, translated); + /* Translate X86IOMMUIrq to MSI message */ + x86_iommu_irq_to_msi_message(&irq, translated); out: trace_vtd_ir_remap_msi(origin->address, origin->data, @@ -3051,6 +3042,12 @@ static void vtd_address_space_unmap_all(IntelIOMMUState *s) } } +static void vtd_address_space_refresh_all(IntelIOMMUState *s) +{ + vtd_address_space_unmap_all(s); + vtd_switch_address_space_all(s); +} + static int vtd_replay_hook(IOMMUTLBEntry *entry, void *private) { memory_region_notify_one((IOMMUNotifier *)private, entry); @@ -3160,10 +3157,7 @@ static void vtd_init(IntelIOMMUState *s) s->cap |= VTD_CAP_CM; } - vtd_iommu_lock(s); - vtd_reset_context_cache_locked(s); - vtd_reset_iotlb_locked(s); - vtd_iommu_unlock(s); + vtd_reset_caches(s); /* Define registers with default values and bit semantics */ vtd_define_long(s, DMAR_VER_REG, 0x10UL, 0, 0); @@ -3226,11 +3220,7 @@ static void vtd_reset(DeviceState *dev) IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev); vtd_init(s); - - /* - * When device reset, throw away all mappings and external caches - */ - vtd_address_space_unmap_all(s); + vtd_address_space_refresh_all(s); } static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) @@ -3248,13 +3238,6 @@ static bool vtd_decide_config(IntelIOMMUState *s, Error **errp) { X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s); - /* Currently Intel IOMMU IR only support "kernel-irqchip={off|split}" */ - if (x86_iommu->intr_supported && kvm_irqchip_in_kernel() && - !kvm_irqchip_is_split()) { - error_setg(errp, "Intel Interrupt Remapping cannot work with " - "kernel-irqchip=on, please use 'split|off'."); - return false; - } if (s->intr_eim == ON_OFF_AUTO_ON && !x86_iommu->intr_supported) { error_setg(errp, "eim=on cannot be selected without intremap=on"); return false; diff --git a/hw/i386/trace-events b/hw/i386/trace-events index 9e6fc4dca9..6ac347d18c 100644 --- a/hw/i386/trace-events +++ b/hw/i386/trace-events @@ -101,6 +101,20 @@ amdvi_mode_invalid(uint8_t level, uint64_t addr)"error: translation level 0x%"PR amdvi_page_fault(uint64_t addr) "error: page fault accessing guest physical address 0x%"PRIx64 amdvi_iotlb_hit(uint8_t bus, uint8_t slot, uint8_t func, uint64_t addr, uint64_t txaddr) "hit iotlb devid %02x:%02x.%x gpa 0x%"PRIx64" hpa 0x%"PRIx64 amdvi_translation_result(uint8_t bus, uint8_t slot, uint8_t func, uint64_t addr, uint64_t txaddr) "devid: %02x:%02x.%x gpa 0x%"PRIx64" hpa 0x%"PRIx64 +amdvi_mem_ir_write_req(uint64_t addr, uint64_t val, uint32_t size) "addr 0x%"PRIx64" data 0x%"PRIx64" size 0x%"PRIx32 +amdvi_mem_ir_write(uint64_t addr, uint64_t val) "addr 0x%"PRIx64" data 0x%"PRIx64 +amdvi_ir_remap_msi_req(uint64_t addr, uint64_t data, uint8_t devid) "addr 0x%"PRIx64" data 0x%"PRIx64" devid 0x%"PRIx8 +amdvi_ir_remap_msi(uint64_t addr, uint64_t data, uint64_t addr2, uint64_t data2) "(addr 0x%"PRIx64", data 0x%"PRIx64") -> (addr 0x%"PRIx64", data 0x%"PRIx64")" +amdvi_err(const char *str) "%s" +amdvi_ir_irte(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" offset 0x%"PRIx64 +amdvi_ir_irte_val(uint32_t data) "data 0x%"PRIx32 +amdvi_ir_err(const char *str) "%s" +amdvi_ir_intctl(uint8_t val) "int_ctl 0x%"PRIx8 +amdvi_ir_target_abort(const char *str) "%s" +amdvi_ir_delivery_mode(const char *str) "%s" +amdvi_ir_generate_msi_message(uint8_t vector, uint8_t delivery_mode, uint8_t dest_mode, uint8_t dest, uint8_t rh) "vector %d delivery-mode %d dest-mode %d dest-id %d rh %d" +amdvi_ir_irte_ga(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" offset 0x%"PRIx64 +amdvi_ir_irte_ga_val(uint64_t hi, uint64_t lo) "hi 0x%"PRIx64" lo 0x%"PRIx64 # hw/i386/vmport.c vmport_register(unsigned char command, void *func, void *opaque) "command: 0x%02x func: %p opaque: %p" diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c index 8a01a2dd25..abc3c03158 100644 --- a/hw/i386/x86-iommu.c +++ b/hw/i386/x86-iommu.c @@ -25,6 +25,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "trace.h" +#include "sysemu/kvm.h" void x86_iommu_iec_register_notifier(X86IOMMUState *iommu, iec_notify_fn fn, void *data) @@ -52,6 +53,30 @@ void x86_iommu_iec_notify_all(X86IOMMUState *iommu, bool global, } } +/* Generate one MSI message from VTDIrq info */ +void x86_iommu_irq_to_msi_message(X86IOMMUIrq *irq, MSIMessage *msg_out) +{ + X86IOMMU_MSIMessage msg = {}; + + /* Generate address bits */ + msg.dest_mode = irq->dest_mode; + msg.redir_hint = irq->redir_hint; + msg.dest = irq->dest; + msg.__addr_hi = irq->dest & 0xffffff00; + msg.__addr_head = cpu_to_le32(0xfee); + /* Keep this from original MSI address bits */ + msg.__not_used = irq->msi_addr_last_bits; + + /* Generate data bits */ + msg.vector = irq->vector; + msg.delivery_mode = irq->delivery_mode; + msg.level = 1; + msg.trigger_mode = irq->trigger_mode; + + msg_out->address = msg.msi_addr; + msg_out->data = msg.msi_data; +} + /* Default X86 IOMMU device */ static X86IOMMUState *x86_iommu_default = NULL; @@ -94,6 +119,14 @@ static void x86_iommu_realize(DeviceState *dev, Error **errp) return; } + /* Both Intel and AMD IOMMU IR only support "kernel-irqchip={off|split}" */ + if (x86_iommu->intr_supported && kvm_irqchip_in_kernel() && + !kvm_irqchip_is_split()) { + error_setg(errp, "Interrupt Remapping cannot work with " + "kernel-irqchip=on, please use 'split|off'."); + return; + } + if (x86_class->realize) { x86_class->realize(dev, errp); } diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c index 321f184595..63c6894c95 100644 --- a/hw/lm32/milkymist.c +++ b/hw/lm32/milkymist.c @@ -138,7 +138,10 @@ milkymist_init(MachineState *machine) bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (bios_filename) { - load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE); + if (load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE) < 0) { + error_report("could not load bios '%s'", bios_filename); + exit(1); + } } reset_info->bootstrap_pc = BIOS_OFFSET; diff --git a/hw/misc/pci-testdev.c b/hw/misc/pci-testdev.c index 32041f535f..1282d151cb 100644 --- a/hw/misc/pci-testdev.c +++ b/hw/misc/pci-testdev.c @@ -85,6 +85,9 @@ typedef struct PCITestDevState { MemoryRegion portio; IOTest *tests; int current; + + uint64_t membar_size; + MemoryRegion membar; } PCITestDevState; #define TYPE_PCI_TEST_DEV "pci-testdev" @@ -253,6 +256,16 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp) pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio); pci_register_bar(pci_dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &d->portio); + if (d->membar_size) { + memory_region_init(&d->membar, OBJECT(d), "pci-testdev-membar", + d->membar_size); + pci_register_bar(pci_dev, 2, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + &d->membar); + } + d->current = -1; d->tests = g_malloc0(IOTEST_MAX * sizeof *d->tests); for (i = 0; i < IOTEST_MAX; ++i) { @@ -305,6 +318,11 @@ static void qdev_pci_testdev_reset(DeviceState *dev) pci_testdev_reset(d); } +static Property pci_testdev_properties[] = { + DEFINE_PROP_SIZE("membar", PCITestDevState, membar_size, 0), + DEFINE_PROP_END_OF_LIST(), +}; + static void pci_testdev_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -319,6 +337,7 @@ static void pci_testdev_class_init(ObjectClass *klass, void *data) dc->desc = "PCI Test Device"; set_bit(DEVICE_CATEGORY_MISC, dc->categories); dc->reset = qdev_pci_testdev_reset; + dc->props = pci_testdev_properties; } static const TypeInfo pci_testdev_info = { diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c index a451d74ee6..81f2de6f07 100644 --- a/hw/pci-bridge/ioh3420.c +++ b/hw/pci-bridge/ioh3420.c @@ -24,7 +24,7 @@ #include "hw/pci/pci_ids.h" #include "hw/pci/msi.h" #include "hw/pci/pcie.h" -#include "ioh3420.h" +#include "hw/pci/pcie_port.h" #define PCI_DEVICE_ID_IOH_EPORT 0x3420 /* D0:F0 express mode */ #define PCI_DEVICE_ID_IOH_REV 0x2 diff --git a/hw/pci-bridge/ioh3420.h b/hw/pci-bridge/ioh3420.h deleted file mode 100644 index ea423cb991..0000000000 --- a/hw/pci-bridge/ioh3420.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef QEMU_IOH3420_H -#define QEMU_IOH3420_H - -#include "hw/pci/pcie_port.h" - -#endif /* QEMU_IOH3420_H */ diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c index b202657954..467bbabe4c 100644 --- a/hw/pci-bridge/xio3130_downstream.c +++ b/hw/pci-bridge/xio3130_downstream.c @@ -23,7 +23,7 @@ #include "hw/pci/pci_ids.h" #include "hw/pci/msi.h" #include "hw/pci/pcie.h" -#include "xio3130_downstream.h" +#include "hw/pci/pcie_port.h" #include "qapi/error.h" #define PCI_DEVICE_ID_TI_XIO3130D 0x8233 /* downstream port */ @@ -127,32 +127,6 @@ static void xio3130_downstream_exitfn(PCIDevice *d) pci_bridge_exitfn(d); } -PCIESlot *xio3130_downstream_init(PCIBus *bus, int devfn, bool multifunction, - const char *bus_name, pci_map_irq_fn map_irq, - uint8_t port, uint8_t chassis, - uint16_t slot) -{ - PCIDevice *d; - PCIBridge *br; - DeviceState *qdev; - - d = pci_create_multifunction(bus, devfn, multifunction, - "xio3130-downstream"); - if (!d) { - return NULL; - } - br = PCI_BRIDGE(d); - - qdev = DEVICE(d); - pci_bridge_map_irq(br, bus_name, map_irq); - qdev_prop_set_uint8(qdev, "port", port); - qdev_prop_set_uint8(qdev, "chassis", chassis); - qdev_prop_set_uint16(qdev, "slot", slot); - qdev_init_nofail(qdev); - - return PCIE_SLOT(d); -} - static Property xio3130_downstream_props[] = { DEFINE_PROP_BIT(COMPAT_PROP_PCP, PCIDevice, cap_present, QEMU_PCIE_SLTCAP_PCP_BITNR, true), diff --git a/hw/pci-bridge/xio3130_downstream.h b/hw/pci-bridge/xio3130_downstream.h deleted file mode 100644 index 8426d9ffa6..0000000000 --- a/hw/pci-bridge/xio3130_downstream.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef QEMU_XIO3130_DOWNSTREAM_H -#define QEMU_XIO3130_DOWNSTREAM_H - -#include "hw/pci/pcie_port.h" - -PCIESlot *xio3130_downstream_init(PCIBus *bus, int devfn, bool multifunction, - const char *bus_name, pci_map_irq_fn map_irq, - uint8_t port, uint8_t chassis, - uint16_t slot); - -#endif /* QEMU_XIO3130_DOWNSTREAM_H */ diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c index bca2f9a5ea..b524908cf1 100644 --- a/hw/pci-bridge/xio3130_upstream.c +++ b/hw/pci-bridge/xio3130_upstream.c @@ -23,7 +23,7 @@ #include "hw/pci/pci_ids.h" #include "hw/pci/msi.h" #include "hw/pci/pcie.h" -#include "xio3130_upstream.h" +#include "hw/pci/pcie_port.h" #define PCI_DEVICE_ID_TI_XIO3130U 0x8232 /* upstream port */ #define XIO3130_REVISION 0x2 @@ -108,28 +108,6 @@ static void xio3130_upstream_exitfn(PCIDevice *d) pci_bridge_exitfn(d); } -PCIEPort *xio3130_upstream_init(PCIBus *bus, int devfn, bool multifunction, - const char *bus_name, pci_map_irq_fn map_irq, - uint8_t port) -{ - PCIDevice *d; - PCIBridge *br; - DeviceState *qdev; - - d = pci_create_multifunction(bus, devfn, multifunction, "x3130-upstream"); - if (!d) { - return NULL; - } - br = PCI_BRIDGE(d); - - qdev = DEVICE(d); - pci_bridge_map_irq(br, bus_name, map_irq); - qdev_prop_set_uint8(qdev, "port", port); - qdev_init_nofail(qdev); - - return PCIE_PORT(d); -} - static const VMStateDescription vmstate_xio3130_upstream = { .name = "xio3130-express-upstream-port", .priority = MIG_PRI_PCI_BUS, diff --git a/hw/pci-bridge/xio3130_upstream.h b/hw/pci-bridge/xio3130_upstream.h deleted file mode 100644 index d0ab7577e2..0000000000 --- a/hw/pci-bridge/xio3130_upstream.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef QEMU_XIO3130_UPSTREAM_H -#define QEMU_XIO3130_UPSTREAM_H - -#include "hw/pci/pcie_port.h" - -PCIEPort *xio3130_upstream_init(PCIBus *bus, int devfn, bool multifunction, - const char *bus_name, pci_map_irq_fn map_irq, - uint8_t port); - -#endif /* QEMU_XIO3130_UPSTREAM_H */ diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index 47293a3915..d9c70f7ce6 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -40,7 +40,7 @@ /* * I440FX chipset data sheet. - * http://download.intel.com/design/chipsets/datashts/29054901.pdf + * https://wiki.qemu.org/File:29054901.pdf */ #define I440FX_PCI_HOST_BRIDGE(obj) \ @@ -95,6 +95,9 @@ typedef struct PIIX3State { #define I440FX_PCI_DEVICE(obj) \ OBJECT_CHECK(PCII440FXState, (obj), TYPE_I440FX_PCI_DEVICE) +#define TYPE_PIIX3_DEVICE "PIIX3" +#define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen" + struct PCII440FXState { /*< private >*/ PCIDevice parent_obj; @@ -142,7 +145,7 @@ static void i440fx_update_memory_mappings(PCII440FXState *d) PCIDevice *pd = PCI_DEVICE(d); memory_region_transaction_begin(); - for (i = 0; i < 13; i++) { + for (i = 0; i < ARRAY_SIZE(d->pam_regions); i++) { pam_update(&d->pam_regions[i], i, pd->config[I440FX_PAM + DIV_ROUND_UP(i, 2)]); } @@ -249,9 +252,7 @@ static void i440fx_pcihost_get_pci_hole_end(Object *obj, Visitor *v, * the 64bit PCI hole will start after "over 4G RAM" and the * reserved space for memory hotplug if any. */ -static void i440fx_pcihost_get_pci_hole64_start(Object *obj, Visitor *v, - const char *name, - void *opaque, Error **errp) +static uint64_t i440fx_pcihost_get_pci_hole64_start_value(Object *obj) { PCIHostState *h = PCI_HOST_BRIDGE(obj); I440FXState *s = I440FX_PCI_HOST_BRIDGE(obj); @@ -263,7 +264,16 @@ static void i440fx_pcihost_get_pci_hole64_start(Object *obj, Visitor *v, if (!value && s->pci_hole64_fix) { value = pc_pci_hole64_start(); } - visit_type_uint64(v, name, &value, errp); + return value; +} + +static void i440fx_pcihost_get_pci_hole64_start(Object *obj, Visitor *v, + const char *name, + void *opaque, Error **errp) +{ + uint64_t hole64_start = i440fx_pcihost_get_pci_hole64_start_value(obj); + + visit_type_uint64(v, name, &hole64_start, errp); } /* @@ -278,7 +288,7 @@ static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v, { PCIHostState *h = PCI_HOST_BRIDGE(obj); I440FXState *s = I440FX_PCI_HOST_BRIDGE(obj); - uint64_t hole64_start = pc_pci_hole64_start(); + uint64_t hole64_start = i440fx_pcihost_get_pci_hole64_start_value(obj); Range w64; uint64_t value, hole64_end; @@ -405,7 +415,7 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type, init_pam(dev, f->ram_memory, f->system_memory, f->pci_address_space, &f->pam_regions[0], PAM_BIOS_BASE, PAM_BIOS_SIZE); - for (i = 0; i < 12; ++i) { + for (i = 0; i < ARRAY_SIZE(f->pam_regions) - 1; ++i) { init_pam(dev, f->ram_memory, f->system_memory, f->pci_address_space, &f->pam_regions[i+1], PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); @@ -417,13 +427,13 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type, * These additional routes can be discovered through ACPI. */ if (xen_enabled()) { PCIDevice *pci_dev = pci_create_simple_multifunction(b, - -1, true, "PIIX3-xen"); + -1, true, TYPE_PIIX3_XEN_DEVICE); piix3 = PIIX3_PCI_DEVICE(pci_dev); pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq, piix3, XEN_PIIX_NUM_PIRQS); } else { PCIDevice *pci_dev = pci_create_simple_multifunction(b, - -1, true, "PIIX3"); + -1, true, TYPE_PIIX3_DEVICE); piix3 = PIIX3_PCI_DEVICE(pci_dev); pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, PIIX_NUM_PIRQS); @@ -741,7 +751,7 @@ static void piix3_class_init(ObjectClass *klass, void *data) } static const TypeInfo piix3_info = { - .name = "PIIX3", + .name = TYPE_PIIX3_DEVICE, .parent = TYPE_PIIX3_PCI_DEVICE, .class_init = piix3_class_init, }; @@ -754,7 +764,7 @@ static void piix3_xen_class_init(ObjectClass *klass, void *data) }; static const TypeInfo piix3_xen_info = { - .name = "PIIX3-xen", + .name = TYPE_PIIX3_XEN_DEVICE, .parent = TYPE_PIIX3_PCI_DEVICE, .class_init = piix3_xen_class_init, }; diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 966a7cf92d..0c38a8dfd3 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -113,9 +113,7 @@ static void q35_host_get_pci_hole_end(Object *obj, Visitor *v, * the 64bit PCI hole will start after "over 4G RAM" and the * reserved space for memory hotplug if any. */ -static void q35_host_get_pci_hole64_start(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) +static uint64_t q35_host_get_pci_hole64_start_value(Object *obj) { PCIHostState *h = PCI_HOST_BRIDGE(obj); Q35PCIHost *s = Q35_HOST_DEVICE(obj); @@ -127,7 +125,16 @@ static void q35_host_get_pci_hole64_start(Object *obj, Visitor *v, if (!value && s->pci_hole64_fix) { value = pc_pci_hole64_start(); } - visit_type_uint64(v, name, &value, errp); + return value; +} + +static void q35_host_get_pci_hole64_start(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + uint64_t hole64_start = q35_host_get_pci_hole64_start_value(obj); + + visit_type_uint64(v, name, &hole64_start, errp); } /* @@ -142,7 +149,7 @@ static void q35_host_get_pci_hole64_end(Object *obj, Visitor *v, { PCIHostState *h = PCI_HOST_BRIDGE(obj); Q35PCIHost *s = Q35_HOST_DEVICE(obj); - uint64_t hole64_start = pc_pci_hole64_start(); + uint64_t hole64_start = q35_host_get_pci_hole64_start_value(obj); Range w64; uint64_t value, hole64_end; diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index 08b7e44e2e..ee9dff2d3a 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -399,7 +399,7 @@ void pci_bridge_exitfn(PCIDevice *pci_dev) /* * before qdev initialization(qdev_init()), this function sets bus_name and - * map_irq callback which are necessry for pci_bridge_initfn() to + * map_irq callback which are necessary for pci_bridge_initfn() to * initialize bus. */ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name, diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index becf550085..7f21b4f9d6 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -183,7 +183,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) } vsc->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues; - vsc->dev.vqs = g_new(struct vhost_virtqueue, vsc->dev.nvqs); + vsc->dev.vqs = g_new0(struct vhost_virtqueue, vsc->dev.nvqs); vsc->dev.vq_index = 0; vsc->dev.backend_features = 0; diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 3962bb74e5..65de952f44 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -142,7 +142,7 @@ static void vfio_ap_reset(DeviceState *dev) ret = ioctl(vapdev->vdev.fd, VFIO_DEVICE_RESET); if (ret) { error_report("%s: failed to reset %s device: %s", __func__, - vapdev->vdev.name, strerror(ret)); + vapdev->vdev.name, strerror(errno)); } } diff --git a/include/block/block.h b/include/block/block.h index b189cf422e..7f5453b45b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -115,6 +115,7 @@ typedef struct HDGeometry { select an appropriate protocol driver, ignoring the format layer */ #define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */ +#define BDRV_O_AUTO_RDONLY 0x20000 /* degrade to read-only if opening read-write fails */ #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH) @@ -125,6 +126,7 @@ typedef struct HDGeometry { #define BDRV_OPT_CACHE_DIRECT "cache.direct" #define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush" #define BDRV_OPT_READ_ONLY "read-only" +#define BDRV_OPT_AUTO_READ_ONLY "auto-read-only" #define BDRV_OPT_DISCARD "discard" #define BDRV_OPT_FORCE_SHARE "force-share" @@ -436,7 +438,8 @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, bool bdrv_is_read_only(BlockDriverState *bs); int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, bool ignore_allow_rdw, Error **errp); -int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); +int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg, + Error **errp); bool bdrv_is_writable(BlockDriverState *bs); bool bdrv_is_sg(BlockDriverState *bs); bool bdrv_is_inserted(BlockDriverState *bs); diff --git a/include/fpu/softfloat-macros.h b/include/fpu/softfloat-macros.h index c86687fa5e..b1d772e6d4 100644 --- a/include/fpu/softfloat-macros.h +++ b/include/fpu/softfloat-macros.h @@ -647,8 +647,8 @@ static inline uint64_t udiv_qrnnd(uint64_t *r, uint64_t n1, asm("dlgr %0, %1" : "+r"(n) : "r"(d)); *r = n >> 64; return n; -#elif defined(_ARCH_PPC64) - /* From Power ISA 3.0B, programming note for divdeu. */ +#elif defined(_ARCH_PPC64) && defined(_ARCH_PWR7) + /* From Power ISA 2.06, programming note for divdeu. */ uint64_t q1, q2, Q, r1, r2, R; asm("divdeu %0,%2,%4; divdu %1,%3,%4" : "=&r"(q1), "=r"(q2) diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index fbfedcb1c0..ed4e758273 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -66,8 +66,6 @@ typedef struct VTDIOTLBEntry VTDIOTLBEntry; typedef struct VTDBus VTDBus; typedef union VTD_IR_TableEntry VTD_IR_TableEntry; typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress; -typedef struct VTDIrq VTDIrq; -typedef struct VTD_MSIMessage VTD_MSIMessage; /* Context-Entry */ struct VTDContextEntry { @@ -197,63 +195,6 @@ union VTD_IR_MSIAddress { uint32_t data; }; -/* Generic IRQ entry information */ -struct VTDIrq { - /* Used by both IOAPIC/MSI interrupt remapping */ - uint8_t trigger_mode; - uint8_t vector; - uint8_t delivery_mode; - uint32_t dest; - uint8_t dest_mode; - - /* only used by MSI interrupt remapping */ - uint8_t redir_hint; - uint8_t msi_addr_last_bits; -}; - -struct VTD_MSIMessage { - union { - struct { -#ifdef HOST_WORDS_BIGENDIAN - uint32_t __addr_head:12; /* 0xfee */ - uint32_t dest:8; - uint32_t __reserved:8; - uint32_t redir_hint:1; - uint32_t dest_mode:1; - uint32_t __not_used:2; -#else - uint32_t __not_used:2; - uint32_t dest_mode:1; - uint32_t redir_hint:1; - uint32_t __reserved:8; - uint32_t dest:8; - uint32_t __addr_head:12; /* 0xfee */ -#endif - uint32_t __addr_hi; - } QEMU_PACKED; - uint64_t msi_addr; - }; - union { - struct { -#ifdef HOST_WORDS_BIGENDIAN - uint16_t trigger_mode:1; - uint16_t level:1; - uint16_t __resved:3; - uint16_t delivery_mode:3; - uint16_t vector:8; -#else - uint16_t vector:8; - uint16_t delivery_mode:3; - uint16_t __resved:3; - uint16_t level:1; - uint16_t trigger_mode:1; -#endif - uint16_t __resved1; - } QEMU_PACKED; - uint32_t msi_data; - }; -}; - /* When IR is enabled, all MSI/MSI-X data bits should be zero */ #define VTD_IR_MSI_DATA (0) diff --git a/include/hw/i386/x86-iommu.h b/include/hw/i386/x86-iommu.h index 7c71fc7470..2b22a579a3 100644 --- a/include/hw/i386/x86-iommu.h +++ b/include/hw/i386/x86-iommu.h @@ -22,6 +22,7 @@ #include "hw/sysbus.h" #include "hw/pci/pci.h" +#include "hw/pci/msi.h" #define TYPE_X86_IOMMU_DEVICE ("x86-iommu") #define X86_IOMMU_DEVICE(obj) \ @@ -35,6 +36,8 @@ typedef struct X86IOMMUState X86IOMMUState; typedef struct X86IOMMUClass X86IOMMUClass; +typedef struct X86IOMMUIrq X86IOMMUIrq; +typedef struct X86IOMMU_MSIMessage X86IOMMU_MSIMessage; typedef enum IommuType { TYPE_INTEL, @@ -78,6 +81,63 @@ struct X86IOMMUState { QLIST_HEAD(, IEC_Notifier) iec_notifiers; /* IEC notify list */ }; +/* Generic IRQ entry information when interrupt remapping is enabled */ +struct X86IOMMUIrq { + /* Used by both IOAPIC/MSI interrupt remapping */ + uint8_t trigger_mode; + uint8_t vector; + uint8_t delivery_mode; + uint32_t dest; + uint8_t dest_mode; + + /* only used by MSI interrupt remapping */ + uint8_t redir_hint; + uint8_t msi_addr_last_bits; +}; + +struct X86IOMMU_MSIMessage { + union { + struct { +#ifdef HOST_WORDS_BIGENDIAN + uint32_t __addr_head:12; /* 0xfee */ + uint32_t dest:8; + uint32_t __reserved:8; + uint32_t redir_hint:1; + uint32_t dest_mode:1; + uint32_t __not_used:2; +#else + uint32_t __not_used:2; + uint32_t dest_mode:1; + uint32_t redir_hint:1; + uint32_t __reserved:8; + uint32_t dest:8; + uint32_t __addr_head:12; /* 0xfee */ +#endif + uint32_t __addr_hi; + } QEMU_PACKED; + uint64_t msi_addr; + }; + union { + struct { +#ifdef HOST_WORDS_BIGENDIAN + uint16_t trigger_mode:1; + uint16_t level:1; + uint16_t __resved:3; + uint16_t delivery_mode:3; + uint16_t vector:8; +#else + uint16_t vector:8; + uint16_t delivery_mode:3; + uint16_t __resved:3; + uint16_t level:1; + uint16_t trigger_mode:1; +#endif + uint16_t __resved1; + } QEMU_PACKED; + uint32_t msi_data; + }; +}; + /** * x86_iommu_get_default - get default IOMMU device * @return: pointer to default IOMMU device @@ -110,4 +170,10 @@ void x86_iommu_iec_register_notifier(X86IOMMUState *iommu, void x86_iommu_iec_notify_all(X86IOMMUState *iommu, bool global, uint32_t index, uint32_t mask); +/** + * x86_iommu_irq_to_msi_message - Populate one MSIMessage from X86IOMMUIrq + * @X86IOMMUIrq: The IRQ information + * @out: Output MSI message + */ +void x86_iommu_irq_to_msi_message(X86IOMMUIrq *irq, MSIMessage *out); #endif diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h index b7da8f555b..dfb75752cb 100644 --- a/include/hw/pci/pci_bus.h +++ b/include/hw/pci/pci_bus.h @@ -1,6 +1,8 @@ #ifndef QEMU_PCI_BUS_H #define QEMU_PCI_BUS_H +#include "hw/pci/pci.h" + /* * PCI Bus datastructures. * diff --git a/include/qemu/option.h b/include/qemu/option.h index 3dfb4493cc..844587cab3 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -132,7 +132,7 @@ typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp); int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, Error **errp); void qemu_opts_print(QemuOpts *opts, const char *sep); -void qemu_opts_print_help(QemuOptsList *list); +void qemu_opts_print_help(QemuOptsList *list, bool print_caption); void qemu_opts_free(QemuOptsList *list); QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list); diff --git a/include/qemu/units.h b/include/qemu/units.h index 68a7758650..1c959d182e 100644 --- a/include/qemu/units.h +++ b/include/qemu/units.h @@ -17,6 +17,24 @@ #define PiB (INT64_C(1) << 50) #define EiB (INT64_C(1) << 60) +/* + * The following lookup table is intended to be used when a literal string of + * the number of bytes is required (for example if it needs to be stringified). + * It can also be used for generic shortcuts of power-of-two sizes. + * This table is generated using the AWK script below: + * + * BEGIN { + * suffix="KMGTPE"; + * for(i=10; i<64; i++) { + * val=2**i; + * s=substr(suffix, int(i/10), 1); + * n=2**(i%10); + * pad=21-int(log(n)/log(10)); + * printf("#define S_%d%siB %*d\n", n, s, pad, val); + * } + * } + */ + #define S_1KiB 1024 #define S_2KiB 2048 #define S_4KiB 4096 diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 830d873f24..c96bcdee14 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -166,9 +166,9 @@ BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read, int error); void blk_error_action(BlockBackend *blk, BlockErrorAction action, bool is_read, int error); -int blk_is_read_only(BlockBackend *blk); -int blk_is_sg(BlockBackend *blk); -int blk_enable_write_cache(BlockBackend *blk); +bool blk_is_read_only(BlockBackend *blk); +bool blk_is_sg(BlockBackend *blk); +bool blk_enable_write_cache(BlockBackend *blk); void blk_set_enable_write_cache(BlockBackend *blk, bool wce); void blk_invalidate_cache(BlockBackend *blk, Error **errp); bool blk_is_inserted(BlockBackend *blk); diff --git a/qapi/block-core.json b/qapi/block-core.json index 0fc1590c1b..d4fe710836 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3656,6 +3656,12 @@ # either generally or in certain configurations. In this case, # the default value does not work and the option must be # specified explicitly. +# @auto-read-only: if true and @read-only is false, QEMU may automatically +# decide not to open the image read-write as requested, but +# fall back to read-only instead (and switch between the modes +# later), e.g. depending on whether the image file is writable +# or whether a writing user is attached to the node +# (default: false, since 3.1) # @detect-zeroes: detect and optimize zero writes (Since 2.1) # (default: off) # @force-share: force share all permission on added nodes. @@ -3671,6 +3677,7 @@ '*discard': 'BlockdevDiscardOptions', '*cache': 'BlockdevCacheOptions', '*read-only': 'bool', + '*auto-read-only': 'bool', '*force-share': 'bool', '*detect-zeroes': 'BlockdevDetectZeroesOptions' }, 'discriminator': 'driver', diff --git a/qdev-monitor.c b/qdev-monitor.c index 802c18a74e..07147c63bf 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -285,10 +285,19 @@ int qdev_device_help(QemuOpts *opts) goto error; } + if (prop_list) { + out_printf("%s options:\n", driver); + } else { + out_printf("There are no options for %s.\n", driver); + } for (prop = prop_list; prop; prop = prop->next) { - out_printf("%s.%s=%s", driver, prop->value->name, prop->value->type); + int len; + out_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len); if (prop->value->has_description) { - out_printf(" (%s)\n", prop->value->description); + if (len < 24) { + out_printf("%*s", 24 - len, ""); + } + out_printf(" - %s\n", prop->value->description); } else { out_printf("\n"); } diff --git a/qemu-img.c b/qemu-img.c index b12f4cd19b..4c96db7ba4 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -269,7 +269,7 @@ static int print_block_option_help(const char *filename, const char *fmt) } printf("Supported options:\n"); - qemu_opts_print_help(create_opts); + qemu_opts_print_help(create_opts, false); qemu_opts_free(create_opts); return 0; } @@ -3773,7 +3773,7 @@ static int print_amend_option_help(const char *format) assert(drv->create_opts); printf("Creation options for '%s':\n", format); - qemu_opts_print_help(drv->create_opts); + qemu_opts_print_help(drv->create_opts, false); printf("\nNote that not all of these options may be amendable.\n"); return 0; } diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index db0b3ee5ef..5363482213 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -907,7 +907,7 @@ static int readv_f(BlockBackend *blk, int argc, char **argv) memset(cmp_buf, pattern, qiov.size); if (memcmp(buf, cmp_buf, qiov.size)) { printf("Pattern verification failed at offset %" - PRId64 ", %zd bytes\n", offset, qiov.size); + PRId64 ", %zu bytes\n", offset, qiov.size); ret = -EINVAL; } g_free(cmp_buf); @@ -1294,7 +1294,7 @@ static void aio_read_done(void *opaque, int ret) memset(cmp_buf, ctx->pattern, ctx->qiov.size); if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) { printf("Pattern verification failed at offset %" - PRId64 ", %zd bytes\n", ctx->offset, ctx->qiov.size); + PRId64 ", %zu bytes\n", ctx->offset, ctx->qiov.size); } g_free(cmp_buf); } diff --git a/target/arm/helper.c b/target/arm/helper.c index 0ea95b0815..96301930cc 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2319,7 +2319,7 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, * * (Note that HCR.DC makes HCR.VM behave as if it is 1.) * - * ATS1Hx always uses the 64bit format (not supported yet). + * ATS1Hx always uses the 64bit format. */ format64 = arm_s1_regime_using_lpae_format(env, mmu_idx); @@ -2347,10 +2347,12 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, par64 |= 1; /* F */ par64 |= (fsr & 0x3f) << 1; /* FS */ - /* Note that S2WLK and FSTAGE are always zero, because we don't - * implement virtualization and therefore there can't be a stage 2 - * fault. - */ + if (fi.stage2) { + par64 |= (1 << 9); /* S */ + } + if (fi.s1ptw) { + par64 |= (1 << 8); /* PTW */ + } } } else { /* fsr is a DFSR/IFSR value for the short descriptor @@ -2442,7 +2444,7 @@ static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri, MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; uint64_t par64; - par64 = do_ats_write(env, value, access_type, ARMMMUIdx_S2NS); + par64 = do_ats_write(env, value, access_type, ARMMMUIdx_S1E2); A32_BANKED_CURRENT_REG_SET(env, par, par64); } diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 88195ab949..fd36425f1a 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -9483,12 +9483,10 @@ static void handle_vec_simd_shli(DisasContext *s, bool is_q, bool insert, int immhb = immh << 3 | immb; int shift = immhb - (8 << size); - if (extract32(immh, 3, 1) && !is_q) { - unallocated_encoding(s); - return; - } + /* Range of size is limited by decode: immh is a non-zero 4 bit field */ + assert(size >= 0 && size <= 3); - if (size > 3 && !is_q) { + if (extract32(immh, 3, 1) && !is_q) { unallocated_encoding(s); return; } diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 02e77ec811..d661d9be62 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -42,7 +42,7 @@ typedef struct { } test_data; static char disk[] = "tests/acpi-test-disk-XXXXXX"; -static const char *data_dir = "tests/acpi-test-data"; +static const char *data_dir = "tests/data/acpi"; #ifdef CONFIG_IASL static const char *iasl = stringify(CONFIG_IASL); #else @@ -708,6 +708,21 @@ static void test_acpi_q35_tcg_bridge(void) free_test_data(&data); } +static void test_acpi_q35_tcg_mmio64(void) +{ + test_data data = { + .machine = MACHINE_Q35, + .variant = ".mmio64", + .required_struct_types = base_required_struct_types, + .required_struct_types_len = ARRAY_SIZE(base_required_struct_types) + }; + + test_acpi_one("-m 128M,slots=1,maxmem=2G " + "-device pci-testdev,membar=2G", + &data); + free_test_data(&data); +} + static void test_acpi_piix4_tcg_cphp(void) { test_data data; @@ -875,6 +890,7 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge); qtest_add_func("acpi/q35", test_acpi_q35_tcg); qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge); + qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64); qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi); qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi); qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp); diff --git a/tests/acpi-test-data/pc/APIC b/tests/data/acpi/pc/APIC Binary files differindex 84509e0ae4..84509e0ae4 100644 --- a/tests/acpi-test-data/pc/APIC +++ b/tests/data/acpi/pc/APIC diff --git a/tests/acpi-test-data/pc/APIC.cphp b/tests/data/acpi/pc/APIC.cphp Binary files differindex 1bf8a0a63b..1bf8a0a63b 100644 --- a/tests/acpi-test-data/pc/APIC.cphp +++ b/tests/data/acpi/pc/APIC.cphp diff --git a/tests/acpi-test-data/pc/APIC.dimmpxm b/tests/data/acpi/pc/APIC.dimmpxm Binary files differindex 427bb08248..427bb08248 100644 --- a/tests/acpi-test-data/pc/APIC.dimmpxm +++ b/tests/data/acpi/pc/APIC.dimmpxm diff --git a/tests/acpi-test-data/pc/DSDT b/tests/data/acpi/pc/DSDT Binary files differindex c6adfe32d5..c6adfe32d5 100644 --- a/tests/acpi-test-data/pc/DSDT +++ b/tests/data/acpi/pc/DSDT diff --git a/tests/acpi-test-data/pc/DSDT.bridge b/tests/data/acpi/pc/DSDT.bridge Binary files differindex f01fa3ad4e..f01fa3ad4e 100644 --- a/tests/acpi-test-data/pc/DSDT.bridge +++ b/tests/data/acpi/pc/DSDT.bridge diff --git a/tests/acpi-test-data/pc/DSDT.cphp b/tests/data/acpi/pc/DSDT.cphp Binary files differindex 3295d81c7f..3295d81c7f 100644 --- a/tests/acpi-test-data/pc/DSDT.cphp +++ b/tests/data/acpi/pc/DSDT.cphp diff --git a/tests/acpi-test-data/pc/DSDT.dimmpxm b/tests/data/acpi/pc/DSDT.dimmpxm Binary files differindex f6ec911b11..f6ec911b11 100644 --- a/tests/acpi-test-data/pc/DSDT.dimmpxm +++ b/tests/data/acpi/pc/DSDT.dimmpxm diff --git a/tests/acpi-test-data/pc/DSDT.ipmikcs b/tests/data/acpi/pc/DSDT.ipmikcs Binary files differindex 2633a8cecf..2633a8cecf 100644 --- a/tests/acpi-test-data/pc/DSDT.ipmikcs +++ b/tests/data/acpi/pc/DSDT.ipmikcs diff --git a/tests/acpi-test-data/pc/DSDT.memhp b/tests/data/acpi/pc/DSDT.memhp Binary files differindex e31ef50296..e31ef50296 100644 --- a/tests/acpi-test-data/pc/DSDT.memhp +++ b/tests/data/acpi/pc/DSDT.memhp diff --git a/tests/acpi-test-data/pc/DSDT.numamem b/tests/data/acpi/pc/DSDT.numamem Binary files differindex 71a975b3e2..71a975b3e2 100644 --- a/tests/acpi-test-data/pc/DSDT.numamem +++ b/tests/data/acpi/pc/DSDT.numamem diff --git a/tests/acpi-test-data/pc/FACP b/tests/data/acpi/pc/FACP Binary files differindex 261ebdc5d1..261ebdc5d1 100644 --- a/tests/acpi-test-data/pc/FACP +++ b/tests/data/acpi/pc/FACP diff --git a/tests/acpi-test-data/pc/FACS b/tests/data/acpi/pc/FACS Binary files differindex fc67ecc407..fc67ecc407 100644 --- a/tests/acpi-test-data/pc/FACS +++ b/tests/data/acpi/pc/FACS diff --git a/tests/acpi-test-data/pc/HPET b/tests/data/acpi/pc/HPET Binary files differindex df689b8f99..df689b8f99 100644 --- a/tests/acpi-test-data/pc/HPET +++ b/tests/data/acpi/pc/HPET diff --git a/tests/acpi-test-data/pc/NFIT.dimmpxm b/tests/data/acpi/pc/NFIT.dimmpxm Binary files differindex 598d331b75..598d331b75 100644 --- a/tests/acpi-test-data/pc/NFIT.dimmpxm +++ b/tests/data/acpi/pc/NFIT.dimmpxm diff --git a/tests/acpi-test-data/pc/SLIT.cphp b/tests/data/acpi/pc/SLIT.cphp Binary files differindex 74ec3b4b46..74ec3b4b46 100644 --- a/tests/acpi-test-data/pc/SLIT.cphp +++ b/tests/data/acpi/pc/SLIT.cphp diff --git a/tests/acpi-test-data/pc/SLIT.memhp b/tests/data/acpi/pc/SLIT.memhp Binary files differindex 74ec3b4b46..74ec3b4b46 100644 --- a/tests/acpi-test-data/pc/SLIT.memhp +++ b/tests/data/acpi/pc/SLIT.memhp diff --git a/tests/acpi-test-data/pc/SRAT.cphp b/tests/data/acpi/pc/SRAT.cphp Binary files differindex ff2137642f..ff2137642f 100644 --- a/tests/acpi-test-data/pc/SRAT.cphp +++ b/tests/data/acpi/pc/SRAT.cphp diff --git a/tests/acpi-test-data/pc/SRAT.dimmpxm b/tests/data/acpi/pc/SRAT.dimmpxm Binary files differindex f5c0267ea2..f5c0267ea2 100644 --- a/tests/acpi-test-data/pc/SRAT.dimmpxm +++ b/tests/data/acpi/pc/SRAT.dimmpxm diff --git a/tests/acpi-test-data/pc/SRAT.memhp b/tests/data/acpi/pc/SRAT.memhp Binary files differindex e508b4ae3c..e508b4ae3c 100644 --- a/tests/acpi-test-data/pc/SRAT.memhp +++ b/tests/data/acpi/pc/SRAT.memhp diff --git a/tests/acpi-test-data/pc/SRAT.numamem b/tests/data/acpi/pc/SRAT.numamem Binary files differindex 119922f497..119922f497 100644 --- a/tests/acpi-test-data/pc/SRAT.numamem +++ b/tests/data/acpi/pc/SRAT.numamem diff --git a/tests/acpi-test-data/pc/SSDT.dimmpxm b/tests/data/acpi/pc/SSDT.dimmpxm Binary files differindex 8ba0e67cb7..8ba0e67cb7 100644 --- a/tests/acpi-test-data/pc/SSDT.dimmpxm +++ b/tests/data/acpi/pc/SSDT.dimmpxm diff --git a/tests/acpi-test-data/q35/APIC b/tests/data/acpi/q35/APIC Binary files differindex 84509e0ae4..84509e0ae4 100644 --- a/tests/acpi-test-data/q35/APIC +++ b/tests/data/acpi/q35/APIC diff --git a/tests/acpi-test-data/q35/APIC.cphp b/tests/data/acpi/q35/APIC.cphp Binary files differindex 1bf8a0a63b..1bf8a0a63b 100644 --- a/tests/acpi-test-data/q35/APIC.cphp +++ b/tests/data/acpi/q35/APIC.cphp diff --git a/tests/acpi-test-data/q35/APIC.dimmpxm b/tests/data/acpi/q35/APIC.dimmpxm Binary files differindex 427bb08248..427bb08248 100644 --- a/tests/acpi-test-data/q35/APIC.dimmpxm +++ b/tests/data/acpi/q35/APIC.dimmpxm diff --git a/tests/acpi-test-data/q35/DSDT b/tests/data/acpi/q35/DSDT Binary files differindex 7576ffcd05..7576ffcd05 100644 --- a/tests/acpi-test-data/q35/DSDT +++ b/tests/data/acpi/q35/DSDT diff --git a/tests/acpi-test-data/q35/DSDT.bridge b/tests/data/acpi/q35/DSDT.bridge Binary files differindex c623cc5d72..c623cc5d72 100644 --- a/tests/acpi-test-data/q35/DSDT.bridge +++ b/tests/data/acpi/q35/DSDT.bridge diff --git a/tests/acpi-test-data/q35/DSDT.cphp b/tests/data/acpi/q35/DSDT.cphp Binary files differindex 7ac526e466..7ac526e466 100644 --- a/tests/acpi-test-data/q35/DSDT.cphp +++ b/tests/data/acpi/q35/DSDT.cphp diff --git a/tests/acpi-test-data/q35/DSDT.dimmpxm b/tests/data/acpi/q35/DSDT.dimmpxm Binary files differindex 3837792dec..3837792dec 100644 --- a/tests/acpi-test-data/q35/DSDT.dimmpxm +++ b/tests/data/acpi/q35/DSDT.dimmpxm diff --git a/tests/acpi-test-data/q35/DSDT.ipmibt b/tests/data/acpi/q35/DSDT.ipmibt Binary files differindex c7f431f058..c7f431f058 100644 --- a/tests/acpi-test-data/q35/DSDT.ipmibt +++ b/tests/data/acpi/q35/DSDT.ipmibt diff --git a/tests/acpi-test-data/q35/DSDT.memhp b/tests/data/acpi/q35/DSDT.memhp Binary files differindex 8fba0baf79..8fba0baf79 100644 --- a/tests/acpi-test-data/q35/DSDT.memhp +++ b/tests/data/acpi/q35/DSDT.memhp diff --git a/tests/data/acpi/q35/DSDT.mmio64 b/tests/data/acpi/q35/DSDT.mmio64 Binary files differnew file mode 100644 index 0000000000..a058ff2ee3 --- /dev/null +++ b/tests/data/acpi/q35/DSDT.mmio64 diff --git a/tests/acpi-test-data/q35/DSDT.numamem b/tests/data/acpi/q35/DSDT.numamem Binary files differindex 6c0d4f2bcb..6c0d4f2bcb 100644 --- a/tests/acpi-test-data/q35/DSDT.numamem +++ b/tests/data/acpi/q35/DSDT.numamem diff --git a/tests/acpi-test-data/q35/FACP b/tests/data/acpi/q35/FACP Binary files differindex 72c9d97902..72c9d97902 100644 --- a/tests/acpi-test-data/q35/FACP +++ b/tests/data/acpi/q35/FACP diff --git a/tests/acpi-test-data/q35/FACS b/tests/data/acpi/q35/FACS Binary files differindex fc67ecc407..fc67ecc407 100644 --- a/tests/acpi-test-data/q35/FACS +++ b/tests/data/acpi/q35/FACS diff --git a/tests/acpi-test-data/q35/HPET b/tests/data/acpi/q35/HPET Binary files differindex df689b8f99..df689b8f99 100644 --- a/tests/acpi-test-data/q35/HPET +++ b/tests/data/acpi/q35/HPET diff --git a/tests/acpi-test-data/q35/MCFG b/tests/data/acpi/q35/MCFG Binary files differindex 79ceb27a03..79ceb27a03 100644 --- a/tests/acpi-test-data/q35/MCFG +++ b/tests/data/acpi/q35/MCFG diff --git a/tests/acpi-test-data/q35/NFIT.dimmpxm b/tests/data/acpi/q35/NFIT.dimmpxm Binary files differindex 598d331b75..598d331b75 100644 --- a/tests/acpi-test-data/q35/NFIT.dimmpxm +++ b/tests/data/acpi/q35/NFIT.dimmpxm diff --git a/tests/acpi-test-data/q35/SLIT.cphp b/tests/data/acpi/q35/SLIT.cphp Binary files differindex 74ec3b4b46..74ec3b4b46 100644 --- a/tests/acpi-test-data/q35/SLIT.cphp +++ b/tests/data/acpi/q35/SLIT.cphp diff --git a/tests/acpi-test-data/q35/SLIT.memhp b/tests/data/acpi/q35/SLIT.memhp Binary files differindex 74ec3b4b46..74ec3b4b46 100644 --- a/tests/acpi-test-data/q35/SLIT.memhp +++ b/tests/data/acpi/q35/SLIT.memhp diff --git a/tests/acpi-test-data/q35/SRAT.cphp b/tests/data/acpi/q35/SRAT.cphp Binary files differindex ff2137642f..ff2137642f 100644 --- a/tests/acpi-test-data/q35/SRAT.cphp +++ b/tests/data/acpi/q35/SRAT.cphp diff --git a/tests/acpi-test-data/q35/SRAT.dimmpxm b/tests/data/acpi/q35/SRAT.dimmpxm Binary files differindex f5c0267ea2..f5c0267ea2 100644 --- a/tests/acpi-test-data/q35/SRAT.dimmpxm +++ b/tests/data/acpi/q35/SRAT.dimmpxm diff --git a/tests/acpi-test-data/q35/SRAT.memhp b/tests/data/acpi/q35/SRAT.memhp Binary files differindex e508b4ae3c..e508b4ae3c 100644 --- a/tests/acpi-test-data/q35/SRAT.memhp +++ b/tests/data/acpi/q35/SRAT.memhp diff --git a/tests/data/acpi/q35/SRAT.mmio64 b/tests/data/acpi/q35/SRAT.mmio64 Binary files differnew file mode 100644 index 0000000000..ac35f3dac4 --- /dev/null +++ b/tests/data/acpi/q35/SRAT.mmio64 diff --git a/tests/acpi-test-data/q35/SRAT.numamem b/tests/data/acpi/q35/SRAT.numamem Binary files differindex 119922f497..119922f497 100644 --- a/tests/acpi-test-data/q35/SRAT.numamem +++ b/tests/data/acpi/q35/SRAT.numamem diff --git a/tests/acpi-test-data/q35/SSDT.dimmpxm b/tests/data/acpi/q35/SSDT.dimmpxm Binary files differindex 2d5b721bcf..2d5b721bcf 100644 --- a/tests/acpi-test-data/q35/SSDT.dimmpxm +++ b/tests/data/acpi/q35/SSDT.dimmpxm diff --git a/tests/acpi-test-data/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh index 11bf743914..bf9ba242ad 100755 --- a/tests/acpi-test-data/rebuild-expected-aml.sh +++ b/tests/data/acpi/rebuild-expected-aml.sh @@ -32,5 +32,3 @@ fi TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test echo "The files were rebuilt and can be added to git." -echo "However, if new files were created, please copy them manually" \ - "to tests/acpi-test-data/pc/ or tests/acpi-test-data/q35/ ." diff --git a/tests/hex-loader-check-data/test.hex b/tests/data/hex-loader/test.hex index 008a90bd4d..008a90bd4d 100644 --- a/tests/hex-loader-check-data/test.hex +++ b/tests/data/hex-loader/test.hex diff --git a/tests/hexloader-test.c b/tests/hexloader-test.c index b653d44ba1..834ed52c22 100644 --- a/tests/hexloader-test.c +++ b/tests/hexloader-test.c @@ -23,7 +23,7 @@ static void hex_loader_test(void) const unsigned int base_addr = 0x00010000; QTestState *s = qtest_initf( - "-M vexpress-a9 -nographic -device loader,file=tests/hex-loader-check-data/test.hex"); + "-M vexpress-a9 -nographic -device loader,file=tests/data/hex-loader/test.hex"); for (i = 0; i < 256; ++i) { uint8_t val = qtest_readb(s, base_addr + i); diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 index da3fb0984b..9f1dece271 100755 --- a/tests/qemu-iotests/081 +++ b/tests/qemu-iotests/081 @@ -168,6 +168,122 @@ echo "== checking that quorum is broken ==" $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io +echo +echo "== checking the blkverify mode with broken content ==" + +quorum="driver=raw,file.driver=quorum,file.vote-threshold=2,file.blkverify=on" +quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw" +quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" +quorum="$quorum,file.children.0.driver=raw" +quorum="$quorum,file.children.1.driver=raw" + +$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io + +echo +echo "== writing the same data to both files ==" + +$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io +$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io + +echo +echo "== checking the blkverify mode with valid content ==" + +$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io + +echo +echo "== checking the blkverify mode with invalid settings ==" + +quorum="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw" +quorum="$quorum,file.children.2.driver=raw" + +$QEMU_IO -c "open -o $quorum" | _filter_qemu_io + +echo +echo "== dynamically adding a child to a quorum ==" + +for verify in false true; do + run_qemu <<EOF + { "execute": "qmp_capabilities" } + { "execute": "blockdev-add", + "arguments": { + "driver": "quorum", + "node-name": "drive0-quorum", + "vote-threshold": 2, + "blkverify": ${verify}, + "children": [ + { + "driver": "$IMGFMT", + "file": { + "driver": "file", + "filename": "$TEST_DIR/1.raw" + } + }, + { + "driver": "$IMGFMT", + "file": { + "driver": "file", + "filename": "$TEST_DIR/2.raw" + } + } + ] + } + } + { "execute": "blockdev-add", + "arguments": { + "node-name": "drive3", + "driver": "$IMGFMT", + "file": { + "driver": "file", + "filename": "$TEST_DIR/2.raw" + } + } + } + { "execute": "x-blockdev-change", + "arguments": { "parent": "drive0-quorum", + "node": "drive3" } } + { "execute": "quit" } +EOF +done + +echo +echo "== dynamically removing a child from a quorum ==" + +for verify in false true; do + for vote_threshold in 1 2; do + run_qemu <<EOF + { "execute": "qmp_capabilities" } + { "execute": "blockdev-add", + "arguments": { + "driver": "quorum", + "node-name": "drive0-quorum", + "vote-threshold": ${vote_threshold}, + "blkverify": ${verify}, + "children": [ + { + "driver": "$IMGFMT", + "file": { + "driver": "file", + "filename": "$TEST_DIR/1.raw" + } + }, + { + "driver": "$IMGFMT", + "file": { + "driver": "file", + "filename": "$TEST_DIR/2.raw" + } + } + ] + } + } + { "execute": "x-blockdev-change", + "arguments": { "parent": "drive0-quorum", + "child": "children.1" } } + { "execute": "quit" } +EOF + done +done + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out index 2533c31c78..8d81736336 100644 --- a/tests/qemu-iotests/081.out +++ b/tests/qemu-iotests/081.out @@ -55,4 +55,74 @@ wrote 10485760/10485760 bytes at offset 0 == checking that quorum is broken == read failed: Input/output error + +== checking the blkverify mode with broken content == +quorum: offset=0 bytes=10485760 contents mismatch at offset 0 + +== writing the same data to both files == +wrote 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== checking the blkverify mode with valid content == +read 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== checking the blkverify mode with invalid settings == +can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2 + +== dynamically adding a child to a quorum == +Testing: +QMP_VERSION +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} + +Testing: +QMP_VERSION +{"return": {}} +{"return": {}} +{"return": {}} +{"error": {"class": "GenericError", "desc": "Cannot add a child to a quorum in blkverify mode"}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} + + +== dynamically removing a child from a quorum == +Testing: +QMP_VERSION +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} + +Testing: +QMP_VERSION +{"return": {}} +{"return": {}} +{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} + +Testing: +QMP_VERSION +{"return": {}} +{"error": {"class": "GenericError", "desc": "blkverify=on can only be set if there are exactly two files and vote-threshold is 2"}} +{"error": {"class": "GenericError", "desc": "Cannot find device=drive0-quorum nor node_name=drive0-quorum"}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} + +Testing: +QMP_VERSION +{"return": {}} +{"return": {}} +{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} + *** done diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out index 19e9fb13ff..0ce18c075b 100644 --- a/tests/qemu-iotests/082.out +++ b/tests/qemu-iotests/082.out @@ -44,171 +44,171 @@ cluster_size: 8192 Testing: create -f qcow2 -o help TEST_DIR/t.qcow2 128M Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: create -f qcow2 -o ? TEST_DIR/t.qcow2 128M Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: create -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 128M Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: create -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 128M Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: create -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 128M Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: create -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 128M Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: create -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 128M Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: create -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 128M Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,help cluster_size=65536 lazy_refcounts=off refcount_bits=16 @@ -227,27 +227,27 @@ qemu-img: Invalid option list: ,, Testing: create -f qcow2 -o help Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: create -o help Supported options: -size Virtual disk size + size=<size> - Virtual disk size Testing: create -f bochs -o help qemu-img: Format driver 'bochs' does not support image creation @@ -300,171 +300,171 @@ cluster_size: 8192 Testing: convert -O qcow2 -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: convert -O qcow2 -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: convert -O qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: convert -O qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: convert -O qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: convert -O qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: convert -O qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: convert -O qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits -nocow Turn off copy-on-write (valid only on btrfs) + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base qemu-img: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,help': No such file or directory @@ -483,27 +483,27 @@ qemu-img: Invalid option list: ,, Testing: convert -O qcow2 -o help Supported options: -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Testing: convert -o help Supported options: -size Virtual disk size + size=<size> - Virtual disk size Testing: convert -O bochs -o help qemu-img: Format driver 'bochs' does not support image creation @@ -564,177 +564,177 @@ cluster_size: 65536 Testing: amend -f qcow2 -o help TEST_DIR/t.qcow2 Creation options for 'qcow2': -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Note that not all of these options may be amendable. Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2 Creation options for 'qcow2': -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Note that not all of these options may be amendable. Testing: amend -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 Creation options for 'qcow2': -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Note that not all of these options may be amendable. Testing: amend -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 Creation options for 'qcow2': -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Note that not all of these options may be amendable. Testing: amend -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 Creation options for 'qcow2': -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Note that not all of these options may be amendable. Testing: amend -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 Creation options for 'qcow2': -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Note that not all of these options may be amendable. Testing: amend -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 Creation options for 'qcow2': -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Note that not all of these options may be amendable. Testing: amend -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 Creation options for 'qcow2': -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Note that not all of these options may be amendable. @@ -757,29 +757,29 @@ qemu-img: Invalid option list: ,, Testing: amend -f qcow2 -o help Creation options for 'qcow2': -size Virtual disk size -compat Compatibility level (0.10 or 1.1) -backing_file File name of a base image -backing_fmt Image format of the base image -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) -encrypt.format Encrypt the image, format choices: 'aes', 'luks' -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase -encrypt.cipher-alg Name of encryption cipher algorithm -encrypt.cipher-mode Name of encryption cipher mode -encrypt.ivgen-alg Name of IV generator algorithm -encrypt.ivgen-hash-alg Name of IV generator hash algorithm -encrypt.hash-alg Name of encryption hash algorithm -encrypt.iter-time Time to spend in PBKDF in milliseconds -cluster_size qcow2 cluster size -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) -lazy_refcounts Postpone refcount updates -refcount_bits Width of a reference count entry in bits + backing_file=<str> - File name of a base image + backing_fmt=<str> - Image format of the base image + cluster_size=<size> - qcow2 cluster size + compat=<str> - Compatibility level (0.10 or 1.1) + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm + encrypt.cipher-mode=<str> - Name of encryption cipher mode + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' + encrypt.hash-alg=<str> - Name of encryption hash algorithm + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds + encrypt.ivgen-alg=<str> - Name of IV generator algorithm + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) + lazy_refcounts=<bool (on/off)> - Postpone refcount updates + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) + refcount_bits=<num> - Width of a reference count entry in bits + size=<size> - Virtual disk size Note that not all of these options may be amendable. Testing: convert -o help Supported options: -size Virtual disk size + size=<size> - Virtual disk size Testing: amend -f bochs -o help qemu-img: Format driver 'bochs' does not support option amendment diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083 index 3c1adbf0fb..9f92317b0a 100755 --- a/tests/qemu-iotests/083 +++ b/tests/qemu-iotests/083 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.rc . ./common.filter -_supported_fmt generic +_supported_fmt raw _supported_proto nbd _supported_os Linux diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232 new file mode 100755 index 0000000000..bc2972d124 --- /dev/null +++ b/tests/qemu-iotests/232 @@ -0,0 +1,147 @@ +#!/bin/bash +# +# Test for auto-read-only +# +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# creator +owner=kwolf@redhat.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img + rm -f $TEST_IMG.snap +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt generic +_supported_proto file +_supported_os Linux + +function do_run_qemu() +{ + echo Testing: "$@" + ( + if ! test -t 0; then + while read cmd; do + echo $cmd + done + fi + echo quit + ) | $QEMU -nographic -monitor stdio -nodefaults "$@" + echo +} + +function run_qemu() +{ + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp | + _filter_generated_node_ids | _filter_imgfmt +} + +function run_qemu_info_block() +{ + echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG" +} + +size=128M + +_make_test_img $size + +echo +echo "=== -drive with read-write image: read-only/auto-read-only combinations ===" +echo + +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on +echo +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off +echo +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none + +echo +echo "=== -drive with read-only image: read-only/auto-read-only combinations ===" +echo + +chmod a-w $TEST_IMG + +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on +echo +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off +echo +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none + +echo +echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ===" +echo + +chmod a+w $TEST_IMG + +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on +echo +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off +echo +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0 + +echo +echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ===" +echo + +chmod a-w $TEST_IMG + +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on +echo +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off +echo +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0 + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out new file mode 100644 index 0000000000..dcb683afa3 --- /dev/null +++ b/tests/qemu-iotests/232.out @@ -0,0 +1,59 @@ +QA output created by 232 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 + +=== -drive with read-write image: read-only/auto-read-only combinations === + +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) + +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) + +=== -drive with read-only image: read-only/auto-read-only combinations === + +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +=== -blockdev with read-write image: read-only/auto-read-only combinations === + +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) + +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) + +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) + +=== -blockdev with read-only image: read-only/auto-read-only combinations === + +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) + +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +node0: TEST_DIR/t.IMGFMT (file, read-only) +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied + +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +node0: TEST_DIR/t.IMGFMT (file, read-only) +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 31f6e77dcb..ebe4fe78bc 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -227,3 +227,4 @@ 227 auto quick 229 auto quick 231 auto quick +232 auto quick diff --git a/util/oslib-posix.c b/util/oslib-posix.c index fbd0dc8c57..c1bee2a581 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -596,6 +596,7 @@ pid_t qemu_fork(Error **errp) void *qemu_alloc_stack(size_t *sz) { void *ptr, *guardpage; + int flags; #ifdef CONFIG_DEBUG_STACK_USAGE void *ptr2; #endif @@ -610,8 +611,18 @@ void *qemu_alloc_stack(size_t *sz) /* allocate one extra page for the guard page */ *sz += pagesz; - ptr = mmap(NULL, *sz, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + flags = MAP_PRIVATE | MAP_ANONYMOUS; +#if defined(MAP_STACK) && defined(__OpenBSD__) + /* Only enable MAP_STACK on OpenBSD. Other OS's such as + * Linux/FreeBSD/NetBSD have a flag with the same name + * but have differing functionality. OpenBSD will SEGV + * if it spots execution with a stack pointer pointing + * at memory that was not allocated with MAP_STACK. + */ + flags |= MAP_STACK; +#endif + + ptr = mmap(NULL, *sz, PROT_READ | PROT_WRITE, flags, -1, 0); if (ptr == MAP_FAILED) { perror("failed to allocate memory for stack"); abort(); diff --git a/util/qemu-option.c b/util/qemu-option.c index 9a5f263294..de42e2a406 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -224,7 +224,14 @@ static const char *opt_type_to_string(enum QemuOptType type) g_assert_not_reached(); } -void qemu_opts_print_help(QemuOptsList *list) +/** + * Print the list of options available in the given list. If + * @print_caption is true, a caption (including the list name, if it + * exists) is printed. The options itself will be indented, so + * @print_caption should only be set to false if the caller prints its + * own custom caption (so that the indentation makes sense). + */ +void qemu_opts_print_help(QemuOptsList *list, bool print_caption) { QemuOptDesc *desc; int i; @@ -234,12 +241,12 @@ void qemu_opts_print_help(QemuOptsList *list) desc = list->desc; while (desc && desc->name) { GString *str = g_string_new(NULL); - if (list->name) { - g_string_append_printf(str, "%s.", list->name); - } - g_string_append_printf(str, "%s=%s", desc->name, + g_string_append_printf(str, " %s=<%s>", desc->name, opt_type_to_string(desc->type)); if (desc->help) { + if (str->len < 24) { + g_string_append_printf(str, "%*s", 24 - (int)str->len, ""); + } g_string_append_printf(str, " - %s", desc->help); } g_ptr_array_add(array, g_string_free(str, false)); @@ -247,6 +254,19 @@ void qemu_opts_print_help(QemuOptsList *list) } g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); + if (print_caption && array->len > 0) { + if (list->name) { + printf("%s options:\n", list->name); + } else { + printf("Options:\n"); + } + } else if (array->len == 0) { + if (list->name) { + printf("There are no options for %s.\n", list->name); + } else { + printf("No options available.\n"); + } + } for (i = 0; i < array->len; i++) { printf("%s\n", (char *)array->pdata[i]); } @@ -930,7 +950,7 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, opts = opts_parse(list, params, permit_abbrev, false, &invalidp, &err); if (err) { if (invalidp && has_help_option(params)) { - qemu_opts_print_help(list); + qemu_opts_print_help(list, true); error_free(err); } else { error_report_err(err); @@ -537,7 +537,7 @@ static QemuOptsList qemu_fw_cfg_opts = { }, { .name = "file", .type = QEMU_OPT_STRING, - .help = "Sets the name of the file from which\n" + .help = "Sets the name of the file from which " "the fw_cfg blob will be loaded", }, { .name = "string", @@ -2743,7 +2743,7 @@ static bool object_create_initial(const char *type, QemuOpts *opts) list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false); for (l = list; l != NULL; l = l->next) { ObjectClass *oc = OBJECT_CLASS(l->data); - printf("%s\n", object_class_get_name(oc)); + printf(" %s\n", object_class_get_name(oc)); } g_slist_free(list); exit(0); @@ -2765,14 +2765,21 @@ static bool object_create_initial(const char *type, QemuOpts *opts) } str = g_string_new(NULL); - g_string_append_printf(str, "%s.%s=%s", type, - prop->name, prop->type); + g_string_append_printf(str, " %s=<%s>", prop->name, prop->type); if (prop->description) { + if (str->len < 24) { + g_string_append_printf(str, "%*s", 24 - (int)str->len, ""); + } g_string_append_printf(str, " - %s", prop->description); } g_ptr_array_add(array, g_string_free(str, false)); } g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); + if (array->len > 0) { + printf("%s options:\n", type); + } else { + printf("There are no options for %s.\n", type); + } for (i = 0; i < array->len; i++) { printf("%s\n", (char *)array->pdata[i]); } |