Delete binary instead of truncating when restarting virt-handler
The containerDisk binary will return "text file busy" if virt-handler
wants to override it. Instead delete the binary and recreate it. This
does not impact running VMIs and allows delivering new versions of the
binary savely.
@@ -423,6 +423,9 @@ func main() {
func copy(sourceFile string, targetFile string) error {
+ if err := os.RemoveAll(targetFile); err != nil {
+ return fmt.Errorf("failed to remove target file: %v", err)
+ }
target, err := os.Create(targetFile)
if err != nil {
return fmt.Errorf("failed to crate target file: %v", err)
