From 7a44ffa6bdca45ae73923379ba0e071651151cfe Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 13 Nov 2018 12:50:41 +0100 Subject: [PATCH] qemu_domain: Track if domain remembers original owner For metadata locking we might need an extra fork() which given latest attempts to do fewer fork()-s is suboptimal. Therefore, there will be a qemu.conf knob to {en|dis}able this feature. But since the feature is actually not metadata locking itself rather than remembering of the original owner of the file this is named as 'rememberOwner'. But patches for that feature are not even posted yet so there is actually no qemu.conf entry in this patch nor a way to enable this feature. Even though this is effectively a dead code for now it is still desired. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- src/qemu/qemu_conf.h | 1 + src/qemu/qemu_domain.c | 7 +++++++ src/qemu/qemu_domain.h | 3 +++ src/qemu/qemu_process.c | 3 +++ 4 files changed, 14 insertions(+) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index f876f9117c..0b5b5a314f 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -92,6 +92,7 @@ struct _virQEMUDriverConfig { bool dynamicOwnership; virBitmapPtr namespaces; + bool rememberOwner; int cgroupControllers; char **cgroupDeviceACL; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1beb5969c1..2f65bbe34e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1963,6 +1963,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr priv) virBitmapFree(priv->namespaces); priv->namespaces = NULL; + priv->rememberOwner = false; + priv->reconnectBlockjobs = VIR_TRISTATE_BOOL_ABSENT; priv->allowReboot = VIR_TRISTATE_BOOL_ABSENT; @@ -2480,6 +2482,9 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, if (priv->chardevStdioLogd) virBufferAddLit(buf, "\n"); + if (priv->rememberOwner) + virBufferAddLit(buf, "\n"); + qemuDomainObjPrivateXMLFormatAllowReboot(buf, priv->allowReboot); qemuDomainObjPrivateXMLFormatPR(buf, priv); @@ -2891,6 +2896,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, priv->namespaces = NULL; } + priv->rememberOwner = virXPathBoolean("count(./rememberOwner) > 0", ctxt); + if ((n = virXPathNodeSet("./vcpus/vcpu", ctxt, &nodes)) < 0) goto error; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 87de433b22..53b5ea1678 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -369,6 +369,9 @@ struct _qemuDomainObjPrivate { /* qemuProcessStartCPUs stores the reason for starting vCPUs here for the * RESUME event handler to use it */ virDomainRunningReason runningReason; + + /* true if libvirt remembers the original owner for files */ + bool rememberOwner; }; # define QEMU_DOMAIN_PRIVATE(vm) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 36164a3183..031383b987 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5898,6 +5898,9 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver, priv->chardevStdioLogd = true; } + /* Track if this domain remembers original owner */ + priv->rememberOwner = cfg->rememberOwner; + qemuProcessPrepareAllowReboot(vm); /* clear the 'blockdev' capability for VMs which have disks that need -- GitLab