From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 87EB59199 for ; Thu, 17 Nov 2022 12:27:40 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 701492B826 for ; Thu, 17 Nov 2022 12:27:40 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 17 Nov 2022 12:27:38 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BFFD643E03 for ; Thu, 17 Nov 2022 12:27:38 +0100 (CET) Message-ID: <335ab365-5286-d88a-2694-2feb087944ce@proxmox.com> Date: Thu, 17 Nov 2022 12:27:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Content-Language: en-US To: Markus Frank , Proxmox VE development discussion References: <20221111142716.235955-1-m.frank@proxmox.com> <20221111142716.235955-2-m.frank@proxmox.com> <72a2cce6-22c5-52ed-ac5e-8fdebc4beedb@proxmox.com> From: Fiona Ebner In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: =?UTF-8?Q?0=0A=09?=AWL 0.028 Adjusted score from AWL reputation of From: =?UTF-8?Q?address=0A=09?=BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict =?UTF-8?Q?Alignment=0A=09?=NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF =?UTF-8?Q?Record=0A=09?=SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH qemu-server v2 1/2] QEMU AMD SEV enable X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2022 11:27:40 -0000 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 :)