Hot-plugging USB into a Xen VM from a script

Xen Panda

I have been run­ning a hybrid Linux/Windows box for some time now, using Xen.  Xen is a bare-met­al hyper­vi­sor with many pow­er­ful fea­tures, includ­ing the abil­i­ty to map phys­i­cal hard­ware (say, a graph­ics card) to guest VMs.  I have strug­gled with get­ting USB to work seam­less­ly, how­ev­er.  My hard­ware pre­vents me from map­ping a phys­i­cal USB device to the guest, so I need­ed a dif­fer­ent solu­tion.

Xen allows emu­lat­ed USB con­trollers to be mapped to the guest, and this works well.  One impor­tant fea­ture is miss­ing, how­ev­er.  It is not pos­si­ble to auto­mat­i­cal­ly con­nect a device to the guest when it is plugged in.

A lot of research and some div­ing into the code brought me to a solu­tion, how­ev­er.  Utilizing the udev inter­face in lin­ux and the low-lev­el hyper­vi­sor inter­faces, I can hot-plug devices at run-time.  This post describes how I got there.

The source code dis­cussed in this arti­cle can be found, in full, at https://bitbucket.org/sczetty/auto-usb-attach/src/master/

Continue read­ing “Hot-plug­ging USB into a Xen VM from a script”

Getting the most out of a networking event

Last week, I attend­ed a net­work­ing event, as a “dry run” for an upcom­ing push toward get­ting out there with our new con­sult­ing arm, ModPii. I observed some things that I found inter­est­ing, and would prob­a­bly be of use to oth­ers out there.

(tl;dr)

Networking for fun

The most impor­tant rule: have fun!  If you aren’t hav­ing fun, you will allow the pres­sures of the moment effect you.  It doesn’t mat­ter who you are, peo­ple enjoy a relaxed, fun demeanor more than a “get it done” one.

So, relax.  Have a snack.  Joke with peo­ple around you.  Talk about your hob­bies.  Have fun!

Continue read­ing “Getting the most out of a net­work­ing event”

Abstract classes as action parameters in .NET Web API 4.0

(I had this sit­ting in draft form for years now, and I just dug it up. Most of it is pret­ty obso­lete, with .net core and all, but I’ll just leave this here.)

In a pre­vi­ous post, I dis­cussed a method for using abstract class­es in ASP.NET MVC 4.0. With it, I was able to clean up and hide the details of imple­men­ta­tion from much of my code. I assumed that it would be rel­a­tive­ly sim­ple to do the equiv­a­lent in Web API, but  I found that the task to be quite dif­fer­ent.

The equiv­a­lent func­tion­al­i­ty requires use of asyn­chro­nous pro­gram­ming, code gen­er­a­tion, and some com­plex pro­cess­ing for han­dling things like IEnumerable. I also found some race con­di­tions that need­ed to be addressed.

Continue read­ing “Abstract class­es as action para­me­ters in .NET Web API 4.0″

Using abstract classes as controller parameters in ASP.NET MVC4

As a part of the API for our prod­uct, we have the need to allow the UI to send us a par­cel of data, and we need to process it dif­fer­ent­ly based sole­ly on a sin­gle para­me­ter in the data.  We have decid­ed to cre­ate an abstract mod­el class to han­dle this, but MVC’s DefaultModelBinder doesn’t work out of the box on abstract class­es (or inter­faces).  There are many dis­cus­sions out there on this, and the accept­ed way to solve this prob­lem is to cre­ate a new ModelBinder class that has more knowl­edge of the inter­nals of your appli­ca­tion than the default does.  I thought about this some, and I decid­ed to try out a few tweaks to the process.

Continue read­ing “Using abstract class­es as con­troller para­me­ters in ASP.NET MVC4

Accepting multiple parameters the “RESTful” way using ASP .NET Web API

I came upon a require­ment at work to sup­port accept­ing mul­ti­ple ids in the Url of a “REST” request. I have no idea if this is actu­al­ly con­sid­ered RESTful or not, but the task was to for­mu­late the URL like so:

GET /FooResource/id1;id2;id3;id4/

The inten­tion was to be able to retrieve mul­ti­ple instances of FooResource with one request.

So, I came up with the fol­low­ing MVC ActionFilter to make my life a lit­tle bit eas­i­er:

Continue read­ing “Accepting mul­ti­ple para­me­ters the “RESTful” way using ASP .NET Web API

TDD and System. DirectoryServices. AccountManagement

So I am hav­ing a bit of a prob­lem here.  Working on a sim­ple library for a client to help them main­tain their Active Directory entries pro­gra­mat­i­cal­ly.  Started with my tests.  (I took this oppor­tu­ni­ty to spike Machine.Specifications, which I am find­ing that I quite like, but that’s for a dif­fer­ent post.)  Then researched into the APIs avail­able from Microsoft.  At first, I was quite excit­ed about the System.DirectoryServices.AccountManagement name­space added in the 3.5 frame­work, until I tried to inject its class­es into my own.

Now I’m run­ning myself in cir­cles, try­ing to fig­ure out how to test my code with­out cre­at­ing (or worse, delet­ing) accounts on my devel­op­ment box.

The team room and types of developers

The devel­op­ment team has recent­ly relin­quished our indi­vid­ual offices in favor of a team room where we are all work­ing togeth­er.  At first, I was skep­ti­cal that I would be able to keep a high lev­el of pro­duc­tiv­i­ty with the dis­trac­tions that a team room, by its very nature, cre­ates.  I couldn’t have been more wrong.  We quick­ly meshed as a team and have become notice­ably more pro­duc­tive.  (You can see the slope change on our burn­down; it is dra­mat­ic!)

One of the side-effects of work­ing in a big room with the rest of the team is that I’ve start­ed to notice the dif­fer­ent devel­op­ment and per­son­al­i­ty styles of the dif­fer­ent mem­bers.  I’ve come up with sev­er­al dif­fer­ent gen­er­al cat­e­gories.  Some peo­ple cross these bound­aries, depend­ing on the sit­u­a­tion.

Continue read­ing “The team room and types of devel­op­ers”

Regretting a lazy design

Last night of the iter­a­tion, we are try­ing to cut a good build. This morning’s scrum fea­tured a flus­tered QA engi­neer who was hav­ing trou­ble com­plet­ing her tests due to “cor­rupt­ed data”. Developers look at each oth­er and think, “rebuild the VM”, but it real­ly turned out to be faulty (and incon­sis­tent) assump­tions, on all of our parts.

The root cause of all our prob­lems tonight, though, dates back to the removal of a data­base con­straint that sup­port­ed an assump­tion that was not removed, about three iter­a­tions ago. (A ques­tion­able design deci­sion, IMHO.) This iter­a­tion, we tried to add a new con­straint that enforced our (now refined) assump­tion in a dif­fer­ent way. We failed. The assump­tion had been bro­ken in sev­er­al places, includ­ing our test data. Now, as we are try­ing to go gold, we have found that we need to revert the con­straints and deal with the messy data, just so that our test suite will con­tin­ue to work.

Now, in the­o­ry, in the field, nobody should be break­ing things. But we are still allow­ing them to, so some­body will, and it will look bad for us. We are stuck between a rock and a hard place now. Thirty min­utes spent com­ing up with a bet­ter design three iter­a­tions ago would have had us at home with our wives and a beer three or four hours ago.

YAML To The Rescue?

Here at work, we have been run­ning into a lot of issues syn­chro­niz­ing the default con­fig­u­ra­tions pro­vid­ed by the devel­op­ers with those that have been pro­vid­ed by the team respon­si­ble for pack­ag­ing releas­es. The sys­tem as it is right now is, how shall we say, clunky, at best, requir­ing the devel­op­ers to go back and recon­fig­ure new fea­tures mul­ti­ple times through­out an iter­a­tion, often every evening before the night­ly build. This sim­ply will not stand.

Continue read­ingYAML To The Rescue?”