From nobody Mon Feb 9 00:30:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606489569; cv=none; d=zohomail.com; s=zohoarc; b=e2K/AFzhnH03fQf/mearJmw1N4q2AzqRblrTwtyQf00nqBVS6VsDyn4iO9tvu4dIaTvG8owcRbqnDnaN7Y/1Qj/AbPbFWqd5PT8tTzZt4aodLDktaODrBjK0DvnJSbiwhG6H+yMcSjXpN24dd9UW+e+go8HYur05/HGvSYm3Jyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606489569; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9daRqsms99+niayOqmJmh212wp18CSXKUuy6wwTmXjM=; b=bUUg0tk7x7FhxpqJ7l3WxOOQ+YqgEZ/mTYsoIIEqbTiwJ1bJTBvE6aofOPOsfLgcf/WnqYHQ/BscfKp6hO8VWIVwiAbZon2bK86z3i2shqgqIxoj9JwjN2UdxeVQ8JCy26GFj6ufORNkbm79LuaP8d4de+wT6o91u4v0YmmKwbE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1606489569579284.71020577178183; Fri, 27 Nov 2020 07:06:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-410-LYG-4z_kOomPuOhg0vV-vA-1; Fri, 27 Nov 2020 10:05:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC7E2612A8; Fri, 27 Nov 2020 15:05:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C80555D731; Fri, 27 Nov 2020 15:05:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9247D1809CB7; Fri, 27 Nov 2020 15:05:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ARF5RDn031137 for ; Fri, 27 Nov 2020 10:05:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id C88235D9E8; Fri, 27 Nov 2020 15:05:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A2DF5D9CC; Fri, 27 Nov 2020 15:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606489566; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9daRqsms99+niayOqmJmh212wp18CSXKUuy6wwTmXjM=; b=i0L/zfrEILvL1z568/foSJsQim/tVz6yeHS5U5W14EXAKuzmvAspLJ5fZl183pm/uG7WDV 6Ol5sRC2Rl/eW67WIBUUwYBEIcnn6fS5ka2j4I5U567Bja1ld+Vm0pemnV7Gdx/yyHQC0P IcKGRqdzfSfzzCvWR+f9gIutehG1/i8= X-MC-Unique: LYG-4z_kOomPuOhg0vV-vA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v1 21/26] qemu: Build command line for virtio-mem Date: Fri, 27 Nov 2020 16:03:07 +0100 Message-Id: <082cd91315ffa886997af5193096758d07292484.1606489221.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: david@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The majority of the code is prepared since virtio-pmem. The alias for virtio-mem is new ("virtiomem"). And again, prealloc doesn't make much sense - the whole point is to dynamically allocate memory for guest and possibly return it to the host (e.g. if the host is running low on memory) and this wouldn't happen with prealloc. Signed-off-by: Michal Privoznik --- src/qemu/qemu_alias.c | 5 +- src/qemu/qemu_command.c | 19 +++++-- ...mory-hotplug-virtio-mem.x86_64-latest.args | 53 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 4 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64= -latest.args diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 68d4a7b480..29c26f0b72 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -521,7 +521,10 @@ qemuAssignDeviceMemoryAlias(virDomainDefPtr def, idx =3D qemuDeviceMemoryGetAliasID(def, mem, oldAlias, prefix); break; case VIR_DOMAIN_MEMORY_MODEL_VIRTIO: - prefix =3D "virtiopmem"; + if (mem->s.virtio.pmem) + prefix =3D "virtiopmem"; + else + prefix =3D "virtiomem"; idx =3D qemuDeviceMemoryGetAliasID(def, mem, true, prefix); break; case VIR_DOMAIN_MEMORY_MODEL_NONE: diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1ee5110b44..a94b81ce15 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2975,9 +2975,14 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backend= Props, nvdimmPmem =3D mem->s.nvdimm.pmem; break; case VIR_DOMAIN_MEMORY_MODEL_VIRTIO: + pagesize =3D mem->s.virtio.pagesize; + needHugepage =3D !!pagesize; + useHugepage =3D !!pagesize; + nodemask =3D mem->s.virtio.sourceNodes; nvdimmPath =3D mem->s.virtio.path; - /* virtio-pmem doesn't need prealloc, it's very likely exposing a = real - * device and thus there's nothing to prealloc */ + /* virtio-pmem doesn't need prealloc. Either it's pmem and thus ve= ry + * likely exposing a real device where is nothing to prealloc, OR = it's + * virtio-mem where we want to unmap pages on the fly. */ allowPrealloc =3D false; break; case VIR_DOMAIN_MEMORY_MODEL_NONE: @@ -3305,7 +3310,10 @@ qemuBuildMemoryDeviceStr(const virDomainDef *def, break; =20 case VIR_DOMAIN_MEMORY_MODEL_VIRTIO: - device =3D "virtio-pmem-pci"; + if (mem->s.virtio.pmem) + device =3D "virtio-pmem-pci"; + else + device =3D "virtio-mem-pci"; =20 case VIR_DOMAIN_MEMORY_MODEL_NONE: case VIR_DOMAIN_MEMORY_MODEL_LAST: @@ -3320,6 +3328,11 @@ qemuBuildMemoryDeviceStr(const virDomainDef *def, if (mem->labelsize) virBufferAsprintf(&buf, "label-size=3D%llu,", mem->labelsize * 102= 4); =20 + if (mem->blocksize) { + virBufferAsprintf(&buf, "block-size=3D%llu,", mem->blocksize * 102= 4); + virBufferAsprintf(&buf, "requested-size=3D%llu,", mem->requestedsi= ze * 1024); + } + if (virUUIDIsValid(mem->uuid)) { char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 diff --git a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest= .args b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args new file mode 100644 index 0000000000..c12248518d --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args @@ -0,0 +1,53 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff \ +-cpu qemu64 \ +-m size=3D2095104k,slots=3D16,maxmem=3D1099511627776k \ +-overcommit mem-lock=3Doff \ +-smp 2,sockets=3D2,dies=3D1,cores=3D1,threads=3D1 \ +-object memory-backend-ram,id=3Dram-node0,size=3D2145386496 \ +-numa node,nodeid=3D0,cpus=3D0-1,memdev=3Dram-node0 \ +-object memory-backend-ram,id=3Dmemvirtiomem0,size=3D1073741824 \ +-device virtio-mem-pci,node=3D0,block-size=3D2097152,requested-size=3D5368= 70912,\ +memdev=3Dmemvirtiomem0,id=3Dvirtiomem0,bus=3Dpci.0,addr=3D0x2 \ +-object memory-backend-file,id=3Dmemvirtiomem1,\ +mem-path=3D/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,size=3D2147483648,\ +host-nodes=3D1-3,policy=3Dbind \ +-device virtio-mem-pci,node=3D0,block-size=3D2097152,requested-size=3D1073= 741824,\ +memdev=3Dmemvirtiomem1,id=3Dvirtiomem1,bus=3Dpci.0,addr=3D0x4 \ +-object memory-backend-file,id=3Dmemvirtiomem2,mem-path=3D/tmp/virtio_mem,\ +size=3D4294967296 \ +-device virtio-mem-pci,node=3D0,block-size=3D2097152,requested-size=3D5368= 70912,\ +memdev=3Dmemvirtiomem2,id=3Dvirtiomem2,bus=3Dpci.0,addr=3D0x5 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1",\ +"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ",\ +"file":"libvirt-1-storage"}' \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Dlibvirt-1-format,id=3Dide0-0-0= ,bootindex=3D1 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ba904149e8..86a039eddd 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3013,6 +3013,7 @@ mymain(void) DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-readonly"); DO_TEST_CAPS_ARCH_LATEST("memory-hotplug-nvdimm-ppc64", "ppc64"); DO_TEST_CAPS_LATEST("memory-hotplug-virtio-pmem"); + DO_TEST_CAPS_LATEST("memory-hotplug-virtio-mem"); =20 DO_TEST("machine-aeskeywrap-on-caps", QEMU_CAPS_AES_KEY_WRAP, --=20 2.26.2