From b66178e2228a1c43806e9330dfdc1a2a07c51719 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Apr 05 2016 13:40:00 +0000 Subject: import libguestfs-1.28.1-1.55.el7_2.2 --- diff --git a/SOURCES/0237-v2v-Use-libvirt-supplied-vmware-datacenterpath-if-av.patch b/SOURCES/0237-v2v-Use-libvirt-supplied-vmware-datacenterpath-if-av.patch new file mode 100644 index 0000000..592a79d --- /dev/null +++ b/SOURCES/0237-v2v-Use-libvirt-supplied-vmware-datacenterpath-if-av.patch @@ -0,0 +1,144 @@ +From 3a937f3fac910fa7109f7edd0608388f52bec95e Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Fri, 9 Oct 2015 12:22:52 +0100 +Subject: [PATCH] v2v: Use libvirt-supplied if + available. + +In libvirt >= 1.2.20, the VMware libvirt driver supplies the correct +dcPath to use via in the libvirt XML. If +libvirt passes us this element, use it. + +This code still allows the user to override dcPath using the --dcPath +option on the command line, but that's mainly for safety so we can fix +any problems in virt-v2v or libvirt in the field. As we get more +confident in libvirt and as libvirt 1.2.20 is more widely adopted, we +will be able to deprecate this parameter entirely. + +Thanks: Matthias Bolte for adding the element +to libvirt in +https://libvirt.org/git/?p=libvirt.git;a=commit;h=636a99058758a0447482f3baad94de8de3ab1151 + +(cherry picked from commit ffea9f97926efc45c894a113b65b2ff467d91b04) +--- + v2v/input_libvirt_vcenter_https.ml | 52 +++++++++++++++++++++++++------------- + v2v/virt-v2v.pod | 9 +++---- + 2 files changed, 38 insertions(+), 23 deletions(-) + +diff --git a/v2v/input_libvirt_vcenter_https.ml b/v2v/input_libvirt_vcenter_https.ml +index 684a7e4..25a8ee9 100644 +--- a/v2v/input_libvirt_vcenter_https.ml ++++ b/v2v/input_libvirt_vcenter_https.ml +@@ -192,9 +192,7 @@ let get_dcPath uri scheme = + * However if there is a cluster involved then the URI may be + * /Folder/Datacenter/Cluster/esxi but dcPath=Folder/Datacenter/Cluster + * won't work. In this case the user has to adjust the path to +- * remove the Cluster name (which still works in libvirt). There +- * should be a way to ask the libvirt vpx driver for the correct +- * path, but there isn't. XXX See also RHBZ#1256823. ++ * remove the Cluster name (which still works in libvirt). + *) + (* Collapse multiple slashes to single slash. *) + let path = Str.global_replace multiple_slash "/" path in +@@ -242,19 +240,6 @@ let map_source_to_uri ?readahead verbose dcPath password uri scheme server path + let datastore = Str.matched_group 1 path + and path = Str.matched_group 2 path in + +- (* Get the dcPath. *) +- let dcPath = +- match dcPath with +- | None -> +- let dcPath = get_dcPath uri scheme in +- if verbose then +- printf "vcenter: calculated dcPath as: %s\n" dcPath; +- dcPath +- | Some dcPath -> +- if verbose then +- printf "vcenter: using --dcpath from the command line: %s\n" dcPath; +- dcPath in +- + let port = + match uri.uri_port with + | 443 -> "" +@@ -317,11 +302,12 @@ let map_source_to_uri ?readahead verbose dcPath password uri scheme server path + + (* Subclass specialized for handling VMware vCenter over https. *) + class input_libvirt_vcenter_https +- verbose dcPath password libvirt_uri parsed_uri scheme server guest = ++ verbose cmdline_dcPath password libvirt_uri parsed_uri scheme server guest = + object + inherit input_libvirt verbose password libvirt_uri guest + + val saved_source_paths = Hashtbl.create 13 ++ val mutable dcPath = "" + + method source () = + if verbose then +@@ -336,6 +322,38 @@ object + let xml = Domainxml.dumpxml ?password ?conn:libvirt_uri guest in + let source, disks = parse_libvirt_xml ?conn:libvirt_uri ~verbose xml in + ++ (* Find the element from the XML, if it ++ * exists. This was added in libvirt >= 1.2.20. ++ *) ++ let xml_dcPath = ++ let doc = Xml.parse_memory xml in ++ let xpathctx = Xml.xpath_new_context doc in ++ Xml.xpath_register_ns xpathctx ++ "vmware" "http://libvirt.org/schemas/domain/vmware/1.0"; ++ let xpath_string = xpath_string xpathctx in ++ xpath_string "/domain/vmware:datacenterpath" in ++ ++ (* Calculate the dcPath we're going to use. *) ++ dcPath <- ( ++ match cmdline_dcPath, xml_dcPath with ++ (* Command line --dcpath parameter overrides everything, allowing ++ * users to correct any mistakes in v2v or libvirt. ++ *) ++ | Some p, (None|Some _) -> ++ if verbose then ++ printf "vcenter: using --dcpath from the command line: %s\n" p; ++ p ++ | None, Some p -> ++ if verbose then ++ printf "vcenter: using from libvirt: %s\n" p; ++ p ++ | None, None -> ++ let p = get_dcPath parsed_uri scheme in ++ if verbose then ++ printf "vcenter: guessed dcPath from URI: %s\n" p; ++ p ++ ); ++ + (* Save the original source paths, so that we can remap them again + * in [#adjust_overlay_parameters]. + *) +diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod +index 2e257de..b8caebc 100644 +--- a/v2v/virt-v2v.pod ++++ b/v2v/virt-v2v.pod +@@ -155,6 +155,9 @@ See I<--network> below. + + =item B<--dcpath> Folder/Datacenter + ++B You don't need to use this parameter if you have ++S 1.2.17-13.el7_2.4>. ++ + For VMware vCenter, override the C parameter used to + select the datacenter. Virt-v2v can usually calculate this from the + C URI, but if it gets it wrong, then you can override it using +@@ -845,12 +848,6 @@ added to the URI, eg: + + vpx://user@server/Folder/Datacenter/esxi + +-Virt-v2v needs to calculate the C parameter from the URI, and +-it does this by removing the final C element, so in the above +-example C. As it is not always possible to +-correctly calculate C from the URI, you can override this +-using the I<--dcpath> parameter. +- + For full details of libvirt URIs, see: L + + Typical errors from libvirt / virsh when the URI is wrong include: +-- +1.8.3.1 + diff --git a/SOURCES/0238-v2v-update-URL-with-glance-metadata.patch b/SOURCES/0238-v2v-update-URL-with-glance-metadata.patch new file mode 100644 index 0000000..a07ebba --- /dev/null +++ b/SOURCES/0238-v2v-update-URL-with-glance-metadata.patch @@ -0,0 +1,26 @@ +From e423737f2b70c4bc709e75344985e7b1f6691bd4 Mon Sep 17 00:00:00 2001 +From: Pino Toscano +Date: Tue, 16 Feb 2016 14:42:44 +0100 +Subject: [PATCH] v2v: update URL with glance metadata + +(cherry picked from commit 967e887e43cea3ffb6572b24cc995a0bb893e80f) +--- + v2v/output_glance.ml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/v2v/output_glance.ml b/v2v/output_glance.ml +index f120cfa..f8c8806 100644 +--- a/v2v/output_glance.ml ++++ b/v2v/output_glance.ml +@@ -94,7 +94,7 @@ object + "os_type", inspect.i_type; + "os_distro", + (match inspect.i_distro with +- (* http://docs.openstack.org/grizzly/openstack-compute/admin/content/image-metadata.html *) ++ (* http://docs.openstack.org/cli-reference/glance.html#image-service-property-keys *) + | "archlinux" -> "arch" + | "sles" -> "sled" + | x -> x (* everything else is the same in libguestfs and OpenStack *) +-- +1.8.3.1 + diff --git a/SOURCES/0239-v2v-glance-Add-OUTPUT-TO-GLANCE-section-to-the-docum.patch b/SOURCES/0239-v2v-glance-Add-OUTPUT-TO-GLANCE-section-to-the-docum.patch new file mode 100644 index 0000000..54d4122 --- /dev/null +++ b/SOURCES/0239-v2v-glance-Add-OUTPUT-TO-GLANCE-section-to-the-docum.patch @@ -0,0 +1,64 @@ +From ec25f65e929813530d4ff5bbf027bccaf2137b2b Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 16 Feb 2016 12:29:41 +0000 +Subject: [PATCH] v2v: glance: Add "OUTPUT TO GLANCE" section to the + documentation. + +(cherry picked from commit bae3d92e88b7e74af11a5d0905710cf00f2504e3) +--- + v2v/virt-v2v.pod | 25 ++++++++++++++++++++++--- + 1 file changed, 22 insertions(+), 3 deletions(-) + +diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod +index b8caebc..876d5f6 100644 +--- a/v2v/virt-v2v.pod ++++ b/v2v/virt-v2v.pod +@@ -116,7 +116,7 @@ run on OpenStack (only KVM-based OpenStack is supported), you can do: + + virt-v2v -i disk disk.img -o glance + +-To control the name of the image in Glance, use the I<-on> option. ++See L below. + + =head2 Convert disk image to disk image + +@@ -309,8 +309,7 @@ This is the same as I<-o local>. + =item B<-o glance> + + Set the output method to OpenStack Glance. In this mode the converted +-guest is uploaded to Glance. You can control the image name by setting +-the I<-on> option. ++guest is uploaded to Glance. See L below. + + =item B<-o libvirt> + +@@ -1139,6 +1138,26 @@ additional details. + If you export several guests, then you can import them all at the same + time through the UI. + ++=head1 OUTPUT TO GLANCE ++ ++To output to OpenStack Glance, use the I<-o glance> option. ++ ++This runs the L CLI program which must be installed on the ++virt-v2v conversion host. For authentication to work, you will need ++to set C environment variables. In most cases you can do this ++by sourcing a file called something like F. ++ ++Virt-v2v adds metadata for the guest to Glance, describing such things ++as the guest operating system and what drivers it requires. The ++command C will display the metadata as "Property" ++fields such as C and C. ++ ++=head2 Glance and sparseness ++ ++Glance image upload doesn't appear to correctly handle sparseness. ++For this reason, using qcow2 will be faster and use less space on the ++Glance server. Use the virt-v2v S> option. ++ + =head1 RESOURCE REQUIREMENTS + + =head2 Network +-- +1.8.3.1 + diff --git a/SOURCES/0240-v2v-glance-Allow-Glance-backend-to-import-multiple-d.patch b/SOURCES/0240-v2v-glance-Allow-Glance-backend-to-import-multiple-d.patch new file mode 100644 index 0000000..2cfe0ba --- /dev/null +++ b/SOURCES/0240-v2v-glance-Allow-Glance-backend-to-import-multiple-d.patch @@ -0,0 +1,204 @@ +From 7997ac9e9ee0b041c54d20f5e3a6c6aa68f5c2e7 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 16 Feb 2016 12:30:00 +0000 +Subject: [PATCH] v2v: glance: Allow Glance backend to import multiple disks + (RHBZ#1308769). + +(cherry picked from commit 6200ae7204f4db3b93707acf7356083e121f854f) +--- + v2v/output_glance.ml | 133 ++++++++++++++++++++++++++------------------------- + v2v/virt-v2v.pod | 24 ++++++++++ + 2 files changed, 93 insertions(+), 64 deletions(-) + +diff --git a/v2v/output_glance.ml b/v2v/output_glance.ml +index f8c8806..1ca37eb 100644 +--- a/v2v/output_glance.ml ++++ b/v2v/output_glance.ml +@@ -51,11 +51,7 @@ object + if Sys.command "glance image-list > /dev/null" <> 0 then + error (f_"glance: glance client is not installed or set up correctly. You may need to set environment variables or source a script to enable authentication. See preceding messages for details."); + +- (* OpenStack only supports single image VMs, I think? *) +- let nr_targets = List.length targets in +- if nr_targets <> 1 then +- error (f_"glance: OpenStack conversion only supports virtual machines with a single disk image. This VM has %d") nr_targets; +- ++ (* Write targets to a temporary local file - see above for reason. *) + List.map ( + fun t -> + let target_file = tmpdir // t.target_overlay.ov_sd in +@@ -66,68 +62,77 @@ object + (* See #supported_firmware above. *) + assert (target_firmware = TargetBIOS); + +- (* Upload the disk image (there should only be one - see above). *) +- let { target_file = target_file; target_format = target_format } = +- List.hd targets in +- let cmd = +- sprintf "glance image-create --name %s --disk-format=%s --container-format=bare --file %s" +- (quote source.s_name) (quote target_format) target_file in +- if verbose then printf "%s\n%!" cmd; +- if Sys.command cmd <> 0 then +- error (f_"glance: image upload to glance failed, see earlier errors"); ++ (* The first disk, assumed to be the system, will be called ++ * "guestname". Subsequent disks, assumed to be data disks, ++ * will be called "guestname-disk2" etc. The manual strongly ++ * hints you should import the data disks to Cinder. ++ *) ++ List.iteri ( ++ fun i { target_file = target_file; target_format = target_format } -> ++ let name = ++ if i == 0 then source.s_name ++ else sprintf "%s-disk%d" source.s_name (i+1) in + +- (* Set the properties (ie. metadata). *) +- let min_ram = source.s_memory /^ 1024L /^ 1024L in +- let properties = [ +- "hw_disk_bus", +- (match guestcaps.gcaps_block_bus with +- | Virtio_blk -> "virtio" +- | IDE -> "ide"); +- "hw_vif_model", +- (match guestcaps.gcaps_net_bus with +- | Virtio_net -> "virtio" +- | E1000 -> "e1000" +- | RTL8139 -> "rtl8139"); +- "architecture", guestcaps.gcaps_arch; +- "hypervisor_type", "kvm"; +- "vm_mode", "hvm"; +- "os_type", inspect.i_type; +- "os_distro", +- (match inspect.i_distro with +- (* http://docs.openstack.org/cli-reference/glance.html#image-service-property-keys *) +- | "archlinux" -> "arch" +- | "sles" -> "sled" +- | x -> x (* everything else is the same in libguestfs and OpenStack *) +- ) +- ] in +- let properties = +- match inspect.i_major_version, inspect.i_minor_version with +- | 0, 0 -> properties +- | x, 0 -> ("os_version", string_of_int x) :: properties +- | x, y -> ("os_version", sprintf "%d.%d" x y) :: properties in ++ let cmd = ++ sprintf "glance image-create --name %s --disk-format=%s --container-format=bare --file %s" ++ (quote name) (quote target_format) target_file in ++ if verbose then printf "%s\n%!" cmd; ++ if Sys.command cmd <> 0 then ++ error (f_"glance: image upload to glance failed, see earlier errors"); + +- (* Glance doesn't appear to check the properties. *) +- let cmd = +- sprintf "glance image-update --min-ram %Ld %s %s" +- min_ram +- (String.concat " " ( +- List.map ( +- fun (k, v) -> +- sprintf "--property %s=%s" (quote k) (quote v) ++ (* Set the properties (ie. metadata). *) ++ let min_ram = source.s_memory /^ 1024L /^ 1024L in ++ let properties = [ ++ "hw_disk_bus", ++ (match guestcaps.gcaps_block_bus with ++ | Virtio_blk -> "virtio" ++ | IDE -> "ide"); ++ "hw_vif_model", ++ (match guestcaps.gcaps_net_bus with ++ | Virtio_net -> "virtio" ++ | E1000 -> "e1000" ++ | RTL8139 -> "rtl8139"); ++ "architecture", guestcaps.gcaps_arch; ++ "hypervisor_type", "kvm"; ++ "vm_mode", "hvm"; ++ "os_type", inspect.i_type; ++ "os_distro", ++ (match inspect.i_distro with ++ (* http://docs.openstack.org/cli-reference/glance.html#image-service-property-keys *) ++ | "archlinux" -> "arch" ++ | "sles" -> "sled" ++ | x -> x (* everything else is the same in libguestfs and OpenStack*) ++ ) ++ ] in ++ let properties = ++ match inspect.i_major_version, inspect.i_minor_version with ++ | 0, 0 -> properties ++ | x, 0 -> ("os_version", string_of_int x) :: properties ++ | x, y -> ("os_version", sprintf "%d.%d" x y) :: properties in ++ ++ (* Glance doesn't appear to check the properties. *) ++ let cmd = ++ sprintf "glance image-update --min-ram %Ld %s %s" ++ min_ram ++ (String.concat " " ++ (List.map ( ++ fun (k, v) -> ++ sprintf "--property %s=%s" (quote k) (quote v) ++ ) properties ++ )) ++ (quote name) in ++ if verbose then printf "%s\n%!" cmd; ++ if Sys.command cmd <> 0 then ( ++ warning ~prog (f_"glance: failed to set image properties (ignored)"); ++ (* Dump out the image properties so the user can set them. *) ++ printf "Image properties:\n"; ++ printf " --min-ram %Ld\n" min_ram; ++ List.iter ( ++ fun (k, v) -> ++ printf " --property %s=%s" (quote k) (quote v) + ) properties +- )) +- (quote source.s_name) in +- if verbose then printf "%s\n%!" cmd; +- if Sys.command cmd <> 0 then ( +- warning ~prog (f_"glance: failed to set image properties (ignored)"); +- (* Dump out the image properties so the user can set them. *) +- printf "Image properties:\n"; +- printf " --min-ram %Ld\n" min_ram; +- List.iter ( +- fun (k, v) -> +- printf " --property %s=%s" (quote k) (quote v) +- ) properties +- ) ++ ) ++ ) targets + end + + let output_glance = new output_glance +diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod +index 876d5f6..d4fdf5d 100644 +--- a/v2v/virt-v2v.pod ++++ b/v2v/virt-v2v.pod +@@ -1158,6 +1158,30 @@ Glance image upload doesn't appear to correctly handle sparseness. + For this reason, using qcow2 will be faster and use less space on the + Glance server. Use the virt-v2v S> option. + ++=head2 Glance and multiple disks ++ ++If the guest has a single disk, then the name of the disk in Glance ++will be the name of the guest. You can control this using the I<-on> ++option. ++ ++Glance doesn't have a concept of associating multiple disks with a ++single guest, and Nova doesn't allow you to boot a guest from multiple ++Glance disks either. If the guest has multiple disks, then the first ++(assumed to be the system disk) will have the name of the guest, and ++the second and subsequent data disks will be called ++C-disk2>, C-disk3> etc. It may be best to ++leave the system disk in Glance, and import the data disks to Cinder ++(see next section). ++ ++=head2 Importing disks into Cinder ++ ++Since most virt-v2v guests are "pets", Glance is perhaps not the best ++place to store them. There is no way for virt-v2v to upload directly ++to Cinder (L), so instead you ++must import them yourself by doing: ++ ++ cinder create --image-id ++ + =head1 RESOURCE REQUIREMENTS + + =head2 Network +-- +1.8.3.1 + diff --git a/SPECS/libguestfs.spec b/SPECS/libguestfs.spec index 3bde710..3959f0f 100644 --- a/SPECS/libguestfs.spec +++ b/SPECS/libguestfs.spec @@ -20,7 +20,7 @@ Summary: Access and modify virtual machine disk images Name: libguestfs Epoch: 1 Version: 1.28.1 -Release: 1.55%{?dist} +Release: 1.55%{?dist}.2 License: LGPLv2+ # Source and patches. @@ -271,6 +271,10 @@ Patch0233: 0233-v2v-o-rhev-o-vdsm-Set-DefaultDisplayType-back-to-1-R.patch Patch0234: 0234-v2v-Move-anti-virus-AV-detection-code-to-a-separate-.patch Patch0235: 0235-v2v-Detect-AVG-Technologies-as-AV-software-RHBZ-1261.patch Patch0236: 0236-perl-Set-program-name-to-the-true-name-instead-of-pe.patch +Patch0237: 0237-v2v-Use-libvirt-supplied-vmware-datacenterpath-if-av.patch +Patch0238: 0238-v2v-update-URL-with-glance-metadata.patch +Patch0239: 0239-v2v-glance-Add-OUTPUT-TO-GLANCE-section-to-the-docum.patch +Patch0240: 0240-v2v-glance-Allow-Glance-backend-to-import-multiple-d.patch # Use git for patch management. BuildRequires: git @@ -1346,6 +1350,14 @@ cp %{SOURCE7} $RPM_BUILD_ROOT%{_datadir}/virt-tools/rhev-apt.exe %changelog +* Thu Mar 10 2016 Richard W.M. Jones - 1:1.28.1-1.55.el7_2.3 +- v2v: Copy additional disks to Glance + resolves: rhbz#1316625 + +* Tue Feb 09 2016 Richard W.M. Jones - 1:1.28.1-1.55.el7_2.1 +- virt-v2v pull dcpath from libvirt + resolves: rhbz#1305526 + * Mon Sep 14 2015 Richard W.M. Jones - 1:1.28.1-1.55 - Fix previous commit by applying the patch this time (1243493)