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

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