Blame SOURCES/0075-v2v-parse_libvirt_xml-handle-srN-CDROM-devices-RHBZ-.patch

97ae69
From 0b6ae16f01aaa1a6d5ba9f240e131c688c7224ca Mon Sep 17 00:00:00 2001
97ae69
From: Pino Toscano <ptoscano@redhat.com>
97ae69
Date: Thu, 9 Aug 2018 15:01:37 +0200
97ae69
Subject: [PATCH] v2v: parse_libvirt_xml: handle srN CDROM devices
97ae69
 (RHBZ#1612785)
97ae69
97ae69
This device naming is mostly written by virt-p2v, so get the slot from
97ae69
it directly without using the drive_index "decoding" function.
97ae69
---
97ae69
 v2v/parse_libvirt_xml.ml | 10 ++++++++++
97ae69
 1 file changed, 10 insertions(+)
97ae69
97ae69
diff --git a/v2v/parse_libvirt_xml.ml b/v2v/parse_libvirt_xml.ml
97ae69
index 57e741574..4912f1cc0 100644
97ae69
--- a/v2v/parse_libvirt_xml.ml
97ae69
+++ b/v2v/parse_libvirt_xml.ml
97ae69
@@ -385,6 +385,16 @@ let parse_libvirt_xml ?conn xml =
97ae69
         let target_dev = xpath_string "target/@dev" in
97ae69
         match target_dev with
97ae69
         | None -> None
97ae69
+        | Some dev when String.is_prefix dev "sr" ->
97ae69
+           (* "srN" devices are found mostly in the physical XML written by
97ae69
+            * virt-p2v.
97ae69
+            *)
97ae69
+           let name = String.sub dev 2 (String.length dev - 2) in
97ae69
+           (try Some (int_of_string name)
97ae69
+            with Failure _ ->
97ae69
+              warning (f_"could not parse device name ā€˜%sā€™ from the source libvirt XML") dev;
97ae69
+              None
97ae69
+           )
97ae69
         | Some dev ->
97ae69
            let rec loop = function
97ae69
              | [] ->
97ae69
-- 
fd1da6
2.17.2
97ae69