]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/QemuServer.pm
PCI: use warnings/strict and fix setting $vga from config2command
[qemu-server.git] / PVE / QemuServer.pm
index 9b646b56fdd7091cd140806fd7a3bd61cb9fdddd..3be7e240276bc138b8d6cd50a2726ca860b23117 100644 (file)
@@ -3214,7 +3214,7 @@ sub config_to_command {
 
     # host pci device passthrough
     my ($kvm_off, $gpu_passthrough, $legacy_igd) = PVE::QemuServer::PCI::print_hostpci_devices(
-       $vmid, $conf, $devices, $winversion, $q35, $bridges, $arch, $machine_type, $bootorder);
+       $vmid, $conf, $devices, $vga, $winversion, $q35, $bridges, $arch, $machine_type, $bootorder);
 
     # usb devices
     my $usb_dev_features = {};
@@ -4195,39 +4195,6 @@ sub qemu_block_set_io_throttle {
 
 }
 
-# old code, only used to shutdown old VM after update
-sub __read_avail {
-    my ($fh, $timeout) = @_;
-
-    my $sel = new IO::Select;
-    $sel->add($fh);
-
-    my $res = '';
-    my $buf;
-
-    my @ready;
-    while (scalar (@ready = $sel->can_read($timeout))) {
-       my $count;
-       if ($count = $fh->sysread($buf, 8192)) {
-           if ($buf =~ /^(.*)\(qemu\) $/s) {
-               $res .= $1;
-               last;
-           } else {
-               $res .= $buf;
-           }
-       } else {
-           if (!defined($count)) {
-               die "$!\n";
-           }
-           last;
-       }
-    }
-
-    die "monitor read timeout\n" if !scalar(@ready);
-
-    return $res;
-}
-
 sub qemu_block_resize {
     my ($vmid, $deviceid, $storecfg, $volid, $size) = @_;
 
@@ -5969,7 +5936,8 @@ sub update_disk_config {
        my $volid = $drive->{file};
        return if !$volid;
 
-       my $path = $volid_hash->{$volid}->{path} if $volid_hash->{$volid};
+       my $path;
+       $path = $volid_hash->{$volid}->{path} if $volid_hash->{$volid};
        if ($referenced->{$volid} || ($path && $referencedpath->{$path})) {
            print "$prefix remove entry '$opt', its volume '$volid' is in use\n";
            $changes = 1;
@@ -6190,8 +6158,7 @@ sub restore_proxmox_backup_archive {
 
        $fh->seek(0, 0) || die "seek failed - $!\n";
 
-       my $outfd = new IO::File ($tmpfn, "w") ||
-           die "unable to write config for VM $vmid\n";
+       my $outfd = IO::File->new($tmpfn, "w") || die "unable to write config for VM $vmid\n";
 
        my $cookie = { netcount => 0 };
        while (defined(my $line = <$fh>)) {
@@ -6364,8 +6331,7 @@ sub restore_vma_archive {
 
        $fh->seek(0, 0) || die "seek failed - $!\n";
 
-       my $outfd = new IO::File ($tmpfn, "w") ||
-           die "unable to write config for VM $vmid\n";
+       my $outfd = IO::File->new($tmpfn, "w") || die "unable to write config for VM $vmid\n";
 
        my $cookie = { netcount => 0 };
        while (defined(my $line = <$fh>)) {
@@ -6515,11 +6481,9 @@ sub restore_tar_archive {
 
        my $confsrc = "$tmpdir/qemu-server.conf";
 
-       my $srcfd = new IO::File($confsrc, "r") ||
-           die "unable to open file '$confsrc'\n";
+       my $srcfd = IO::File->new($confsrc, "r") || die "unable to open file '$confsrc'\n";
 
-       my $outfd = new IO::File ($tmpfn, "w") ||
-           die "unable to write config for VM $vmid\n";
+       my $outfd = IO::File->new($tmpfn, "w") || die "unable to write config for VM $vmid\n";
 
        my $cookie = { netcount => 0 };
        while (defined (my $line = <$srcfd>)) {
@@ -6574,6 +6538,7 @@ sub do_snapshots_with_qemu {
 
     my $storage_name = PVE::Storage::parse_volume_id($volid);
     my $scfg = $storecfg->{ids}->{$storage_name};
+    die "could not find storage '$storage_name'\n" if !defined($scfg);
 
     if ($qemu_snap_storage->{$scfg->{type}} && !$scfg->{krbd}){
        return 1;