[pve-devel] [PATCH] add scsi-block detection

Alexandre DERUMIER aderumier at odiso.com
Mon Mar 19 10:13:12 CET 2012


seem to work 


root at kvmtest3:/# perl test.pl /dev/disk/by-id/scsi-3600144f0f62f0e0000004f4b9fd800af 
$VAR1 = { 
'revision' => '1.0', 
'venodor' => 'NEXENTA', 
'removable' => 0, 
'product' => 'COMSTAR', 
'device' => 0 
}; 



root at kvmtest3:/# ls -l /dev/disk/by-id/scsi-3600144f0f62f0e0000004f4b9fd800af 
lrwxrwxrwx 1 root root 12 Mar 17 14:50 /dev/disk/by-id/scsi-3600144f0f62f0e0000004f4b9fd800af -> ../../dm-357 




----- Mail original -----

De: "Dietmar Maurer" <dietmar at proxmox.com> 
À: "Alexandre DERUMIER" <aderumier at odiso.com> 
Cc: pve-devel at pve.proxmox.com 
Envoyé: Lundi 19 Mars 2012 09:55:24 
Objet: RE: [pve-devel] [PATCH] add scsi-block detection 

Please can you test if this works to identify the multipath scsi devices? 

------------------------- 
#!/usr/bin/perl -w 

use strict; 
use IO::File; 
use Data::Dumper; 

sub scsi_inquiry { 
my($fh, $noerr) = @_; 

my $SG_IO = 0x2285; 
my $SG_GET_VERSION_NUM = 0x2282; 

my $versionbuf = "\x00" x 8; 
my $ret = ioctl($fh, $SG_GET_VERSION_NUM, $versionbuf); 
if (!$ret) { 
die "scsi ioctl SG_GET_VERSION_NUM failoed - $!\n" if !$noerr; 
return undef; 
} 
my $version = unpack("I", $versionbuf); 

if ($version < 30000) { 
die "scsi generic interface too old\n" if !$noerr; 
return undef; 
} 

my $buf = "\x00" x 36; 
my $sensebuf = "\x00" x 8; 
my $cmd = pack("C x3 C x11", 0x12, 36); 

my $packet = pack("i i C C s I P P P I I i P C C C C S S i I I", 
ord('S'), -3, length($cmd), length($sensebuf), 0, 
length($buf), $buf, $cmd, $sensebuf, 6000); 

$ret = ioctl($fh, $SG_IO, $packet); 
if (!$ret) { 
die "scsi ioctl SG_IO failed - $!\n" if !$noerr; 
return undef; 
} 

my @res = unpack("i i C C s I P P P I I i P C C C C S S i I I", $packet); 
if ($res[17] || $res[18]) { 
die "scsi ioctl SG_IO status error - $!\n" if !$noerr; 
return undef; 
} 

my $res = {}; 
($res->{device}, $res->{removable}, $res->{venodor}, 
$res->{product}, $res->{revision}) = unpack("C C x6 A8 A16 A4", $buf); 

return $res; 
} 

my $devfn = shift || die "no device specified\n"; 

my $fh=IO::File->new("+<$devfn") || die "can't open '$devfn' - $!\n"; 

my $data = scsi_inquiry($fh); 
print Dumper($data); 

close($fh); 


> -----Original Message----- 
> From: Alexandre DERUMIER [mailto:aderumier at odiso.com] 
> Sent: Montag, 19. März 2012 07:06 
> To: Dietmar Maurer 
> Cc: pve-devel at pve.proxmox.com 
> Subject: Re: [pve-devel] [PATCH] add scsi-block detection 
> 
> Hi Dietmar, 
> I found this : 
> 
> http://search.cpan.org/~mooli/Device-SCSI-1.004/lib/Device/SCSI.pm 
> 
> 
> use Device::SCSI; 
> 
> my @devices = Device::SCSI->enumerate; 
> 
> my $device = Device::SCSI->new($devices[0]); 
> my %inquiry = %{ $device->inquiry }; 
> my ($result, $sense) = $device->execute($command, $wanted, $data); 
> $device->close; 
> 
> 
> Seem to be what we want to do ... 
> 
> ----- Mail original ----- 
> 
> De: "Dietmar Maurer" <dietmar at proxmox.com> 
> À: "Alexandre DERUMIER" <aderumier at odiso.com> 
> Cc: pve-devel at pve.proxmox.com 
> Envoyé: Vendredi 16 Mars 2012 15:58:54 
> Objet: RE: [pve-devel] [PATCH] add scsi-block detection 
> 
> > maybe 
> > 
> > bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version) do the 
> > job ? 
> 
> AFAIK the inquiry command fail, so we need to execute an scsi inquiry. 
> 
> - Dietmar 
> 
> 
> 
> -- 
> 
> -- 
> 
> 
> 
> 
> Alexandre D erumier 
> Ingénieur Système 
> Fixe : 03 20 68 88 90 
> Fax : 03 20 68 90 81 
> 45 Bvd du Général Leclerc 59100 Roubaix - France 
> 12 rue Marivaux 75002 Paris - France 
> 




-- 




	Alexandre D erumier 
Ingénieur Système 
Fixe : 03 20 68 88 90 
Fax : 03 20 68 90 81 
45 Bvd du Général Leclerc 59100 Roubaix - France 
12 rue Marivaux 75002 Paris - France 
	
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.proxmox.com/pipermail/pve-devel/attachments/20120319/71bb0b38/attachment.htm>


More information about the pve-devel mailing list