Tuesday Feb 17, 2009

VirtualBox pause and resume

I have a VirtualBox running ubuntu that is acting as a print server for my HP Officejet J6410 and although that works well it chews a significant amount of CPU resource which given that the printer is not in use most of the time seems a bit of a waste, especially when the Sun Ray server can have 4 active sessions running on it. So now I am running this simple script:

#!/bin/ksh93 -p 

logger -p daemon.notice -t ${0##\*/}[$$] |&

exec >&p 2>&1

while :
do
        echo resuming vbox
        su - vbox -c "VBoxManage -nologo controlvm ubunto resume"

        ssh print-server sudo ntpdate 3.uk.pool.ntp.org

        while ping printer 2 > /dev/null 2>&1
        do
                sleep 60
        done
        echo pausing vbox
        su - vbox -c "VBoxManage -nologo controlvm ubunto pause"
        until ping printer 2 > /dev/null 2>&1
        do
                sleep 1
        done
done

After the usual magic to redirect it's output to syslog this just loops forever pinging the printer. If the printer is alive the VrtualBox is resumed and if the printer is not alive the VirtualBox is paused. So as soon as the printer is turned on the virtual box is ready and then within 60 seconds of the printer being turned off the virtualbox is paused.


So that the clock on the VirtualBox is kept correct (the guest additions are, I am told, supposed to do this for free but in practice they do not for me) after resuming there is the ssh onto the virtual machine to set it's clock\*, so I have a work around in place for VirtualBox which is itself a work around for a defect in Solaris and that work around is also working around another issue with Solaris.


Life on the bleeding edge is always fun!



\*) I would normally use the address of my server to sync with but thanks to the issues with build 108 I currently don't have a working ntp server on the system.

Sunday Feb 08, 2009

New Home printer VirtualBox & Ubuntu to the rescue

I've got a new printer for home, an HP OfficeJet J6410, but the bad news is on Solaris the hpijs server for ghostscript fails and while I have made some progress debugging this it will clearly take some time to get to the root cause. As part of the debugging I ran up a Ubuntu linux in VirtualBox to see if the problem was a generic ghostscript/CUPS problem.

Since Ubuntu had no problem printing for the short term I have given the Ubuntu system a virtual network interface so that I can configure the Sun Ray server to print via the Ubuntu print-server, which if I use the cups-lpd server, will do the formatting for the remote hosts. The remote hosts therefore just have to send PostScript to the print-server and only it needs to be able run the hpijs server.

I'm running the VirtualBox headless and gdm turned off, infact everything except CUPS, xinetd and sshd turned off. I've not written an SMF service to start the VirtualBox yet in the hope that this is infact a very short lived situation as the Solaris print service will be up and running soon. Anyway I now have working printing on Solaris

Now back to what I know about ghostscript and the hpijs service. If you know more (which would not be hard) then let me know.

The problem is that ghostscript called from foomatic-gswrapper fails with a range check error:

: pearson FSS 51 $; truss -faeo /tmp/tr.$$ /usr/lib/lp/bin/foomatic-gswrapper>
truss -faeo /tmp/tr.$$  /usr/lib/lp/bin/foomatic-gswrapper  -D -dBATCH -dPARANOIDSAFER -dQUIET -dNOPAUSE -sDEVICE=ijs -sIjsServer=hpijs -dIjsUseOutputFD -sOutputFile=-
foomatic-gswrapper: gs '-D' '-dBATCH' '-dPARANOIDSAFER' '-dQUIET' '-dNOPAUSE' '-sDEVICE=ijs' '-sIjsServer=hpijs' '-dIjsUseOutputFD' '-sOutputFile=/dev/fd/3' 3>&1 1>&2
unable to set Quality=0, ColorMode=2, MediaType=0, err=4
following will be used Quality=0, ColorMode=2, MediaType=0
unable to set paper size=17, err=4
Unrecoverable error: rangecheck in setscreen
Operand stack:
    -0.0  0  --nostringval--
: pearson FSS 52 $; 

The errors, unable to set Quality and unable to set paper size appear to home from the hpijp server that returns NO_PRINTER_SELECTED (4) if these routines are called prior to the printer context is set up.

Quite how and why the printer context is not getting set up is the question. I've now rebuilt both ghostscript and the hpijs service from source and worked out how to get foomatic to use the new ones and I still have the issue but at least I should now be able to do diagnosis in my own time while the printer is usable by everyone on the local network.

Building ghostscript was simple:

$ ./configure –prefix=/opt/cjgsw

Then make and make install.

Building hpijs was less simple and I am not entirely sure I have it built correctly in fact I stronly suspect it is not built correctly. At least I have my binaries behaving the same way as the Solaris binaries, ie the failure mode is the same. My configure line was:

 $ ./configure LIBS=”-lsocket -lnsl” --prefix=/opt/cjgsw --disable-pp-build --ena
ble-static –disable-shared

All the –enable-static and –disable-shared are required or the linker gets upset during the build I think the next stop would be an update to gcc....

Friday Jan 30, 2009

OpenSolaris updates virtualbox

After a short delay VirtualBox for OpenSolaris has been upgraded. Update manager popped up to tell me and ask if I wanted the upgrade and created a new boot environment with the package installed. Very cool. Alas now I have to reboot to install it so my laptop won't reach three weeks uptime:

cjg@brompton:~$ uptime
 10:12pm  up 18 days  0:05,  2 users,  load average: 0.16, 0.27, 0.84
cjg@brompton:~$ beadm list
BE            Active Mountpoint Space  Policy Created          
--            ------ ---------- -----  ------ -------          
opensolaris   -      -          89.37M static 2008-11-27 12:14 
opensolaris-1 -      -          8.39M  static 2008-11-30 13:14 
opensolaris-2 -      -          13.36M static 2008-12-02 11:27 
opensolaris-3 N      /          12.70M static 2008-12-06 20:02 
opensolaris-4 R      -          9.44G  static 2009-01-30 21:42 
cjg@brompton:~$ 

Thursday Jan 22, 2009

Powerline network control from OpenSolaris


At last I can configure my ethernet over power devices from OpenSolaris. I do have to run Windows XP in VirtualBox in seamless mode with a virtual network adapter but you can hardly tell.


My requirement for Windows on the bare metal has just disappeared.

Sunday Dec 07, 2008

VirtualBox on home Sun Ray server

I'm after best practices for VirtualBox on a home Sun Ray server. My solution is to have a “vbox” role and create a VirtualBox named after each user contianing the OS that they need. For most users this there is no need as everything they need is available natively on Solaris but there are some apps that only work on Windows so for that user they get those apps.

The upside of this is that I get to manage the images (and since I will have to fix them that is good). Plus I can pause and VM when the user removes their card by having my utdetach script do:

su - vbox -c "pfexec VBoxManage controlvm $1 pause" > /dev/null

and then the utattach script do:

su - vbox -c "pfexec VBoxManage controlvm $1 resume" > /dev/null

So that the Virtual Machines are not burning resources when they need not be. The temptation to also do:

su - vbox -c "pfexec VBoxManage snapshot $1 take $(date '+%F-%T')”

in the detach is strong but I need to better understand the disk space implications of that and whether letting ZFS handle that would be better.

About

This is the old blog of Chris Gerhard. It has mostly moved to http://chrisgerhard.wordpress.com

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today