@@ -1321,6 +1321,14 @@ FWCfgState *pc_memory_init(MachineState *machine,
for (i = 0; i < nb_option_roms; i++) {
rom_add_option(option_rom[i].name, option_rom[i].bootindex);
}
+
+ if (enable_mlock) {
+ if (os_mlock() < 0) {
+ error_report("qemu: locking memory failed\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+
guest_info->fw_cfg = fw_cfg;
return fw_cfg;
}
@@ -136,6 +136,7 @@ extern uint8_t qemu_extra_params_fw[2];
extern QEMUClockType rtc_clock;
extern const char *mem_path;
extern int mem_prealloc;
+extern bool enable_mlock;
#define MAX_NODES 128
@@ -134,6 +134,7 @@ const char* keyboard_layout = NULL;
ram_addr_t ram_size;
const char *mem_path = NULL;
int mem_prealloc = 0; /* force preallocation of physical target memory */
+bool enable_mlock = false;
int nb_nics;
NICInfo nd_table[MAX_NICS];
int autostart;
@@ -1419,16 +1420,7 @@ static void smp_parse(QemuOpts *opts)
static void configure_realtime(QemuOpts *opts)
{
- bool enable_mlock;
-
enable_mlock = qemu_opt_get_bool(opts, "mlock", true);
-
- if (enable_mlock) {
- if (os_mlock() < 0) {
- fprintf(stderr, "qemu: locking memory failed\n");
- exit(1);
- }
- }
}