my $pcisysfs = "/sys/bus/pci";
my $confdesc = {
- iothread => {
- optional => 1,
- type => 'boolean',
- description => "Enable iothread dataplane.",
- default => 0,
- },
onboot => {
optional => 1,
type => 'boolean',
optional => 1,
type => 'string',
description => "scsi controller model",
- enum => [qw(lsi lsi53c810 virtio-scsi-pci megasas pvscsi)],
+ enum => [qw(lsi lsi53c810 virtio-scsi-pci virtio-scsi-single megasas pvscsi)],
default => 'lsi',
},
description => {
optional => 1,
description => "Emulated CPU type.",
type => 'string',
- enum => [ qw(486 athlon pentium pentium2 pentium3 coreduo core2duo kvm32 kvm64 qemu32 qemu64 phenom Conroe Penryn Nehalem Westmere SandyBridge Haswell Broadwell Opteron_G1 Opteron_G2 Opteron_G3 Opteron_G4 Opteron_G5 host) ],
+ enum => [ qw(486 athlon pentium pentium2 pentium3 coreduo core2duo kvm32 kvm64 qemu32 qemu64 phenom Conroe Penryn Nehalem Westmere SandyBridge IvyBridge Haswell Broadwell Opteron_G1 Opteron_G2 Opteron_G3 Opteron_G4 Opteron_G5 host) ],
default => 'kvm64',
},
parent => get_standard_option('pve-snapshot-name', {
my $scsidesc = {
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|directsync] [,format=f] [,backup=yes|no] [,rerror=ignore|report|stop] [,werror=enospc|ignore|report|stop] [,aio=native|threads] [,discard=ignore|on]',
+ typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback|unsafe|directsync] [,format=f] [,backup=yes|no] [,rerror=ignore|report|stop] [,werror=enospc|ignore|report|stop] [,aio=native|threads] [,discard=ignore|on] [,iothread=on]',
description => "Use volume as SCSI hard disk or CD-ROM (n is 0 to " . ($MAX_SCSI_DISKS - 1) . ").",
};
PVE::JSONSchema::register_standard_option("pve-qm-scsi", $scsidesc);
my $virtiodesc = {
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|directsync] [,format=f] [,backup=yes|no] [,rerror=ignore|report|stop] [,werror=enospc|ignore|report|stop] [,aio=native|threads] [,discard=ignore|on]',
+ typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback|unsafe|directsync] [,format=f] [,backup=yes|no] [,rerror=ignore|report|stop] [,werror=enospc|ignore|report|stop] [,aio=native|threads] [,discard=ignore|on] [,iothread=on]',
description => "Use volume as VIRTIO hard disk (n is 0 to " . ($MAX_VIRTIO_DISKS - 1) . ").",
};
PVE::JSONSchema::register_standard_option("pve-qm-virtio", $virtiodesc);
my $res = {};
return $res if $data eq '0';
-
+
$data = $confdesc->{hotplug}->{default} if $data eq '1';
foreach my $feature (PVE::Tools::split_list($data)) {
# ideX = [volume=]volume-id[,media=d][,cyls=c,heads=h,secs=s[,trans=t]]
# [,snapshot=on|off][,cache=on|off][,format=f][,backup=yes|no]
# [,rerror=ignore|report|stop][,werror=enospc|ignore|report|stop]
-# [,aio=native|threads][,discard=ignore|on]
+# [,aio=native|threads][,discard=ignore|on][,iothread=on]
sub parse_drive {
my ($key, $data) = @_;
foreach my $p (split (/,/, $data)) {
next if $p =~ m/^\s*$/;
- if ($p =~ m/^(file|volume|cyls|heads|secs|trans|media|snapshot|cache|format|rerror|werror|backup|aio|bps|mbps|mbps_max|bps_rd|mbps_rd|mbps_rd_max|bps_wr|mbps_wr|mbps_wr_max|iops|iops_max|iops_rd|iops_rd_max|iops_wr|iops_wr_max|size|discard)=(.+)$/) {
+ if ($p =~ m/^(file|volume|cyls|heads|secs|trans|media|snapshot|cache|format|rerror|werror|backup|aio|bps|mbps|mbps_max|bps_rd|mbps_rd|mbps_rd_max|bps_wr|mbps_wr|mbps_wr_max|iops|iops_max|iops_rd|iops_rd_max|iops_wr|iops_wr_max|size|discard|iothread)=(.+)$/) {
my ($k, $v) = ($1, $2);
$k = 'file' if $k eq 'volume';
return undef if $res->{backup} && $res->{backup} !~ m/^(yes|no)$/;
return undef if $res->{aio} && $res->{aio} !~ m/^(native|threads)$/;
return undef if $res->{discard} && $res->{discard} !~ m/^(ignore|on)$/;
+ return undef if $res->{iothread} && $res->{iothread} !~ m/^(on)$/;
return undef if $res->{mbps_rd} && $res->{mbps};
return undef if $res->{mbps_wr} && $res->{mbps};
my ($vmid, $drive) = @_;
my $opts = '';
- foreach my $o (@qemu_drive_options, 'mbps', 'mbps_rd', 'mbps_wr', 'mbps_max', 'mbps_rd_max', 'mbps_wr_max', 'backup') {
+ foreach my $o (@qemu_drive_options, 'mbps', 'mbps_rd', 'mbps_wr', 'mbps_max', 'mbps_rd_max', 'mbps_wr_max', 'backup', 'iothread') {
$opts .= ",$o=$drive->{$o}" if $drive->{$o};
}
if ($drive->{interface} eq 'virtio') {
my $pciaddr = print_pci_addr("$drive->{interface}$drive->{index}", $bridges);
$device = "virtio-blk-pci,drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}$pciaddr";
- $device .= ",iothread=iothread0" if $conf->{iothread};
+ $device .= ",iothread=iothread-$drive->{interface}$drive->{index}" if $drive->{iothread};
} elsif ($drive->{interface} eq 'scsi') {
- $maxdev = ($conf->{scsihw} && ($conf->{scsihw} !~ m/^lsi/)) ? 256 : 7;
- my $controller = int($drive->{index} / $maxdev);
+
+ my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive);
my $unit = $drive->{index} % $maxdev;
my $devicetype = 'hd';
my $path = '';
}
if (!$conf->{scsihw} || ($conf->{scsihw} =~ m/^lsi/)){
- $device = "scsi-$devicetype,bus=scsihw$controller.0,scsi-id=$unit,drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}";
+ $device = "scsi-$devicetype,bus=$controller_prefix$controller.0,scsi-id=$unit,drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}";
} else {
- $device = "scsi-$devicetype,bus=scsihw$controller.0,channel=0,scsi-id=0,lun=$drive->{index},drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}";
+ $device = "scsi-$devicetype,bus=$controller_prefix$controller.0,channel=0,scsi-id=0,lun=$drive->{index},drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}";
}
} elsif ($drive->{interface} eq 'ide'){
$opts .= ",$o=" . int($v*1024*1024) if $v;
}
- # use linux-aio by default (qemu default is threads)
- $opts .= ",aio=native" if !$drive->{aio};
+ # aio native works only with O_DIRECT
+ if (!$drive->{aio}) {
+ if(!$drive->{cache} || $drive->{cache} eq 'none' || $drive->{cache} eq 'directsync') {
+ $opts .= ",aio=native";
+ } else {
+ $opts .= ",aio=threads";
+ }
+ }
+
my $path;
my $volid = $drive->{file};
push @$cmd, '-smbios', "type=1,$conf->{smbios1}";
}
- push @$cmd, '-object', "iothread,id=iothread0" if $conf->{iothread};
-
if ($q35) {
# the q35 chipset support native usb2, so we enable usb controller
# by default for this machine type
push @$cpuFlags , 'hv_vapic' if !$nokvm;
push @$cpuFlags , 'hv_time' if !$nokvm;
- } else {
+ } else {
push @$cpuFlags , 'hv_spinlocks=0xffff' if !$nokvm;
}
}
if (qemu_machine_feature_enabled ($machine_type, $kvmver, 2, 3)) {
push @$cpuFlags , '+kvm_pv_unhalt' if !$nokvm;
+ push @$cpuFlags , '+kvm_pv_eoi' if !$nokvm;
}
$cpu .= "," . join(',', @$cpuFlags) if scalar(@$cpuFlags);
- # Note: enforce needs kernel 3.10, so we do not use it for now
- # push @$cmd, '-cpu', "$cpu,enforce";
- push @$cmd, '-cpu', $cpu;
+ push @$cmd, '-cpu', "$cpu,enforce";
my $memory = $conf->{memory} || $defaults->{memory};
my $static_memory = 0;
}
}
+ if($drive->{interface} eq 'virtio'){
+ push @$cmd, '-object', "iothread,id=iothread-$ds" if $drive->{iothread};
+ }
+
if ($drive->{interface} eq 'scsi') {
- my $maxdev = ($scsihw !~ m/^lsi/) ? 256 : 7;
- my $controller = int($drive->{index} / $maxdev);
- $pciaddr = print_pci_addr("scsihw$controller", $bridges);
- push @$devices, '-device', "$scsihw,id=scsihw$controller$pciaddr" if !$scsicontroller->{$controller};
+ my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive);
+
+ $pciaddr = print_pci_addr("$controller_prefix$controller", $bridges);
+ my $scsihw_type = $scsihw =~ m/^virtio-scsi-single/ ? "virtio-scsi-pci" : $scsihw;
+
+ my $iothread = '';
+ if($conf->{scsihw} && $conf->{scsihw} eq "virtio-scsi-single" && $drive->{iothread}){
+ $iothread .= ",iothread=iothread-$controller_prefix$controller";
+ push @$cmd, '-object', "iothread,id=iothread-$controller_prefix$controller";
+ }
+
+ push @$devices, '-device', "$scsihw_type,id=$controller_prefix$controller$pciaddr$iothread" if !$scsicontroller->{$controller};
$scsicontroller->{$controller}=1;
}
if (!$q35) {
# add pci bridges
+ if (qemu_machine_feature_enabled ($machine_type, $kvmver, 2, 3)) {
+ $bridges->{1} = 1;
+ $bridges->{2} = 1;
+ }
+
+ $bridges->{3} = 1 if $scsihw =~ m/^virtio-scsi-single/;
+
while (my ($k, $v) = each %$bridges) {
$pciaddr = print_pci_addr("pci.$k");
unshift @$devices, '-device', "pci-bridge,id=pci.$k,chassis_nr=$k$pciaddr" if $k > 0;
} elsif ($deviceid =~ m/^(virtio)(\d+)$/) {
+ qemu_iothread_add($vmid, $deviceid, $device);
+
qemu_driveadd($storecfg, $vmid, $device);
my $devicefull = print_drivedevice_full($storecfg, $conf, $vmid, $device);
die $err;
}
- } elsif ($deviceid =~ m/^(scsihw)(\d+)$/) {
+ } elsif ($deviceid =~ m/^(virtioscsi|scsihw)(\d+)$/) {
+
my $scsihw = defined($conf->{scsihw}) ? $conf->{scsihw} : "lsi";
my $pciaddr = print_pci_addr($deviceid);
- my $devicefull = "$scsihw,id=$deviceid$pciaddr";
+ my $scsihw_type = $scsihw eq 'virtio-scsi-single' ? "virtio-scsi-pci" : $scsihw;
+
+ my $devicefull = "$scsihw_type,id=$deviceid$pciaddr";
+
+ if($deviceid =~ m/^virtioscsi(\d+)$/ && $device->{iothread}) {
+ qemu_iothread_add($vmid, $deviceid, $device);
+ $devicefull .= ",iothread=iothread-$deviceid";
+ }
qemu_deviceadd($vmid, $devicefull);
qemu_deviceaddverify($vmid, $deviceid);
qemu_findorcreatescsihw($storecfg,$conf, $vmid, $device);
qemu_driveadd($storecfg, $vmid, $device);
-
+
my $devicefull = print_drivedevice_full($storecfg, $conf, $vmid, $device);
eval { qemu_deviceadd($vmid, $devicefull); };
if (my $err = $@) {
my $bridgeid = $2;
my $pciaddr = print_pci_addr($deviceid);
my $devicefull = "pci-bridge,id=pci.$bridgeid,chassis_nr=$bridgeid$pciaddr";
-
+
qemu_deviceadd($vmid, $devicefull);
qemu_deviceaddverify($vmid, $deviceid);
} else {
- die "can't hotplug device '$deviceid'\n";
+ die "can't hotplug device '$deviceid'\n";
}
return 1;
qemu_devicedel($vmid, $deviceid);
qemu_devicedelverify($vmid, $deviceid);
qemu_drivedel($vmid, $deviceid);
-
- } elsif ($deviceid =~ m/^(lsi)(\d+)$/) {
-
+ qemu_iothread_del($conf, $vmid, $deviceid);
+
+ } elsif ($deviceid =~ m/^(virtioscsi|scsihw)(\d+)$/) {
+
qemu_devicedel($vmid, $deviceid);
-
+ qemu_devicedelverify($vmid, $deviceid);
+ qemu_iothread_del($conf, $vmid, $deviceid);
+
} elsif ($deviceid =~ m/^(scsi)(\d+)$/) {
+ #qemu 2.3 segfault on drive_del with virtioscsi + iothread
+ my $device = parse_drive($deviceid, $conf->{$deviceid});
+ die "virtioscsi with iothread is not hot-unplugglable currently" if $device->{iothread};
+
qemu_devicedel($vmid, $deviceid);
qemu_drivedel($vmid, $deviceid);
-
+ qemu_deletescsihw($conf, $vmid, $deviceid);
+
} elsif ($deviceid =~ m/^(net)(\d+)$/) {
qemu_devicedel($vmid, $deviceid);
my $ret = vm_mon_cmd($vmid, "device_del", id => $deviceid);
}
+sub qemu_iothread_add {
+ my($vmid, $deviceid, $device) = @_;
+
+ if ($device->{iothread}) {
+ my $iothreads = vm_iothreads_list($vmid);
+ qemu_objectadd($vmid, "iothread-$deviceid", "iothread") if !$iothreads->{"iothread-$deviceid"};
+ }
+}
+
+sub qemu_iothread_del {
+ my($conf, $vmid, $deviceid) = @_;
+
+ my $device = parse_drive($deviceid, $conf->{$deviceid});
+ if ($device->{iothread}) {
+ my $iothreads = vm_iothreads_list($vmid);
+ qemu_objectdel($vmid, "iothread-$deviceid") if $iothreads->{"iothread-$deviceid"};
+ }
+}
+
sub qemu_objectadd {
my($vmid, $objectid, $qomtype) = @_;
my $ret = vm_human_monitor_command($vmid, "drive_del drive-$deviceid");
$ret =~ s/^\s+//;
-
+
return 1 if $ret eq "";
-
+
# NB: device not found errors mean the drive was auto-deleted and we ignore the error
- return 1 if $ret =~ m/Device \'.*?\' not found/s;
-
+ return 1 if $ret =~ m/Device \'.*?\' not found/s;
+
die "deleting drive $deviceid failed : $ret\n";
}
sub qemu_devicedelverify {
my ($vmid, $deviceid) = @_;
- # need to verify that the device is correctly removed as device_del
+ # need to verify that the device is correctly removed as device_del
# is async and empty return is not reliable
for (my $i = 0; $i <= 5; $i++) {
sub qemu_findorcreatescsihw {
my ($storecfg, $conf, $vmid, $device) = @_;
- my $maxdev = ($conf->{scsihw} && ($conf->{scsihw} !~ m/^lsi/)) ? 256 : 7;
- my $controller = int($device->{index} / $maxdev);
- my $scsihwid="scsihw$controller";
+ my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $device);
+
+ my $scsihwid="$controller_prefix$controller";
my $devices_list = vm_devices_list($vmid);
if(!defined($devices_list->{$scsihwid})) {
- vm_deviceplug($storecfg, $conf, $vmid, $scsihwid);
+ vm_deviceplug($storecfg, $conf, $vmid, $scsihwid, $device);
+ }
+
+ return 1;
+}
+
+sub qemu_deletescsihw {
+ my ($conf, $vmid, $opt) = @_;
+
+ my $device = parse_drive($opt, $conf->{$opt});
+
+ if ($conf->{scsihw} && ($conf->{scsihw} eq 'virtio-scsi-single')) {
+ vm_deviceunplug($vmid, $conf, "virtioscsi$device->{index}");
+ return 1;
+ }
+
+ my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $device);
+
+ my $devices_list = vm_devices_list($vmid);
+ foreach my $opt (keys %{$devices_list}) {
+ if (PVE::QemuServer::valid_drivename($opt)) {
+ my $drive = PVE::QemuServer::parse_drive($opt, $conf->{$opt});
+ if($drive->{interface} eq 'scsi' && $drive->{index} < (($maxdev-1)*($controller+1))) {
+ return 1;
+ }
+ }
}
+ my $scsihwid="scsihw$controller";
+
+ vm_deviceunplug($vmid, $conf, $scsihwid);
+
return 1;
}
sub qemu_set_link_status {
my ($vmid, $device, $up) = @_;
- vm_mon_cmd($vmid, "set_link", name => $device,
+ vm_mon_cmd($vmid, "set_link", name => $device,
up => $up ? JSON::true : JSON::false);
}
my ($vmid, $conf, $defaults, $opt, $value) = @_;
return $value if !check_running($vmid);
-
+
my $memory = $conf->{memory} || $defaults->{memory};
- $value = $defaults->{memory} if !$value;
+ $value = $defaults->{memory} if !$value;
return $value if $value == $memory;
my $static_memory = $STATICMEM;
my $fast_plug_option = {
'lock' => 1,
'name' => 1,
- 'onboot' => 1,
+ 'onboot' => 1,
'shares' => 1,
'startup' => 1,
};
} elsif ($opt eq 'balloon') {
# enable/disable balloning device is not hotpluggable
my $old_balloon_enabled = !!(!defined($conf->{balloon}) || $conf->{balloon});
- my $new_balloon_enabled = !!(!defined($conf->{pending}->{balloon}) || $conf->{pending}->{balloon});
+ my $new_balloon_enabled = !!(!defined($conf->{pending}->{balloon}) || $conf->{pending}->{balloon});
die "skip\n" if $old_balloon_enabled != $new_balloon_enabled;
# allow manual ballooning if shares is set to zero
my $balloon = $conf->{pending}->{balloon} || $conf->{memory} || $defaults->{memory};
vm_mon_cmd($vmid, "balloon", value => $balloon*1024*1024);
}
- } elsif ($opt =~ m/^net(\d+)$/) {
+ } elsif ($opt =~ m/^net(\d+)$/) {
# some changes can be done without hotplug
- vmconfig_update_net($storecfg, $conf, $hotplug_features->{network},
+ vmconfig_update_net($storecfg, $conf, $hotplug_features->{network},
$vmid, $opt, $value);
} elsif (valid_drivename($opt)) {
# some changes can be done without hotplug
die "internal error" if $opt !~ m/net(\d+)/;
my $iface = "tap${vmid}i$1";
-
+
if (&$safe_num_ne($oldnet->{rate}, $newnet->{rate})) {
PVE::Network::tap_rate_limit($iface, $newnet->{rate});
}
return 1;
}
}
-
+
if ($hotplug) {
vm_deviceplug($storecfg, $conf, $vmid, $opt, $newnet);
} else {
if (!drive_is_cdrom($old_drive)) {
- if ($drive->{file} ne $old_drive->{file}) {
+ if ($drive->{file} ne $old_drive->{file}) {
die "skip\n" if !$hotplug;
# unplug and register as unused
vm_deviceunplug($vmid, $conf, $opt);
vmconfig_register_unused_drive($storecfg, $vmid, $conf, $old_drive)
-
+
} else {
# update existing disk
# skip non hotpluggable value
- if (&$safe_num_ne($drive->{discard}, $old_drive->{discard}) ||
+ if (&$safe_num_ne($drive->{discard}, $old_drive->{discard}) ||
+ &$safe_string_ne($drive->{iothread}, $old_drive->{iothread}) ||
&$safe_string_ne($drive->{cache}, $old_drive->{cache})) {
die "skip\n";
}
&$safe_num_ne($drive->{iops_max}, $old_drive->{iops_max}) ||
&$safe_num_ne($drive->{iops_rd_max}, $old_drive->{iops_rd_max}) ||
&$safe_num_ne($drive->{iops_wr_max}, $old_drive->{iops_wr_max})) {
-
+
qemu_block_set_io_throttle($vmid,"drive-$opt",
($drive->{mbps} || 0)*1024*1024,
($drive->{mbps_rd} || 0)*1024*1024,
$drive->{iops_wr_max} || 0);
}
-
+
return 1;
}
} else { # cdrom
-
+
if ($drive->{file} eq 'none') {
vm_mon_cmd($vmid, "eject",force => JSON::true,device => "drive-$opt");
} else {
vm_mon_cmd($vmid, "eject", force => JSON::true,device => "drive-$opt"); # force eject if locked
vm_mon_cmd($vmid, "change", device => "drive-$opt",target => "$path") if $path;
}
-
+
return 1;
}
}
}
- die "skip\n" if !$hotplug || $opt =~ m/(ide|sata)(\d+)/;
+ die "skip\n" if !$hotplug || $opt =~ m/(ide|sata)(\d+)/;
# hotplug new disks
vm_deviceplug($storecfg, $conf, $vmid, $opt, $drive);
}
qemu_set_link_status($vmid, $opt, 0) if $nicconf->{link_down};
}
}
-
+
vm_mon_cmd_nocheck($vmid, 'qom-set',
path => "machine/peripheral/balloon0",
property => "guest-stats-polling-interval",
my $vollist = get_vm_volumes($conf);
PVE::Storage::deactivate_volumes($storecfg, $vollist);
}
-
+
foreach my $ext (qw(mon qmp pid vnc qga)) {
unlink "/var/run/qemu-server/${vmid}.$ext";
}
-
+
vmconfig_apply_pending($vmid, $conf, $storecfg) if $apply_pending_changes;
};
warn $@ if $@; # avoid errors - just warn
balloon0 => { bus => 0, addr => 3 },
watchdog => { bus => 0, addr => 4 },
scsihw0 => { bus => 0, addr => 5 },
+ 'pci.3' => { bus => 0, addr => 5 }, #can also be used for virtio-scsi-single bridge
scsihw1 => { bus => 0, addr => 6 },
ahci0 => { bus => 0, addr => 7 },
qga0 => { bus => 0, addr => 8 },
'virtio13' => { bus => 2, addr => 8 },
'virtio14' => { bus => 2, addr => 9 },
'virtio15' => { bus => 2, addr => 10 },
+ 'virtioscsi0' => { bus => 3, addr => 1 },
+ 'virtioscsi1' => { bus => 3, addr => 2 },
+ 'virtioscsi2' => { bus => 3, addr => 3 },
+ 'virtioscsi3' => { bus => 3, addr => 4 },
+ 'virtioscsi4' => { bus => 3, addr => 5 },
+ 'virtioscsi5' => { bus => 3, addr => 6 },
+ 'virtioscsi6' => { bus => 3, addr => 7 },
+ 'virtioscsi7' => { bus => 3, addr => 8 },
+ 'virtioscsi8' => { bus => 3, addr => 9 },
+ 'virtioscsi9' => { bus => 3, addr => 10 },
+ 'virtioscsi10' => { bus => 3, addr => 11 },
+ 'virtioscsi11' => { bus => 3, addr => 12 },
+ 'virtioscsi12' => { bus => 3, addr => 13 },
+ 'virtioscsi13' => { bus => 3, addr => 14 },
+ 'virtioscsi14' => { bus => 3, addr => 15 },
+ 'virtioscsi15' => { bus => 3, addr => 16 },
+ 'virtioscsi16' => { bus => 3, addr => 17 },
+ 'virtioscsi17' => { bus => 3, addr => 18 },
+ 'virtioscsi18' => { bus => 3, addr => 19 },
+ 'virtioscsi19' => { bus => 3, addr => 20 },
+ 'virtioscsi20' => { bus => 3, addr => 21 },
+ 'virtioscsi21' => { bus => 3, addr => 22 },
+ 'virtioscsi22' => { bus => 3, addr => 23 },
+ 'virtioscsi23' => { bus => 3, addr => 24 },
+ 'virtioscsi24' => { bus => 3, addr => 25 },
+ 'virtioscsi25' => { bus => 3, addr => 26 },
+ 'virtioscsi26' => { bus => 3, addr => 27 },
+ 'virtioscsi27' => { bus => 3, addr => 28 },
+ 'virtioscsi28' => { bus => 3, addr => 29 },
+ 'virtioscsi29' => { bus => 3, addr => 30 },
+ 'virtioscsi30' => { bus => 3, addr => 31 },
+
};
if (defined($devices->{$id}->{bus}) && defined($devices->{$id}->{addr})) {
return $devices;
}
+sub vm_iothreads_list {
+ my ($vmid) = @_;
+
+ my $res = vm_mon_cmd($vmid, 'query-iothreads');
+
+ my $iothreads = {};
+ foreach my $iothread (@$res) {
+ $iothreads->{ $iothread->{id} } = $iothread->{"thread-id"};
+ }
+
+ return $iothreads;
+}
+
+sub scsihw_infos {
+ my ($conf, $drive) = @_;
+
+ my $maxdev = 0;
+
+ if ($conf->{scsihw} && ($conf->{scsihw} =~ m/^lsi/)) {
+ $maxdev = 7;
+ } elsif ($conf->{scsihw} && ($conf->{scsihw} eq 'virtio-scsi-single')) {
+ $maxdev = 1;
+ } else {
+ $maxdev = 256;
+ }
+
+ my $controller = int($drive->{index} / $maxdev);
+ my $controller_prefix = ($conf->{scsihw} && $conf->{scsihw} eq 'virtio-scsi-single') ? "virtioscsi" : "scsihw";
+
+ return ($maxdev, $controller, $controller_prefix);
+}
+
1;