[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 03/58] target/i386: Parse TDX vm type
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH v2 03/58] target/i386: Parse TDX vm type |
Date: |
Mon, 21 Aug 2023 09:27:43 +0100 |
User-agent: |
Mutt/2.2.9 (2022-11-12) |
On Fri, Aug 18, 2023 at 05:49:46AM -0400, Xiaoyao Li wrote:
> TDX VM requires VM type KVM_X86_TDX_VM to be passed to
> kvm_ioctl(KVM_CREATE_VM).
>
> If tdx-guest object is specified to confidential-guest-support, like,
>
> qemu -machine ...,confidential-guest-support=tdx0 \
> -object tdx-guest,id=tdx0,...
>
> it parses VM type as KVM_X86_TDX_VM.
>
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
> target/i386/kvm/kvm.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
> index 62f237068a3a..77f4772afe6c 100644
> --- a/target/i386/kvm/kvm.c
> +++ b/target/i386/kvm/kvm.c
> @@ -32,6 +32,7 @@
> #include "sysemu/runstate.h"
> #include "kvm_i386.h"
> #include "sev.h"
> +#include "tdx.h"
> #include "xen-emu.h"
> #include "hyperv.h"
> #include "hyperv-proto.h"
> @@ -158,6 +159,7 @@ static int kvm_get_one_msr(X86CPU *cpu, int index,
> uint64_t *value);
> static const char* vm_type_name[] = {
> [KVM_X86_DEFAULT_VM] = "default",
> [KVM_X86_SW_PROTECTED_VM] = "sw-protected-vm",
> + [KVM_X86_TDX_VM] = "tdx",
> };
>
> int kvm_get_vm_type(MachineState *ms, const char *vm_type)
> @@ -170,12 +172,18 @@ int kvm_get_vm_type(MachineState *ms, const char
> *vm_type)
> kvm_type = KVM_X86_DEFAULT_VM;
> } else if (!g_ascii_strcasecmp(vm_type, "sw-protected-vm")) {
> kvm_type = KVM_X86_SW_PROTECTED_VM;
> - } else {
> + } else if (!g_ascii_strcasecmp(vm_type, "tdx")) {
> + kvm_type = KVM_X86_TDX_VM;
> + }else {
> error_report("Unknown kvm-type specified '%s'", vm_type);
> exit(1);
> }
> }
This whole block of code should go away - as this should not exist
as a user visible property. It should be sufficient to use the
tdx-guest object type to identify use of TDX.
>
> + if (ms->cgs && object_dynamic_cast(OBJECT(ms->cgs), TYPE_TDX_GUEST)) {
> + kvm_type = KVM_X86_TDX_VM;
> + }
> +
> /*
> * old KVM doesn't support KVM_CAP_VM_TYPES and KVM_X86_DEFAULT_VM
> * is always supported
> --
> 2.34.1
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- [PATCH v2 00/58] TDX QEMU support, Xiaoyao Li, 2023/08/18
- [PATCH v2 03/58] target/i386: Parse TDX vm type, Xiaoyao Li, 2023/08/18
- Re: [PATCH v2 03/58] target/i386: Parse TDX vm type,
Daniel P . Berrangé <=
- [PATCH v2 04/58] target/i386: Introduce kvm_confidential_guest_init(), Xiaoyao Li, 2023/08/18
- [PATCH v2 05/58] i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context, Xiaoyao Li, 2023/08/18
- [PATCH v2 06/58] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES, Xiaoyao Li, 2023/08/18
[PATCH v2 07/58] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object, Xiaoyao Li, 2023/08/18