<div dir="ltr">Hello,<div>      I'm new to libvirt. I have tried to launch a sev vm with secret injection recently, and I found the command domsetlaunchsecstate is what I need. But I had some problem to make it work. Here is what I did to use this command.</div><div>1. run command: virsh create sev-guest.xml</div><div>2. create secret header file and secret file.</div><div>3. run command: virsh domsetlaunchsecstate sev-guest-1 --secrethdr <hdr-filename> --secret <secret-filename> .</div><div>But it will report this error: SEV: not in correct state.</div><div>I think it is because the vm is not in a paused state. So how can I launch a sev vm which is in a paused state? How should I revise my xml file?</div><div><br></div><div>The sev-guest.xml I use is as follows:</div><div> <font color="#000000" style="background-color:rgb(243,243,243)"><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre"><</span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre">domain</span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre"> </span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre">type</span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre">=</span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre">"kvm"</span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre">></span></font></div><div style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre"><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <name>sev-guest-1</name></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <uuid>d50a4205-40e0-4482-b0dc-f26bb4a1a9ff</uuid></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <metadata></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <libosinfo:libosinfo xmlns:libosinfo="<a href="http://libosinfo.org/xmlns/libvirt/domain/1.0">http://libosinfo.org/xmlns/libvirt/domain/1.0</a>"></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <libosinfo:os id="<a href="http://ubuntu.com/ubuntu/16.04">http://ubuntu.com/ubuntu/16.04</a>"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </libosinfo:libosinfo></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  </metadata></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <memory>4194304</memory></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <currentMemory>4194304</currentMemory></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <memtune></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <hard_limit>4563402</hard_limit></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  </memtune></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <vcpu>32</vcpu></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <cpu mode='custom' match='exact' check='partial'></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">     <model fallback='forbid'>EPYC</model></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  </cpu></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <os></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <type arch="x86_64" machine="q35">hvm</type></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <loader readonly="yes" type="pflash">/data01/OVMF.fd</loader></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <nvram template="/data01/OVMF.fd">/var/lib/libvirt/qemu/nvram/sev-guest-1_VARS.fd</nvram></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <boot dev="hd"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  </os></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  </font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <features></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <acpi/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <apic/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  </features></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <clock offset="utc"></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <timer name="rtc" tickpolicy="catchup"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <timer name="pit" tickpolicy="delay"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <timer name="hpet" present="no"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  </clock></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <pm></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <suspend-to-mem enabled="no"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <suspend-to-disk enabled="no"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  </pm></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <devices></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <emulator>/usr/local/bin/qemu-system-x86_64</emulator></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <disk type="file" device="disk"></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <driver name="qemu" type="qcow2"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <source file="/data01/AMDSEV/sev-guest-1.qcow2"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <target dev="sda" bus="scsi"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </disk></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <controller type="scsi" index="0" model="virtio-scsi"></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <driver iommu="on"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </controller></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <controller type="virtio-serial" index="0"></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <driver iommu="on"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </controller></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <controller type="usb" index="0" model="ich9-ehci1"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <controller type="usb" index="0" model="ich9-uhci1"></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <master startport="0"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </controller></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <controller type="usb" index="0" model="ich9-uhci2"></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <master startport="2"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </controller></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <controller type="usb" index="0" model="ich9-uhci3"></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <master startport="4"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </controller></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <controller type='pci' index='1' model='pcie-root-port'></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <model name='pcie-root-port'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <target chassis='1' port='0x8'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <alias name='pci.1'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </controller></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <controller type='pci' index='2' model='pcie-root-port'></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <model name='pcie-root-port'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <target chassis='2' port='0x9'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <alias name='pci.2'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </controller></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <controller type='pci' index='3' model='pcie-root-port'></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <model name='pcie-root-port'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <target chassis='3' port='0xa'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <alias name='pci.3'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </controller></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <controller type='pci' index='4' model='pcie-root-port'></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <model name='pcie-root-port'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <target chassis='4' port='0xb'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <alias name='pci.4'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x3'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </controller></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <console type="pty"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <input type="tablet" bus="usb"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <graphics type="vnc" port="-1" listen="127.0.0.1"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <video></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <model type="vga"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <address type='pci' slot='0x07'/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </video></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <memballoon model="virtio"></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">      <driver iommu="on"/></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    </memballoon></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  </devices></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  <launchSecurity type="sev"></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <cbitpos>51</cbitpos></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <reducedPhysBits>1</reducedPhysBits></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <policy>0x05</policy></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <dhCert>XXXXXXXXX</dhCert></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">    <session>XXXXXXXXXXXXXXXXx</session></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">  </launchSecurity></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)"></domain></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)"><br></font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">Thank you in advance,</font></div><div style=""><font color="#000000" style="background-color:rgb(243,243,243)">Peixuan</font></div><div><span style="color:rgb(128,128,128)"><br></span></div></div></div>