Am 17.11.22 um 11:50 schrieb Markus Frank:>>> @@ -2113,6 +2171,17 @@ sub parse_guest_agent { >>> return $res; >>> } >>> +sub parse_memory_encryption { >>> + my ($value) = @_; >>> + >>> + return if !$value; >>> + >>> + my $res = eval { parse_property_string($memory_encryption_fmt, >>> $value) }; >>> + warn $@ if $@; >>> + return $res; >>> +} >> >> Why not fail if parsing fails? > replaced warn with die
You can also just remove the eval to make the error propagate ;) And I guess the whole helper could be replaced at the call side with an inline parse_property_string($memory_encryption_fmt, $value) if $value but no big deal. >>> + # Get reduced-phys-bits & cbitpos from QMP, if not set >>> + if ( >>> + !$memory_encryption->{'reduced-phys-bits'} >>> + || !$memory_encryption->{cbitpos} >>> + ) { >>> + my $fakevmid = -1; >>> + my $qemu_cmd = get_command_for_arch($arch); >>> + my $pidfile = >>> PVE::QemuServer::Helpers::pidfile_name($fakevmid); >>> + my $default_machine = $default_machines->{$arch}; >>> + my $cmd = [ >>> + $qemu_cmd, >>> + '-machine', $default_machine, >>> + '-display', 'none', >>> + '-chardev', >>> "socket,id=qmp,path=/var/run/qemu-server/$fakevmid.qmp,server=on,wait=off", >>> + '-mon', 'chardev=qmp,mode=control', >>> + '-pidfile', $pidfile, >>> + '-S', '-daemonize' >>> + ]; >> >> Instead of daemonizing, pidfile etc. we could also use --qmp stdio and >> pass the commands via stdin like: >> {"execute": "qmp_capabilities"} >> {"execute": "query-sev-capabilities"} >> {"execute": "quit"} >> which might be a bit more straight-forward. But maybe we prefer re-using >> the existing infrastructure with the fake ID, not sure? > What would be the best way to send stdin to "kvm -qmp stdio" here? > > Not the same way like I would do in shell or yes?: > echo '{"execute": "qmp_capabilities"} {"execute": > "query-sev-capabilities"} {"execute": "quit"}' | kvm -qmp stdio The run_command helper can take an "input => $input" parameter. Haven't actually used it myself, but there are existing examples in our code base :) _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel