[pve-devel] [PATCH 03/11] add print_drivedevice_full sub for disk -device syntax
Derumier Alexandre
aderumier at odiso.com
Wed Sep 7 15:34:38 CEST 2011
Signed-off-by: Derumier Alexandre <aderumier at odiso.com>
---
PVE/QemuServer.pm | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 1d11e6f..29bbf86 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -843,6 +843,42 @@ sub print_drive {
return "$drive->{file}$opts";
}
+sub print_drivedevice_full {
+ my ($storecfg, $vmid, $drive) = @_;
+
+ my $device = '';
+ my $maxdev = 0;
+
+ if ($drive->{interface} eq 'virtio') {
+
+ $device="virtio-blk-pci,drive=drive-$drive->{interface}$drive->{index},id=device-$drive->{interface}$drive->{index}";
+ }
+
+ elsif ($drive->{interface} eq 'scsi') {
+
+ $maxdev = 7;
+ my $controller = int ($drive->{index} / $maxdev);
+ my $unit = $drive->{index} % $maxdev;
+
+ $device="scsi-disk,bus=scsi$controller.0,scsi-id=$unit,drive=drive-$drive->{interface}$drive->{index},id=device-$drive->{interface}$drive->{index}";
+ }
+
+ elsif ($drive->{interface} eq 'ide'){
+
+ $maxdev = 2;
+ my $controller = int ($drive->{index} / $maxdev);
+ my $unit = $drive->{index} % $maxdev;
+
+ $device="ide-drive,bus=ide.$controller,unit=$unit,drive=drive-$drive->{interface}$drive->{index},id=device-$drive->{interface}$drive->{index}";
+ }
+
+ if ($drive->{interface} eq 'usb'){
+ # -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
+ }
+
+ return $device;
+}
+
sub print_drive_full {
my ($storecfg, $vmid, $drive) = @_;
@@ -2002,6 +2038,7 @@ sub config_to_command {
my $tmp = print_drive_full ($storecfg, $vmid, $drive);
$tmp .= ",boot=on" if $conf->{bootdisk} && ($conf->{bootdisk} eq $ds);
push @$cmd, '-drive', $tmp;
+ push @$cmd, '-device',print_drivedevice_full ($storecfg,$vmid, $drive);
});
push @$cmd, '-m', $conf->{memory} || $defaults->{memory};
--
1.7.2.5
More information about the pve-devel
mailing list