On Wed, Mar 11, 2020 at 03:54:33PM +0100, Martin Kletzander wrote:
The validation helps us fail early and with a sensible error message.
The NIL
UUID is not valid for oVirt, but other than that there is no other logic in
there merely because the UUID types are a matter of the generator and they are
just forwarded in this partucular case.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
v2v/output_rhv_upload.ml | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
index 9e60d8c73150..e833569318b3 100644
--- a/v2v/output_rhv_upload.ml
+++ b/v2v/output_rhv_upload.ml
@@ -49,6 +49,16 @@ after their uploads (if you do, you must supply one for each disk):
-oo rhv-disk-uuid=UUID Disk UUID
")
+let is_nonnil_uuid uuid =
+ let nil_uuid = "00000000-0000-0000-0000-000000000000" in
+ let rex_uuid = lazy (
+ let hex = "[a-fA-F0-9]" in
+ let str = sprintf "^%s{8}-%s{4}-%s{4}-%s{4}-%s{12}$" hex hex hex hex hex
in
+ PCRE.compile str
+ ) in
+ if uuid = nil_uuid then false
+ else PCRE.matches (Lazy.force rex_uuid) uuid
Actually the use of lazy here is wrong. The regular expression
is not being created lazily at all.
You need to do something like:
let is_nonnil_uuid =
let nil_uuid = "00000000-0000-0000-0000-000000000000" in
let rex_uuid = lazy (
let hex = "[a-fA-F0-9]" in
let str = sprintf "^%s{8}-%s{4}-%s{4}-%s{4}-%s{12}$" hex hex hex hex hex in
PCRE.compile str
) in
fun uuid ->
if uuid = nil_uuid then false
else PCRE.matches (Lazy.force rex_uuid) uuid
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/