]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/QemuServer.pm
fix #2510: hostpci: always check if device exists
[qemu-server.git] / PVE / QemuServer.pm
index 0d0e6108914e73bf059ffe0ad406302cc4ace3c2..6267cae09538413f2b014c8a80d94e9c508e5da3 100644 (file)
@@ -2246,13 +2246,11 @@ sub parse_hostpci {
     my @idlist = split(/;/, $res->{host});
     delete $res->{host};
     foreach my $id (@idlist) {
-       if ($id =~ m/\./) { # full id 00:00.1
-           push @{$res->{pciid}}, {
-               id => $id,
-           };
-       } else { # partial id 00:00
-           $res->{pciid} = PVE::SysFSTools::lspci($id);
+       my $devs = PVE::SysFSTools::lspci($id);
+       if (!scalar(@$devs)) {
+           die "no pci device found for '$id'\n";
        }
+       push @{$res->{pciid}}, @$devs;
     }
     return $res;
 }
@@ -5369,7 +5367,6 @@ sub vm_start {
          my $pcidevices = $d->{pciid};
          foreach my $pcidevice (@$pcidevices) {
                my $pciid = $pcidevice->{id};
-               $pciid = "0000:$pciid" if $pciid !~ m/^[0-9a-f]{4}:/;
 
                my $info = PVE::SysFSTools::pci_device_info("$pciid");
                die "IOMMU not present\n" if !PVE::SysFSTools::check_iommu_support();
@@ -6722,7 +6719,7 @@ sub qemu_img_convert {
     my $cachemode;
     my $src_path;
     my $src_is_iscsi = 0;
-    my $src_format = 'raw';
+    my $src_format;
 
     if ($src_storeid) {
        PVE::Storage::activate_volumes($storecfg, [$src_volid], $snapname);
@@ -6747,14 +6744,15 @@ sub qemu_img_convert {
 
     my $cmd = [];
     push @$cmd, '/usr/bin/qemu-img', 'convert', '-p', '-n';
-    push @$cmd, '-l', "snapshot.name=$snapname" if($snapname && $src_format eq "qcow2");
+    push @$cmd, '-l', "snapshot.name=$snapname"
+       if $snapname && $src_format && $src_format eq "qcow2";
     push @$cmd, '-t', 'none' if $dst_scfg->{type} eq 'zfspool';
     push @$cmd, '-T', $cachemode if defined($cachemode);
 
     if ($src_is_iscsi) {
        push @$cmd, '--image-opts';
        $src_path = convert_iscsi_path($src_path);
-    } else {
+    } elsif ($src_format) {
        push @$cmd, '-f', $src_format;
     }