[PATCH 7/7] qemudomainsnapshotxml2xmltest: Add test case for a snapshot with 'inactiveDomain' element

Peter Krempa posted 7 patches 3 years, 5 months ago
[PATCH 7/7] qemudomainsnapshotxml2xmltest: Add test case for a snapshot with 'inactiveDomain' element
Posted by Peter Krempa 3 years, 5 months ago
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 .../memory-snapshot-inactivedomain.xml        | 148 ++++++++++++++++++
 tests/qemudomainsnapshotxml2xmltest.c         |   2 +
 2 files changed, 150 insertions(+)
 create mode 100644 tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml

diff --git a/tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml b/tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml
new file mode 100644
index 0000000000..3acc6d952b
--- /dev/null
+++ b/tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml
@@ -0,0 +1,148 @@
+<domainsnapshot>
+  <name>test-snap</name>
+  <state>running</state>
+  <creationTime>1661417356</creationTime>
+  <memory snapshot='external' file='/tmp/ble.img'/>
+  <domain type='kvm'>
+    <name>snapshot-inactivedomain</name>
+    <uuid>14beef2c-8cae-4ea8-bf55-e48fe0cd4b73</uuid>
+    <memory unit='KiB'>1024000</memory>
+    <currentMemory unit='KiB'>1024000</currentMemory>
+    <vcpu placement='static' current='1'>8</vcpu>
+    <resource>
+      <partition>/machine</partition>
+    </resource>
+    <os>
+      <type arch='x86_64' machine='pc-i440fx-7.0'>hvm</type>
+      <boot dev='hd'/>
+    </os>
+    <features>
+      <acpi/>
+      <apic/>
+      <vmport state='off'/>
+    </features>
+    <cpu mode='custom' match='exact' check='none'>
+      <model fallback='forbid'>qemu64</model>
+    </cpu>
+    <clock offset='utc'/>
+    <on_poweroff>destroy</on_poweroff>
+    <on_reboot>restart</on_reboot>
+    <on_crash>restart</on_crash>
+    <pm>
+      <suspend-to-mem enabled='no'/>
+      <suspend-to-disk enabled='no'/>
+    </pm>
+    <devices>
+      <emulator>/usr/bin/qemu-system-x86_64</emulator>
+      <controller type='usb' index='0' model='ich9-ehci1'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/>
+      </controller>
+      <controller type='usb' index='0' model='ich9-uhci1'>
+        <master startport='0'/>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>
+      </controller>
+      <controller type='usb' index='0' model='ich9-uhci2'>
+        <master startport='2'/>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/>
+      </controller>
+      <controller type='usb' index='0' model='ich9-uhci3'>
+        <master startport='4'/>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/>
+      </controller>
+      <controller type='virtio-serial' index='0'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+      </controller>
+      <controller type='ide' index='0'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+      </controller>
+      <controller type='scsi' index='0' model='virtio-scsi'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
+      </controller>
+      <controller type='sata' index='0'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
+      </controller>
+      <controller type='pci' index='0' model='pci-root'/>
+      <input type='mouse' bus='ps2'/>
+      <input type='keyboard' bus='ps2'/>
+      <audio id='1' type='none'/>
+      <memballoon model='virtio'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+      </memballoon>
+    </devices>
+    <seclabel type='dynamic' model='selinux' relabel='yes'/>
+  </domain>
+  <inactiveDomain type='kvm'>
+    <name>snapshot-inactivedomain</name>
+    <uuid>14beef2c-8cae-4ea8-bf55-e48fe0cd4b73</uuid>
+    <memory unit='KiB'>1024000</memory>
+    <currentMemory unit='KiB'>1024000</currentMemory>
+    <vcpu placement='static' current='1'>8</vcpu>
+    <os>
+      <type arch='x86_64' machine='pc-i440fx-7.0'>hvm</type>
+      <boot dev='hd'/>
+    </os>
+    <features>
+      <acpi/>
+      <apic/>
+      <vmport state='off'/>
+    </features>
+    <cpu mode='custom' match='exact' check='none'>
+      <model fallback='forbid'>qemu64</model>
+    </cpu>
+    <clock offset='utc'/>
+    <on_poweroff>destroy</on_poweroff>
+    <on_reboot>restart</on_reboot>
+    <on_crash>restart</on_crash>
+    <pm>
+      <suspend-to-mem enabled='no'/>
+      <suspend-to-disk enabled='no'/>
+    </pm>
+    <devices>
+      <emulator>/usr/bin/qemu-system-x86_64</emulator>
+      <controller type='usb' index='0' model='ich9-ehci1'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/>
+      </controller>
+      <controller type='usb' index='0' model='ich9-uhci1'>
+        <master startport='0'/>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>
+      </controller>
+      <controller type='usb' index='0' model='ich9-uhci2'>
+        <master startport='2'/>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/>
+      </controller>
+      <controller type='usb' index='0' model='ich9-uhci3'>
+        <master startport='4'/>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/>
+      </controller>
+      <controller type='pci' index='0' model='pci-root'/>
+      <controller type='virtio-serial' index='0'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+      </controller>
+      <controller type='ide' index='0'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+      </controller>
+      <controller type='scsi' index='0' model='virtio-scsi'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
+      </controller>
+      <controller type='sata' index='0'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
+      </controller>
+      <input type='mouse' bus='ps2'/>
+      <input type='keyboard' bus='ps2'/>
+      <audio id='1' type='none'/>
+      <memballoon model='virtio'>
+        <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+      </memballoon>
+    </devices>
+  </inactiveDomain>
+  <cookie>
+    <cpu mode='custom' match='exact' check='full'>
+      <model fallback='forbid'>qemu64</model>
+      <feature policy='require' name='x2apic'/>
+      <feature policy='require' name='hypervisor'/>
+      <feature policy='require' name='lahf_lm'/>
+      <feature policy='disable' name='svm'/>
+    </cpu>
+    <slirpHelper/>
+  </cookie>
+</domainsnapshot>
diff --git a/tests/qemudomainsnapshotxml2xmltest.c b/tests/qemudomainsnapshotxml2xmltest.c
index 6881d692ee..a09404a9d5 100644
--- a/tests/qemudomainsnapshotxml2xmltest.c
+++ b/tests/qemudomainsnapshotxml2xmltest.c
@@ -160,6 +160,8 @@ mymain(void)
     DO_TEST_OUT("external_vm_redefine", "c7a5fdbd-edaf-9455-926a-d65c16db1809",
                 0);

+    DO_TEST_OUT("memory-snapshot-inactivedomain", "14beef2c-8cae-4ea8-bf55-e48fe0cd4b73", 0);
+
     DO_TEST_INOUT("empty", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8",
                   1386166249, 0);
     DO_TEST_INOUT("noparent", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8",
-- 
2.37.1
Re: [PATCH 7/7] qemudomainsnapshotxml2xmltest: Add test case for a snapshot with 'inactiveDomain' element
Posted by Daniel P. Berrangé 3 years, 4 months ago
On Thu, Aug 25, 2022 at 11:46:10AM +0200, Peter Krempa wrote:
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  .../memory-snapshot-inactivedomain.xml        | 148 ++++++++++++++++++
>  tests/qemudomainsnapshotxml2xmltest.c         |   2 +
>  2 files changed, 150 insertions(+)
>  create mode 100644 tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml

snip

> diff --git a/tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml b/tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml
> new file mode 100644
> index 0000000000..3acc6d952b
> --- /dev/null
> +++ b/tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml
> @@ -0,0 +1,148 @@


> +  <cookie>
> +    <cpu mode='custom' match='exact' check='full'>
> +      <model fallback='forbid'>qemu64</model>
> +      <feature policy='require' name='x2apic'/>
> +      <feature policy='require' name='hypervisor'/>
> +      <feature policy='require' name='lahf_lm'/>
> +      <feature policy='disable' name='svm'/>
> +    </cpu>
> +    <slirpHelper/>
> +  </cookie>
> +</domainsnapshot>

As best I can tell this  <cookie> element is undocumented and further
contains arbitrary undocumented hypervisor specific XML content :-(

This is really horrible and really should have been hidden behind a
driver specific XML namespace.

Can someone explain more about the <cookie> ?

If this is a strictly output only element, which applications are
not expected to parse or interpret, just pass along "as is", then
it is possible we can fix/improve this, to clearly demarcate what
is our public XML schema and what is opaque driver specific schema.

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 :|
Re: [PATCH 7/7] qemudomainsnapshotxml2xmltest: Add test case for a snapshot with 'inactiveDomain' element
Posted by Peter Krempa 3 years, 4 months ago
On Mon, Sep 26, 2022 at 12:07:07 +0100, Daniel P. Berrangé wrote:
> On Thu, Aug 25, 2022 at 11:46:10AM +0200, Peter Krempa wrote:
> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > ---
> >  .../memory-snapshot-inactivedomain.xml        | 148 ++++++++++++++++++
> >  tests/qemudomainsnapshotxml2xmltest.c         |   2 +
> >  2 files changed, 150 insertions(+)
> >  create mode 100644 tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml
> 
> snip
> 
> > diff --git a/tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml b/tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml
> > new file mode 100644
> > index 0000000000..3acc6d952b
> > --- /dev/null
> > +++ b/tests/qemudomainsnapshotxml2xmlout/memory-snapshot-inactivedomain.xml
> > @@ -0,0 +1,148 @@
> 
> 
> > +  <cookie>
> > +    <cpu mode='custom' match='exact' check='full'>
> > +      <model fallback='forbid'>qemu64</model>
> > +      <feature policy='require' name='x2apic'/>
> > +      <feature policy='require' name='hypervisor'/>
> > +      <feature policy='require' name='lahf_lm'/>
> > +      <feature policy='disable' name='svm'/>
> > +    </cpu>
> > +    <slirpHelper/>
> > +  </cookie>
> > +</domainsnapshot>
> 
> As best I can tell this  <cookie> element is undocumented and further
> contains arbitrary undocumented hypervisor specific XML content :-(
> 
> This is really horrible and really should have been hidden behind a
> driver specific XML namespace.
> 
> Can someone explain more about the <cookie> ?

AFAIK it's something akin to the migration cookie, but for the save
image/snapshot it's stored inside the snapshot XML, rather than passed
via a side-band.

IIUC it's required also in the snapshot XML (not just in the save image
XML) as internal snapshots don't store the XML in-band.

> If this is a strictly output only element, which applications are
> not expected to parse or interpret, just pass along "as is", then
> it is possible we can fix/improve this, to clearly demarcate what
> is our public XML schema and what is opaque driver specific schema.

It's indeed private and driver specific. There's a driver specific
callback to format it.