On 2024-12-26 11:57, Daniel P. Smith wrote:
Add a container for the "cooked" command line for a domain. This provides for
the backing memory to be directly associated with the domain being constructed.
This is done in anticipation that the domain construction path may need to be
invoked multiple times, thus ensuring each instance had a distinct memory
allocation.
Signed-off-by: Daniel P. Smith <dpsm...@apertussolutions.com>
@@ -1018,39 +1037,52 @@ static struct domain *__init create_dom0(struct
boot_info *bi)
panic("Error creating d%uv0\n", bd->domid);
/* Grab the DOM0 command line. */
- if ( bd->kernel->cmdline_pa || bi->kextra )
+ if ( (bd->kernel->cmdline_pa &&
+ ((char *)__va(bd->kernel->cmdline_pa))[0]) ||
+ bi->kextra )
{
- if ( bd->kernel->cmdline_pa )
- safe_strcpy(cmdline,
- cmdline_cook(__va(bd->kernel->cmdline_pa),
bi->loader));
+ size_t cmdline_size = domain_cmdline_size(bi, bd);
+
+ if ( cmdline_size )
+ {
+ if ( !(cmdline = xzalloc_array(char, cmdline_size)) )
+ panic("Error allocating cmdline buffer for %pd\n", d);
I guess I wasn't clear last time. Instead of two levels of indent, I
was thinking at the top level:
/* Grab the DOM0 command line. */
cmdline_size = domain_cmdline_size(bi, bd);
if ( cmdline_size )
{
domain_cmdline_size() checks all the pointers, so this removes
duplication and indent.
The rest looks good.
Regards,
Jason