From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
Michal Privoznik <mprivozn@redhat.com>,
Daniel Henrique Barboza <danielhb413@gmail.com>,
Richard Henderson <richard.henderson@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Igor Mammedov <imammedo@redhat.com>
Subject: [PULL 3/3] hostmem: Don't report pmem attribute if unsupported
Date: Thu, 18 Feb 2021 18:24:15 -0500 [thread overview]
Message-ID: <20210218232415.1001078-4-ehabkost@redhat.com> (raw)
In-Reply-To: <20210218232415.1001078-1-ehabkost@redhat.com>
From: Michal Privoznik <mprivozn@redhat.com>
When management applications (like Libvirt) want to check whether
memory-backend-file.pmem is supported they can list object
properties using 'qom-list-properties'. However, 'pmem' is
declared always (and thus reported always) and only at runtime
QEMU errors out if it was built without libpmem (and thus can not
guarantee write persistence). This is suboptimal since we have
ability to declare attributes at compile time.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1915216
Message-Id: <dfcc5dc7e2efc0283bc38e3036da2c0323621cdb.1611647111.git.mprivozn@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
backends/hostmem-file.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 733408e076f..b683da9daf8 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -124,6 +124,7 @@ static void file_memory_backend_set_align(Object *o, Visitor *v,
fb->align = val;
}
+#ifdef CONFIG_LIBPMEM
static bool file_memory_backend_get_pmem(Object *o, Error **errp)
{
return MEMORY_BACKEND_FILE(o)->is_pmem;
@@ -140,17 +141,9 @@ static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp)
return;
}
-#ifndef CONFIG_LIBPMEM
- if (value) {
- error_setg(errp, "Lack of libpmem support while setting the 'pmem=on'"
- " of %s. We can't ensure data persistence.",
- object_get_typename(o));
- return;
- }
-#endif
-
fb->is_pmem = value;
}
+#endif /* CONFIG_LIBPMEM */
static bool file_memory_backend_get_readonly(Object *obj, Error **errp)
{
@@ -203,8 +196,10 @@ file_backend_class_init(ObjectClass *oc, void *data)
file_memory_backend_get_align,
file_memory_backend_set_align,
NULL, NULL);
+#ifdef CONFIG_LIBPMEM
object_class_property_add_bool(oc, "pmem",
file_memory_backend_get_pmem, file_memory_backend_set_pmem);
+#endif
object_class_property_add_bool(oc, "readonly",
file_memory_backend_get_readonly,
file_memory_backend_set_readonly);
--
2.28.0
next prev parent reply other threads:[~2021-02-18 23:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-18 23:24 [PULL 0/3] Machine and x86 queue, 2021-02-18 Eduardo Habkost
2021-02-18 23:24 ` [PULL 1/3] i386: Add the support for AMD EPYC 3rd generation processors Eduardo Habkost
2021-02-18 23:24 ` [PULL 2/3] device-crash-test: Remove problematic language Eduardo Habkost
2021-02-18 23:24 ` Eduardo Habkost [this message]
2021-02-18 23:38 ` [PULL 0/3] Machine and x86 queue, 2021-02-18 Eduardo Habkost
2021-02-19 14:54 ` Peter Maydell
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=20210218232415.1001078-4-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=danielhb413@gmail.com \
--cc=imammedo@redhat.com \
--cc=mprivozn@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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).