[libvirt] [PATCH v2 1/6] test_driver: implement virDomainAttachDeviceFlags
Erik Skultety
eskultet at redhat.com
Fri Aug 16 15:26:46 UTC 2019
On Fri, Aug 16, 2019 at 05:57:36PM +0300, Ilias Stamatis wrote:
> On Fri, Aug 16, 2019 at 5:39 PM Erik Skultety <eskultet at redhat.com> wrote:
> >
> > ...
> >
> > > +
> > > + if (operation == TEST_DEVICE_DETACH)
> > > + parse_flags |= VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
> >
> > ^This should be added by patch 3/5
> >
> > > +
> > > + if (xml) {
> > > + if (!(dev = virDomainDeviceDefParse(xml, def,
> > > + driver->caps, driver->xmlopt,
> > > + NULL, parse_flags)))
> > > + goto cleanup;
> > > + } else if (alias) {
> > > + if (VIR_ALLOC(dev) < 0 || virDomainDefFindDevice(def, alias, dev, true) < 0)
> > > + goto cleanup;
> > > + }
> > > +
> > > + switch (operation) {
> > > + case TEST_DEVICE_ATTACH:
> > > + if (testDomainAttachDeviceLiveAndConfig(def, dev) < 0)
> > > + goto cleanup;
> > > + break;
> > > + case TEST_DEVICE_DETACH:
> > > + break;
> > > + case TEST_DEVICE_UPDATE:
> > > + break;
> > > + }
> > > +
> > > + ret = 0;
> > > + cleanup:
> > > + if (xml)
> > > + virDomainDeviceDefFree(dev);
> > > + else
> > > + VIR_FREE(dev);
> >
> > virDomainDeviceDefFree() can handle both cases.
>
> It cannot! This got me as well and made me wonder!
>
> Try attaching a device with an alias and then try detaching it with
> virDomainDetachDeviceAlias and use virDomainDeviceDefFree to free the
> resource.
>
> The program crashes with:
> free(): double free detected in tcache 2
Hmm, I'll have a look at why that is, probably on Sunday, I'll go ahead and
perform the other changes on my branch, but I won't merge the series yet.
Regards,
Erik
More information about the libvir-list
mailing list