diff options
| -rw-r--r-- | hw/scsi/scsi-disk.c | 19 | ||||
| -rw-r--r-- | qga/commands-posix.c | 10 | ||||
| -rw-r--r-- | qga/qapi-schema.json | 8 | ||||
| -rw-r--r-- | softmmu/memory.c | 5 | ||||
| -rw-r--r-- | stubs/ram-block.c | 6 | ||||
| -rw-r--r-- | target/i386/helper.c | 10 | ||||
| -rw-r--r-- | target/i386/kvm.c | 10 | ||||
| -rw-r--r-- | util/vfio-helpers.c | 14 |
8 files changed, 63 insertions, 19 deletions
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e859534eaf..90841ad791 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -461,6 +461,25 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed) } error = scsi_sense_buf_to_errno(r->req.sense, sizeof(r->req.sense)); break; +#ifdef CONFIG_LINUX + /* These errno mapping are specific to Linux. For more information: + * - scsi_decide_disposition in drivers/scsi/scsi_error.c + * - scsi_result_to_blk_status in drivers/scsi/scsi_lib.c + * - blk_errors[] in block/blk-core.c + */ + case EBADE: + /* DID_NEXUS_FAILURE -> BLK_STS_NEXUS. */ + scsi_req_complete(&r->req, RESERVATION_CONFLICT); + break; + case ENODATA: + /* DID_MEDIUM_ERROR -> BLK_STS_MEDIUM. */ + scsi_check_condition(r, SENSE_CODE(READ_ERROR)); + break; + case EREMOTEIO: + /* DID_TARGET_FAILURE -> BLK_STS_TARGET. */ + scsi_req_complete(&r->req, HARDWARE_ERROR); + break; +#endif case ENOMEDIUM: scsi_check_condition(r, SENSE_CODE(NO_MEDIUM)); break; diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 12c1ba5ef7..c089e38120 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1285,6 +1285,7 @@ static void get_disk_deps(const char *disk_dir, GuestDiskInfo *disk) g_debug("failed to list entries in %s", deps_dir); return; } + disk->has_dependencies = true; while ((dep = g_dir_read_name(dp_deps)) != NULL) { g_autofree char *dep_dir = NULL; strList *dep_item = NULL; @@ -1297,8 +1298,8 @@ static void get_disk_deps(const char *disk_dir, GuestDiskInfo *disk) g_debug(" adding dependent device: %s", dev_name); dep_item = g_new0(strList, 1); dep_item->value = dev_name; - dep_item->next = disk->dependents; - disk->dependents = dep_item; + dep_item->next = disk->dependencies; + disk->dependencies = dep_item; } } g_dir_close(dp_deps); @@ -1351,8 +1352,9 @@ static GuestDiskInfoList *get_disk_partitions( partition->name = dev_name; partition->partition = true; /* Add parent disk as dependent for easier tracking of hierarchy */ - partition->dependents = g_new0(strList, 1); - partition->dependents->value = g_strdup(disk_dev); + partition->dependencies = g_new0(strList, 1); + partition->dependencies->value = g_strdup(disk_dev); + partition->has_dependencies = true; item = g_new0(GuestDiskInfoList, 1); item->value = partition; diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 6ca85f995f..3b3d1d0bd9 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -870,9 +870,9 @@ # # @name: device node (Linux) or device UNC (Windows) # @partition: whether this is a partition or disk -# @dependents: list of dependent devices; e.g. for LVs of the LVM this will -# hold the list of PVs, for LUKS encrypted volume this will -# contain the disk where the volume is placed. (Linux) +# @dependencies: list of device dependencies; e.g. for LVs of the LVM this will +# hold the list of PVs, for LUKS encrypted volume this will +# contain the disk where the volume is placed. (Linux) # @address: disk address information (only for non-virtual devices) # @alias: optional alias assigned to the disk, on Linux this is a name assigned # by device mapper @@ -880,7 +880,7 @@ # Since 5.2 ## { 'struct': 'GuestDiskInfo', - 'data': {'name': 'str', 'partition': 'bool', 'dependents': ['str'], + 'data': {'name': 'str', 'partition': 'bool', '*dependencies': ['str'], '*address': 'GuestDiskAddress', '*alias': 'str'} } ## diff --git a/softmmu/memory.c b/softmmu/memory.c index 71951fe4dc..aa393f1bb0 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1806,7 +1806,10 @@ bool memory_region_is_ram_device(MemoryRegion *mr) uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr) { uint8_t mask = mr->dirty_log_mask; - if (global_dirty_log && (mr->ram_block || memory_region_is_iommu(mr))) { + RAMBlock *rb = mr->ram_block; + + if (global_dirty_log && ((rb && qemu_ram_is_migratable(rb)) || + memory_region_is_iommu(mr))) { mask |= (1 << DIRTY_MEMORY_MIGRATION); } return mask; diff --git a/stubs/ram-block.c b/stubs/ram-block.c index 73c0a3ee08..108197683b 100644 --- a/stubs/ram-block.c +++ b/stubs/ram-block.c @@ -1,6 +1,7 @@ #include "qemu/osdep.h" #include "exec/ramlist.h" #include "exec/cpu-common.h" +#include "exec/memory.h" void *qemu_ram_get_host_addr(RAMBlock *rb) { @@ -29,3 +30,8 @@ int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque) { return 0; } + +int ram_block_discard_disable(bool state) +{ + return 0; +} diff --git a/target/i386/helper.c b/target/i386/helper.c index 516ce0cad8..034f46bcc2 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -908,16 +908,14 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data) return; } - if (recursive) { - need_reset = true; - msg = g_strdup_printf("CPU %d: Previous MCE still in progress, " - "raising triple fault", cs->cpu_index); - } - if (!(cenv->cr[4] & CR4_MCE_MASK)) { need_reset = true; msg = g_strdup_printf("CPU %d: MCE capability is not enabled, " "raising triple fault", cs->cpu_index); + } else if (recursive) { + need_reset = true; + msg = g_strdup_printf("CPU %d: Previous MCE still in progress, " + "raising triple fault", cs->cpu_index); } if (need_reset) { diff --git a/target/i386/kvm.c b/target/i386/kvm.c index cf46259534..a2934dda02 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1820,12 +1820,14 @@ int kvm_arch_init_vcpu(CPUState *cs) env->nested_state = g_malloc0(max_nested_state_len); env->nested_state->size = max_nested_state_len; - env->nested_state->format = KVM_STATE_NESTED_FORMAT_VMX; if (cpu_has_vmx(env)) { - vmx_hdr = &env->nested_state->hdr.vmx; - vmx_hdr->vmxon_pa = -1ull; - vmx_hdr->vmcs12_pa = -1ull; + env->nested_state->format = KVM_STATE_NESTED_FORMAT_VMX; + vmx_hdr = &env->nested_state->hdr.vmx; + vmx_hdr->vmxon_pa = -1ull; + vmx_hdr->vmcs12_pa = -1ull; + } else { + env->nested_state->format = KVM_STATE_NESTED_FORMAT_SVM; } } } diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index c469beb061..2bec48e163 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -16,6 +16,7 @@ #include "qapi/error.h" #include "exec/ramlist.h" #include "exec/cpu-common.h" +#include "exec/memory.h" #include "trace.h" #include "qemu/error-report.h" #include "standard-headers/linux/pci_regs.h" @@ -494,8 +495,20 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp) int r; QEMUVFIOState *s = g_new0(QEMUVFIOState, 1); + /* + * VFIO may pin all memory inside mappings, resulting it in pinning + * all memory inside RAM blocks unconditionally. + */ + r = ram_block_discard_disable(true); + if (r) { + error_setg_errno(errp, -r, "Cannot set discarding of RAM broken"); + g_free(s); + return NULL; + } + r = qemu_vfio_init_pci(s, device, errp); if (r) { + ram_block_discard_disable(false); g_free(s); return NULL; } @@ -837,4 +850,5 @@ void qemu_vfio_close(QEMUVFIOState *s) close(s->device); close(s->group); close(s->container); + ram_block_discard_disable(false); } |