From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: Michal Privoznik <mprivozn@redhat.com>,
Juan Quintela <quintela@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
David Hildenbrand <david@redhat.com>
Subject: [PATCH v2 1/2] virtio-mem: Fail if a memory backend with "prealloc=on" is specified
Date: Tue, 25 Jan 2022 14:57:33 +0100 [thread overview]
Message-ID: <20220125135734.134928-2-david@redhat.com> (raw)
In-Reply-To: <20220125135734.134928-1-david@redhat.com>
"prealloc=on" for the memory backend does not work as expected, as
virtio-mem will simply discard all preallocated memory immediately again.
In the best case, it's an expensive NOP. In the worst case, it's an
unexpected allocation error.
Instead, "prealloc=on" should be specified for the virtio-mem device only,
such that virtio-mem will try preallocating memory before plugging
memory dynamically to the guest. Fail if such a memory backend is
provided.
Tested-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
hw/virtio/virtio-mem.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index f55dcf61f2..b7bad6ef96 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -773,6 +773,12 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
error_setg(errp, "'%s' property specifies an unsupported memdev",
VIRTIO_MEM_MEMDEV_PROP);
return;
+ } else if (vmem->memdev->prealloc) {
+ error_setg(errp, "'%s' property specifies a memdev with preallocation"
+ " enabled: %s. Instead, specify 'prealloc=on' for the"
+ " virtio-mem device. ", VIRTIO_MEM_MEMDEV_PROP,
+ object_get_canonical_path_component(OBJECT(vmem->memdev)));
+ return;
}
if ((nb_numa_nodes && vmem->node >= nb_numa_nodes) ||
--
2.34.1
next prev parent reply other threads:[~2022-01-25 14:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-25 13:57 [PATCH v2 0/2] virtio-mem: Handle preallocation with migration David Hildenbrand
2022-01-25 13:57 ` David Hildenbrand [this message]
2022-01-25 13:57 ` [PATCH v2 2/2] " David Hildenbrand
2022-01-31 10:40 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220125135734.134928-2-david@redhat.com \
--to=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=mprivozn@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).