<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Works for me on qemu-5.2.0-0.7.rc2.fc34.x86_64, libvirt v6.10.0-61-gd8c9cc3bd0 with this series patched:</div><div>guest kernel: kernel-5.10.0-0.rc5.20201125git127c501a03d5.85.fc33.x86_64 recompiled with VIRTIO_PMEM</div><div><br></div><div>Steps:</div><div>1. Start VM with <maxMemory> and <numa>:</div><div>Domain xml:</div><div><domain type='kvm' id='5'><br>  <name>pc</name><br>  <uuid>bb508b28-d57b-44bd-9e9c-a134cef24b60</uuid><br>  <maxMemory slots='16' unit='KiB'>20972544</maxMemory><br>  <memory unit='KiB'>1048576</memory></div><div>  <cpu mode='custom' match='exact' check='full'><br>    <numa><br>      <cell id='0' cpus='0-3' memory='1048576' unit='KiB'/><br>    </numa><br>  </cpu></div><div>...</div><div></domain></div><div><br></div><div>2. Attach the virtio memory device:</div><div>➜  ~ cat /tmp/virtio-mem.xml<br>  <memory model='virtio'><br>    <target><br>      <size unit='KiB'>4194304</size><br>      <node>0</node><br>      <block unit='KiB'>2048</block><br>      <requested unit='KiB'>524288</requested><br>    </target><br>  </memory></div><div><br></div><div>➜  ~ virsh attach-device pc /tmp/virtio-mem.xml<br>Device attached successfully</div><div><br></div><div>Before memory attached, the VM memory is:</div><div>[root@localhost ~]# free -m<br>              total        used        free      shared  buff/cache   available<br>Mem:            879         124         601           2         152         615<br>Swap:             0           0           0</div><div><br></div><div>After:</div><div>[root@localhost ~]# free -m<br>              total        used        free      shared  buff/cache   available<br>Mem:           1391         132        1106           2         153        1074<br>Swap:             0           0           0</div><div><br></div><div><br></div><div>3. Attach the virtio pmem device:</div><div>➜  ~ cat /tmp/virtio-pmem.xml<br><memory model='virtio' access='shared'><br>    <source><br>      <path>/tmp/virtio_pmem</path><br>      <pmem/><br>    </source><br>    <target><br>      <size unit='KiB'>524288</size><br>    </target><br>  </memory></div><div><br></div><div>➜  ~ virsh attach-device pc /tmp/virtio-pmem.xml<br>Device attached successfully</div><div><br></div><div>Check it in VM:<br></div><div>[root@localhost ~]# lsblk<br>NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT<br>vda    252:0    0   10G  0 disk <br>└─vda1 252:1    0   10G  0 part /<br>pmem0  259:0    0  512M  0 disk <br></div><div><br></div><div>3. Try to detach them:</div><div>➜  ~ virsh detach-device pc /tmp/virtio-mem.xml <br>error: Failed to detach device from /tmp/virtio-mem.xml<br>error: internal error: unable to execute QEMU command 'device_del': virtio based memory devices cannot be unplugged.<br><br>➜  ~ virsh detach-device pc /tmp/virtio-pmem.xml<br>error: Failed to detach device from /tmp/virtio-pmem.xml<br>error: internal error: unable to execute QEMU command 'device_del': virtio based memory devices cannot be unplugged.</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 27, 2020 at 11:05 PM Michal Privoznik <<a href="mailto:mprivozn@redhat.com">mprivozn@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Available also here:<br>
<br>
<a href="https://gitlab.com/MichalPrivoznik/libvirt/-/commits/virtio_mem/" rel="noreferrer" target="_blank">https://gitlab.com/MichalPrivoznik/libvirt/-/commits/virtio_mem/</a><br>
<br>
There are new virtio variants of pc-dimm and nvdimm devices. This is the<br>
first attempt to impalement support for them in libvirt.<br>
<br>
Thanks to David Hildenbrand for his valuable input!<br>
<br>
Michal Prívozník (26):<br>
  viruuid: Rework virUUIDIsValid()<br>
  internal.h: Introduce VIR_IS_POW2()<br>
  docs: Fix nvdimm example wrt to <uuid/><br>
  domain_conf: Check NVDIMM UUID in ABI stability<br>
  qemu_domain_address: Reformat qemuDomainAssignS390Addresses()<br>
  conf: Require nvdimm path in validate step<br>
  domain_conf: Fix virDomainMemoryModel type<br>
  virDomainMemorySourceDefFormat: Utilize virXMLFormatElement()<br>
  virDomainMemoryTargetDefFormat: Utilize virXMLFormatElement()<br>
  qemu: Move mem validation into post parse validator<br>
  conf: Move some of virDomainMemoryDef members into a union<br>
  conf: Introduce virtio-pmem <memory/> model<br>
  qemu_capabilities: Introduce QEMU_CAPS_DEVICE_VIRTIO_{P}MEM_PCI<br>
  qemu_validate: Require virtio-mem device for mem model virtio<br>
  security: Relabel virtio mem<br>
  qemu: Allow virtio-pmem in CGroups<br>
  qemu: Create virtio-pmem in domain namespace<br>
  qemu_command: Move dimm into qemuBuildDeviceAddressStr()<br>
  qemu: Build command line for virtio-pmem<br>
  conf: Introduce virtio-mem <memory/> model<br>
  qemu: Build command line for virtio-mem<br>
  qemu: Wire up <memory/> live update<br>
  qemu: Wire up MEMORY_DEVICE_SIZE_CHANGE event<br>
  qemu: Refresh the actual size of virtio-mem on monitor reconnect<br>
  virsh: Simplify @flags handing in cmdSetmem() and cmdSetmaxmem()<br>
  virsh: Introduce --virtio to setmem<br>
<br>
 docs/formatdomain.rst                         |  70 +++-<br>
 docs/schemas/domaincommon.rng                 |  16 +<br>
 src/conf/domain_conf.c                        | 372 ++++++++++++++----<br>
 src/conf/domain_conf.h                        |  38 +-<br>
 src/internal.h                                |  10 +<br>
 src/libvirt_private.syms                      |   2 +<br>
 src/qemu/qemu_alias.c                         |  59 ++-<br>
 src/qemu/qemu_capabilities.c                  |   4 +<br>
 src/qemu/qemu_capabilities.h                  |   2 +<br>
 src/qemu/qemu_cgroup.c                        |  43 +-<br>
 src/qemu/qemu_command.c                       | 172 +++++---<br>
 src/qemu/qemu_command.h                       |   5 +-<br>
 src/qemu/qemu_domain.c                        |  99 +++--<br>
 src/qemu/qemu_domain.h                        |   1 +<br>
 src/qemu/qemu_domain_address.c                |  98 +++--<br>
 src/qemu/qemu_domain_address.h                |   3 +-<br>
 src/qemu/qemu_driver.c                        | 198 +++++++++-<br>
 src/qemu/qemu_hotplug.c                       |  22 +-<br>
 src/qemu/qemu_hotplug.h                       |   5 +<br>
 src/qemu/qemu_monitor.c                       |  37 ++<br>
 src/qemu/qemu_monitor.h                       |  27 ++<br>
 src/qemu/qemu_monitor_json.c                  |  94 +++--<br>
 src/qemu/qemu_monitor_json.h                  |   5 +<br>
 src/qemu/qemu_namespace.c                     |  19 +-<br>
 src/qemu/qemu_process.c                       |  52 ++-<br>
 src/qemu/qemu_validate.c                      |  78 ++--<br>
 src/security/security_apparmor.c              |  35 +-<br>
 src/security/security_dac.c                   |  48 ++-<br>
 src/security/security_selinux.c               |  48 ++-<br>
 src/security/virt-aa-helper.c                 |  22 +-<br>
 src/util/virrandom.c                          |   2 +-<br>
 src/util/viruuid.c                            |  17 +-<br>
 src/util/viruuid.h                            |   2 +-<br>
 .../caps_4.1.0.x86_64.xml                     |   1 +<br>
 .../caps_4.2.0.x86_64.xml                     |   1 +<br>
 .../caps_5.0.0.x86_64.xml                     |   1 +<br>
 .../caps_5.1.0.x86_64.xml                     |   2 +<br>
 .../caps_5.2.0.x86_64.xml                     |   2 +<br>
 ...mory-hotplug-virtio-mem.x86_64-latest.args |  53 +++<br>
 .../memory-hotplug-virtio-mem.xml             |  78 ++++<br>
 ...ory-hotplug-virtio-pmem.x86_64-latest.args |  45 +++<br>
 .../memory-hotplug-virtio-pmem.xml            |  54 +++<br>
 tests/qemuxml2argvtest.c                      |   2 +<br>
 ...emory-hotplug-virtio-mem.x86_64-latest.xml |   1 +<br>
 ...mory-hotplug-virtio-pmem.x86_64-latest.xml |   1 +<br>
 tests/qemuxml2xmltest.c                       |   3 +<br>
 tools/virsh-domain.c                          | 138 ++++++-<br>
 47 files changed, 1703 insertions(+), 384 deletions(-)<br>
 create mode 100644 tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args<br>
 create mode 100644 tests/qemuxml2argvdata/memory-hotplug-virtio-mem.xml<br>
 create mode 100644 tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.x86_64-latest.args<br>
 create mode 100644 tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.xml<br>
 create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-virtio-mem.x86_64-latest.xml<br>
 create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-virtio-pmem.x86_64-latest.xml<br>
<br>
-- <br>
2.26.2<br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Tested-by: Han Han <<a href="mailto:hhan@redhat.com" target="_blank">hhan@redhat.com</a>></div></div></div>