[pve-devel] [PATCH 1/2] add sata hdd support

Derumier Alexandre aderumier at odiso.com
Wed Feb 1 13:25:19 CET 2012


Signed-off-by: Derumier Alexandre <aderumier at odiso.com>
---
 PVE/QemuServer.pm |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7d335b7..2518385 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -386,6 +386,7 @@ while (my ($k, $v) = each %$confdesc) {
 my $MAX_IDE_DISKS = 4;
 my $MAX_SCSI_DISKS = 14;
 my $MAX_VIRTIO_DISKS = 6;
+my $MAX_SATA_DISKS = 6;
 my $MAX_USB_DEVICES = 5;
 my $MAX_NETS = 6;
 my $MAX_UNUSED_DISKS = 8;
@@ -448,6 +449,14 @@ my $scsidesc = {
 };
 PVE::JSONSchema::register_standard_option("pve-qm-scsi", $scsidesc);
 
+my $satadesc = {
+    optional => 1,
+    type => 'string', format => 'pve-qm-drive',
+    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 SATA hard disk or CD-ROM (n is 0 to 5).",
+};
+PVE::JSONSchema::register_standard_option("pve-qm-sata", $satadesc);
+
 my $virtiodesc = {
     optional => 1,
     type => 'string', format => 'pve-qm-drive',
@@ -536,6 +545,11 @@ for (my $i = 0; $i < $MAX_IDE_DISKS; $i++)  {
     $confdesc->{"ide$i"} = $idedesc;
 }
 
+for (my $i = 0; $i < $MAX_SATA_DISKS; $i++)  {
+    $drivename_hash->{"sata$i"} = 1;
+    $confdesc->{"sata$i"} = $satadesc;
+}
+
 for (my $i = 0; $i < $MAX_SCSI_DISKS; $i++)  {
     $drivename_hash->{"scsi$i"} = 1;
     $confdesc->{"scsi$i"} = $scsidesc ;
@@ -602,7 +616,8 @@ sub disknames {
     # order is important - used to autoselect boot disk
     return ((map { "ide$_" } (0 .. ($MAX_IDE_DISKS - 1))),
             (map { "scsi$_" } (0 .. ($MAX_SCSI_DISKS - 1))),
-            (map { "virtio$_" } (0 .. ($MAX_VIRTIO_DISKS - 1))));
+            (map { "virtio$_" } (0 .. ($MAX_VIRTIO_DISKS - 1))),
+            (map { "sata$_" } (0 .. ($MAX_SATA_DISKS - 1))));
 }
 
 sub valid_drivename {
@@ -900,6 +915,10 @@ sub print_drivedevice_full {
 	my $devicetype = ($drive->{media} && $drive->{media} eq 'cdrom') ? "cd" : "hd";
 
 	$device = "ide-$devicetype,bus=ide.$controller,unit=$unit,drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}";
+    } elsif ($drive->{interface} eq 'sata'){
+	my $controller = int($drive->{index} / $MAX_SATA_DISKS);
+	my $unit = $drive->{index} % $MAX_SATA_DISKS;
+	$device = "ide-drive,bus=ahci$controller.$unit,drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}";
     } elsif ($drive->{interface} eq 'usb') {
 	die "implement me";
 	#  -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
-- 
1.7.2.5




More information about the pve-devel mailing list