|
|
c659c5 |
From 8009825c396358137576af522acc0b6b20243bac Mon Sep 17 00:00:00 2001
|
|
|
c659c5 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
c659c5 |
Date: Fri, 20 Jan 2023 09:49:04 +0000
|
|
|
c659c5 |
Subject: [PATCH] -o kubevirt: Error on invalid output guest names
|
|
|
c659c5 |
|
|
|
c659c5 |
Kubevirt supports something like RFC 1123 names (without the length
|
|
|
c659c5 |
restriction). Helpfully it prints the regexp that it uses the
|
|
|
c659c5 |
validate the names, so just use the same regexp.
|
|
|
c659c5 |
|
|
|
c659c5 |
Note that virt-v2v never renames guests (since that would add
|
|
|
c659c5 |
unpredictability for automation). You must use the -on option to
|
|
|
c659c5 |
rename the guest if the name is wrong. Hence this is an error, not a
|
|
|
c659c5 |
warning or an attempt to rename the guest.
|
|
|
c659c5 |
|
|
|
c659c5 |
Reported-by: Ming Xie
|
|
|
c659c5 |
Fixes: commit bfa62b4683d312fc2fa9bb3c08963fc4846831b9
|
|
|
c659c5 |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2162332
|
|
|
c659c5 |
(cherry picked from commit 8a9c914544a49bed13eb5baf42290f835bdee7b5)
|
|
|
c659c5 |
---
|
|
|
c659c5 |
output/output_kubevirt.ml | 11 +++++++++++
|
|
|
c659c5 |
1 file changed, 11 insertions(+)
|
|
|
c659c5 |
|
|
|
c659c5 |
diff --git a/output/output_kubevirt.ml b/output/output_kubevirt.ml
|
|
|
c659c5 |
index 0a74dbbe..00e6a8a5 100644
|
|
|
c659c5 |
--- a/output/output_kubevirt.ml
|
|
|
c659c5 |
+++ b/output/output_kubevirt.ml
|
|
|
c659c5 |
@@ -29,6 +29,11 @@ open Utils
|
|
|
c659c5 |
open Output
|
|
|
c659c5 |
open Create_kubevirt_yaml
|
|
|
c659c5 |
|
|
|
c659c5 |
+(* Valid output names for Kubevirt (RHBZ#2162332). *)
|
|
|
c659c5 |
+let rfc1123_re =
|
|
|
c659c5 |
+ PCRE.compile ~anchored:true
|
|
|
c659c5 |
+ "[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*"
|
|
|
c659c5 |
+
|
|
|
c659c5 |
module Kubevirt = struct
|
|
|
c659c5 |
type poptions = output_allocation * string * string * string
|
|
|
c659c5 |
|
|
|
c659c5 |
@@ -60,6 +65,12 @@ module Kubevirt = struct
|
|
|
c659c5 |
|
|
|
c659c5 |
let output_name = Option.default source.s_name options.output_name in
|
|
|
c659c5 |
|
|
|
c659c5 |
+ if not (PCRE.matches rfc1123_re output_name) then
|
|
|
c659c5 |
+ error (f_"-o kubevirt: the guest name must contain only lowercase \
|
|
|
c659c5 |
+ alphanumeric characters, '-' or '.', and must start and \
|
|
|
c659c5 |
+ end with an alphanumeric character. Rerun virt-v2v with \
|
|
|
c659c5 |
+ the '-on name' option to rename it.");
|
|
|
c659c5 |
+
|
|
|
c659c5 |
options.output_alloc, options.output_format, output_name, output_storage
|
|
|
c659c5 |
|
|
|
c659c5 |
let setup dir options source =
|