s10_support.c revision e71ca95ca6de23d33b54cb55cefdef30bc7c969b
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* s10_support is a small cli utility used to perform some brand-specific
* tasks when verifying a zone. This utility is not intended to be called
* by users - it is intended to be invoked by the zones utilities.
*/
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <limits.h>
#include <s10_brand.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stropts.h>
#include <unistd.h>
#include <libintl.h>
#include <locale.h>
#include <dirent.h>
#include <sys/systeminfo.h>
#include <libzonecfg.h>
static void usage(void) __NORETURN;
/*
* XXX This is a temporary flag for the initial release to enable the
* use of features which are not yet tested or fully implemented.
*/
#define PKGINFO_RD_LEN 128
#define PATCHLIST "PATCHLIST="
#if !defined(TEXT_DOMAIN) /* should be defined by cc -D */
#endif
/*PRINTFLIKE1*/
static void
{
char buf[1024];
/* This needs go to stdout so the msgs show up through zoneadm. */
exit(1);
/*NOTREACHED*/
}
static int
s10_verify(char *xmlfile)
{
struct zone_fstab fstab;
struct zone_devtab devtab;
struct zone_dstab dstab;
}
/*
* Check to see whether the zone has any inherit-pkg-dirs
* configured.
*/
}
"inherit-pkg-dirs"));
}
(void) zonecfg_endipdent(handle);
/*
* Check to see whether the zone has any unsupported devices
* configured.
*
* The audio framework has changed in Solaris Next as compared to
* S10. Data indicates the less than 1/10 of 1 percent of zones
* revisit this if there is enough demand.
*/
}
!override) {
}
}
(void) zonecfg_enddevent(handle);
/*
* Check to see whether the zone has any experimental features
* configured.
*/
"exclusive ip-type stacks"));
}
}
"delegated datasets"));
}
(void) zonecfg_enddsent(handle);
return (0);
}
/*
* Read an entry from a pkginfo file. Some of these lines can
* either be arbitrarily long or be continued by a backslash at the end of
* the line. This function coalesces lines that are longer than the read
* buffer, and lines that are continued, into one buffer which is returned.
* The caller must free this memory. NULL is returned when we hit EOF or
* if we run out of memory (errno is set to ENOMEM).
*/
static char *
{
char *start;
char *inp;
char *p;
int char_cnt = 0;
errno = 0;
return (NULL);
}
int len;
break;
}
else
break;
}
start = p;
}
}
return (start);
}
/*
* Read the SUNWcakr pkginfo file and get the PATCHLIST for the pkg.
*/
static int
{
char zonepath[MAXPATHLEN];
char pkginfo[MAXPATHLEN];
char *buf;
int err = 0;
>= sizeof (pkginfo))
return (errno);
int len;
/* remove trailing newline */
if ((*patchlist =
break;
}
}
return (err);
}
/*
* Verify that we have the minimum KU needed.
* Note that KU patches are accumulative so future KUs will still deliver
* 141444 or 141445.
*/
static boolean_t
have_valid_ku(char *zonename)
{
char *p;
char *lastp;
char *pstr;
int i;
char *vers_table[] = {
"141444-09",
"141445-09",
NULL};
return (B_FALSE);
for (i = 0; vers_table[i] != NULL; i++)
if (strcmp(p, vers_table[i]) == 0)
return (B_TRUE);
}
return (B_FALSE);
}
/*
* in either the global zone or the non-global zone.
*/
static int
get_emul_version_number(char *verspath)
{
int vers = 0;
/* If the file doesn't exist, assume version 0 */
return (vers);
if (buf[0] == '#')
continue;
errno = 0;
if (errno != 0) {
}
}
return (vers);
}
/*
* Get the current emulation version that is implemented.
*/
static int
{
}
/*
* Get the emulation version that the S10 image requires. This
* exist on Solaris 10. That file specifies the minimal solaris10 brand
* emulation version that the specific release of S10 requires. If no
* minimal version is specified, the initial emulation remains compatible.
*
* If a new KU patch is created which needs different handling by the
* updated to specify a new version.
*/
static int
{
char zonepath[MAXPATHLEN];
char verspath[MAXPATHLEN];
return (get_emul_version_number(verspath));
}
static void
fail_xvm()
{
char buf[80];
"in a paravirtualized\ndomain is currently not supported"));
}
static int
{
int emul_vers;
int rqd_emul_vers;
if (!have_valid_ku(zonename))
"not supported"));
if (rqd_emul_vers > emul_vers)
"incompatible with the current version of the solaris10 "
"brand."));
sizeof (int)) == -1)
"property"));
fail_xvm();
return (0);
}
static void
usage()
{
"usage:\t%s verify <xml file>\n"
"\t%s boot\n"),
exit(1);
}
int
{
(void) textdomain(TEXT_DOMAIN);
if (argc != 3)
usage();
/*
* XXX This is a temporary env variable for the initial release to
* enable the use of features which are not yet tested or fully
* implemented.
*/
usage();
/*NOTREACHED*/
}