mirror of
git://git.proxmox.com/git/qemu-server.git
synced 2025-01-25 06:03:52 +03:00
unplug scsi controller if no more disk exist
we need to remove scsi controller, because live migration will crash, as on migration target node, we'll start the vm without controller if no disk exist Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
8bb5e28d50
commit
8ce30ddea0
@ -3353,15 +3353,17 @@ sub vm_deviceunplug {
|
||||
qemu_devicedelverify($vmid, $deviceid);
|
||||
qemu_drivedel($vmid, $deviceid);
|
||||
|
||||
} elsif ($deviceid =~ m/^(lsi)(\d+)$/) {
|
||||
} elsif ($deviceid =~ m/^(scsihw)(\d+)$/) {
|
||||
|
||||
qemu_devicedel($vmid, $deviceid);
|
||||
qemu_devicedelverify($vmid, $deviceid);
|
||||
|
||||
} elsif ($deviceid =~ m/^(scsi)(\d+)$/) {
|
||||
|
||||
qemu_devicedel($vmid, $deviceid);
|
||||
qemu_drivedel($vmid, $deviceid);
|
||||
|
||||
qemu_deletescsihw($conf, $vmid, $deviceid);
|
||||
|
||||
} elsif ($deviceid =~ m/^(net)(\d+)$/) {
|
||||
|
||||
qemu_devicedel($vmid, $deviceid);
|
||||
@ -3476,6 +3478,31 @@ sub qemu_findorcreatescsihw {
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub qemu_deletescsihw {
|
||||
my ($conf, $vmid, $opt) = @_;
|
||||
|
||||
my $device = parse_drive($opt, $conf->{$opt});
|
||||
|
||||
my $maxdev = ($conf->{scsihw} && ($conf->{scsihw} !~ m/^lsi/)) ? 256 : 7;
|
||||
my $controller = int($device->{index} / $maxdev);
|
||||
|
||||
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_add_pci_bridge {
|
||||
my ($storecfg, $conf, $vmid, $device) = @_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user