further code cleanups

This commit is contained in:
Dietmar Maurer 2011-10-11 13:28:50 +02:00
parent e8b9c17cac
commit 1dc4f49676

View File

@ -1302,7 +1302,7 @@ sub create_disks {
die "image '$path' does not exists\n"; die "image '$path' does not exists\n";
} }
} }
PVE::QemuServer::vm_deviceadd ($storecfg,$vmid,$ds, $disk); PVE::QemuServer::vm_deviceadd($storecfg, $vmid, $ds, $disk);
}); });
}; };
@ -2248,31 +2248,32 @@ sub next_migrate_port {
sub vm_devices_list { sub vm_devices_list {
my ($vmid) = @_; my ($vmid) = @_;
my $res = vm_monitor_command ($vmid, "info pci", 1); my $res = vm_monitor_command ($vmid, "info pci", 1);
my @lines = split ("\n", $res); my @lines = split ("\n", $res);
my $devices; my $devices;
my $bus; my $bus;
my $addr; my $addr;
my $id; my $id;
foreach my $line (@lines) {
$line =~ s/^\s+//; foreach my $line (@lines) {
if ($line =~ m/^Bus (\d+), device (\d+), function (\d+):$/) { $line =~ s/^\s+//;
$bus=$1; if ($line =~ m/^Bus (\d+), device (\d+), function (\d+):$/) {
$addr=$2; $bus=$1;
} $addr=$2;
if ($line =~ m/^id "([a-z][a-z_\-]*\d*)"$/) { }
if ($line =~ m/^id "([a-z][a-z_\-]*\d*)"$/) {
$id=$1; $id=$1;
$devices->{$id}->{bus}=$bus; $devices->{$id}->{bus}=$bus;
$devices->{$id}->{addr}=$addr; $devices->{$id}->{addr}=$addr;
} }
} }
return $devices; return $devices;
} }
sub vm_deviceadd { sub vm_deviceadd {
my ($storecfg,$vmid, $deviceid,$device) = @_; my ($storecfg, $vmid, $deviceid, $device) = @_;
my $cfspath = cfs_config_path($vmid); my $cfspath = cfs_config_path($vmid);
my $conf = PVE::Cluster::cfs_read_file($cfspath) || {}; my $conf = PVE::Cluster::cfs_read_file($cfspath) || {};
@ -2281,9 +2282,9 @@ sub vm_deviceadd {
if($deviceid =~ m/^(virtio)(\d+)$/) { if($deviceid =~ m/^(virtio)(\d+)$/) {
my $drive = print_drive_full($storecfg,$vmid, $device); my $drive = print_drive_full($storecfg, $vmid, $device);
vm_monitor_command($vmid, "drive_add auto $drive", 1); vm_monitor_command($vmid, "drive_add auto $drive", 1);
my $devicefull = print_drivedevice_full($storecfg,$vmid, $device); my $devicefull = print_drivedevice_full($storecfg, $vmid, $device);
vm_monitor_command($vmid, "device_add $devicefull", 1); vm_monitor_command($vmid, "device_add $devicefull", 1);
} }