[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 4/4] virtio-mem: Add support for suspend+wake-up with plugged
|
From: |
Juraj Marcin |
|
Subject: |
[PATCH v2 4/4] virtio-mem: Add support for suspend+wake-up with plugged memory |
|
Date: |
Tue, 13 Aug 2024 17:39:20 +0200 |
Before, the virtio-mem device would unplug all the memory with any reset
of the device, including during the wake-up of the guest from a
suspended state. Due to this, the virtio-mem driver in the Linux kernel
disallowed suspend-to-ram requests in the guest when the
VIRTIO_MEM_F_PERSISTENT_SUSPEND feature is not exposed by QEMU.
This patch adds the code to skip the reset on wake-up and exposes
theVIRTIO_MEM_F_PERSISTENT_SUSPEND feature to the guest kernel driver
when suspending is possible in QEMU (currently only x86).
Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
hw/virtio/virtio-mem.c | 10 ++++++++++
hw/virtio/virtio-qmp.c | 3 +++
2 files changed, 13 insertions(+)
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index aeee381eb2..ce228da369 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -883,6 +883,9 @@ static uint64_t virtio_mem_get_features(VirtIODevice *vdev,
uint64_t features,
if (vmem->unplugged_inaccessible == ON_OFF_AUTO_ON) {
virtio_add_feature(&features, VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE);
}
+ if (qemu_wakeup_suspend_enabled()) {
+ virtio_add_feature(&features, VIRTIO_MEM_F_PERSISTENT_SUSPEND);
+ }
return features;
}
@@ -1841,6 +1844,13 @@ static void virtio_mem_system_reset_hold(Object *obj,
ResetType type)
{
VirtIOMEM *vmem = VIRTIO_MEM(obj);
+ /*
+ * When waking up from standby/suspend-to-ram, do not unplug any memory.
+ */
+ if (type == RESET_TYPE_WAKEUP) {
+ return;
+ }
+
/*
* During usual resets, we will unplug all memory and shrink the usable
* region size. This is, however, not possible in all scenarios. Then,
diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c
index 1dd96ed20f..cccc6fe761 100644
--- a/hw/virtio/virtio-qmp.c
+++ b/hw/virtio/virtio-qmp.c
@@ -450,6 +450,9 @@ static const qmp_virtio_feature_map_t
virtio_mem_feature_map[] = {
FEATURE_ENTRY(VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, \
"VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE: Unplugged memory cannot be "
"accessed"),
+ FEATURE_ENTRY(VIRTIO_MEM_F_PERSISTENT_SUSPEND, \
+ "VIRTIO_MEM_F_PERSISTENT_SUSPND: Plugged memory will remain "
+ "plugged when suspending+resuming"),
{ -1, "" }
};
#endif
--
2.46.0
- [PATCH v2 1/4] reset: Use ResetType for qemu_devices_reset() and MachineClass::reset(), (continued)
- [PATCH v2 1/4] reset: Use ResetType for qemu_devices_reset() and MachineClass::reset(), Juraj Marcin, 2024/08/13
- [PATCH v2 2/4] reset: Add RESET_TYPE_WAKEUP, Juraj Marcin, 2024/08/13
- Re: [PATCH v2 2/4] reset: Add RESET_TYPE_WAKEUP, Peter Maydell, 2024/08/13
- Re: [PATCH v2 2/4] reset: Add RESET_TYPE_WAKEUP, Juraj Marcin, 2024/08/14
- Re: [PATCH v2 2/4] reset: Add RESET_TYPE_WAKEUP, David Hildenbrand, 2024/08/20
- Re: [PATCH v2 2/4] reset: Add RESET_TYPE_WAKEUP, Peter Maydell, 2024/08/20
- Re: [PATCH v2 2/4] reset: Add RESET_TYPE_WAKEUP, David Hildenbrand, 2024/08/20
- Re: [PATCH v2 2/4] reset: Add RESET_TYPE_WAKEUP, Juraj Marcin, 2024/08/28
- Re: [PATCH v2 2/4] reset: Add RESET_TYPE_WAKEUP, David Hildenbrand, 2024/08/29
- Re: [PATCH v2 2/4] reset: Add RESET_TYPE_WAKEUP, Peter Maydell, 2024/08/29
[PATCH v2 4/4] virtio-mem: Add support for suspend+wake-up with plugged memory,
Juraj Marcin <=
[PATCH v2 3/4] virtio-mem: Use new Resettable framework instead of LegacyReset, Juraj Marcin, 2024/08/13