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

CloningVolumeSource doesn't support clones between pools #67

Open
richt-volx opened this issue Aug 21, 2024 · 0 comments
Open

CloningVolumeSource doesn't support clones between pools #67

richt-volx opened this issue Aug 21, 2024 · 0 comments

Comments

@richt-volx
Copy link

richt-volx commented Aug 21, 2024

I tried cloning a volume between 2 libvirt storage pools as follows:

volume {
    name  = "my-new-root-volume"
    bus   = "virtio"
    pool  = "default"
    alias = "artifact"
    source {
      type   = "cloning"
      pool   = "my-library-pool"
      volume = "noble-server-cloudimg-amd64.img"
    }
  }

Running that gives with -debug gives the following relevant log entries:

==> test_build.libvirt.cloud_image: Preparing volumes...
    test_build.libvirt.cloud_image: Preparing volume 
...
==> test_build.libvirt.cloud_image: Pausing after run of step 'stepPrepareVolumes'. Press enter to continue. 
==> test_build.libvirt.cloud_image: Sending the domain definition to libvirt
==> test_build.libvirt.cloud_image: Pausing after run of step 'stepDefineDomain'. Press enter to continue. 
==> test_build.libvirt.cloud_image: Starting the Libvirt domain
==> test_build.libvirt.cloud_image: DomainCreate.RPC: Storage volume not found: no storage vol with matching name 'my-new-root-volume'

Checking with virsh shows that 'my-new-root-volume' has been created in 'my-library-pool', not in 'default'.

The issue here is in the call to StorageVolCreateXMLFrom in PreparationContext.CloneVolumeFrom preparation_context.go

	ref, err := pctx.Driver.StorageVolCreateXMLFrom(sourcePool, volumeXML, sourceVol, 0)

This is actually passing the sourcePool twice - once as the Pool parameter, and again as sourceVol.Pool. If we alter the call to CloneVolumeFrom to pass in the target pool as the 'Pool' parameter libvirt does the right thing and creates the cloned volume in the specified target pool ('default' in this case).

I have a branch with the updates to get cross-pool clones working, let me know if it would be helpful to tidy it up and open a PR for it.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant