From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH v12 qemu-server 07/16] clone disk: allow cloning from an unused or unreferenced disk
Date: Mon, 14 Mar 2022 16:55:20 +0100 [thread overview]
Message-ID: <1647262537.el5ineow9k.astroid@nora.none> (raw)
In-Reply-To: <<20220309100919.31512-8-f.ebner@proxmox.com>
On March 9, 2022 11:09 am, Fabian Ebner wrote:
> and also when source and target drivename are different. In those
> cases, it is done via qemu-img convert/dd.
>
> In preparation to allow import from existing PVE-managed disks.
>
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
> PVE/API2/Qemu.pm | 2 ++
> PVE/QemuServer.pm | 29 +++++++++++++++++++----------
> 2 files changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 9b8eb88..3b86034 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -3228,6 +3228,7 @@ __PACKAGE__->register_method({
>
> my $dest_info = {
> vmid => $newid,
> + drivename => $opt,
> storage => $storage,
> format => $format,
> };
> @@ -3489,6 +3490,7 @@ __PACKAGE__->register_method({
>
> my $dest_info = {
> vmid => $vmid,
> + drivename => $disk,
> storage => $storeid,
> format => $format,
> };
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index ed06239..b98ed3d 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -7574,15 +7574,25 @@ sub clone_disk {
> my ($storecfg, $source, $dest, $full, $newvollist, $jobs, $completion, $qga, $bwlimit) = @_;
>
> my ($vmid, $running) = $source->@{qw(vmid running)};
> - my ($drivename, $drive, $snapname) = $source->@{qw(drivename drive snapname)};
> + my ($src_drivename, $drive, $snapname) = $source->@{qw(drivename drive snapname)};
>
> - my ($newvmid, $efisize) = $dest->@{qw(vmid efisize)};
> + my ($newvmid, $dst_drivename, $efisize) = $dest->@{qw(vmid drivename efisize)};
> my ($storage, $format) = $dest->@{qw(storage format)};
>
> + if ($src_drivename && $dst_drivename && $src_drivename ne $dst_drivename) {
> + die "cloning from/to EFI disk requires EFI disk\n"
> + if $src_drivename eq 'efidisk0' || $dst_drivename eq 'efidisk0';
> + die "cloning from/to TPM state requires TPM state\n"
> + if $src_drivename eq 'tpmstate0' || $dst_drivename eq 'tpmstate0';
potential follow-up: should we check `$running && !$snapname` here (continued below)
> + }
> +
> my $newvolid;
>
> + print "create " . ($full ? 'full' : 'linked') . " clone of drive ";
> + print "$src_drivename " if $src_drivename;
> + print "($drive->{file})\n";
> +
> if (!$full) {
> - print "create linked clone of drive $drivename ($drive->{file})\n";
> $newvolid = PVE::Storage::vdisk_clone($storecfg, $drive->{file}, $newvmid, $snapname);
> push @$newvollist, $newvolid;
> } else {
> @@ -7592,7 +7602,6 @@ sub clone_disk {
>
> my $dst_format = resolve_dst_disk_format($storecfg, $storeid, $volname, $format);
>
> - print "create full clone of drive $drivename ($drive->{file})\n";
> my $name = undef;
> my $size = undef;
> if (drive_is_cloudinit($drive)) {
> @@ -7603,9 +7612,9 @@ sub clone_disk {
> }
> $snapname = undef;
> $size = PVE::QemuServer::Cloudinit::CLOUDINIT_DISK_SIZE;
> - } elsif ($drivename eq 'efidisk0') {
> + } elsif ($dst_drivename eq 'efidisk0') {
> $size = $efisize or die "internal error - need to specify EFI disk size\n";
> - } elsif ($drivename eq 'tpmstate0') {
> + } elsif ($dst_drivename eq 'tpmstate0') {
> $dst_format = 'raw';
> $size = PVE::QemuServer::Drive::TPMSTATE_DISK_SIZE;
> } else {
> @@ -7629,9 +7638,9 @@ sub clone_disk {
> }
>
> my $sparseinit = PVE::Storage::volume_has_feature($storecfg, 'sparseinit', $newvolid);
> - if (!$running || $snapname) {
> + if (!$running || !$src_drivename || $snapname) {
> # TODO: handle bwlimits
> - if ($drivename eq 'efidisk0') {
> + if ($dst_drivename eq 'efidisk0') {
> # the relevant data on the efidisk may be smaller than the source
> # e.g. on RBD/ZFS, so we use dd to copy only the amount
> # that is given by the OVMF_VARS.fd
> @@ -7647,9 +7656,9 @@ sub clone_disk {
> qemu_img_convert($drive->{file}, $newvolid, $size, $snapname, $sparseinit);
> }
> } else {
corresponding to this else branch here - mirroring but changing
drivename is not something we currently ever want to do, so we might
want to guard against it?
> - die "cannot move TPM state while VM is running\n" if $drivename eq 'tpmstate0';
> + die "cannot move TPM state while VM is running\n" if $src_drivename eq 'tpmstate0';
>
> - qemu_drive_mirror($vmid, $drivename, $newvolid, $newvmid, $sparseinit, $jobs,
> + qemu_drive_mirror($vmid, $src_drivename, $newvolid, $newvmid, $sparseinit, $jobs,
> $completion, $qga, $bwlimit);
> }
> }
> --
> 2.30.2
>
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
>
next prev parent reply other threads:[~2022-03-14 15:55 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-09 10:09 [pve-devel] [PATCH-SERIES v12 qemu-server/manager] API for disk import and OVF Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 01/16] device unplug: verify that unplugging scsi disk completed Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 02/16] api: create disks: always activate/update size when attaching existing volume Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 03/16] api: update: pass correct config when creating disks Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 04/16] clone disk: remove check for min QEMU version 2.7 Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 05/16] clone disk: group source and target parameters Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 06/16] clone disk: pass in efi vars size rather than config Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 07/16] clone disk: allow cloning from an unused or unreferenced disk Fabian Ebner
[not found] ` <<20220309100919.31512-8-f.ebner@proxmox.com>
2022-03-14 15:55 ` Fabian Grünbichler [this message]
2022-03-17 10:35 ` Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 08/16] efivars size: allow overriding efidisk parameter Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 09/16] schema: add pve-volume-id-or-absolute-path Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 10/16] parse ovf: untaint path when calling file_size_info Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 11/16] api: add endpoint for parsing .ovf files Fabian Ebner
[not found] ` <<20220309100919.31512-12-f.ebner@proxmox.com>
2022-03-14 15:55 ` Fabian Grünbichler
2022-03-15 13:00 ` Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 12/16] image convert: allow block device as source Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 13/16] api: factor out check/cleanup for drive params Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 14/16] schema: drive: use separate schema when disk allocation is possible Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 15/16] api: support VM disk import Fabian Ebner
[not found] ` <<20220309100919.31512-16-f.ebner@proxmox.com>
2022-03-14 15:54 ` Fabian Grünbichler
2022-03-16 9:29 ` Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 qemu-server 16/16] api: update vm: print drive string for newly allocated/imported drives Fabian Ebner
2022-03-09 10:09 ` [pve-devel] [PATCH v12 manager 1/1] api: nodes: add readovf endpoint Fabian Ebner
2022-03-14 15:57 ` [pve-devel] partially-applied: [PATCH-SERIES v12 qemu-server/manager] API for disk import and OVF Fabian Grünbichler
2022-03-16 10:00 ` Fabian Ebner
2022-03-16 10:29 ` Fabian Grünbichler
2022-03-16 11:25 ` Fabian Ebner
2022-03-16 11:58 ` Fabian Grünbichler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1647262537.el5ineow9k.astroid@nora.none \
--to=f.gruenbichler@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox