Thursday Apr 05, 2012

Setting up port forwarding for 7000 appliance VM in VirtualBox

I've been using the 7000 appliance VM for a lot of testing lately and relied on others to set up the networking for the VM for me, but finally, I decided to take the dive and do it myself.  After some experimenting, I came up with a very brief number of steps to do this all using the VirtualBox CLI instead of the GUI.

First download the VM image and unpack it somewhere.  I put it in /var/tmp. Then, set your VBOX_USER_HOME to some place with lots of disk space and import the VM:

export VBOX_USER_HOME=/var/tmp/MyVirtualBox
VBoxManage import /var/tmp/simulator/vbox-2011.\ ZFS\ Storage\ 7000.ovf

(go get a cup of tea...)

Then, set up port forwarding of the VM appliance BUI and shell:

First set up port as NAT:
VBoxManage modifyvm Sun_ZFS_Storage_7000 --nic1 nat

Then set up rules for port forwarding (pick some unused port numbers):
VBoxManage modifyvm Sun_ZFS_Storage_7000 --natpf1 "guestssh,tcp,,4622,,22"
VBoxManage modifyvm Sun_ZFS_Storage_7000 --natpf1 "guestbui,tcp,,46215,,215"

Verify the settings using:
VBoxManage showvminfo Sun_ZFS_Storage_7000 | grep -i nic

Start the appliance:
$ VBoxHeadless --startvm Sun_ZFS_Storage_7000 &

Connect to it using your favorite RDP client.  I use a Sun Ray, so I use the Sun Ray Windows Connector client:
$ /opt/SUNWuttsc/bin/uttsc -g 800x600 -P <portnumber> <your-hostname> &

The portnumber is displayed in the output of the --startvm command.(This did not work after I updated to VirtualBox 4.1.12, so maybe at this point, you need to use the VirtualBox GUI.)

It takes a while to first bring up the VM, so please be patient. The longest time is in loading the smf service descriptions, but fortunately, that only needs to be done the first time the VM boots.  There is also a delay in just booting the appliance, so give it some time.

Be sure to set the NIC rule on only one port and not all ports otherwise there will be a conflict in ports and it won't work.

After going through the initial configuration screen, you can connect to it using ssh or your browser:

ssh -p 45022 root@<your-host-name>


BTW, for the initial configuration, I only had to set the hostname and password.  The rest of the defaults were set by VirtualBox and seemed to work fine.

Sunday Nov 20, 2011

How to trace a function array argument in DTrace

I still use dtrace just about every day in my job and found that I had to print an argument to a function which was an array of strings.  The array was variable length up to about 10 items.  I'm not sure if the is the right way to do it, but it seems to work and is not too painful if the array size is small.

Here's an example.  Suppose in your application, you have the following function, where n is number of item in the array s.

void arraytest(int n, char **s)
    /* Loop thru s[0] to s[n-1] */

How do you use DTrace to print out the values of s[i] or of s[0] to s[n-1]?  DTrace does not have if-then blocks or for loops, so you can't do something like:

    for i=0; i<arg0; i++
        trace arg1[i];

It turns out that you can use probe ordering as a kind of iterator. Probes with the same name will fire in the order that they appear in the script, so I can save the value of "n" in the first probe and then use it as part of the predicate of the next probe to determine if the other probe should fire or not.  So the first probe for tracing the arraytest function is:

    self->n = arg0;

Then, if I want to print out the first few items of the array, I first check the value of n.  If it's greater than the index that I want to print out, then I can print that index.  For example, if I want to print out the 3rd element of the array, I would do something like:

/self->n > 2/
    printf("%s",stringof(arg1 + 2 * sizeof(pointer)));

Actually, that doesn't quite work because arg1 is a pointer to an array of pointers and needs to be copied twice from the user process space to the kernel space (which is where dtrace is). Also, the sizeof(char *) is 8, but for some reason, I have to use 4 which is the sizeof(uint32_t). (I still don't know how that works.)  So, the script that prints the 3rd element of the array should look like:

    /* first, save the size of the array so that we don't get     
       invalid address errors when indexing arg1+n. */
    self->n = arg0;
/self->n > 2/
    /* print the 3rd element (index = 2) of the second arg. */
    i = 2;
    size = 4;
    self->a_t = copyin(arg1+size*i,size);
    printf("%s: a[%d]=%s",probefunc,i,copyinstr(*(uint32_t *)self->a_t));

If your array is large, then it's quite painful since you have to write one probe for every array index.  For example, here's the full script for printing the first 5 elements of the array:

#!/usr/sbin/dtrace -s
        /* first, save the size of the array so that we don't get
           invalid address errors when indexing arg1+n. */
        self->n = arg0;
/self->n > 0/
        i = 0;
        size = sizeof(uint32_t);
        self->a_t = copyin(arg1+size*i,size);
        printf("%s: a[%d]=%s",probefunc,i,copyinstr(*(uint32_t *)self->a_t));
/self->n > 1/
        i = 1;
        size = sizeof(uint32_t);
        self->a_t = copyin(arg1+size*i,size);
        printf("%s: a[%d]=%s",probefunc,i,copyinstr(*(uint32_t *)self->a_t));
/self->n > 2/
        i = 2;
        size = sizeof(uint32_t);
        self->a_t = copyin(arg1+size*i,size);
        printf("%s: a[%d]=%s",probefunc,i,copyinstr(*(uint32_t *)self->a_t));
/self->n > 3/
        i = 3;
        size = sizeof(uint32_t);
        self->a_t = copyin(arg1+size*i,size);
        printf("%s: a[%d]=%s",probefunc,i,copyinstr(*(uint32_t *)self->a_t));
/self->n > 4/
        i = 4;
        size = sizeof(uint32_t);
        self->a_t = copyin(arg1+size*i,size);
        printf("%s: a[%d]=%s",probefunc,i,copyinstr(*(uint32_t *)self->a_t));

If the array is large, then your script will also have to be very long to print out all values of the array.

Friday Mar 11, 2011

DTrace script for who exec'd a process

I was wondering what process was executing logadm on a test system so I wrote a simple dtrace one-liner:

dtrace -q -n 'proc:::exec { self->parent = execname;}' -n 'syscall::exec*:return /execname == "logadm"/ { printf("%Y %s execs %s\\n",walltimestamp,self->parent,curpsinfo->pr_psargs); }'

 Here is sample output:

2011 Mar 11 17:35:00 sh execs /usr/sbin/logadm

In this case, it turned out to be cron, but I also found the script useful to check if and when a process was called in other cases.  Actually, this example was not too useful, but I didn't want to show the actual bug that I was working on.  However, I ended up using that DTrace one-liner many times this week.

Wednesday Dec 05, 2007

Favorite Podcasts for December 2007

I was talking to some coworkers at lunch the other day about my favorite podcasts, so here's an updated list for December 2007 (I still use iTunes to subscribe to them, but I put links for more information):

Daily Giz Wiz - Dick DeBartolo and Leo Laporte review gadgets Monday thru Friday

Car Talk's Call of the Week

WNYC's Radio Lab - sometimes contains material not suitable for young children

NPR Shuffle - an  assortment of news from NPR (National Public Radio)

NPR Technology

NPR Health and Science

Wait Wait... Don't Tell Me! - NPR quiz show

This American Life

net@nite - Web 2.0 stuff with Leo Laporte and Amber MacArthur. I really like that they put all the links that they discuss on their website.

Jumping Monkeys - A parenting podcast with Leo Laporte and Megan Morrone

While compiling the links above, I noticed that NPR has a huge assortment of podcasts which I really need to explore.

Tuesday Mar 20, 2007

Favorite podcasts for March 2007

I'm still addicted to podcasts while commuting.  Ever since I started listening to podcasts about a year or so ago, I've been waiting to hear "From WHYY ... This is FRESH AIR."  Well, finally that time has come.  You can download the latest episodes from iTunes or directly from NPR here.

 I also just found another one of my radio favorites--Car Talk.  Their podcast is not free, but they have a free "Call of the Week" available on iTunes. (The link on to the "Call of the Week" seems to be broken).

And one more podcast I'm listening to is from Jonathan Coulton called "Thing a Week".  Jonathan posts a new original song every week.  I'm not sure if he's still doing this, but there appears to be 52 free songs on iTunes.  My favorite so far is "Code Monkey".  I happened to search for it on You Tube and actually found a video of Jonathan performing this song.  Enjoy!

Tuesday Nov 14, 2006

Wait wait, don't tell me what my favorite podcast is...

 wait wait logo

Wait wait, don't tell me what my favorite podcast is...

uh... actually let me reword that. 

Q: What is my favorite podcast?

A: "Wait wait don't tell me!" from National Public Radio.

I've been listening to this hour long weekly podcast for about a 8 months now.  Occasionally I listen to it on the radio in real time on the weekends, but mostly, I burn it to a CD-RW and listen to it in the car.  It's a current events news quiz type show making fun of what just happened in the past week or two with popular and obscure questions on the news.  It's a call-in show with some regular cast members (such as Paula Poundstone) and a few celebrities every so often.

My favorite celebrities have been Alan Alda and Tom Hanks.  I think this show has been on for several years, but I just discovered it and look forward to listening to it every week.  Enjoy!

Another one of my favorites was Inside the Net with Amber MacArthur and Leo Laporte.  I say "was" because they just replaced it with a new video podcast called "net@nite".  Fortunately for me, they still have a podcast version which I can listen to in the car.  The thing I liked best about Inside the Net was that it went in depth into a particular "Web 2.0" web site and gave the human perspective of who was behind it, how it was formed, etc.  Infact, I feel that it was only after they interviewed the creators of YouTube, did YouTube actually take off.

Net@nite has only had 2 episodes so far and the first one was kind of boring even though they managed to get Steve Chen (from YouTube) on for a few minutes.   I'll listen to the second episode later this week after I finish listening to another episode of This American Life (650,000 civilian deaths in Iraq?  Really?)


Friday May 05, 2006

Favorite podcasts for Spring 2006

Been too busy to blog lately. But not too busy to keep listening to podcasts, so I thought I would update my favorite podcasts for Spring 2006. They are (not in any particular order):

Reviews for the Weekend by Ebert and Ropert. - I watch about 2 or 3 movies a year in a theater, however, I really enjoy listening to movie reviews. It's great to know that I'm not missing much...

Security Now! - This computer security podcast is pretty technical and even a pseudo-geek like me sometimes can't keep up with how public key encryption works for example.

NPR Technology - A summary of the weeks technology broadcasts from National Public Radio. - Still haven't learned to speak Mandarin yet. But, at least I've learned a few phrases (Bù hǎo yì si). This is not your typical foreign language class. It's quite entertaining and useful for the modern world. For example: Dàn shì tā méi yŏu shŏu jī. That's something about not having a cell phone.. :-)

The Naked Scientist - Interesting Science show from the BBC. Probably middle school or high school level at times. But, it's been a long time since I was in high school. We had fun listening to this on the drive from SF to Tahoe. Definitely helps pass the time.

This Week's Challenge - NPR Music Puzzler - A musical puzzle in a common song is played in the style of another composer. For example, one was "Scarborough Affair" in the style of Beethoven's moonlight sonata.

Michael Feldman's Whad'Ya Know - Uh.. not sure how to describe this one. A short satire on the news.

NPR: Wait Wait...Don't Tell Me! - Current events quiz. Common events and a few obscure ones.

Inside the Net with Amber MacArthur - Interviews by Amber MacArthur with people who are doing "Web 2.0" sites.

Game ON! - A game podcast by our own Chief Gaming Officer Chris Melissinos from Sun Microsystems. Yes, I admit that I still play video and computer games once in a while (well more like every week...) My current favorite is Runscape which is an online RPG game in Java. Over 100 servers supply the game to hundreds of thousands of people around the world. I'm a level 37 monk. :-) I wonder what hardware they run on?

Wednesday Jan 18, 2006

Ferrari mp3 player

picture of MP3 player

For all you Ferrari fans... Since I've been blogging about my SanDisk MP3 player a lot, I happened to notice an article in about a Ferrari MP3 player. Looks pretty cool, but is it for real? I took a quick look at Oregon Scientific's webpage and there was no mention of this player. Hm...

Sunday Jan 15, 2006

Are podcasts overrated? Not to me.

I've been hearing that podcasts are overrated and just a fad. I don't think so. Maybe because I've just discovered them a few months ago, but I think they're here to stay. I listen to podcasts in the car, at home while doing household work, and while at the gym exercising (whenever I get around to going to the gym...). I used to listen to the radio at those times, but the programs that I like are not always on when I have time to listen to them. So, podcasts to the rescue. I probably listen to about 8 hours a week as follows:

Unfortunately our own Richard Giles who did the I/O Podcast (about Sun Microsystems) just left Sun last week, so I have to find another Sun related podcast to listen to.

I'm not ashamed to say that "I love podcasts". :-)

Wednesday Dec 14, 2005

Audacity to the rescue

Finally found a workaround to my SanDisk player not playing some MP3 podcasts. I use iTunes to convert to MP3 and that works for about 80% of the podcasts I want to listen to, but some MP3 files still won't play on the SanDisk. I was just playing with Audacity and found that it can export to MP3 if you have the lame encoder. Well, that seemed to fix my problem. I just load the "bad" MP3 file and then export it back out again. I can now play the exported file. Very strange... but, it works for now.

So, Audacity or maybe I should open source to the rescue!

Saturday Dec 03, 2005

Favorite Podcasts for Nov 2005

Still continuing to use my SanDisk 1Gb MP3 player and thought I'd list some of my favorite podcasts every so often. But, before that, I do have a few gripes about the SanDisk player. The main problem is that it only plays MP3 and WMA formats. It doesn't play AAC, MPEG2, WAV, or any other popular formats that podcasters use. I use iTunes to convert to MP3 and that works for about 80% of the podcasts I want to listen to, but some MP3 files still won't play on the SanDisk. I reported it to SanDisk support and they have not been able to figure it out. I tried different bit rates, too. Fortunately, that 80% that does work keeps me occupied enough.

So, here's my list of favorites for this month that I subscribe to (in no particular order):

I use iTunes to search for the podcasts by going to the Music Store, selecting Podcasts from the list on the left, then entering any of the above. I'm curious how my tastes will change over the upcoming year, so I hope to post favorites every so often. All these favorites are not explicit and pretty much appropriate for any audience (although my kids are completely bored with the topics except for maybe learning Mandarin.) Being in the computer industry and frequently being asked by friends and relatives to help them with their PCs and networking, I found that "KFI Tech Guy" and "Security Now!" are very helpful. I really should get into some non-technical stuff, though. I tried "Skepticality", but that wouldn't play on my SanDisk.

Monday Nov 14, 2005

More on SanDisk MP3 player

I've had my SanDisk 1Gb MP3 player for about one month now. I can't say that it rocks, but it doesn't suck either. For my use, it works well. It's small, durable, and comes with a case. I wind the earphones around it and can fit it in my front pants pocket. It did lockup once and I ended up having to reinitialize it. I think that was caused by copying files to it from Mac OS, Windows XP, and Solaris x86 systems, deleting files from Mac OS and Windows XP and from the player itself. Somewhere along the line, the player must have gotten mixed up. My son was also recording stuff near a pool using the builtin microphone. I mostly use my Mac to transfer files now and haven't seen any lockups, although the Mac leaves some odd names .dot files around.

I just bought a VR3 FM modulator to listen to my MP3 player thru my car stereo. The VRFM8 was around $24.99 at Costco. I can't seem to find an exact picture of it anywhere, though. Basically it plugs into your car adapter and transmits on an FM station either from a USB memory stick that you plug into the base or a MP3 player that you plug in using an included audio cable. It allows you to select from several different FM stations to broadcast and I found that 88.9 worked fine for me.

Sound quality is ok. Probably equivalent to the radio (duh!). But, that's fine since I find myself listening to podcasts more than music right now. Can hardly wait to drive into work just to be able to listen to all those great podcasts mentioned in the blogs such as I/O Podcasts. :-)

Wednesday Nov 09, 2005

Using an MP3 player and podcasts

sandisk MP3 player

I recently bought a SanDisk 1Gb MP3 player just on a whim. (Well, actually, my son wanted an iPod and I wasn't about to buy him one when I don't even have one. He still doesn't have an iPod...) So, after the initial excitement and copying 50 songs or so, I wasn't really sure what to do with it. I tried exercising with it, but found that the earphones kept getting loose and my arms kept bumping into the earphone cord. A college kid told me I'm supposed to wear the long strap behind my neck. Ok, that works better.

I also tried going for long walks with it, but I got too much wind interference and it was hard to hear. I guess that's why some people have their volume really loud.

After about a month, I also started to get bored of the music I had loaded on to it. So, now what? While listening to the radio (the SanDisk player has a builtin FM tuner), I heard about podcasts. Yea, I know, Where have you been?. I had heard about them before, but never connected the dots. So, I started downloading podcasts from iTunes. My favorites are NPR's Science Friday and Engadget. I just found out the NPR has doubled their podcasts so, I'm going to to find out more.

Now, I'm pretty happy to do the dishes, water the yard, etc. while listening to podcasts on my mp3 player. Still running into a few issues which I'll cover later.




« July 2016