mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

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

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