scsi-block auto detection

Signed-off-by: Derumier Alexandre <aderumier@odiso.com>
This commit is contained in:
Derumier Alexandre 2011-12-13 09:59:28 +01:00 committed by Dietmar Maurer
parent 0888fdce30
commit 231f2e13cb

View File

@ -445,7 +445,7 @@ PVE::JSONSchema::register_standard_option("pve-qm-ide", $idedesc);
my $scsidesc = { my $scsidesc = {
optional => 1, optional => 1,
type => 'string', format => 'pve-qm-drive', type => 'string', format => 'pve-qm-drive',
typetext => '[volume=]volume,] [,media=cdrom|disk|block] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback|unsafe] [,format=f] [,backup=yes|no] [,aio=native|threads]', typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback|unsafe] [,format=f] [,backup=yes|no] [,aio=native|threads]',
description => "Use volume as SCSI hard disk or CD-ROM (n is 0 to 13).", description => "Use volume as SCSI hard disk or CD-ROM (n is 0 to 13).",
}; };
PVE::JSONSchema::register_standard_option("pve-qm-scsi", $scsidesc); PVE::JSONSchema::register_standard_option("pve-qm-scsi", $scsidesc);
@ -880,13 +880,19 @@ sub print_drivedevice_full {
my $controller = int($drive->{index} / $maxdev); my $controller = int($drive->{index} / $maxdev);
my $unit = $drive->{index} % $maxdev; my $unit = $drive->{index} % $maxdev;
my $devicetype = 'hd'; my $devicetype = 'hd';
if ($drive->{media}) { my $path = '';
if($drive->{media} eq 'cdrom') { if (drive_is_cdrom($drive)) {
$devicetype = 'cd'; $devicetype = 'cd';
} elsif ($drive->{media} eq 'block') { } else {
$devicetype = 'block'; if ($drive->{file} =~ m|^/|) {
} $path = $drive->{file};
} } else {
$path = PVE::Storage::path($storecfg, $drive->{file});
}
if ($path =~ m|^/dev/| ) {
$devicetype = 'block';
}
}
$device = "scsi-$devicetype,bus=scsi$controller.0,scsi-id=$unit,drive=drive-$drive->{interface}$drive->{index},id=device-$drive->{interface}$drive->{index}"; $device = "scsi-$devicetype,bus=scsi$controller.0,scsi-id=$unit,drive=drive-$drive->{interface}$drive->{index},id=device-$drive->{interface}$drive->{index}";
} elsif ($drive->{interface} eq 'ide'){ } elsif ($drive->{interface} eq 'ide'){