Rather than always re-generating the alias store it in the definition
and in the status XML.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
src/qemu/qemu_command.c | 23 +++------------------
src/qemu/qemu_command.h | 3 +--
src/qemu/qemu_domain.c | 16 +++++++++++++--
src/qemu/qemu_hotplug.c | 34 ++++++++++---------------------
src/util/virstoragefile.c | 1 +
src/util/virstoragefile.h | 3 +++
tests/qemustatusxml2xmldata/modern-in.xml | 4 ++++
7 files changed, 37 insertions(+), 47 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c38dde5a60..84d7d51c7c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9669,7 +9669,6 @@ qemuBuildPanicCommandLine(virCommandPtr cmd,
* qemuBuildPRManagerInfoProps:
* @disk: disk definition
* @propsret: Returns JSON object containing properties of the pr-manager-helper object
- * @aliasret: alias of the pr-manager-helper object
*
* Build the JSON properties for the pr-manager object.
*
@@ -9678,32 +9677,19 @@ qemuBuildPanicCommandLine(virCommandPtr cmd,
*/
int
qemuBuildPRManagerInfoProps(const virDomainDiskDef *disk,
- virJSONValuePtr *propsret,
- char **aliasret)
+ virJSONValuePtr *propsret)
{
- char *alias = NULL;
int ret = -1;
*propsret = NULL;
- *aliasret = NULL;
-
- if (virStoragePRDefIsManaged(disk->src->pr)) {
- if (VIR_STRDUP(alias, qemuDomainGetManagedPRAlias()) < 0)
- goto cleanup;
- } else {
- if (!(alias = qemuDomainGetUnmanagedPRAlias(disk->info.alias)))
- goto cleanup;
- }
if (virJSONValueObjectCreate(propsret,
"s:path", disk->src->pr->path,
NULL) < 0)
goto cleanup;
- VIR_STEAL_PTR(*aliasret, alias);
ret = 0;
cleanup:
- VIR_FREE(alias);
return ret;
}
@@ -9715,7 +9701,6 @@ qemuBuildMasterPRCommandLine(virCommandPtr cmd,
size_t i;
bool managedAdded = false;
virJSONValuePtr props = NULL;
- char *alias = NULL;
char *tmp = NULL;
int ret = -1;
@@ -9732,14 +9717,13 @@ qemuBuildMasterPRCommandLine(virCommandPtr cmd,
managedAdded = true;
}
- if (qemuBuildPRManagerInfoProps(disk, &props, &alias) < 0)
+ if (qemuBuildPRManagerInfoProps(disk, &props) < 0)
goto cleanup;
if (!(tmp = virQEMUBuildObjectCommandlineFromJSON("pr-manager-helper",
- alias,
+ disk->src->pr->mgralias,
props)))
goto cleanup;
- VIR_FREE(alias);
virJSONValueFree(props);
props = NULL;
@@ -9749,7 +9733,6 @@ qemuBuildMasterPRCommandLine(virCommandPtr cmd,
ret = 0;
cleanup:
- VIR_FREE(alias);
virJSONValueFree(props);
return ret;
}
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 621592cd79..28bc33558b 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -56,8 +56,7 @@ virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver,
/* Generate the object properties for pr-manager */
int qemuBuildPRManagerInfoProps(const virDomainDiskDef *disk,
- virJSONValuePtr *propsret,
- char **alias);
+ virJSONValuePtr *propsret);
/* Generate the object properties for a secret */
int qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 92217e66fe..1572ce5c2d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1941,6 +1941,9 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
src->nodestorage = virXPathString("string(./nodenames/nodename[@type='storage']/@name)", ctxt);
src->nodeformat = virXPathString("string(./nodenames/nodename[@type='format']/@name)", ctxt);
+ if (src->pr)
+ src->pr->mgralias = virXPathString("string(./reservations/@mgralias)", ctxt);
+
if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0)
return -1;
@@ -1961,6 +1964,9 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
virBufferAddLit(buf, "</nodenames>\n");
}
+ if (src->pr)
+ virBufferAsprintf(buf, "<reservations mgralias='%s'/>\n", src->pr->mgralias);
+
if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0)
return -1;
@@ -11932,7 +11938,8 @@ qemuDomainPrepareDiskCachemode(virDomainDiskDefPtr disk)
static int
qemuDomainPrepareStorageSourcePR(virStorageSourcePtr src,
- qemuDomainObjPrivatePtr priv)
+ qemuDomainObjPrivatePtr priv,
+ const char *parentalias)
{
if (!src->pr)
return 0;
@@ -11940,6 +11947,11 @@ qemuDomainPrepareStorageSourcePR(virStorageSourcePtr src,
if (virStoragePRDefIsManaged(src->pr)) {
if (!(src->pr->path = qemuDomainGetManagedPRSocketPath(priv)))
return -1;
+ if (VIR_STRDUP(src->pr->mgralias, qemuDomainGetManagedPRAlias()) < 0)
+ return -1;
+ } else {
+ if (!(src->pr->mgralias = qemuDomainGetUnmanagedPRAlias(parentalias)))
+ return -1;
}
return 0;
@@ -11962,7 +11974,7 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
if (qemuDomainPrepareDiskSourceChain(disk, NULL, cfg, priv->qemuCaps) < 0)
return -1;
- if (qemuDomainPrepareStorageSourcePR(disk->src, priv) < 0)
+ if (qemuDomainPrepareStorageSourcePR(disk->src, priv, disk->info.alias) < 0)
return -1;
return 0;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 6557711ec1..9481123c19 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -387,13 +387,11 @@ qemuDomainMaybeStartPRDaemon(virDomainObjPtr vm,
static int
qemuMaybeBuildPRManagerInfoProps(virDomainObjPtr vm,
const virDomainDiskDef *disk,
- virJSONValuePtr *propsret,
- char **aliasret)
+ virJSONValuePtr *propsret)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
*propsret = NULL;
- *aliasret = NULL;
if (!disk->src->pr)
return 0;
@@ -404,7 +402,7 @@ qemuMaybeBuildPRManagerInfoProps(virDomainObjPtr vm,
return 0;
}
- return qemuBuildPRManagerInfoProps(disk, propsret, aliasret);
+ return qemuBuildPRManagerInfoProps(disk, propsret);
}
@@ -425,7 +423,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
char *devstr = NULL;
char *drivestr = NULL;
char *drivealias = NULL;
- char *prmgrAlias = NULL;
bool driveAdded = false;
bool secobjAdded = false;
bool encobjAdded = false;
@@ -462,7 +459,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0)
goto error;
- if (qemuMaybeBuildPRManagerInfoProps(vm, disk, &prmgrProps, &prmgrAlias) < 0)
+ if (qemuMaybeBuildPRManagerInfoProps(vm, disk, &prmgrProps) < 0)
goto error;
/* Start daemon only after prmgrProps is built. Otherwise
@@ -511,7 +508,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
}
if (prmgrProps) {
- rv = qemuMonitorAddObject(priv->mon, "pr-manager-helper", prmgrAlias,
+ rv = qemuMonitorAddObject(priv->mon, "pr-manager-helper",
+ disk->src->pr->mgralias,
prmgrProps);
prmgrProps = NULL; /* qemuMonitorAddObject consumes */
if (rv < 0)
@@ -541,7 +539,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
virJSONValueFree(encobjProps);
virJSONValueFree(secobjProps);
qemuDomainSecretDiskDestroy(disk);
- VIR_FREE(prmgrAlias);
VIR_FREE(drivealias);
VIR_FREE(drivestr);
VIR_FREE(devstr);
@@ -559,7 +556,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
if (encobjAdded)
ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias));
if (prmgrAdded)
- ignore_value(qemuMonitorDelObject(priv->mon, prmgrAlias));
+ ignore_value(qemuMonitorDelObject(priv->mon, disk->src->pr->mgralias));
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -2;
virErrorRestore(&orig_err);
@@ -3832,22 +3829,18 @@ static bool qemuIsMultiFunctionDevice(virDomainDefPtr def,
static int
qemuDomainDiskNeedRemovePR(virDomainObjPtr vm,
virDomainDiskDefPtr disk,
- char **aliasret,
bool *stopDaemon)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
size_t i;
- *aliasret = NULL;
*stopDaemon = false;
if (!disk->src->pr)
return 0;
- if (!virStoragePRDefIsManaged(disk->src->pr)) {
- *aliasret = qemuDomainGetUnmanagedPRAlias(disk->info.alias);
- return *aliasret ? 0 : -1;
- }
+ if (!virStoragePRDefIsManaged(disk->src->pr))
+ return 0;
for (i = 0; i < vm->def->ndisks; i++) {
const virDomainDiskDef *domainDisk = vm->def->disks[i];
@@ -3862,9 +3855,6 @@ qemuDomainDiskNeedRemovePR(virDomainObjPtr vm,
if (i != vm->def->ndisks)
return 0;
- if (VIR_STRDUP(*aliasret, qemuDomainGetManagedPRAlias()) < 0)
- return -1;
-
if (priv->prDaemonRunning)
*stopDaemon = true;
@@ -3885,7 +3875,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
char *drivestr;
char *objAlias = NULL;
char *encAlias = NULL;
- char *prmgrAlias = NULL;
bool stopPRDaemon = false;
VIR_DEBUG("Removing disk %s from domain %p %s",
@@ -3924,7 +3913,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
}
}
- if (qemuDomainDiskNeedRemovePR(vm, disk, &prmgrAlias, &stopPRDaemon) < 0)
+ if (qemuDomainDiskNeedRemovePR(vm, disk, &stopPRDaemon) < 0)
return -1;
qemuDomainObjEnterMonitor(driver, vm);
@@ -3943,9 +3932,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
VIR_FREE(encAlias);
/* If it fails, then so be it - it was a best shot */
- if (prmgrAlias)
- ignore_value(qemuMonitorDelObject(priv->mon, prmgrAlias));
- VIR_FREE(prmgrAlias);
+ if (disk->src->pr)
+ ignore_value(qemuMonitorDelObject(priv->mon, disk->src->pr->mgralias));
if (disk->src->haveTLS)
ignore_value(qemuMonitorDelObject(priv->mon, disk->src->tlsAlias));
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index dbbe758f30..54de2c1c30 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1899,6 +1899,7 @@ virStoragePRDefFree(virStoragePRDefPtr prd)
return;
VIR_FREE(prd->path);
+ VIR_FREE(prd->mgralias);
VIR_FREE(prd);
}
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 3a90c60fa5..1631c4cf66 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -221,6 +221,9 @@ typedef virStoragePRDef *virStoragePRDefPtr;
struct _virStoragePRDef {
int managed; /* enum virTristateBool */
char *path;
+
+ /* manager object alias */
+ char *mgralias;
};
typedef struct _virStorageDriverData virStorageDriverData;
diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxml2xmldata/modern-in.xml
index d57e1f605f..d63fcf79f1 100644
--- a/tests/qemustatusxml2xmldata/modern-in.xml
+++ b/tests/qemustatusxml2xmldata/modern-in.xml
@@ -308,11 +308,15 @@
<backingStore type='file' index='1'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/base.qcow2'>
+ <reservations managed='yes'>
+ <source type='unix' path='/somepath/ux.sck' mode='client'/>
+ </reservations>
<privateData>
<nodenames>
<nodename type='storage' name='test-storage'/>
<nodename type='format' name='test-format'/>
</nodenames>
+ <reservations mgralias='test-alias'/>
<relPath>base.qcow2</relPath>
</privateData>
</source>
--
2.16.2
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 05/14/2018 12:45 PM, Peter Krempa wrote: > Rather than always re-generating the alias store it in the definition > and in the status XML. > > Signed-off-by: Peter Krempa <pkrempa@redhat.com> > --- > src/qemu/qemu_command.c | 23 +++------------------ > src/qemu/qemu_command.h | 3 +-- > src/qemu/qemu_domain.c | 16 +++++++++++++-- > src/qemu/qemu_hotplug.c | 34 ++++++++++--------------------- > src/util/virstoragefile.c | 1 + > src/util/virstoragefile.h | 3 +++ > tests/qemustatusxml2xmldata/modern-in.xml | 4 ++++ > 7 files changed, 37 insertions(+), 47 deletions(-) Yes, this makes sense to me. I've kept alias in status XML for all the versions until the very last one. You have my ACK, but since John was opposed maybe we should ask for his opinion too (so that we don't go behind his back). Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On 05/14/2018 11:19 AM, Michal Privoznik wrote: > On 05/14/2018 12:45 PM, Peter Krempa wrote: >> Rather than always re-generating the alias store it in the definition >> and in the status XML. >> >> Signed-off-by: Peter Krempa <pkrempa@redhat.com> >> --- >> src/qemu/qemu_command.c | 23 +++------------------ >> src/qemu/qemu_command.h | 3 +-- >> src/qemu/qemu_domain.c | 16 +++++++++++++-- >> src/qemu/qemu_hotplug.c | 34 ++++++++++--------------------- >> src/util/virstoragefile.c | 1 + >> src/util/virstoragefile.h | 3 +++ >> tests/qemustatusxml2xmldata/modern-in.xml | 4 ++++ >> 7 files changed, 37 insertions(+), 47 deletions(-) > > Yes, this makes sense to me. I've kept alias in status XML for all the > versions until the very last one. You have my ACK, but since John was > opposed maybe we should ask for his opinion too (so that we don't go > behind his back). > I still see no purpose for an alias to be saved since it's static, but I seem to be alone in that thinking. Just as much as I was alone in the thinking that qemuDomainGetManagedPRAlias is unnecessary and that a constant static string would work just the same. I'm also not convinced that a non managed system should be supported, but I recall Michal noting something during one of the reviews that it was useful for some future work. Shouldn't at the very least the formatting of the path and alias only occur for !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)... Would mean passing @flags to virStoragePRDefFormat. At the very least it'll make it obvious about it's only being formatted for the active/status guest. John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Mon, May 14, 2018 at 18:03:00 -0400, John Ferlan wrote: > > > On 05/14/2018 11:19 AM, Michal Privoznik wrote: > > On 05/14/2018 12:45 PM, Peter Krempa wrote: > >> Rather than always re-generating the alias store it in the definition > >> and in the status XML. > >> > >> Signed-off-by: Peter Krempa <pkrempa@redhat.com> > >> --- > >> src/qemu/qemu_command.c | 23 +++------------------ > >> src/qemu/qemu_command.h | 3 +-- > >> src/qemu/qemu_domain.c | 16 +++++++++++++-- > >> src/qemu/qemu_hotplug.c | 34 ++++++++++--------------------- > >> src/util/virstoragefile.c | 1 + > >> src/util/virstoragefile.h | 3 +++ > >> tests/qemustatusxml2xmldata/modern-in.xml | 4 ++++ > >> 7 files changed, 37 insertions(+), 47 deletions(-) > > > > Yes, this makes sense to me. I've kept alias in status XML for all the > > versions until the very last one. You have my ACK, but since John was > > opposed maybe we should ask for his opinion too (so that we don't go > > behind his back). > > > > I still see no purpose for an alias to be saved since it's static, but I > seem to be alone in that thinking. Just as much as I was alone in the > thinking that qemuDomainGetManagedPRAlias is unnecessary and that a > constant static string would work just the same. I'm also not convinced > that a non managed system should be supported, but I recall Michal > noting something during one of the reviews that it was useful for some > future work. The point of storing the aliases in the XML is that it records the state as we've used when we've created the object in qemu. If we will need to change the naming scheme for some reason we'd require to add a lot of code which will use the old/new alias depending on which would be originally used. By storing it into the status XML you are relieved of all this by just using what was used before. The future work referenced by Michal is the blockdev work, where the hot-remove code paths for disks will need to use the correct alias for the individual layer of the backing chain rather than the disk. I'll need to tweak this for the Authentication/encryption/TLS secrets as well, since they can't all share the same alias even when they correspond to the same disk. > Shouldn't at the very least the formatting of the path and alias only > occur for !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)... Would mean > passing @flags to virStoragePRDefFormat. At the very least it'll make > it obvious about it's only being formatted for the active/status guest. The alias is formatted in the <privateData> section of the virStorageSource which is only formatted when the XML is active. That is handled by the global storage source private data formatter. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2025 Red Hat, Inc.