qemu: Set memoryBackingDir in private data upon start

This way we keep the path for each running VM.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Martin Kletzander 2024-09-18 10:40:59 +02:00
parent da8a1d7943
commit f58a4dc9d5
12 changed files with 26 additions and 2 deletions

View File

@ -1795,7 +1795,7 @@ qemuGetMemoryBackingPath(qemuDomainObjPrivate *priv,
/* This is the old way of setting up per-domain directories */
static void
static int
qemuDomainSetPrivatePathsOld(virQEMUDriver *driver,
virDomainObj *vm)
{
@ -1808,6 +1808,13 @@ qemuDomainSetPrivatePathsOld(virQEMUDriver *driver,
if (!priv->channelTargetDir)
priv->channelTargetDir = g_strdup_printf("%s/domain-%s",
cfg->channelTargetDir, vm->def->name);
if (!priv->memoryBackingDir &&
qemuGetMemoryBackingDomainPath(priv, vm->def,
&priv->memoryBackingDir) < 0)
return -1;
return 0;
}
@ -1829,6 +1836,11 @@ qemuDomainSetPrivatePaths(virQEMUDriver *driver,
priv->channelTargetDir = g_strdup_printf("%s/%s",
cfg->channelTargetDir, domname);
if (!priv->memoryBackingDir &&
qemuGetMemoryBackingDomainPath(priv, vm->def,
&priv->memoryBackingDir) < 0)
return -1;
return 0;
}
@ -3434,7 +3446,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
priv->memoryBackingDir = virXPathString("string(./memoryBackingDir/@path)", ctxt);
qemuDomainSetPrivatePathsOld(driver, vm);
if (qemuDomainSetPrivatePathsOld(driver, vm) < 0)
return -1;
if (virCPUDefParseXML(ctxt, "./cpu", VIR_CPU_TYPE_GUEST, &priv->origCPU,
false) < 0)

View File

@ -231,6 +231,7 @@
</devices>
<libDir path='/var/lib/libvirt/qemu/domain-4-copy'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-4-copy'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/4-copy'/>
<chardevStdioLogd/>
<allowReboot value='yes'/>
<nodename index='0'/>

View File

@ -230,6 +230,7 @@
</devices>
<libDir path='/var/lib/libvirt/qemu/domain-4-copy'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-4-copy'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/4-copy'/>
<chardevStdioLogd/>
<allowReboot value='yes'/>
<nodename index='0'/>

View File

@ -21,6 +21,7 @@
<numad nodeset='0-2' cpuset='1,3'/>
<libDir path='/tmp'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/1-QEMUGuest1'/>
<allowReboot value='yes'/>
<nodename index='0'/>
<fdset index='0'/>

View File

@ -254,6 +254,7 @@
</job>
<libDir path='/var/lib/libvirt/qemu/domain-1-nest'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-1-nest'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/1-nest'/>
<chardevStdioLogd/>
<allowReboot value='yes'/>
<nodename index='0'/>

View File

@ -320,6 +320,7 @@
</devices>
<libDir path='/var/lib/libvirt/qemu/domain-11-migr'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-11-migr'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/11-migr'/>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='forbid'>EPYC-Rome</model>
<vendor>AMD</vendor>

View File

@ -257,6 +257,7 @@
<numad nodeset='0' cpuset='0-7'/>
<libDir path='/var/lib/libvirt/qemu/domain-4-upstream'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-4-upstream'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/4-upstream'/>
<chardevStdioLogd/>
<allowReboot value='yes'/>
<nodename index='0'/>

View File

@ -286,6 +286,7 @@
<numad nodeset='0' cpuset='0-7'/>
<libDir path='/var/lib/libvirt/qemu/domain-3-upstream'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-3-upstream'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/3-upstream'/>
<chardevStdioLogd/>
<allowReboot value='yes'/>
<nodename index='0'/>

View File

@ -268,6 +268,7 @@
</devices>
<libDir path='/var/lib/libvirt/qemu/domain-7-nest'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-7-nest'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/7-nest'/>
<chardevStdioLogd/>
<allowReboot value='yes'/>
<nodename index='0'/>

View File

@ -258,6 +258,7 @@
<numad nodeset='6' cpuset='0-7'/>
<libDir path='/var/lib/libvirt/qemu/domain-1-upstream'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-1-upstream'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/1-upstream'/>
<chardevStdioLogd/>
<allowReboot value='yes'/>
<nodename index='123'/>

View File

@ -256,6 +256,7 @@
<numad nodeset='6' cpuset='0-7'/>
<libDir path='/var/lib/libvirt/qemu/domain-1-upstream'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-1-upstream'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/1-upstream'/>
<chardevStdioLogd/>
<allowReboot value='yes'/>
<nodename index='0'/>

View File

@ -307,6 +307,7 @@
<numad nodeset='0-2' cpuset='1,3'/>
<libDir path='/tmp'/>
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target'/>
<memoryBackingDir path='/var/lib/libvirt/qemu/ram/1729-QEMUGuest1'/>
<allowReboot value='yes'/>
<nodename index='0'/>
<fdset index='0'/>