Skip to contentSkip to conversation

virtio-mem: improve error message when unplug of device fails due to plugged memory

PATCH In review David Hildenbrand 2 participants 2 messages Apr 16, 2024 – Apr 26, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-mem: improve error message when unplug of device fails due to plugged memory

The error message is actually expressive, considering QEMU only. But when called from Libvirt, talking about "size" can be confusing, because in Libvirt "size" translates to the memory backend size in QEMU (maximum size) and "current" translates to the QEMU "size" property.

Let's simply avoid talking about the "size" property and spell out that some device memory is still plugged.

Cc Liang Cong <[email protected]>
Cc Mario Casquero <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
---
 hw/virtio/virtio-mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/virtio-mem.c +2 -2
index ffd119ebac..ef64bf1b4a 100644
@@ -1832,8 +1832,8 @@ static void virtio_mem_unplug_request_check(VirtIOMEM *vmem, Error **errp)
     }
 
     if (vmem->size) {
-        error_setg(errp, "virtio-mem device cannot get unplugged while"
-                   " '" VIRTIO_MEM_SIZE_PROP "' != '0'");
+        error_setg(errp, "virtio-mem device cannot get unplugged while some"
+                   " of its memory is still plugged");
         return;
     }
     if (vmem->requested_size) {
Signature · 1 line
2.44.0
Tested-by on v1 1/1
#1 lore raw

This patch has been successfully tested. Boot up a VM with a virtio-mem device, hotplug some memory increasing the requested-size, finally try to unplug the device and see the new message:
(qemu) device_del vmem0
Error: virtio-mem device cannot get unplugged while some of its memory is still plugged

Quoted 35 lines · David Hildenbrand

The error message is actually expressive, considering QEMU only. But when called from Libvirt, talking about "size" can be confusing, because in Libvirt "size" translates to the memory backend size in QEMU (maximum size) and "current" translates to the QEMU "size" property.

Let's simply avoid talking about the "size" property and spell out that some device memory is still plugged.

Cc Liang Cong <[email protected]>
Cc Mario Casquero <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
---
 hw/virtio/virtio-mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/virtio-mem.c +2 -3
index ffd119ebac..ef64bf1b4a 100644
@@ -1832,8 +1832,8 @@ static void virtio_mem_unplug_request_check(VirtIOMEM *vmem, Error **errp)
     }
 
     if (vmem->size) {
-        error_setg(errp, "virtio-mem device cannot get unplugged while"
-                   " '" VIRTIO_MEM_SIZE_PROP "' != '0'");
+        error_setg(errp, "virtio-mem device cannot get unplugged while some"
+                   " of its memory is still plugged");
         return;
     }
     if (vmem->requested_size) {
--

2.44.0