diff options
-rw-r--r-- | hw/i386/pc.c | 5 | ||||
-rw-r--r-- | hw/virtio/vhost.c | 10 | ||||
-rw-r--r-- | hw/virtio/virtio.c | 24 | ||||
-rw-r--r-- | include/hw/i386/apic-msidef.h | 2 | ||||
-rw-r--r-- | include/hw/virtio/virtio.h | 1 | ||||
-rw-r--r-- | scripts/dump-guest-memory.py | 12 |
6 files changed, 42 insertions, 12 deletions
diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c3afe5b..186545d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1842,6 +1842,11 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, X86CPU *cpu = X86_CPU(dev); PCMachineState *pcms = PC_MACHINE(hotplug_dev); + if (!pcms->acpi_dev) { + error_setg(&local_err, "CPU hot unplug not supported without ACPI"); + goto out; + } + pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); assert(idx != -1); if (idx == 0) { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index ddc42f0..e4290ce 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -493,21 +493,21 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev, j = 0; r = vhost_verify_ring_part_mapping(dev, vq->desc, vq->desc_phys, vq->desc_size, start_addr, size); - if (!r) { + if (r) { break; } j++; r = vhost_verify_ring_part_mapping(dev, vq->avail, vq->avail_phys, vq->avail_size, start_addr, size); - if (!r) { + if (r) { break; } j++; r = vhost_verify_ring_part_mapping(dev, vq->used, vq->used_phys, vq->used_size, start_addr, size); - if (!r) { + if (r) { break; } } @@ -1138,6 +1138,10 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, r = dev->vhost_ops->vhost_get_vring_base(dev, &state); if (r < 0) { VHOST_OPS_DEBUG("vhost VQ %d ring restore failed: %d", idx, r); + /* Connection to the backend is broken, so let's sync internal + * last avail idx to the device used idx. + */ + virtio_queue_restore_last_avail_idx(vdev, idx); } else { virtio_queue_set_last_avail_idx(vdev, idx, state.num); } diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ea532dc..ad564b0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -182,7 +182,7 @@ void virtio_queue_update_rings(VirtIODevice *vdev, int n) { VRing *vring = &vdev->vq[n].vring; - if (!vring->desc) { + if (!vring->num || !vring->desc || !vring->align) { /* not yet setup -> nothing to do */ return; } @@ -1414,6 +1414,9 @@ void virtio_config_modern_writel(VirtIODevice *vdev, void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr) { + if (!vdev->vq[n].vring.num) { + return; + } vdev->vq[n].vring.desc = addr; virtio_queue_update_rings(vdev, n); } @@ -1426,6 +1429,9 @@ hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n) void virtio_queue_set_rings(VirtIODevice *vdev, int n, hwaddr desc, hwaddr avail, hwaddr used) { + if (!vdev->vq[n].vring.num) { + return; + } vdev->vq[n].vring.desc = desc; vdev->vq[n].vring.avail = avail; vdev->vq[n].vring.used = used; @@ -1494,8 +1500,10 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) */ assert(k->has_variable_vring_alignment); - vdev->vq[n].vring.align = align; - virtio_queue_update_rings(vdev, n); + if (align) { + vdev->vq[n].vring.align = align; + virtio_queue_update_rings(vdev, n); + } } static bool virtio_queue_notify_aio_vq(VirtQueue *vq) @@ -2310,6 +2318,16 @@ void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx) vdev->vq[n].shadow_avail_idx = idx; } +void virtio_queue_restore_last_avail_idx(VirtIODevice *vdev, int n) +{ + rcu_read_lock(); + if (vdev->vq[n].vring.desc) { + vdev->vq[n].last_avail_idx = vring_used_idx(&vdev->vq[n]); + vdev->vq[n].shadow_avail_idx = vdev->vq[n].last_avail_idx; + } + rcu_read_unlock(); +} + void virtio_queue_update_used_idx(VirtIODevice *vdev, int n) { rcu_read_lock(); diff --git a/include/hw/i386/apic-msidef.h b/include/hw/i386/apic-msidef.h index 8b4d4cc..420b411 100644 --- a/include/hw/i386/apic-msidef.h +++ b/include/hw/i386/apic-msidef.h @@ -26,6 +26,6 @@ #define MSI_ADDR_DEST_ID_SHIFT 12 #define MSI_ADDR_DEST_IDX_SHIFT 4 -#define MSI_ADDR_DEST_ID_MASK 0x00ffff0 +#define MSI_ADDR_DEST_ID_MASK 0x000ff000 #endif /* HW_APIC_MSIDEF_H */ diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 5abada6..098bdaa 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -272,6 +272,7 @@ hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev, int n); hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n); uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n); void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx); +void virtio_queue_restore_last_avail_idx(VirtIODevice *vdev, int n); void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n); void virtio_queue_update_used_idx(VirtIODevice *vdev, int n); VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n); diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py index 69dd5ef..1af26c1 100644 --- a/scripts/dump-guest-memory.py +++ b/scripts/dump-guest-memory.py @@ -546,13 +546,15 @@ shape and this command should mostly work.""" return None def add_vmcoreinfo(self): - if not gdb.parse_and_eval("vmcoreinfo_find()") \ - or not gdb.parse_and_eval("vmcoreinfo_find()->has_vmcoreinfo"): + vmci = '(VMCoreInfoState *)' + \ + 'object_resolve_path_type("", "vmcoreinfo", 0)' + if not gdb.parse_and_eval("%s" % vmci) \ + or not gdb.parse_and_eval("(%s)->has_vmcoreinfo" % vmci): return - fmt = gdb.parse_and_eval("vmcoreinfo_find()->vmcoreinfo.guest_format") - addr = gdb.parse_and_eval("vmcoreinfo_find()->vmcoreinfo.paddr") - size = gdb.parse_and_eval("vmcoreinfo_find()->vmcoreinfo.size") + fmt = gdb.parse_and_eval("(%s)->vmcoreinfo.guest_format" % vmci) + addr = gdb.parse_and_eval("(%s)->vmcoreinfo.paddr" % vmci) + size = gdb.parse_and_eval("(%s)->vmcoreinfo.size" % vmci) fmt = le16_to_cpu(fmt) addr = le64_to_cpu(addr) |