diff options
author | jm22469 <none@none> | 2008-07-11 13:06:15 -0700 |
---|---|---|
committer | jm22469 <none@none> | 2008-07-11 13:06:15 -0700 |
commit | 045b72beb2c350d3331f90b3c626be055e6c8b7b (patch) | |
tree | ad50e6244fa13d843264542a1ae0383c0d2ff994 /usr/src/cmd/rcm_daemon | |
parent | 65b180883d21463716cc4a2c6f5708a76eb0731e (diff) | |
download | illumos-gate-045b72beb2c350d3331f90b3c626be055e6c8b7b.tar.gz |
6701708 VIO DR removal of in-use VCC service does not return a useful error message
Diffstat (limited to 'usr/src/cmd/rcm_daemon')
-rw-r--r-- | usr/src/cmd/rcm_daemon/Makefile.com | 15 | ||||
-rwxr-xr-x | usr/src/cmd/rcm_daemon/common/SUNW,vdevices.pl | 138 |
2 files changed, 152 insertions, 1 deletions
diff --git a/usr/src/cmd/rcm_daemon/Makefile.com b/usr/src/cmd/rcm_daemon/Makefile.com index 00a36402f8..a7293e76f1 100644 --- a/usr/src/cmd/rcm_daemon/Makefile.com +++ b/usr/src/cmd/rcm_daemon/Makefile.com @@ -61,6 +61,10 @@ COMMON_MOD_SRC = \ sparc_MOD_SRC = $(COMMON)/ttymux_rcm.c +COMMON_PERL_SCRIPT_SRC = + +sparc_PERL_SCRIPT_SRC = SUNW,vdevices.pl + COMMON_MOD_OBJ = \ filesys_rcm.o \ dump_rcm.o \ @@ -128,6 +132,9 @@ SRCS = $(RCM_SRC) $(COMMON_MOD_SRC) POFILES = $(SRCS:.c=.po) POFILE = prcm_daemon.po +PERL_SCRIPTS = $(COMMON_PERL_SRC) $($(MACH)_PERL_SCRIPT_SRC) +RCM_SCRIPTS = $(PERL_SCRIPTS) + # install specifics ROOTLIB_RCM = $(ROOTLIB)/$(RCM_DIR) @@ -136,6 +143,7 @@ ROOTLIB_RCM_DAEMON = $(RCM_DAEMON:%=$(ROOTLIB_RCM)/%) ROOTLIB_RCM_MODULES = $(COMMON_RCM_MODS:%=$(ROOTLIB_RCM_MOD)/%) \ $($(MACH)_RCM_MODS:%=$(ROOTLIB_RCM_MOD)/%) ROOTLIB_RCM_SCRIPT = $(ROOTLIB_RCM)/$(SCRIPT_DIR) +ROOTLIB_RCM_SCRIPTS = $(RCM_SCRIPTS:%=$(ROOTLIB_RCM_SCRIPT)/%) ROOTETC_RCM = $(ROOTETC)/$(RCM_DIR) ROOTETC_RCM_SCRIPT = $(ROOTETC_RCM)/$(SCRIPT_DIR) @@ -147,6 +155,7 @@ lint := TARGET= lint $(ROOTETC_RCM) := GROUP = sys $(ROOTETC_RCM_SCRIPT) := GROUP = sys +$(ROOTLIB_RCM_SCRIPTS) := FILEMODE = 555 .KEEP_STATE: @@ -159,7 +168,8 @@ install: all \ $(ROOTLIB_RCM_MODULES) \ $(ROOTLIB_RCM_SCRIPT) \ $(ROOTETC_RCM) \ - $(ROOTETC_RCM_SCRIPT) + $(ROOTETC_RCM_SCRIPT) \ + $(ROOTLIB_RCM_SCRIPTS) clean: $(RM) $(RCM_OBJ) $(COMMON_MOD_OBJ) $($(MACH)_MOD_OBJ) $(POFILES) @@ -209,3 +219,6 @@ $(ROOTETC_RCM): $(ROOTETC_RCM_SCRIPT): $(INS.dir) + +$(ROOTLIB_RCM_SCRIPT)/%: $(COMMON)/% + $(INS.file) diff --git a/usr/src/cmd/rcm_daemon/common/SUNW,vdevices.pl b/usr/src/cmd/rcm_daemon/common/SUNW,vdevices.pl new file mode 100755 index 0000000000..0c5d4d9ca7 --- /dev/null +++ b/usr/src/cmd/rcm_daemon/common/SUNW,vdevices.pl @@ -0,0 +1,138 @@ +#!/usr/bin/perl -w +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# + +# +# RCM script to allow/deny removal of miscellaneous virtual devices +# from an LDoms domain. +# +# Currently, the only device in this category is vcc +# (virtual-console-concentrator). +# + +use strict; + +my $vcc_path_prefix = "/devices/virtual-devices\@100/channel-devices\@200/"; +my $vcc_leaf_node = "virtual-console-concentrator"; + +my $cmd; +my %dispatch; + + +sub do_scriptinfo +{ + print "rcm_log_debug=do_scriptinfo\n"; + + print "rcm_script_version=1\n"; + print "rcm_script_func_info=VIO DR (VCC)\n"; + + exit (0); +} + +sub do_resourceinfo +{ + print "rcm_log_debug=do_resourceinfo\n"; + print "rcm_resource_usage_info=" . + "in use by virtual console service (vntsd)\n"; + + exit (0); +} + +sub do_register +{ + print "rcm_log_debug=do_register\n"; + + # + # Identify any vcc devices in the system. Vntsd always keeps the + # ":ctl" node open as a way to create or remove console ports, so + # use that as a proxy for the entire device. + # + my $path = $vcc_path_prefix . $vcc_leaf_node . "\*ctl"; + my @devs = glob $path; + my $consdev; + + # + # Tell the RCM framework to notify us if there is a request to + # remove a vcc device. + # + printf "rcm_log_debug=do_register: %d devices\n", scalar(@devs); + foreach $consdev(@devs) { + print "rcm_resource_name=$consdev\n"; + } + + exit (0); +} + +sub do_queryremove +{ + my $rsrc = shift(@ARGV); + + print "rcm_log_debug=do_queryremove: '$rsrc'\n"; + + # + # fuser(1M) sends to stdout the pids of any processes using the + # device. Some other information always appears on stderr and + # must be discarded to avoid invalidating the test. + # + my $str = `/usr/sbin/fuser $rsrc 2>/dev/null`; + + if ($? != 0) { + printf "rcm_log_err=do_queryremove: " . + "fuser failed (status %d)\n", $?; + print "rcm_failure_reason=helper command (fuser) failed\n"; + exit (1); + } + + my @words = split(/ /, $str); + + # Allow the operation if device not opened by any processes. + if (scalar(@words) != 0) { + print "rcm_log_debug=BLOCKED\n"; + print "rcm_failure_reason=device " . + "in use by virtual console service (vntsd)\n"; + exit (3); + } + + exit (0); +} + +$cmd = shift(@ARGV); + +# dispatch table for RCM commands +%dispatch = ( + "scriptinfo" => \&do_scriptinfo, + "resourceinfo" => \&do_resourceinfo, + "register" => \&do_register, + "queryremove" => \&do_queryremove +); + +if (defined($dispatch{$cmd})) { + &{$dispatch{$cmd}}; +} else { + exit (2); +} |