virt-xml: Fix --define with stdin XML

And rework the `refresh-machine-type` testcase to trigger it

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2024-09-23 10:34:41 -04:00
parent b83a1b0d0f
commit de00ff7661
4 changed files with 29 additions and 19 deletions

View File

@ -1,17 +1,10 @@
<domain type="kvm">
<name>test</name>
<uuid>6695eb01-f6a4-8304-79aa-97f2502e193f</uuid>
<memory unit="KiB">8388608</memory>
<currentMemory unit="KiB">2097152</currentMemory>
<vcpu placement="static">2</vcpu>
<os>
<type arch="x86_64" machine="q35">hvm</type>
<boot dev="hd"/>
</os>
<clock offset="utc"/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
</devices>
</domain>
<currentMemory unit="KiB">2097152</currentMemory>
<vcpu placement="static">2</vcpu>
<os>
- <type arch="x86_64" machine="pc-q35-foobar">hvm</type>
+ <type arch="x86_64" machine="q35">hvm</type>
<boot dev="hd"/>
</os>
<clock offset="utc"/>
Domain 'refresh-machine' defined successfully.

View File

@ -0,0 +1,17 @@
<domain type='kvm'>
<name>refresh-machine</name>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine="pc-q35-foobar">hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
</devices>
</domain>

View File

@ -1417,7 +1417,7 @@ c.add_invalid("test --add-device --xml ./@foo=bar", grep="--xml can only be used
c.add_invalid("test-for-virtxml --edit --boot refresh-machine-type=yes", grep="Don't know how to refresh")
c.add_compare("test --print-xml --edit --vcpus 7", "print-xml") # test --print-xml
c.add_compare("--edit --cpu host-passthrough", "stdin-edit", input_file=(_VIRTXMLDIR + "virtxml-stdin-edit.xml")) # stdin test
c.add_compare("--connect %(URI-KVM-X86)s --edit --boot refresh-machine-type=yes", "refresh-machine-type", input_file=(_VIRTXMLDIR + "virtxml-stdin-edit.xml")) # refresh-machine-type test. we need to use stdin XML since we can't get the libvirt testdriver to start with the machine XML we need
c.add_compare("--connect %(URI-KVM-X86)s --edit --print-diff --define --boot refresh-machine-type=yes", "refresh-machine-type", input_file=(_VIRTXMLDIR + "virtxml-refresh-machine-in.xml")) # refresh-machine-type test. we need to use stdin XML since we can't get the libvirt testdriver to start with the machine XML we need
c.add_compare("--build-xml --cpu pentium3,+x2apic", "build-cpu")
c.add_compare("--build-xml --tpm path=/dev/tpm", "build-tpm")
c.add_compare("--build-xml --blkiotune weight=100,device0.path=/dev/sdf,device.weight=200,device0.read_bytes_sec=10000,device0.write_bytes_sec=10000,device0.read_iops_sec=20000,device0.write_iops_sec=20000", "build-blkiotune")

View File

@ -546,7 +546,7 @@ def main(conn=None):
elif vm_is_running and not performed_update:
print_stdout(
_("Changes will take effect after the domain is fully powered off."))
elif defined_xml_is_unchanged(conn, domain, original_xml):
elif defined_xml_is_unchanged(conn, dom, original_xml):
log.warning(_("XML did not change after domain define. You may "
"have changed a value that libvirt is setting by default."))