Richard W.M. Jones
2016-Feb-16 15:54 UTC
[Libguestfs] [PATCH 0/2] v2v: glance: Allow Glance backend to import multiple disks
This patch series lifts the previous restriction that virt-v2v would refuse to convert a guest to Glance that had more than one disk. The first patch is just better documentation for the Glance output mode. The second patch contains the change (best viewed with 'git diff -w' since it is mostly a whitespace change). virt-v2v -o glance will now create multiple disks called: - guestname # assumed system disk - guestname-disk2 # assumed data disks - guestname-disk3 - etc. Probably you'd want to immediately import the data disks into Cinder, and possibly the system disk too. Unfortunately direct import from virt-v2v to Cinder is not possible at this time (https://bugzilla.redhat.com/1155229). Rich.
Richard W.M. Jones
2016-Feb-16 15:54 UTC
[Libguestfs] [PATCH 1/2] v2v: glance: Add "OUTPUT TO GLANCE" section to the documentation.
--- 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 0b19814..55a4cee 100644 --- a/v2v/virt-v2v.pod +++ b/v2v/virt-v2v.pod @@ -122,7 +122,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</OUTPUT TO GLANCE> below. =head2 Convert disk image to disk image @@ -429,8 +429,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</OUTPUT TO GLANCE> below. =item B<-o libvirt> @@ -1441,6 +1440,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<glance(1)> CLI program which must be installed on the +virt-v2v conversion host. For authentication to work, you will need +to set C<OS_*> environment variables. In most cases you can do this +by sourcing a file called something like F<keystonerc_admin>. + +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<glance image-show> will display the metadata as "Property" +fields such as C<os_type> and C<hw_disk_bus>. + +=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<I<-of qcow2>> option. + =head1 RESOURCE REQUIREMENTS =head2 Network -- 2.5.0
Richard W.M. Jones
2016-Feb-16 15:54 UTC
[Libguestfs] [PATCH 2/2] v2v: glance: Allow Glance backend to import multiple disks (RHBZ#1308769).
--- 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 f9d70a9..20d5441 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/grizzly/openstack-compute/admin/content/image-metadata.html *) - | "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/grizzly/openstack-compute/admin/content/image-metadata.html *) + | "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 (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 (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 55a4cee..e4e157b 100644 --- a/v2v/virt-v2v.pod +++ b/v2v/virt-v2v.pod @@ -1460,6 +1460,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<I<-of qcow2>> 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<I<guestname>-disk2>, C<I<guestname>-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<https://bugzilla.redhat.com/1155229>), so instead you +must import them yourself by doing: + + cinder create --image-id <GLANCE-IMAGE-UUID> <SIZE> + =head1 RESOURCE REQUIREMENTS =head2 Network -- 2.5.0
Pino Toscano
2016-Feb-17 15:33 UTC
Re: [Libguestfs] [PATCH 0/2] v2v: glance: Allow Glance backend to import multiple disks
On Tuesday 16 February 2016 15:54:17 Richard W.M. Jones wrote:> This patch series lifts the previous restriction that virt-v2v would > refuse to convert a guest to Glance that had more than one disk. > > The first patch is just better documentation for the Glance output > mode. The second patch contains the change (best viewed with > 'git diff -w' since it is mostly a whitespace change). > > virt-v2v -o glance will now create multiple disks called: > > - guestname # assumed system disk > - guestname-disk2 # assumed data disks > - guestname-disk3 > - etc. > > Probably you'd want to immediately import the data disks into Cinder, > and possibly the system disk too. > > Unfortunately direct import from virt-v2v to Cinder is not possible at > this time (https://bugzilla.redhat.com/1155229).LGTM. Note my recent 967e887e will conflict with patch #2... -- Pino Toscano
Apparently Analagous Threads
- [PATCH 1/2] v2v: -o glance: add property for UEFI firmware (RHBZ#1445659)
- [PATCH] v2v: -o glance: set all properties during creation (RHBZ#1374405)
- [PATCH 0/2] v2v: Add -o openstack target.
- [PATCH v2 0/2] v2v: Add -o openstack target.
- [PATCH v2 0/2] v2v: -o null: Use the qemu null device driver.