On April 1, 2021 12:19 pm, Dominic Jäger wrote: > On Wed, Mar 31, 2021 at 05:12:28PM +0200, Fabian Grünbichler wrote: >> this is starting to shape up nicely. as promised, I now took a stab at >> (roughly!) integrating this into our regular flow (see diff below): >> .... >> >> - we could likely drop the separate import_disk API call, and let the >> `importdisk` CLI command prepare parameters for a regular VM config >> update > I think dropping importdisk is a good idea, too. > >> I'm sure I've missed some corner cases, as I've only tested create_vm >> with importing, and not the other newly exposed APIs. > > I didn't get the importdisk API to work yet. > But I'd look closer at stuff like that > if (!$device_options) { > $device_options = "$storeid:0"; <=== should be -1 > } > only if we keep it? > > One thing is important: That import parameter was at the place of the default > storage
yes, I just roughly moved the code to see whether the approach works out and then tested a single entry point. if there are no objections into merging it like that, it would definitely need a cleanup and more testing :) > > PVE/API2/Qemu.pm | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm > index 41e1ab7..73af497 100644 > --- a/PVE/API2/Qemu.pm > +++ b/PVE/API2/Qemu.pm > @@ -1469,7 +1469,7 @@ my $update_vm_api = sub { > PVE::QemuServer::vmconfig_register_unused_drive($storecfg, > $vmid, $conf, PVE::QemuServer::parse_drive($opt, $conf->{pending}->{$opt})) > if defined($conf->{pending}->{$opt}); > > - &$create_disks($rpcenv, $authuser, $conf->{pending}, $arch, > $storecfg, $vmid, undef, {$opt => $param->{$opt}}, {$opt => > $import_devices->{$opt}}); > + &$create_disks($rpcenv, $authuser, $conf->{pending}, $arch, > $storecfg, $vmid, undef, {$opt => $param->{$opt}}, undef, {$opt => > $import_devices->{$opt}}); > } elsif ($opt =~ m/^serial\d+/) { > if ((!defined($conf->{$opt}) || $conf->{$opt} eq 'socket') > && $param->{$opt} eq 'socket') { > $rpcenv->check_vm_perm($authuser, $vmid, undef, > ['VM.Config.HWType']); > > >> stat shows how much boilerplace/duplication this removes, although there >> is probably even more potential here since `create_vm` partly duplicates >> the `update_vm_api` sub that ends up calling `create_disks`: > Is that urgent? no, it's just something I noticed since I added the same code in the same context in two places ;) _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel