[pve-devel] [PATCH 1/1] add initiator-name to iscsi drives if configured
mir at datanom.net
mir at datanom.net
Tue May 13 03:10:40 CEST 2014
From: Michael Rasmussen <mir at datanom.net>
Signed-off-by: Michael Rasmussen <mir at datanom.net>
---
PVE/QemuServer.pm | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 2cb2d95..c4ec8fa 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1125,6 +1125,20 @@ sub print_drivedevice_full {
return $device;
}
+sub get_initiator_name {
+ my $initiator = undef;
+
+ open (FILE, '/etc/iscsi/initiatorname.iscsi') or return undef;
+ while (<FILE>) {
+ next unless m/^\s*InitiatorName\s*=\s*([\.\-:\w]+)/;
+ $initiator = $1;
+ last;
+ }
+ close FILE;
+
+ return $initiator;
+}
+
sub print_drive_full {
my ($storecfg, $vmid, $drive) = @_;
@@ -2612,8 +2626,17 @@ sub config_to_command {
push @$devices, '-device', "ahci,id=ahci$controller,multifunction=on$pciaddr" if !$ahcicontroller->{$controller};
$ahcicontroller->{$controller}=1;
}
-
- push @$devices, '-drive',print_drive_full($storecfg, $vmid, $drive);
+
+ my $drive_cmd = print_drive_full($storecfg, $vmid, $drive);
+ push @$devices, '-drive',$drive_cmd;
+
+ # Add iscsi option
+ my $iscsi_opts = undef;
+ if ($drive_cmd =~ m|^file=iscsi://|) {
+ my $initiator = get_initiator_name(); # return undef or string
+ $iscsi_opts = "initiator-name=$initiator" if $initiator;
+ }
+ push @$devices, '-iscsi',$iscsi_opts if $iscsi_opts;
push @$devices, '-device',print_drivedevice_full($storecfg, $conf, $vmid, $drive, $bridges);
});
--
2.0.0.rc2
----
This mail was virus scanned and spam checked before delivery.
This mail is also DKIM signed. See header dkim-signature.
More information about the pve-devel
mailing list