HV: refine init_vm_bootargs_info()
changes:
1. The VM load order type condition is not needed, since the function
is called only when create SOS VM or pre-launched VM;
2. Fixed wrong parameter of fill_seed_arg() which introduced by commit
80262f0602
.
3. More comments on why multiboot string could override the pre-
configured VM bootargs and why append multiboot cmdline to SOS VM
bootargs;
Tracked-On: #5815
Signed-off-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
27b3ebfad4
commit
ef737c3089
|
@ -114,33 +114,32 @@ static char mod_cmdline[PRE_VM_NUM + SOS_VM_NUM][MAX_BOOTARGS_SIZE] = { '\0' };
|
||||||
static void init_vm_bootargs_info(struct acrn_vm *vm, const struct acrn_multiboot_info *mbi)
|
static void init_vm_bootargs_info(struct acrn_vm *vm, const struct acrn_multiboot_info *mbi)
|
||||||
{
|
{
|
||||||
struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
|
struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
|
||||||
char *bootargs = vm_config->os_config.bootargs;
|
|
||||||
|
|
||||||
if ((vm_config->load_order == PRE_LAUNCHED_VM) || (vm_config->load_order == SOS_VM)) {
|
vm->sw.bootargs_info.src_addr = vm_config->os_config.bootargs;
|
||||||
if (mod_cmdline[vm->vm_id][0] == '\0') {
|
/* If multiboot string of the kernel module exists, it would OVERRIDE the pre-configured build-in VM bootargs,
|
||||||
vm->sw.bootargs_info.src_addr = bootargs;
|
* which means we give user a chance to re-configure VM bootargs at bootloader runtime. e.g. GRUB menu
|
||||||
} else {
|
|
||||||
/* override build-in bootargs with multiboot module string which is configurable
|
|
||||||
* at bootloader boot time. e.g. GRUB menu
|
|
||||||
*/
|
*/
|
||||||
|
if (mod_cmdline[vm->vm_id][0] != '\0') {
|
||||||
vm->sw.bootargs_info.src_addr = &mod_cmdline[vm->vm_id][0];
|
vm->sw.bootargs_info.src_addr = &mod_cmdline[vm->vm_id][0];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (vm_config->load_order == SOS_VM) {
|
if (vm_config->load_order == SOS_VM) {
|
||||||
if (strncat_s((char *)vm->sw.bootargs_info.src_addr, MAX_BOOTARGS_SIZE, " ", 1U) == 0) {
|
if (strncat_s((char *)vm->sw.bootargs_info.src_addr, MAX_BOOTARGS_SIZE, " ", 1U) == 0) {
|
||||||
char seed_args[MAX_SEED_ARG_SIZE] = "";
|
char seed_args[MAX_SEED_ARG_SIZE] = "";
|
||||||
|
|
||||||
fill_seed_arg(seed_args, true);
|
fill_seed_arg(seed_args, MAX_SEED_ARG_SIZE);
|
||||||
/* Fill seed argument for SOS
|
/* Fill seed argument for SOS
|
||||||
* seed_args string ends with a white space and '\0', so no aditional delimiter is needed
|
* seed_args string ends with a white space and '\0', so no additional delimiter is needed
|
||||||
*/
|
*/
|
||||||
if (strncat_s((char *)vm->sw.bootargs_info.src_addr, MAX_BOOTARGS_SIZE,
|
if (strncat_s((char *)vm->sw.bootargs_info.src_addr, MAX_BOOTARGS_SIZE,
|
||||||
seed_args, (MAX_BOOTARGS_SIZE - 1U)) != 0) {
|
seed_args, (MAX_BOOTARGS_SIZE - 1U)) != 0) {
|
||||||
pr_err("failed to fill seed arg to SOS bootargs!");
|
pr_err("failed to fill seed arg to SOS bootargs!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there is cmdline from mbi->mi_cmdline, merge it with configured SOS bootargs. */
|
/* If there is cmdline from mbi->mi_cmdline, merge it with configured SOS bootargs.
|
||||||
|
* This is very helpful when one of configured bootargs need to be revised at GRUB runtime
|
||||||
|
* (e.g. "root="), since the later one would override the previous one if multiple bootargs exist.
|
||||||
|
*/
|
||||||
if (((mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE) != 0U) && (*(mbi->mi_cmdline) != '\0')) {
|
if (((mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE) != 0U) && (*(mbi->mi_cmdline) != '\0')) {
|
||||||
if (strncat_s((char *)vm->sw.bootargs_info.src_addr, MAX_BOOTARGS_SIZE,
|
if (strncat_s((char *)vm->sw.bootargs_info.src_addr, MAX_BOOTARGS_SIZE,
|
||||||
mbi->mi_cmdline, (MAX_BOOTARGS_SIZE - 1U)) != 0) {
|
mbi->mi_cmdline, (MAX_BOOTARGS_SIZE - 1U)) != 0) {
|
||||||
|
|
Loading…
Reference in New Issue