Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: yaroslavborbat <[email protected]>
  • Loading branch information
yaroslavborbat committed Jan 20, 2025
1 parent 638934b commit 94e3bb4
Showing 1 changed file with 2 additions and 49 deletions.
51 changes: 2 additions & 49 deletions images/virt-artifact/patches/032-hotplug-container-disk.patch
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,10 @@ index fa4e86ee17..c40f1fad89 100644
pvcName := storagetypes.PVCNameFromVirtVolume(&volume)
diff --git a/pkg/virt-handler/container-disk/hotplug.go b/pkg/virt-handler/container-disk/hotplug.go
new file mode 100644
index 0000000000..06057e67c5
index 0000000000..553f76cb0a
--- /dev/null
+++ b/pkg/virt-handler/container-disk/hotplug.go
@@ -0,0 +1,585 @@
@@ -0,0 +1,538 @@
+package container_disk
+
+import (
Expand Down Expand Up @@ -1189,53 +1189,7 @@ index 0000000000..06057e67c5
+ return disksInfo, nil
+}
+
+func (m *hotplugMounter) umount2(vmi *v1.VirtualMachineInstance) error {
+ if vmi.UID == "" {
+ return nil
+ }
+
+ record, err := m.getMountTargetRecord(vmi)
+ if err != nil {
+ return err
+ } else if record == nil {
+ // no entries to unmount
+
+ log.DefaultLogger().Object(vmi).Infof("No hotplug container disk mount entries found to unmount")
+ return nil
+ }
+
+ log.DefaultLogger().Object(vmi).Infof("Found hotplug container disk mount entries")
+ for _, entry := range record.MountTargetEntries {
+ log.DefaultLogger().Object(vmi).Infof("Looking to see if hotplug containerdisk is mounted at path %s", entry.TargetFile)
+ file, err := safepath.NewFileNoFollow(entry.TargetFile)
+ if err != nil {
+ if errors.Is(err, os.ErrNotExist) {
+ continue
+ }
+ return fmt.Errorf(failedCheckMountPointFmt, entry.TargetFile, err)
+ }
+ _ = file.Close()
+ if mounted, err := isolation.IsMounted(file.Path()); err != nil {
+ return fmt.Errorf(failedCheckMountPointFmt, file, err)
+ } else if mounted {
+ log.DefaultLogger().Object(vmi).Infof("unmounting hotplug container disk at path %s", file)
+ // #nosec No risk for attacket injection. Parameters are predefined strings
+ out, err := virt_chroot.UmountChroot(file.Path()).CombinedOutput()
+ if err != nil {
+ return fmt.Errorf(failedUnmountFmt, file, string(out), err)
+ }
+ }
+ }
+ err = m.deleteMountTargetRecord(vmi)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (m *hotplugMounter) Umount(vmi *v1.VirtualMachineInstance) error {
+ return m.umount2(vmi)
+ record, err := m.getMountTargetRecord(vmi)
+ if err != nil {
+ return err
Expand Down Expand Up @@ -1307,7 +1261,6 @@ index 0000000000..06057e67c5
+}
+
+func (m *hotplugMounter) UmountAll(vmi *v1.VirtualMachineInstance) error {
+ return m.umount2(vmi)
+ if vmi.UID == "" {
+ return nil
+ }
Expand Down

0 comments on commit 94e3bb4

Please sign in to comment.