package app import ( "errors" "github.com/Nwflower/reims-go/internal/driver" "github.com/Nwflower/reims-go/internal/vmstart" ) // CloneVMCoW derives a VM through the source VM's owning driver. func (a *App) CloneVMCoW(sourceName, cloneName string) error { return a.CloneVMCoWWithDriver("", sourceName, cloneName) } func (a *App) CloneVMCoWWithDriver(driverID, sourceName, cloneName string) error { a.mu.Lock() svc := a.lifecycleSvc a.mu.Unlock() if svc == nil { return errors.New("driver lifecycle is not initialized") } ref := driver.VMRef{DriverID: driverID, Name: sourceName} w := vmstart.LineWriter(func(line string) { a.emitVMLogForDriver(driverID, cloneName, line) }) if err := svc.CloneCoW(a.baseCtx(), ref, cloneName, w, w); err != nil { return err } a.wakePoll() a.emitLifecycleStateChanged() return nil }