[PATCH 03/14] virDomainDiskSourceNVMeFormat: Format only valid 'managed' values
Peter Krempa
pkrempa at redhat.com
Tue Mar 24 12:12:35 UTC 2020
On Tue, Mar 24, 2020 at 12:38:58 +0100, Michal Privoznik wrote:
> On 23. 3. 2020 19:11, Peter Krempa wrote:
> > VIR_TRISTATE_BOOL_ABSENT which maps to the 'default' string would not be
> > parsed back, so we shouldn't format it either.
> >
> > Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> > ---
> > src/conf/domain_conf.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > index f1e4d33a8d..f6a225e4e6 100644
> > --- a/src/conf/domain_conf.c
> > +++ b/src/conf/domain_conf.c
> > @@ -24662,8 +24662,9 @@ virDomainDiskSourceNVMeFormat(virBufferPtr attrBuf,
> > const virStorageSourceNVMeDef *nvme)
> > {
> > virBufferAddLit(attrBuf, " type='pci'");
> > - virBufferAsprintf(attrBuf, " managed='%s'",
> > - virTristateBoolTypeToString(nvme->managed));
> > + if (nvme->managed != VIR_TRISTATE_BOOL_ABSENT)
> > + virBufferAsprintf(attrBuf, " managed='%s'",
> > + virTristateBoolTypeToString(nvme->managed));
> > virBufferAsprintf(attrBuf, " namespace='%llu'", nvme->namespc);
> > virPCIDeviceAddressFormat(childBuf, nvme->pciAddr, false);
> > }
> >
>
> There is a postparse callback which deals with _ABSENT (see commit
> 8cd7196974d):
>
>
> static int
> virDomainDiskDefPostParse(virDomainDiskDefPtr disk,
> const virDomainDef *def,
> virDomainXMLOptionPtr xmlopt)
> {
> ...
> if (disk->src->type == VIR_STORAGE_TYPE_NVME) {
> if (disk->src->nvme->managed == VIR_TRISTATE_BOOL_ABSENT)
> disk->src->nvme->managed = VIR_TRISTATE_BOOL_YES;
> }
> ...
> }
>
> But maybe the callback is not called from tests where virStorageSource
> is parsed directly?
Well, the issue is when the virStorageSource is created from the backing
store rather than parsed from XML which is added later on.
More information about the libvir-list
mailing list