[Libguestfs] [PATCH] v2v: parse_libvirt_xml: handle srN CDROM devices (RHBZ#1612785)

Pino Toscano ptoscano at redhat.com
Thu Aug 9 13:05:26 UTC 2018


This device naming is mostly written by virt-p2v, so get the slot from
it directly without using the drive_index "decoding" function.
---
 v2v/parse_libvirt_xml.ml | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/v2v/parse_libvirt_xml.ml b/v2v/parse_libvirt_xml.ml
index 36d2f66dd..55432f537 100644
--- a/v2v/parse_libvirt_xml.ml
+++ b/v2v/parse_libvirt_xml.ml
@@ -396,7 +396,15 @@ let parse_libvirt_xml ?conn xml =
                 else
                   loop rest
            in
-           loop ["hd"; "sd"; "vd"; "xvd"; "fd"] in
+           if String.is_prefix dev "sr" then (
+             let name = String.sub dev 2 (String.length dev - 2) in
+             try Some (int_of_string name)
+             with Failure _ ->
+               warning (f_"could not parse device name ‘%s’ from the source libvirt XML") dev;
+               None
+           )
+           else
+             loop ["hd"; "sd"; "vd"; "xvd"; "fd"] in
 
       let typ =
         match xpath_string "@device" with
-- 
2.17.1




More information about the Libguestfs mailing list