public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC container] api: create: disallow passing along existing disk for restore
Date: Mon, 11 Apr 2022 12:39:50 +0200	[thread overview]
Message-ID: <20220411103950.44029-1-f.ebner@proxmox.com> (raw)

For VMs, the plan is to allow passing along disk options (with the
currently configured disks) for a restore operation to cause those
disks to be kept instead of removing and restoring them from backup.
Users might expect the same behavior for containers once that feature
exists, but implementing it requires partial restore functionality and
caution with the mount point structure, so for now, error out instead.

This is a breaking change, but hopefully, the impact is limited:
* Specifying a volume owned by a different container to have it (or
  rather its file system contents) be overwritten/merged during
  restore is a rather unusual use case.
* Specifying a volume owned by the current container only worked if it
  was not referenced, because otherwise it would be removed when the
  container was destroyed just before restore_archive() is called.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

IMHO we cannot use the same syntax for VMs and containers if the
behavior will be different, so if this change is not okay, I'll use an
alternative to the one outlined above, for example, simply a list of
drive keys to be left untouched.

 src/PVE/API2/LXC.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index ea4827f..5c8c83d 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -349,6 +349,11 @@ __PACKAGE__->register_method({
 	    if ($mountpoint->{type} ne 'volume') { # bind or device
 		die "Only root can pass arbitrary filesystem paths.\n"
 		    if !$is_root;
+	    } elsif ($restore && $volid !~ $PVE::LXC::NEW_DISK_RE) {
+		raise_param_exc({
+		    $ms => "cannot specify existing disk for restore - use <storage ID>:<size> ".
+			"syntax to allocate a new disk instead\n",
+		});
 	    } else {
 		my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
 		&$check_and_activate_storage($sid);
-- 
2.30.2





             reply	other threads:[~2022-04-11 10:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11 10:39 Fabian Ebner [this message]
2022-04-19  9:54 ` 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=20220411103950.44029-1-f.ebner@proxmox.com \
    --to=f.ebner@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal