Merge pull request #4630 from computezrmle/increase_vbox_vram

Configure more vram to avoid VMs get stuck during boot
This commit is contained in:
Vitalii Koshura 2022-02-22 09:58:30 +01:00 committed by GitHub
commit 7e3d1ea0c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 0 deletions

View File

@ -251,6 +251,18 @@ namespace vboxmanage {
retval = vbm_popen(command, output, "modifychipset"); retval = vbm_popen(command, output, "modifychipset");
if (retval) return retval; if (retval) return retval;
// Tweak the VM's Graphics Controller Options
//
vboxlog_msg("Setting Graphics Controller Options for VM.");
sprintf(buf, "%d", (int)vram_size_mb);
command = "modifyvm \"" + vm_name + "\" ";
command += "--vram " + string(buf) + " ";
command += "--graphicscontroller " + vm_graphics_controller_type + " ";
retval = vbm_popen(command, output, "modifygraphicscontroller");
if (retval) return retval;
// Tweak the VM's Boot Options // Tweak the VM's Boot Options
// //
vboxlog_msg("Setting Boot Options for VM."); vboxlog_msg("Setting Boot Options for VM.");

View File

@ -134,6 +134,8 @@ void VBOX_JOB::clear() {
// Initialize default values // Initialize default values
vm_disk_controller_type = "ide"; vm_disk_controller_type = "ide";
vm_disk_controller_model = "PIIX4"; vm_disk_controller_model = "PIIX4";
vm_graphics_controller_type = "VBoxVGA";
vram_size_mb = VBOX_VRAM_MIN;
} }
int VBOX_JOB::parse() { int VBOX_JOB::parse() {
@ -163,6 +165,12 @@ int VBOX_JOB::parse() {
else if (xp.parse_string("vm_disk_controller_type", vm_disk_controller_type)) continue; else if (xp.parse_string("vm_disk_controller_type", vm_disk_controller_type)) continue;
else if (xp.parse_string("vm_disk_controller_model", vm_disk_controller_model)) continue; else if (xp.parse_string("vm_disk_controller_model", vm_disk_controller_model)) continue;
else if (xp.parse_string("os_name", os_name)) continue; else if (xp.parse_string("os_name", os_name)) continue;
else if (xp.parse_double("vram_size_mb", vram_size_mb)) {
// keep it within the valid range
if (vram_size_mb < VBOX_VRAM_MIN) vram_size_mb = VBOX_VRAM_MIN;
else if (vram_size_mb > VBOX_VRAM_MAX) vram_size_mb = VBOX_VRAM_MAX;
continue;
}
else if (xp.parse_double("memory_size_mb", memory_size_mb)) continue; else if (xp.parse_double("memory_size_mb", memory_size_mb)) continue;
else if (xp.parse_double("job_duration", job_duration)) continue; else if (xp.parse_double("job_duration", job_duration)) continue;
else if (xp.parse_double("minimum_checkpoint_interval", minimum_checkpoint_interval)) continue; else if (xp.parse_double("minimum_checkpoint_interval", minimum_checkpoint_interval)) continue;

View File

@ -22,6 +22,20 @@
#define JOB_FILENAME "vbox_job.xml" #define JOB_FILENAME "vbox_job.xml"
#ifndef VBOX_VRAM_MIN
// Default value suggested by VirtualBox v6.1.30
// when a VM is created manually using a Linux 64-bit template.
// VirtualBox does not complain if lower values are used (9-16 MB)
// but certain VMs occasionally hang when they boot (Rosetta).
// They don't hang if vram is at least 16 MB.
#define VBOX_VRAM_MIN 16.0
#endif
#ifndef VBOX_VRAM_MAX
// highest value currently accepted by VirtualBox v6.1.30
#define VBOX_VRAM_MAX 128.0
#endif
// Represents the state of a intermediate upload // Represents the state of a intermediate upload
class VBOX_INTERMEDIATE_UPLOAD { class VBOX_INTERMEDIATE_UPLOAD {
public: public:
@ -68,6 +82,14 @@ public:
std::string vm_disk_controller_model; std::string vm_disk_controller_model;
// the disk controller model to emulate // the disk controller model to emulate
std::string vm_graphics_controller_type;
// the graphics controller type to emulate
double vram_size_mb;
// size of the video memory allocation for the VM, in megabytes
// should be between VBOX_VRAM_MIN and VBOX_VRAM_MAX MB
// default: VBOX_VRAM_MIN MB
double memory_size_mb; double memory_size_mb;
// size of the memory allocation for the VM, in megabytes // size of the memory allocation for the VM, in megabytes