On 9/9/19 1:18 AM, Thomas Huth wrote: > On 07/09/2019 02.16, Matthew Rosato wrote: >> From: Pierre Morel <pmo...@linux.ibm.com> >> >> We use a S390PCIGroup structure to hold the information >> related to zPCI Function group. >> >> This allows us to be ready to support multiple groups and to retrieve >> the group information from the host. >> >> Signed-off-by: Pierre Morel <pmo...@linux.ibm.com> >> --- >> hw/s390x/s390-pci-bus.c | 42 ++++++++++++++++++++++++++++++++++++++++++ >> hw/s390x/s390-pci-bus.h | 11 ++++++++++- >> hw/s390x/s390-pci-inst.c | 22 +++++++++++++--------- >> 3 files changed, 65 insertions(+), 10 deletions(-) >> >> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c >> index 963a41c..e625217 100644 >> --- a/hw/s390x/s390-pci-bus.c >> +++ b/hw/s390x/s390-pci-bus.c >> @@ -730,6 +730,46 @@ static void s390_pci_iommu_free(S390pciState *s, PCIBus >> *bus, int32_t devfn) >> object_unref(OBJECT(iommu)); >> } >> >> +static S390PCIGroup *s390_grp_create(int ug) >> +{ >> + S390PCIGroup *grp; >> + S390pciState *s = s390_get_phb(); >> + >> + grp = g_new0(S390PCIGroup, 1); >> + grp->ug = ug; >> + QTAILQ_INSERT_TAIL(&s->zpci_grps, grp, link); >> + return grp; >> +} > > Maybe an ignorant question, but shouldn't there also be some kind of > clean up function that also frees the memory again, e.g. during a > machine reset? Or are these groups supposed to survive a machine reset?
Hmm.. Well, I think it is in line with the way the devices themselves are handled during reset (they are not removed during a reset unless there was a pending unplug and their info persists). But you have a point in that it seems sketchy to leave the group information around, particularly in cases where the last device associated with the group has been unplugged. So yes, I think there is some work to be done here. I need to investigate whether a precautionary wiping of the list (minus the default group) at machine reset is really good enough or whether we need to remove group info sooner (device unplug). Thanks, Matt