Qemu is a machine emulator that can run operating systems and programs for one machine on a different machine. Mostly it is not used as emulator but as virtualizer in collaboration with KVM or XEN kernel components. In that case it utilizes the virtualization technology of the hardware to virtualize guests.
While qemu has a command line interface and a monitor to interact with running guests those is rarely used that way for other means than development purposes. Libvirt provides an abstraction from specific versions and hypervisors and encapsulates some workarounds and best practices.
Upgrading the machine type
You might want to update your machine type of an existing defined guest to:
to pick up latest security fixes and features
continue using a guest created on a now unsupported release
In general it is recommended to update machine types when upgrading qemu/kvm to a new major version. But this can likely never be an automated task as this change is guest visible. The guest devices might change in appearance, new features will be announced to the guest and so on. Linux is usually very good at tolerating such changes, but it depends so much on the setup and workload of the guest that this has to be evaluated by the owner/admin of the system. Other operating systems where known to often have severe impacts by changing the hardware. Consider a machine type change similar to replacing all devices and firmware of a physical machine to the latest revision - all considerations that apply there apply to evaluating a machine type upgrade as well.
As usual with major configuration changes it is wise to back up your guest definition and disk state to be able to do a rollback just in case. There is no integrated single command to update the machine type via virsh or similar tools. It is a normal part of your machine definition. And therefore updated the same way as most others.
First shutdown your machine and wait until it has reached that state.
virsh shutdown <yourmachine> # wait virsh list --inactive # should now list your machine as "shut off"
Then edit the machine definition and find the type in the type tag at the machine attribute.
virsh edit <yourmachine> <type arch='x86_64' machine='pc-i440fx-xenial'>hvm</type>
Change this to the value you want. If you need to check what types are available via "-M ?" Note that while providing upstream types as convenience only Ubuntu types are supported. There you can also see what the current default would be. In general it is strongly recommended that you change to newer types if possible to exploit newer features, but also to benefit of bugfixes that only apply to the newer device virtualization.
kvm -M ? # lists machine types, e.g. pc-i440fx-xenial Ubuntu 16.04 PC (i440FX + PIIX, 1996) (default) ...
After this you can start your guest again. You can check the current machine type from guest and host depending on your needs.
virsh start <yourmachine> # check from host, via dumping the active xml definition virsh dumpxml <yourmachine> | xmllint --xpath "string(//domain/os/type/@machine)" - # or from the guest via dmidecode (if supported) sudo dmidecode | grep Product -A 1 Product Name: Standard PC (i440FX + PIIX, 1996) Version: pc-i440fx-xenial
If you keep non-live definitions around like xml files remember to update those as well.