diff options
Diffstat (limited to 'pkg/machine/qemu/config.go')
-rw-r--r-- | pkg/machine/qemu/config.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/pkg/machine/qemu/config.go b/pkg/machine/qemu/config.go index 05a1d74d3..3d1032fba 100644 --- a/pkg/machine/qemu/config.go +++ b/pkg/machine/qemu/config.go @@ -5,6 +5,7 @@ package qemu import ( "errors" + "io/ioutil" "os" "time" @@ -59,6 +60,8 @@ type MachineVMV1 struct { } type MachineVM struct { + // ConfigPath is the path to the configuration file + ConfigPath MachineFile // The command line representation of the qemu command CmdLine []string // HostUser contains info about host user @@ -83,11 +86,11 @@ type MachineVM struct { // ImageConfig describes the bootable image for the VM type ImageConfig struct { - IgnitionFilePath string + IgnitionFilePath MachineFile // ImageStream is the update stream for the image ImageStream string // ImagePath is the fq path to - ImagePath string + ImagePath MachineFile } // HostUser describes the host user @@ -171,11 +174,19 @@ func (m *MachineFile) GetPath() string { // the actual path func (m *MachineFile) Delete() error { if m.Symlink != nil { - if err := os.Remove(*m.Symlink); err != nil { + if err := os.Remove(*m.Symlink); err != nil && !errors.Is(err, os.ErrNotExist) { logrus.Errorf("unable to remove symlink %q", *m.Symlink) } } - return os.Remove(m.Path) + if err := os.Remove(m.Path); err != nil && !errors.Is(err, os.ErrNotExist) { + return err + } + return nil +} + +// Read the contents of a given file and return in []bytes +func (m *MachineFile) Read() ([]byte, error) { + return ioutil.ReadFile(m.GetPath()) } // NewMachineFile is a constructor for MachineFile |