Skip to content

Commit

Permalink
MTV-1495 | Add missing luks keys to the warm migration
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Necas <mnecas@redhat.com>
  • Loading branch information
mnecas committed Sep 24, 2024
1 parent 62b9a07 commit 4a9c159
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions virt-v2v/cmd/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ func runVirtV2VInspection(disks []string) error {
}

func runVirtV2vInPlace() error {
var err error
args := []string{"-v", "-x", "-i", "libvirtxml"}
args = append(args, "--root")
if val, found := os.LookupEnv("V2V_RootDisk"); found {
args = append(args, val)
} else {
args = append(args, "first")
}
if envStaticIPs := os.Getenv("V2V_staticIPs"); envStaticIPs != "" {
for _, macToIp := range strings.Split(envStaticIPs, "_") {
args = append(args, "--mac", macToIp)
}
args, err = addCommonArgs(args)
if err != nil {
return err
}
args = append(args, "/mnt/v2v/input.xml")
v2vCmd := exec.Command("/usr/libexec/virt-v2v-in-place", args...)
Expand Down Expand Up @@ -158,7 +158,24 @@ func virtV2vVsphereArgs() (args []string, err error) {
}
args = append(args, "-i", "libvirt", "-ic", os.Getenv("V2V_libvirtURL"))
args = append(args, "-ip", "/etc/secret/secretKey")
args, err = addCommonArgs(args)
if err != nil {
return nil, err
}
if info, err := os.Stat(global.VDDK); err == nil && info.IsDir() {
args = append(args,
"-it", "vddk",
"-io", fmt.Sprintf("vddk-libdir=%s", global.VDDK),
"-io", fmt.Sprintf("vddk-thumbprint=%s", os.Getenv("V2V_fingerprint")),
)
}

args = append(args, "--", os.Getenv("V2V_vmName"))
return args, nil
}

// addCommonArgs adds a v2v arguments which is used for both virt-v2v and virt-v2v-in-place
func addCommonArgs(args []string) ([]string, error) {
if envStaticIPs := os.Getenv("V2V_staticIPs"); envStaticIPs != "" {
for _, macToIp := range strings.Split(envStaticIPs, "_") {
args = append(args, "--mac", macToIp)
Expand All @@ -172,22 +189,13 @@ func virtV2vVsphereArgs() (args []string, err error) {
}
args = append(args, luksArgs...)

if info, err := os.Stat(global.VDDK); err == nil && info.IsDir() {
args = append(args,
"-it", "vddk",
"-io", fmt.Sprintf("vddk-libdir=%s", global.VDDK),
"-io", fmt.Sprintf("vddk-thumbprint=%s", os.Getenv("V2V_fingerprint")),
)
}
var extraArgs []string
if envExtraArgs := os.Getenv("V2V_extra_args"); envExtraArgs != "" {
if err := json.Unmarshal([]byte(envExtraArgs), &extraArgs); err != nil {
return nil, fmt.Errorf("Error parsing extra arguments %v", err)
}
}
args = append(args, extraArgs...)

args = append(args, "--", os.Getenv("V2V_vmName"))
return args, nil
}

Expand Down

0 comments on commit 4a9c159

Please sign in to comment.