virStoragePRDefFormat: Suppress path formatting for migratable XML

If there are managed reservations for a disk source, the path to
the pr-helper socket is generated automatically by libvirt when
needed and points somewhere under priv->libDir. Therefore it is
very unlikely that the path will work even on migration
destination (the libDir is derived from domain short name and its
ID).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2018-07-03 13:58:33 +02:00
parent 900403a3b2
commit 0da435118c
3 changed files with 8 additions and 4 deletions

View File

@ -23565,7 +23565,8 @@ virDomainStorageSourceFormat(virBufferPtr attrBuf,
return -1;
if (src->pr)
virStoragePRDefFormat(childBuf, src->pr);
virStoragePRDefFormat(childBuf, src->pr,
flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE);
return 0;
}

View File

@ -1982,11 +1982,13 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt)
void
virStoragePRDefFormat(virBufferPtr buf,
virStoragePRDefPtr prd)
virStoragePRDefPtr prd,
bool migratable)
{
virBufferAsprintf(buf, "<reservations managed='%s'",
virTristateBoolTypeToString(prd->managed));
if (prd->path) {
if (prd->path &&
(prd->managed == VIR_TRISTATE_BOOL_NO || !migratable)) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
virBufferAddLit(buf, "<source type='unix'");

View File

@ -395,7 +395,8 @@ void virStorageAuthDefFormat(virBufferPtr buf, virStorageAuthDefPtr authdef);
void virStoragePRDefFree(virStoragePRDefPtr prd);
virStoragePRDefPtr virStoragePRDefParseXML(xmlXPathContextPtr ctxt);
void virStoragePRDefFormat(virBufferPtr buf,
virStoragePRDefPtr prd);
virStoragePRDefPtr prd,
bool migratable);
bool virStoragePRDefIsEqual(virStoragePRDefPtr a,
virStoragePRDefPtr b);
bool virStoragePRDefIsManaged(virStoragePRDefPtr prd);