mirror of https://github.com/jetkvm/kvm.git
fix(usbgadget): do not panic if a change isn't found
This commit is contained in:
parent
b4dd4961fc
commit
c4782f28dc
|
@ -48,6 +48,11 @@ func (c *ChangeSetResolver) doResolveChanges(initial bool) error {
|
|||
|
||||
for _, key := range c.orderedChanges {
|
||||
change := c.changesMap[key.(string)]
|
||||
if change == nil {
|
||||
c.l.Error().Str("key", key.(string)).Msg("fileChange not found")
|
||||
continue
|
||||
}
|
||||
|
||||
if !initial {
|
||||
change.ResetActionResolution()
|
||||
}
|
||||
|
|
|
@ -177,12 +177,7 @@ func (u *UsbGadget) Init() error {
|
|||
|
||||
u.udc = udcs[0]
|
||||
|
||||
err := u.WithTransaction(func() error {
|
||||
u.tx.MountConfigFS()
|
||||
u.tx.CreateConfigPath()
|
||||
u.tx.WriteGadgetConfig()
|
||||
return nil
|
||||
})
|
||||
err := u.configureUsbGadget()
|
||||
if err != nil {
|
||||
return u.logError("unable to initialize USB stack", err)
|
||||
}
|
||||
|
@ -196,13 +191,19 @@ func (u *UsbGadget) UpdateGadgetConfig() error {
|
|||
|
||||
u.loadGadgetConfig()
|
||||
|
||||
err := u.WithTransaction(func() error {
|
||||
u.tx.WriteGadgetConfig()
|
||||
return nil
|
||||
})
|
||||
err := u.configureUsbGadget()
|
||||
if err != nil {
|
||||
return u.logError("unable to update gadget config", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *UsbGadget) configureUsbGadget() error {
|
||||
return u.WithTransaction(func() error {
|
||||
u.tx.MountConfigFS()
|
||||
u.tx.CreateConfigPath()
|
||||
u.tx.WriteGadgetConfig()
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue