]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/API2/Qemu.pm
bug fix: allow to set devices directly (-ide1 /dev/XYZ)
[qemu-server.git] / PVE / API2 / Qemu.pm
index 380dec44ad349f0201bb5f557af120153eb2076e..a1d4ed25365c1d55927ffe77ceb6319a3c260e38 100644 (file)
@@ -85,21 +85,25 @@ my $create_disks = sub {
            delete $disk->{format}; # no longer needed
            $res->{$ds} = PVE::QemuServer::print_drive($vmid, $disk);
        } else {
+
            my $path = $rpcenv->check_volume_access($authuser, $storecfg, $vmid, $volid);
-           PVE::Storage::activate_volumes($storecfg, [ $volid ])
-               if PVE::Storage::parse_volume_id ($volid, 1);
+           
+           my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
 
-           my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
-           my $dl = PVE::Storage::vdisk_list($storecfg, $storeid, undef);
            my $foundvolid = undef;
 
-           PVE::Storage::foreach_volid($dl, sub {
-               my ($volumeid) = @_;
-               if($volumeid eq $volid) {
-                   $foundvolid = 1;
-                   return;
-               }
-           });
+           if ($storeid) {
+               PVE::Storage::activate_volumes($storecfg, [ $volid ]);
+               my $dl = PVE::Storage::vdisk_list($storecfg, $storeid, undef);
+
+               PVE::Storage::foreach_volid($dl, sub {
+                   my ($volumeid) = @_;
+                   if($volumeid eq $volid) {
+                       $foundvolid = 1;
+                       return;
+                   }
+               });
+           }
        
            die "image '$path' does not exists\n" if (!(-f $path || -b $path || $foundvolid));
            $res->{$ds} = $settings->{$ds};
@@ -674,6 +678,15 @@ my $vmconfig_update_disk = sub {
                &$vmconfig_delete_option($rpcenv, $authuser, $conf, $storecfg, $vmid, $opt, $force);
                $conf = PVE::QemuServer::load_config($vmid); # update/reload
            }
+
+            if($drive->{bps} != $old_drive->{bps} ||
+               $drive->{bps_rd} != $old_drive->{bps_rd} ||
+               $drive->{bps_wr} != $old_drive->{bps_wr} ||
+               $drive->{iops} != $old_drive->{iops} ||
+               $drive->{iops_rd} != $old_drive->{iops_rd} ||
+               $drive->{iops_wr} != $old_drive->{iops_wr} ) {
+               PVE::QemuServer::qemu_block_set_io_throttle($vmid,"drive-$opt",$drive->{bps}, $drive->{bps_rd}, $drive->{bps_wr}, $drive->{iops}, $drive->{iops_rd}, $drive->{iops_wr}) if !PVE::QemuServer::drive_is_cdrom($drive);
+            }
        }
     }
 
@@ -1141,7 +1154,7 @@ __PACKAGE__->register_method({
        # test if VM exists
        my $conf = PVE::QemuServer::load_config($param->{vmid});
 
-       my $vmstatus = PVE::QemuServer::vmstatus($param->{vmid});
+       my $vmstatus = PVE::QemuServer::vmstatus($param->{vmid}, 1);
        my $status = $vmstatus->{$param->{vmid}};
 
        $status->{ha} = &$vm_is_ha_managed($param->{vmid});
@@ -1715,7 +1728,7 @@ __PACKAGE__->register_method({
 
        my $res = '';
        eval {
-           $res = PVE::QemuServer::vm_monitor_command($vmid, $param->{command});
+           $res = PVE::QemuServer::vm_human_monitor_command($vmid, $param->{command});
        };
        $res = "ERROR: $@" if $@;