Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: annual HOWTO rampage, mini edition



At Sat, 06 Jan 2024 14:26:57 -0500, Greg Troxel <gdt%lexort.com@localhost> wrote:
Subject: Re: annual HOWTO rampage, mini edition
>
> As usual, I'm trimming things when I have nothing to say to them.
>
> "Greg A. Woods" <woods%planix.ca@localhost> writes:
>
> > BTW, the following sentence is not exactly right:
> >
> > 	Xen when using a vga console does not process console input.
>
> Are you saying that during xen boot but before reliquishing you can type
> at xen on the console and do things?
>
> Or that you can pass a xen config option to tell xen to keep the
> console?  If you do, can you +++ to get to xen, and does the rest go to
> xencons?

Five '+'s ("+++++") is the escape into DDB for any NetBSD XEN3_DOM*
kernel.

Input is switched from dom0 to Xen and back again with three presses of
the Xen "comswitch" character, which is by default <CTRL-A>.

I would never explicitly restrict Xen to "console=com1".  The default
will at worst spew Xen's console output on the VGA display, which could
be a good thing for debugging purposes.  Maybe it's bad for a kiosk
machine that for some reason uses Xen, but that's a special case, not a
basic thing for a setup HowTo.

So the "Selecting the console for Xen" still needs fixing:

	With GENERIC, the boot options are passed on to /netbsd, but
	there is currently no mechanism to pass these to NetBSD and Xen
	via the "multiboot" mechanism.  The normal defaults for Xen and
	the NetBSD XEN3_DOM0 kernel will normally just work, but in
	special cases it may be necessary to also specify them directly
	in /boot.cfg.

	By default, the hypervisor (Xen itself) will use both the VGA
	device and the first serial port (which it calls "com1") as the
	console, copying its output to both simultaneously.  The VGA
	console is relinquished by Xen just before the dom0 is started.

	By default NetBSD XEN3_DOM0 uses xencons(4) as its console, but
	for dom0 this is only suitable for serial consoles, thus if
	using the VGA (and keyboard) one must specify this on the
	/netbsd command line:

	menu=Xen:load /netbsd-XEN3_DOM0.gz bootdev=sd0 console=pc; multiboot /xen.gz console=vga dom0_mem=512M

	Note that the Xen "dom0_mem=" parameter is always required, as is
	the "bootdev=" for NetBSD.

	It may in some cases be useful to prevent Xen from
	re-initialising the VGA hardware by adding the following to the
	/xen command line:

	vga=current,keep

I don't think you can actually do much with Xen via its console unless
you're using one of its various debugging features.

I haven't actually tested to see if Xen with a VGA console will still
take over the console if it sees three <CTRL-A> chars or not, but it
certainly does with a serial console.  I haven't got a convenient test
machine to test this on (unless I can get Xen to boot on my old
macbook with just reFIT).

The Xen documentation doesn't differentiate what it means about the
separation of display and keyboard hardware when it talks about "VGA"
and I haven't read enough of the code to understand what it does.

> > We need to note that Xen (at least since 4.13) hides the COM port it is
> > using from the dom0.  I.e. by default NetBSD-XEN3_DOM0 can't see any
> > "com0", period.
>
> Added a note; I see com0 missing one mine.
>
> > So, when using a serial console (on the first COM port), booting a
> > XEN3_DOM0 kernel with "console=com0" actually attaches the console to
> > xencons(4) (as it's the only active and present console device and the
> > requested device is not found).  The "console=com0" parameter, if given,
> > is ignored.
>
> ok, but this seems like a consequence of defaults in a broken setup, and
> not what we want to instruct.  The howto is about how to do it right.

Exactly my point.  Telling XEN3_DOM0 to use "console=com0" is always wrong.

> > I've also confirmed that "console=xencons" is redundant and unnecessary
> > when using a serial console (at least with recent-ish NetBSD, probably
> > 9.x and newer, but maybe going back much further).
>
> Because vga is witheld if xen is serial, or because xencons is higher
> priority, or ?

Hmmmm... let's see what the source says:

	/usr/src/sys/arch/xen/x86/consinit.c:consinit():  (called by init_main())

	If dom0 _and_ if "console=pc" (or "tty0")
		try to attach that, but return if it doesn't work
		(should panic!?!? or attach xencons(4)???)
	else
		attach xencons(4) as the console.

So I think the example for serial console should still omit the
"console=xencons" part:

	menu=Xen:load /netbsd-XEN3_DOM0.gz bootdev=sd0;multiboot /xen.gz dom0_mem=512M

Also from CVS it looks like xencons(4) is the default since NetBSD-3.0.

And of course also omit that from the explanation by explaining it is
the (always-correct) default:

	If using serial console with Xen then the defaults are correct.
	Xen will handle the serial port and pass I/O to/from xencons(4).
	NetBSD will connect its console(4) device to xencons(4) and
	console I/O will happen there.  The only exception is if Xen
	sees its "comswitch" character (<CTRL-A> by default) three times
	in quick succession, in which case it will take over serial I/O
	until three more presses.  Xen console interactions can be used
	for various debugging features which are not usually present in
	the default /xen kernel.

One could keep the part about resetting the UART with /xen, but I would
only refer to other documentation for such things -- I've never in all
my years of using NetBSD encountered a situation where the UART is not
correctly and completely configured by /boot.

To that end the part about getting /boot and GENERIC running correctly
with the desired console and options first should still be explicitly
mentioned.

> Partially adapted, with some questions left.  I am not entirely ok with
> your drive to leave everything to defaults without explaining.

I agree explanations are good and necessary, but I don't like seeing the
defaults in the example /boot.cfg lines -- they seem to confuse people
as they are all too often mistaken for required parameters.

> > We should also fix the Xentools package(s) to install
> > xen-command-line(7) and try to upstream that fix.
>
> ENOPATCH!

working on it!


Not (mostly) Related To Consoles:
==================================

First off, the section on "Config files" should be updated to key/value
syntax forms for the "disk=" section.  I don't think the positional
parameter form is suitable for a HowTo.  Using explicit "key=value"
pairs makes everything most obvious on first glance and MUCH harder to
misread.

I also just noticed mention of "root=" to configured the boot device.  I
think that's the deprecated parameter name, with the apparently
preferred one being "bootdev=", if one believes boot(8).  This is, in
whatever form, in effect a required parameter and so should be present
in all examples too.

I'm not so happy with the various command-line options and parameters
for various kinds of kernels only being in boot(8).  It's not obvious.
Even boot.cfg(5) would be slightly more obvious, though that only
mentions "multiboot" in an example!  Maybe a separate netbsd(8) page
would be best.  Minimal fixes for boot.cfg(5):

--- boot.cfg.5.~1.31.~	2021-03-07 17:13:01.000000000 -0800
+++ boot.cfg.5	2024-01-07 13:23:50.118949951 -0800
@@ -181,9 +181,9 @@
 menu=Boot from second disk:boot hd1a:
 menu=Boot with module foo:load /foo.kmod;boot
 menu=Boot with modules foo and bar:load /foo.kmod;load /bar.kmod;boot
-menu=Boot Xen with 256MB for dom0:load /netbsd-XEN3_DOM0 console=pc;multiboot /usr/pkg/xen3-kernel/xen.gz dom0_mem=256M
-menu=Boot Xen with 256MB for dom0 (serial):load /netbsd-XEN3_DOM0 console=com0;multiboot /usr/pkg/xen3-kernel/xen.gz dom0_mem=256M console=com1 com1=115200,8n1
-menu=Boot Xen with dom0 in single-user mode:load /netbsd-XEN3_DOM0 -s;multiboot /usr/pkg/xen3-kernel/xen.gz dom0_mem=256M
+menu=Boot Xen with 256MB for dom0:load /netbsd-XEN3_DOM0 bootdev=sd0 console=pc;multiboot /usr/pkg/xen3-kernel/xen.gz dom0_mem=256M
+menu=Boot Xen with 256MB for dom0 (serial):load /netbsd-XEN3_DOM0 bootdev=sd0;multiboot /usr/pkg/xen3-kernel/xen.gz dom0_mem=256M
+menu=Boot Xen with dom0 in single-user mode (serial):load /netbsd-XEN3_DOM0 -s bootdev=sd0;multiboot /usr/pkg/xen3-kernel/xen.gz dom0_mem=256M
 menu=Go to command line (advanced users only):prompt
 clear=1
 timeout=-1
@@ -196,11 +196,6 @@
 load=/miniroot.kmod
 .Ed
 .Pp
-N.B. Xen counts serial ports from com1 upwards, but
-.Nx
-counts from com0, so the appropriate device name must be used.
-Please see the Xen with serial console example above.
-.Pp
 This will clear the screen and display:
 .Bd -literal -offset indent
 Welcome to NetBSD
@@ -215,7 +210,7 @@
       5. Boot with modules foo and bar
       6. Boot Xen with 256 MB for dom0
       7. Boot Xen with 256 MB for dom0 (serial)
-      8. Boot Xen with dom0 in single-user mode
+      8. Boot Xen with dom0 in single-user mode (serial)
       9. Go to command line (advanced users only)

 Option [1]:


--
					Greg A. Woods <gwoods%acm.org@localhost>

Kelowna, BC     +1 250 762-7675           RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost>     Avoncote Farms <woods%avoncote.ca@localhost>

Attachment: pgpFBvzT1c9kh.pgp
Description: OpenPGP Digital Signature



Home | Main Index | Thread Index | Old Index