Add a bootstatic callback for dom0, which allows to take NFS boot informations
from the command line (nfsroot=, ip=) in the same way domUs did. While there convert a for (;;) loop to TAILQ_FOREACH(). From Christoph Egger in private mail. Make all bootstatic callbacks return the new NFS_BOOTSTATIC_NOSTATIC flag when no nfs boot information is found on command line.
This commit is contained in:
parent
a92a400fbf
commit
afc9294f4e
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: autoconf.c,v 1.24 2007/06/24 01:43:34 dyoung Exp $ */
|
||||
/* $NetBSD: autoconf.c,v 1.25 2007/07/08 21:14:14 bouyer Exp $ */
|
||||
/* NetBSD: autoconf.c,v 1.75 2003/12/30 12:33:22 pk Exp */
|
||||
|
||||
/*-
|
||||
@ -45,7 +45,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.24 2007/06/24 01:43:34 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.25 2007/07/08 21:14:14 bouyer Exp $");
|
||||
|
||||
#include "opt_xen.h"
|
||||
#include "opt_compat_oldboot.h"
|
||||
@ -433,7 +433,7 @@ found:
|
||||
|
||||
xen_parse_cmdline(XEN_PARSE_BOOTDEV, &xcp);
|
||||
|
||||
for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next) {
|
||||
TAILQ_FOREACH(dv, &alldevs, dv_list) {
|
||||
if (is_valid_disk(dv) == 0)
|
||||
continue;
|
||||
|
||||
@ -492,6 +492,41 @@ found:
|
||||
#include <dev/pci/pcivar.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(NFS_BOOT_BOOTSTATIC) && defined(DOM0OPS)
|
||||
static int
|
||||
dom0_bootstatic_callback(struct nfs_diskless *nd)
|
||||
{
|
||||
#if 0
|
||||
struct ifnet *ifp = nd->nd_ifp;
|
||||
#endif
|
||||
union xen_cmdline_parseinfo xcp;
|
||||
struct sockaddr_in *sin;
|
||||
|
||||
memset(&xcp, 0, sizeof(xcp.xcp_netinfo));
|
||||
xcp.xcp_netinfo.xi_ifno = 0; /* XXX first interface hardcoded */
|
||||
xcp.xcp_netinfo.xi_root = nd->nd_root.ndm_host;
|
||||
xen_parse_cmdline(XEN_PARSE_NETINFO, &xcp);
|
||||
|
||||
nd->nd_myip.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[0]);
|
||||
nd->nd_gwip.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[2]);
|
||||
nd->nd_mask.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[3]);
|
||||
|
||||
sin = (struct sockaddr_in *) &nd->nd_root.ndm_saddr;
|
||||
memset((void *)sin, 0, sizeof(*sin));
|
||||
sin->sin_len = sizeof(*sin);
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_addr.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[1]);
|
||||
|
||||
if (nd->nd_myip.s_addr == 0)
|
||||
return NFS_BOOTSTATIC_NOSTATIC;
|
||||
else
|
||||
return (NFS_BOOTSTATIC_HAS_MYIP|NFS_BOOTSTATIC_HAS_GWIP|
|
||||
NFS_BOOTSTATIC_HAS_MASK|NFS_BOOTSTATIC_HAS_SERVADDR|
|
||||
NFS_BOOTSTATIC_HAS_SERVER);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
device_register(struct device *dev, void *aux)
|
||||
{
|
||||
@ -500,14 +535,21 @@ device_register(struct device *dev, void *aux)
|
||||
* not available driver independently later.
|
||||
* For disks, there is nothing useful available at attach time.
|
||||
*/
|
||||
#if NXENNET_HYPERVISOR > 0 || NXENNET_XENBUS > 0
|
||||
#if NXENNET_HYPERVISOR > 0 || NXENNET_XENBUS > 0 || defined(DOM0OPS)
|
||||
if (device_class(dev) == DV_IFNET) {
|
||||
union xen_cmdline_parseinfo xcp;
|
||||
|
||||
xen_parse_cmdline(XEN_PARSE_BOOTDEV, &xcp);
|
||||
if (strncmp(xcp.xcp_bootdev, dev->dv_xname, 16) == 0) {
|
||||
#ifdef NFS_BOOT_BOOTSTATIC
|
||||
#ifdef DOM0OPS
|
||||
if (xen_start_info.flags & SIF_PRIVILEGED) {
|
||||
nfs_bootstatic_callback = dom0_bootstatic_callback;
|
||||
} else
|
||||
#endif
|
||||
#if NXENNET_HYPERVISOR > 0 || NXENNET_XENBUS > 0
|
||||
nfs_bootstatic_callback = xennet_bootstatic_callback;
|
||||
#endif
|
||||
#endif
|
||||
goto found;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xen_machdep.c,v 1.18 2007/06/28 20:54:47 bouyer Exp $ */
|
||||
/* $NetBSD: xen_machdep.c,v 1.19 2007/07/08 21:14:14 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
@ -63,7 +63,7 @@
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.18 2007/06/28 20:54:47 bouyer Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.19 2007/07/08 21:14:14 bouyer Exp $");
|
||||
|
||||
#include "opt_xen.h"
|
||||
|
||||
@ -163,12 +163,16 @@ lgdt(struct region_descriptor *rdp)
|
||||
void
|
||||
xen_parse_cmdline(int what, union xen_cmdline_parseinfo *xcp)
|
||||
{
|
||||
char _cmd_line[128], *cmd_line, *opt, *s;
|
||||
char _cmd_line[256], *cmd_line, *opt, *s;
|
||||
int b, i, ipidx = 0;
|
||||
uint32_t xi_ip[5];
|
||||
size_t len;
|
||||
|
||||
cmd_line = strncpy(_cmd_line, xen_start_info.cmd_line, 128);
|
||||
cmd_line[127] = '\0';
|
||||
len = strlcpy(_cmd_line, xen_start_info.cmd_line, sizeof(_cmd_line));
|
||||
if (len > sizeof(_cmd_line)) {
|
||||
printf("command line exceeded limit of 255 chars. Truncated.\n");
|
||||
}
|
||||
cmd_line = _cmd_line;
|
||||
|
||||
switch (what) {
|
||||
case XEN_PARSE_BOOTDEV:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_xennet.c,v 1.49 2007/03/04 06:01:10 christos Exp $ */
|
||||
/* $NetBSD: if_xennet.c,v 1.50 2007/07/08 21:14:14 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.49 2007/03/04 06:01:10 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.50 2007/07/08 21:14:14 bouyer Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_nfs_boot.h"
|
||||
@ -1304,9 +1304,12 @@ xennet_bootstatic_callback(struct nfs_diskless *nd)
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_addr.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[1]);
|
||||
|
||||
return (NFS_BOOTSTATIC_HAS_MYIP|NFS_BOOTSTATIC_HAS_GWIP|
|
||||
NFS_BOOTSTATIC_HAS_MASK|NFS_BOOTSTATIC_HAS_SERVADDR|
|
||||
NFS_BOOTSTATIC_HAS_SERVER);
|
||||
if (nd->nd_myip.s_addr == 0)
|
||||
return NFS_BOOTSTATIC_NOSTATIC;
|
||||
else
|
||||
return (NFS_BOOTSTATIC_HAS_MYIP|NFS_BOOTSTATIC_HAS_GWIP|
|
||||
NFS_BOOTSTATIC_HAS_MASK|NFS_BOOTSTATIC_HAS_SERVADDR|
|
||||
NFS_BOOTSTATIC_HAS_SERVER);
|
||||
}
|
||||
#endif /* defined(NFS_BOOT_BOOTSTATIC) */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_xennet_xenbus.c,v 1.15 2007/03/04 06:01:10 christos Exp $ */
|
||||
/* $NetBSD: if_xennet_xenbus.c,v 1.16 2007/07/08 21:14:15 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.15 2007/03/04 06:01:10 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.16 2007/07/08 21:14:15 bouyer Exp $");
|
||||
|
||||
#include "opt_xen.h"
|
||||
#include "opt_nfs_boot.h"
|
||||
@ -1174,10 +1174,12 @@ xennet_bootstatic_callback(struct nfs_diskless *nd)
|
||||
sin->sin_len = sizeof(*sin);
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_addr.s_addr = ntohl(xcp.xcp_netinfo.xi_ip[1]);
|
||||
|
||||
return (NFS_BOOTSTATIC_HAS_MYIP|NFS_BOOTSTATIC_HAS_GWIP|
|
||||
NFS_BOOTSTATIC_HAS_MASK|NFS_BOOTSTATIC_HAS_SERVADDR|
|
||||
NFS_BOOTSTATIC_HAS_SERVER);
|
||||
if (nd->nd_myip.s_addr == 0)
|
||||
return NFS_BOOTSTATIC_NOSTATIC;
|
||||
else
|
||||
return (NFS_BOOTSTATIC_HAS_MYIP|NFS_BOOTSTATIC_HAS_GWIP|
|
||||
NFS_BOOTSTATIC_HAS_MASK|NFS_BOOTSTATIC_HAS_SERVADDR|
|
||||
NFS_BOOTSTATIC_HAS_SERVER);
|
||||
}
|
||||
#endif /* defined(NFS_BOOT_BOOTSTATIC) */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user