Skip to content

Conversation

@MusicDin
Copy link
Member

@MusicDin MusicDin commented Apr 25, 2024

This is first part of the Improve VM import from external sources.

It introduces the new migration source type conversion, which ensures the received image is converted using qemu-img into the raw image format.

All virt-v2v bits are stripped away and will be introduced in the second part where we will also introduce conversion option virtio which will run virt-v2v-in-place on converted image to ensure virtio drivers are present.


TODO:

@github-actions github-actions bot added Documentation Documentation needs updating API Changes to the REST API labels Apr 25, 2024
@github-actions
Copy link

Heads up @ru-fu - the "Documentation" label was applied to this issue.

@MusicDin MusicDin force-pushed the feat/vm-import branch 3 times, most recently from 0c4b4ea to 1cbf3cd Compare April 25, 2024 14:44
@MusicDin MusicDin force-pushed the feat/vm-import branch 3 times, most recently from f51053f to f78b84b Compare May 8, 2024 14:56
@MusicDin
Copy link
Member Author

For tests we could use VMDK images provided on ubuntu cloud (https://cloud-images.ubuntu.com/releases/22.04/release-20240514). They are a bit bulky (~600MiB), but offer a reliable way to get images without the need to prepare them during the tests or store pre-build image within a repository.

@tomponline
Copy link
Member

For tests we could use VMDK images provided on ubuntu cloud (https://cloud-images.ubuntu.com/releases/22.04/release-20240514). They are a bit bulky (~600MiB), but offer a reliable way to get images without the need to prepare them during the tests or store pre-build image within a repository.

Sounds good, thanks.

@tomponline
Copy link
Member

Are there ubuntu-minimal variants we can use that are smaller?

@MusicDin
Copy link
Member Author

I couldn't find one, but it would very practical to use minimal images.

@MusicDin MusicDin force-pushed the feat/vm-import branch 2 times, most recently from 2b81fb4 to eb4a929 Compare May 24, 2024 10:23
@MusicDin MusicDin marked this pull request as ready for review May 24, 2024 13:58
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its somewhat concerning me that this implementation for image conversion has been implemented inside the migration functions.

I realise the lxd-migrate tool uses the migration protocol, but as the migration handlers are already quite complex, I'm wondering if we should take this opportunity to add a new function to the storage subsystem CreateInstanceFromConversion and then separate the handlers entirely.

Even if no conversion options are being used (i.e straight raw import too).

What do you think?

MusicDin added 21 commits July 17, 2024 15:20
The volume size of the imported VM disk is:
1. User specified storage pool and volume size - respect even if image won't fit in the pool (error out in such case).
2. User did not specify volume size - depends on conversion option format:
   a) format is enabled: Use the size of the uncompressed image (we get that info from qemu-img info)
   b) format is disabled: Use the value from SourceDiskSize field - We need to know the volume size before copying the image / disk as it will go directly into the volume.

Signed-off-by: Din Music <[email protected]>
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tomponline tomponline merged commit 2a24306 into canonical:main Jul 17, 2024
@MusicDin MusicDin deleted the feat/vm-import branch July 17, 2024 18:44
hamistao pushed a commit to hamistao/lxd that referenced this pull request Jul 17, 2024
This is first part of the [Improve VM import from external
sources](https://discourse.ubuntu.com/t/improve-vm-import-from-external-sources/41762).

It introduces the new migration source type `conversion`, which ensures
the received image is converted using `qemu-img` into the raw image
format.

All virt-v2v bits are stripped away and will be introduced in the second
part where we will also introduce conversion option `virtio` which will
run virt-v2v-in-place on converted image to ensure virtio drivers are
present.

---

TODO:
- [x] qemu-img info is not provided with image format explicitly
([Comment on
spec](https://discourse.ubuntu.com/t/improve-vm-import-from-external-sources/41762/15))
- [x] conversionOpts: `--conversion=format` (list of conversion options)
- [x] Add tests for conversion
(canonical/lxd-ci#179)

Signed-off-by: hamistao <[email protected]>
tomponline added a commit that referenced this pull request Jul 24, 2024
Wrong path is passed to the `isImageTypeRaw` check.

Introduced in #13385
tomponline added a commit that referenced this pull request Jul 26, 2024
This PR adds new conversion option `virtio` (disabled by default). When
enabled, LXD invokes `virt-v2v-in-place` tool on the host to inject
virtio drivers into the image. For Windows images, additional drivers
need to be present in `/usr/share/virt-tools`.

This requires:
- For rebase: #13385
- Custom command in LXD snap to invoke virt-v2v-in-place on the host:
canonical/lxd-pkg-snap#510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API Changes to the REST API Documentation Documentation needs updating

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants