Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Support virtio ISO from data domain in VM import #570

Merged
merged 1 commit into from
Aug 31, 2022

Conversation

smelamud
Copy link
Member

@smelamud smelamud commented Aug 3, 2022

Path to a virtio ISO image used in VM import was constructed assuming
that the image is located in an ISO domain. To support ISO images
located in a data domain we need to pass the storage domain ID to
ConvertVmCommand and use prepareImage()/teardownImage() to obtain the
path to the image on the host where VM conversion is running.

Due to limitation of prepareImage()/teardownImage() on VDSM side, these
calls cannot be nested. That's why the ISO image located in a data
domain can be used exclusively by a single instance of ConvertVmCommand.
Usage of it by any running VM or by other ConvertVmCommand instances in
the same time is prohibited.

Change-Id: I835602a9019ecbcf4c63529a9d006bc43ee793be
Bug-Url: https://bugzilla.redhat.com/1721455
Signed-off-by: Shmuel Melamud smelamud@redhat.com

@smelamud smelamud added the virt label Aug 3, 2022
@smelamud smelamud self-assigned this Aug 3, 2022
@smelamud smelamud requested a review from liranr23 August 3, 2022 02:29
return;
}
DiskImage isoImage = imagesHandler.getSnapshotLeaf(new Guid(getParameters().getVirtioIsoName()));
imagesHandler.teardownImage(getStoragePoolId(),
Copy link
Member

Choose a reason for hiding this comment

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

and what if this iso is used concurrently by another VM on this host?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. So, I can block this, like it is done in MeasureVolumeCommand - it fails in validation, if the disk is used by a running VM.

But there is also a case when the same ISO is used by several ConvertVm commands. I can use in-memory locks for this, for disks on data domains only.

Copy link
Member

Choose a reason for hiding this comment

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

So it means we cannot attach the ISO if is used by an active VM? Does anything prevents using it by multiple active VMs not considering the import? Is it a limitation of prepare / tear down image on the Vdsm side, perhaps missing support for using and sharing read-only images (how do we use CDs if it is the case? or can we not use CDs from data domains)? Please explain in the commit message what we reasonably can do, cannot do and actually do here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member Author

Choose a reason for hiding this comment

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

Another question is: what will happen, if some VM using the ISO image will be started after the ConvertVmCommand is started? I don't see this solved for MeasureVolumeCommand also. And cannot figure out a good way to prevent this.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mz-pdm In MeasureVolumeCommand there was a different reason for blocking usage of the same disk by any active VMs. Not because of prepare/teardownImage(), but because qemu cannot use a disk that was open for writing by another process. If a VM using the disk starts after starting MeasureVmCommand, qemu will fail to start.

In our case the ISO disk will be opened for reading, but the limitation of prepare/teardownImage() still exists. Although, it is quite unlikely that some VM will use the ISO with virtio drivers as a disk.

Copy link
Member

Choose a reason for hiding this comment

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

There may be other ISOs that users might use in running VMs. If I understand you correctly, there is nothing preventing attempts to start multiple VMs using the same ISO, but it will fail in Vdsm on preparing the image.

If we cannot resolve it easily, we could perhaps do:

  • Providing a doc text explaining the limitations.

  • Does or could the user get a comprehensible error message on such a VM start failure?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mz-pdm I've talked with Benny about prepare/teardownImage(). There are two important things:

  1. teardownImage() does not affect running VMs using the same disk. This situation is handled inside VDSM since 4.4.
  2. It is true that several commands cannot use prepare/teardownImage() on the same disk simultaneously. But this is true for block storage only. It's not a problem for file storage.

I'll update the patch accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

Great, good news, thanks.

Copy link
Member

@mz-pdm mz-pdm left a comment

Choose a reason for hiding this comment

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

Looks like a nice change but sharing the image requires clarification and the change should get additional review from another reviewer.

@@ -189,17 +202,39 @@ protected boolean validate() {

if (getVm().getOrigin() != OriginType.KVM &&
getParameters().getVirtioIsoName() != null &&
getVirtioIsoStorageDomainType() == StorageDomainType.ISO &&
Copy link
Member

Choose a reason for hiding this comment

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

Cool, does this fix, together with the other changes here, https://bugzilla.redhat.com/2109021 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Path to a virtio ISO image used in VM import was constructed assuming
that the image is located in an ISO domain. To support ISO images
located in a data domain we need to pass the storage domain ID to
ConvertVmCommand and use prepareImage()/teardownImage() to obtain the
path to the image on the host where VM conversion is running.

Due to limitation of prepareImage()/teardownImage() on VDSM side, these
calls cannot be nested. That's why the ISO image located in a block data
domain can be used exclusively by a single instance of ConvertVmCommand.

Change-Id: I835602a9019ecbcf4c63529a9d006bc43ee793be
Bug-Url: https://bugzilla.redhat.com/1721455
Signed-off-by: Shmuel Melamud <smelamud@redhat.com>
@mz-pdm
Copy link
Member

mz-pdm commented Aug 18, 2022

Looks good to me.

@smelamud
Copy link
Member Author

@mz-pdm So, can you approve?

@smelamud smelamud merged commit 7906d9e into oVirt:master Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants