On Fri, Dec 04, 2020 at 13:17:52 +0100, Peter Krempa wrote:
On Thu, Dec 03, 2020 at 13:36:23 +0100, Michal Privoznik wrote:
> QEMU gained this new virtio-mem model. It's similar to pc-dimm
> in a sense that guest uses it as memory, but in a sense very
> different from it as it can dynamically change allocation,
> without need for hotplug. More specifically, the device has two
> attributes more (it has more of course, but these two are
> important here):
>
> 1) block-size - the granularity of the device. You can imagine
> the device being divided into blocks, each 'block-size' long.
>
> 2) requested-size - the portion of the device that is in use by
> the guest.
>
> And it all works like this: at guest startup/hotplug both
> block-size and requested-size are specified. When sysadmin wants
> to give some more memory to the guest, or take some back, they
> change the 'requested-size' attribute which is propagated to the
> guest where virtio-mem module takes corresponding action.
> This means, that 'requested-size' must be a whole number product
> of 'block-size' and of course has to be in rage [0, max-size]
> (including). The 'max-size' is yet another attribute but if not
> set it's "inherited" from corresponding memory-backend-* object.
>
> Therefore, two new elements are introduced under <target/>, to
> reflect these attributes:
>
> <memory model='virtio'>
> <target>
> <size unit='KiB'>4194304</size>
> <node>0</node>
> <block unit='KiB'>2048</block>
> <requested unit='KiB'>524288</requested>
> </target>
> <address type='pci' domain='0x0000' bus='0x00'
slot='0x05' function='0x0'/>
> </memory>
>
> The intent here is that <requested/> will be allowed to change
> via virDomainUpdateDeviceFlags() API.
>
> Note, QEMU does inform us about success of allocation via an
> event - this is covered in next patches.
>
> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
> ---
> docs/formatdomain.rst | 22 ++++
> docs/schemas/domaincommon.rng | 10 ++
> src/conf/domain_conf.c | 103 ++++++++++++++++--
> src/conf/domain_conf.h | 5 +
> .../memory-hotplug-virtio-mem.xml | 78 +++++++++++++
> ...emory-hotplug-virtio-mem.x86_64-latest.xml | 1 +
> tests/qemuxml2xmltest.c | 1 +
> 7 files changed, 213 insertions(+), 7 deletions(-)
> create mode 100644 tests/qemuxml2argvdata/memory-hotplug-virtio-mem.xml
> create mode 120000
tests/qemuxml2xmloutdata/memory-hotplug-virtio-mem.x86_64-latest.xml
Disregard any comments about size being actual size ...