On Tue, Jan 08, 2019 at 09:28:07PM -0000, Michael van Elst wrote: > b...@bsd.de (Christoph Badura) writes: > > >With "raidctl -A softroot raid0" the XEN3_DOM0 kernel does not detect > >raid0 as root device. > > raidframe checks if the system was booted from one of the raid components > marked as softroot and only then forces the kernel to mount partition 'a' > of that raid as root. > > NetBSD/xen doesn't know where it was booted from, it assumes > that this is the first (in ROOT_FIRST order) registered disk device. > You can pass a bootdev on the Xen command line that will be used > to find a booted_device, if it isn't found the command line argument > is passed to MI code as a bootspec (not booted_device) instead. > > >It also doesn't detect raid0 as root device when > >the dom0 kernel is loaded with "bootdev=raid0". > > raidframe searches for a component as 'booted_device', so you need to make > Xen set 'booted_device' to a component. But raidframe has another magic > that it will not match a '/dev/dk*' component. Instead, it will use > the parent device of the wedge to match 'booted_device'. > > So, assuming 'raid0' has a component 'dk0' which is based on 'wd0', it > should work to specify 'wd0' as bootdev.
That does work. However, that is besides the point bootdev=raid0 is supposed to work but it doesn't. The reason for that is in the code that overrides rootspec with bootspec. rootspec gets initialized by config(8) like so: For "config <name> root on ?": const char *rootspec = NULL; dev_t rootdev = NODEV; /* wildcarded */ And for, e.g., "config <name> root on sd0e": const char *rootspec = "sd0e"; dev_t rootdev = makedev(4, 4); /* sd0e */ I.e. rootspec and rootdev need to be set in pairs. Apparently that bit was overlooked when the code to override rootspec was added in r1.216. The following works and is tested. Note that it is relative to r1.220 and the line numbers are offset because of local instrumentation. --- kern_subr.c.orig 2019-01-03 15:39:38.000000000 +0100 +++ kern_subr.c 2019-01-10 16:06:56.000000000 +0100 @@ -214,15 +223,30 @@ /* * Let bootcode augment "rootspec". */ - if (rootspec == NULL) + if (rootspec == NULL) { rootspec = bootspec; + if (rootspec != NULL) { + /* parsedisk writes to bootspec */ + dv = parsedisk(bootspec, strlen(bootspec), 0, &nrootdev); + if (dv != NULL) { + rootspec = bootspec; + rootdev = nrootdev; + } else { + printf("cannot parse bootspec \"%s\"\n", bootspec); + boothowto |= RB_ASKNAME; + } + } + } + + DPRINTF(("%s: rootspec %s, rootdev 0x%llu, boothowto 0x%x\n", __func__, + rootspec, (unsigned long long)rootdev, boothowto)); --chris