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