[pve-devel] [PATCH] add scsi-block detection
Alexandre DERUMIER
aderumier at odiso.com
Fri Mar 16 15:45:22 CET 2012
I didn't have checked,
but i found this in
scsi-disk.c
static int scsi_block_initfn(SCSIDevice *dev)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
int sg_version;
int rc;
if (!s->qdev.conf.bs) {
error_report("scsi-block: drive property not set");
return -1;
}
/* check we are using a driver managing SG_IO (version 3 and after) */
if (bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version) < 0 ||
sg_version < 30000) {
error_report("scsi-block: scsi generic interface too old");
return -1;
}
/* get device type from INQUIRY data */
rc = get_device_type(s);
if (rc < 0) {
error_report("scsi-block: INQUIRY failed");
return -1;
}
/* Make a guess for the block size, we'll fix it when the guest sends.
* READ CAPACITY. If they don't, they likely would assume these sizes
* anyway. (TODO: check in /sys).
*/
if (s->qdev.type == TYPE_ROM || s->qdev.type == TYPE_WORM) {
s->qdev.blocksize = 2048;
} else {
s->qdev.blocksize = 512;
}
return scsi_initfn(&s->qdev);
}
maybe
bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version)
do the job ?
----- 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:20:41
Objet: RE: [pve-devel] [PATCH] add scsi-block detection
Have you checked what kind of test the scsi-block driver usese itself? Maybe a simple ioctl call?
> -----Original Message-----
> From: Alexandre DERUMIER [mailto:aderumier at odiso.com]
> Sent: Freitag, 16. März 2012 12:12
> To: Dietmar Maurer
> Cc: pve-devel at pve.proxmox.com
> Subject: Re: [pve-devel] [PATCH] add scsi-block detection
>
> yes,it's work, i tested it with my multipathed iscsi luns.
>
> ----- Mail original -----
>
> De: "Dietmar Maurer" <dietmar at proxmox.com>
> À: "Derumier Alexandre" <aderumier at odiso.com>, pve-
> devel at pve.proxmox.com
> Envoyé: Vendredi 16 Mars 2012 11:18:22
> Objet: RE: [pve-devel] [PATCH] add scsi-block detection
>
> And such multipath device works with the scsi-block driver (you tested that)?
>
> - Dietmar
>
> > -----Original Message-----
> > From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> > bounces at pve.proxmox.com] On Behalf Of Derumier Alexandre
> > Sent: Freitag, 16. März 2012 08:57
> > To: pve-devel at pve.proxmox.com
> > Subject: [pve-devel] [PATCH] add scsi-block detection
> >
> >
> > Signed-off-by: Derumier Alexandre <aderumier at odiso.com>
> > ---
> > PVE/QemuServer.pm | 48
> > +++++++++++++++++++++++++++++++++++++++++++++---
> > 1 files changed, 45 insertions(+), 3 deletions(-)
> >
> > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index
> > 3991606..13a7852 100644
> > --- a/PVE/QemuServer.pm
> > +++ b/PVE/QemuServer.pm
> > @@ -25,6 +25,7 @@ use PVE::Cluster qw(cfs_register_file cfs_read_file
> > cfs_write_file cfs_lock_file use PVE::INotify; use PVE::ProcFSTools;
> > use Time::HiRes qw(gettimeofday);
> > +use Unix::Mknod qw(:all);
> >
> > my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
> >
> > @@ -904,9 +905,8 @@ sub print_drivedevice_full { } else { $path =
> > PVE::Storage::path($storecfg, $drive->{file}); }
> > - if ($path =~ m|^/dev/| ) {
> > - $devicetype = 'block';
> > - }
> > +
> > + $devicetype = 'block' if path_is_scsi($path);
> > }
> >
> > $device = "scsi-$devicetype,bus=lsi$controller.0,scsi-
> > id=$unit,drive=drive-$drive->{interface}$drive->{index},id=$drive-
> > >{interface}$drive->{index}";
> > @@ -2904,6 +2904,48 @@ sub vm_stopall { print $msg; }
> >
> > +sub path_is_scsi {
> > + my ($path) = @_;
> > +
> > + return if ($path !~ m|^/dev/|);
> > +
> > + my $bdev = undef;
> > + #if path is /dev/xxx
> > + if($path =~ m|^/dev/[^/]+/?$|) {
> > + $bdev = $path;
> > + }
> > + #if path is /dev/disk/
> > + elsif ($path =~ m|^/dev/disk/|) {
> > + $bdev = readlink($path);
> > + #if multipath, we need to find real device if($bdev =~
> > + m/(dm-(\d+))$/) { my $dir="/sys/block/$1/slaves/"; my $dh =
> > + IO::Dir->new ($dir); if (defined $dh) { while (defined(my $tmp =
> > + $dh->read)) { if ($tmp =~ m/([0-9A-Za-z])$/) { $bdev="/dev/$tmp"; }
> > + } } } elsif ($bdev =~ m/(\w+)/) { $bdev="/dev/$1"; } }
> > +
> > + return if !$bdev;
> > +
> > + my $st=stat($bdev);
> > + my $major=Unix::Mknod::major($st->rdev);
> > +
> > + if ($major =~ m/^(\d+)$/) {
> > + $major = $1;
> > + my @scsimajors =
> > (8,65,66,67,68,69,70,71,128,129,130,131,132,133,134,135);
> > + return 1 if (grep /^$major$/, @scsimajors) } }
> > +
> > # pci helpers
> >
> > sub file_write {
> > --
> > 1.7.2.5
> >
> > _______________________________________________
> > pve-devel mailing list
> > pve-devel at pve.proxmox.com
> > http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
>
>
>
> --
>
> --
>
>
>
>
> 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
More information about the pve-devel
mailing list