Archive for the ‘Programming’ Category

connect usb hardware to kvm

Saturday, June 14th, 2014

Since I’ve found really few documentation on connecting usb devices to kvm virtual machine without middle software like spice or libvirt I’ll post what I found here.

 

I’ve found two method but only the 2nd work with usb2serial adapter.

USBVIDPID=0403:6001
USBD=""
for line in $(lsusb | grep $USBVIDPID | sed -n "s/Bus 0*\([0-9]*\) Device 0*\([0-9]*\).*/-device usb-host,hostbus=\\1,hostaddr=\\2/p")
do
USBD="$USBD $line"
done
USBVIDPID=0403:6001
cnt=0
USBD=""
killall usbredirserver
for line in $(lsusb | grep $USBVIDPID | sed -n "s/Bus 0*\([0-9]*\) Device 0*\([0-9]*\).*/\\1-\\2/p")
do
/usr/sbin/usbredirserver -p $(( 4000 + $cnt )) $line >/var/log/kvm/${NAME}-usb-$line.log 2>&1 &
USBD="$USBD -chardev socket,id=usbredirchardev${cnt},host=localhost,port=$(( 4000 + $cnt )) \
-device usb-redir,chardev=usbredirchardev${cnt},id=usbredirdev${cnt},debug=3" #,bus=ehci.0,
let cnt=cnt+1
done

querying Tivoli Workload Scheduler 8.5 (tws) using web services

Friday, October 1st, 2010

Pubblico un esempio di client per l’interrogazione di tws mediante web services utilizzando perl…

#!/bin/perl

#ppm install SOAP::Lite
#ppm install Crypt::SSLeay

use SOAP::Lite
#trace=>’all’
;

#use SOAP::Lite +trace => [qw(method fault headers result debug)];

my $username = ‘user’;
my $password = ‘pass’;
my $host     = ‘host’;

sub SOAP::Transport::HTTP::Client::get_basic_credentials {
return $username => $password;
}

$wsdl = “https://$host:31116/PlanServicesWeb/services/SchedulingFactory/wsdl/SchedulingFactory.wsdl”;

#$service = “https://$host:31116/PlanServicesWeb/services/JobStreamService”;
#$service = “https://$host:31116/PlanServicesWeb/services/JobService”;

$service = “https://$host:31116/PlanServicesWeb/services/SchedulingFactory”;

$ns1 = “http://services.ws.tws.ibm.com/TWS-Scheduling”;
$ns2 = “http://types.ws.tws.ibm.com/TWS-Types”;

my $soap = SOAP::Lite->new( proxy => $service );
$soap->readable(1);
$soap->ns($ns2,’ns2′);
$soap->ns($ns1,’ns1′);

my $result=$soap->call(“queryJobs”,
SOAP::Data->name(“engineName” => undef )->prefix(ns1),
SOAP::Data->name(“filter” => \SOAP::Data->value(
SOAP::Data->name(“details”)->prefix(ns2),
SOAP::Data->name(“minimum”)->prefix(ns2),
SOAP::Data->name(“maximum”)->prefix(ns2),
SOAP::Data->name(“dataType”=>”WORKSTATION_NAME”)->prefix(ns2),
SOAP::Data->name(“value”=> \SOAP::Data->value(
SOAP::Data->name(string=>”WK17″)->prefix(“xsd”),
),
)->prefix(ns2),

SOAP::Data->name(“dataType”=>”JOB_STREAM_NAME”)->prefix(ns2),
SOAP::Data->name(“value”=> \SOAP::Data->value(
SOAP::Data->name(string=>”IGS*”)->prefix(“xsd”),
),
)->prefix(ns2),
),
)->prefix(ns1)->type(“ns2:FilterCriteria”),

);

die $result->faultstring if ($result->fault);

#use Data::Dumper qw(Dumper);
#print Dumper ($result);

foreach my $a ($result->valueof(“//queryJobsResponse/queryJobsReturn/JobInstance”)) {
print sprintf “%-11s %-16s %-16s %-16s %-16s %-5s\n”, $a->{workstationName},
$a->{jobName},
$a->{jobStreamName},
$a->{startTime},
$a->{actualEnd},
$a->{internalStatus};
}

exit;