hostmem: Don't report pmem attribute if unsupported
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>
This commit is contained in:
parent
1a14d4e16a
commit
def835f0da
@ -124,6 +124,7 @@ static void file_memory_backend_set_align(Object *o, Visitor *v,
|
|||||||
fb->align = val;
|
fb->align = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIBPMEM
|
||||||
static bool file_memory_backend_get_pmem(Object *o, Error **errp)
|
static bool file_memory_backend_get_pmem(Object *o, Error **errp)
|
||||||
{
|
{
|
||||||
return MEMORY_BACKEND_FILE(o)->is_pmem;
|
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;
|
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;
|
fb->is_pmem = value;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_LIBPMEM */
|
||||||
|
|
||||||
static bool file_memory_backend_get_readonly(Object *obj, Error **errp)
|
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_get_align,
|
||||||
file_memory_backend_set_align,
|
file_memory_backend_set_align,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
#ifdef CONFIG_LIBPMEM
|
||||||
object_class_property_add_bool(oc, "pmem",
|
object_class_property_add_bool(oc, "pmem",
|
||||||
file_memory_backend_get_pmem, file_memory_backend_set_pmem);
|
file_memory_backend_get_pmem, file_memory_backend_set_pmem);
|
||||||
|
#endif
|
||||||
object_class_property_add_bool(oc, "readonly",
|
object_class_property_add_bool(oc, "readonly",
|
||||||
file_memory_backend_get_readonly,
|
file_memory_backend_get_readonly,
|
||||||
file_memory_backend_set_readonly);
|
file_memory_backend_set_readonly);
|
||||||
|
Loading…
Reference in New Issue
Block a user