qemu_conf: Add param memory_backing_dir

Add new parameter memory_backing_dir where files will be stored when memoryBacking
source is selected as file.

Value is stored inside char* memoryBackingDir
This commit is contained in:
Jaroslav Safka 2017-02-02 13:27:31 +00:00 committed by Michal Privoznik
parent 7c0c5f6d4b
commit 48d9e6cdcc
5 changed files with 19 additions and 0 deletions

View File

@ -109,6 +109,8 @@ module Libvirtd_qemu =
let gluster_debug_level_entry = int_entry "gluster_debug_level" let gluster_debug_level_entry = int_entry "gluster_debug_level"
let memory_entry = str_entry "memory_backing_dir"
(* Each entry in the config is one of the following ... *) (* Each entry in the config is one of the following ... *)
let entry = default_tls_entry let entry = default_tls_entry
| vnc_entry | vnc_entry
@ -125,6 +127,7 @@ module Libvirtd_qemu =
| log_entry | log_entry
| nvram_entry | nvram_entry
| gluster_debug_level_entry | gluster_debug_level_entry
| memory_entry
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ] let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
let empty = [ label "#empty" . eol ] let empty = [ label "#empty" . eol ]

View File

@ -673,3 +673,7 @@
# devices entries throughout the domain lifetime. This namespace is turned on # devices entries throughout the domain lifetime. This namespace is turned on
# by default. # by default.
#namespaces = [ "mount" ] #namespaces = [ "mount" ]
# This directory is used for memoryBacking source if configured as file.
# NOTE: big files will be stored here
#memory_backing_dir = "/var/lib/libvirt/qemu/ram"

View File

@ -186,6 +186,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
goto error; goto error;
if (virAsprintf(&cfg->nvramDir, "%s/nvram", cfg->libDir) < 0) if (virAsprintf(&cfg->nvramDir, "%s/nvram", cfg->libDir) < 0)
goto error; goto error;
if (virAsprintf(&cfg->memoryBackingDir, "%s/ram", cfg->libDir) < 0)
goto error;
} else { } else {
char *rundir; char *rundir;
char *cachedir; char *cachedir;
@ -231,6 +233,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
if (virAsprintf(&cfg->nvramDir, if (virAsprintf(&cfg->nvramDir,
"%s/qemu/nvram", cfg->configBaseDir) < 0) "%s/qemu/nvram", cfg->configBaseDir) < 0)
goto error; goto error;
if (virAsprintf(&cfg->memoryBackingDir, "%s/qemu/ram", cfg->configBaseDir) < 0)
goto error;
} }
if (virAsprintf(&cfg->configDir, "%s/qemu", cfg->configBaseDir) < 0) if (virAsprintf(&cfg->configDir, "%s/qemu", cfg->configBaseDir) < 0)
@ -408,6 +412,8 @@ static void virQEMUDriverConfigDispose(void *obj)
VIR_FREE(cfg->lockManagerName); VIR_FREE(cfg->lockManagerName);
virFirmwareFreeList(cfg->firmwares, cfg->nfirmwares); virFirmwareFreeList(cfg->firmwares, cfg->nfirmwares);
VIR_FREE(cfg->memoryBackingDir);
} }
@ -835,6 +841,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
} }
} }
if (virConfGetValueString(conf, "memory_backing_dir", &cfg->memoryBackingDir) < 0)
goto cleanup;
ret = 0; ret = 0;
cleanup: cleanup:

View File

@ -195,6 +195,8 @@ struct _virQEMUDriverConfig {
virFirmwarePtr *firmwares; virFirmwarePtr *firmwares;
size_t nfirmwares; size_t nfirmwares;
unsigned int glusterDebugLevel; unsigned int glusterDebugLevel;
char *memoryBackingDir;
}; };
/* Main driver state */ /* Main driver state */

View File

@ -94,3 +94,4 @@ module Test_libvirtd_qemu =
{ "namespaces" { "namespaces"
{ "1" = "mount" } { "1" = "mount" }
} }
{ "memory_backing_dir" = "/var/lib/libvirt/qemu/ram" }