public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container 1/2] restore: pass target vmid to config recovery
@ 2020-11-25 14:07 Fabian Grünbichler
  2020-11-25 14:07 ` [pve-devel] [PATCH container 2/2] restore: add more informational messages Fabian Grünbichler
  2021-01-26 17:52 ` [pve-devel] applied: [PATCH container 1/2] restore: pass target vmid to config recovery Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Fabian Grünbichler @ 2020-11-25 14:07 UTC (permalink / raw)
  To: pve-devel

so that we get the correct warning prefix when the config contains bogus lines.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/PVE/API2/LXC.pm   |  4 ++--
 src/PVE/LXC/Create.pm | 19 +++++++++++--------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 9ecfb12..a263104 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -354,7 +354,7 @@ __PACKAGE__->register_method({
 		    die "can't overwrite running container\n" if PVE::LXC::check_running($vmid);
 		    if ($is_root && $archive ne '-') {
 			my $orig_conf;
-			($orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($storage_cfg, $archive);
+			($orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($storage_cfg, $archive, $vmid);
 			$was_template = delete $orig_conf->{template};
 			# When we're root call 'restore_configuration' with restricted=0,
 			# causing it to restore the raw lxc entries, among which there may be
@@ -366,7 +366,7 @@ __PACKAGE__->register_method({
 		if ($storage_only_mode) {
 		    if ($restore) {
 			if (!defined($orig_mp_param)) {
-			    (undef, $orig_mp_param) = PVE::LXC::Create::recover_config($storage_cfg, $archive);
+			    (undef, $orig_mp_param) = PVE::LXC::Create::recover_config($storage_cfg, $archive, $vmid);
 			}
 			$mp_param = $orig_mp_param;
 			die "rootfs configuration could not be recovered, please check and specify manually!\n"
diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm
index 39902a2..d3939de 100644
--- a/src/PVE/LXC/Create.pm
+++ b/src/PVE/LXC/Create.pm
@@ -173,22 +173,24 @@ sub restore_tar_archive {
 }
 
 sub recover_config {
-    my ($storage_cfg, $volid) = @_;
+    my ($storage_cfg, $volid, $vmid) = @_;
 
     my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
     if (defined($storeid)) {
 	my $scfg = PVE::Storage::storage_check_enabled($storage_cfg, $storeid);
 	if ($scfg->{type} eq 'pbs') {
-	    return recover_config_from_proxmox_backup($storage_cfg, $volid);
+	    return recover_config_from_proxmox_backup($storage_cfg, $volid, $vmid);
 	}
     }
 
     my $archive = PVE::Storage::abs_filesystem_path($storage_cfg, $volid);
-    recover_config_from_tar($archive);
+    recover_config_from_tar($archive, $vmid);
 }
 
 sub recover_config_from_proxmox_backup {
-    my ($storage_cfg, $volid) = @_;
+    my ($storage_cfg, $volid, $vmid) = @_;
+
+    $vmid //= 0;
 
     my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
     my $scfg = PVE::Storage::storage_config($storage_cfg, $storeid);
@@ -208,7 +210,7 @@ sub recover_config_from_proxmox_backup {
     PVE::Storage::PBSPlugin::run_raw_client_cmd(
 	$scfg,  $storeid, $cmd, $param, outfunc => $outfunc);
 
-    my $conf = PVE::LXC::Config::parse_pct_config("/lxc/0.conf" , $raw);
+    my $conf = PVE::LXC::Config::parse_pct_config("/lxc/${vmid}.conf" , $raw);
 
     delete $conf->{snapshots};
 
@@ -222,15 +224,16 @@ sub recover_config_from_proxmox_backup {
 }
 
 sub recover_config_from_tar {
-    my ($archive) = @_;
+    my ($archive, $vmid) = @_;
 
     my ($raw, $conf_file) = PVE::Storage::extract_vzdump_config_tar($archive, qr!(\./etc/vzdump/(pct|vps)\.conf)$!);
     my $conf;
     my $mp_param = {};
+    $vmid //= 0;
 
     if ($conf_file =~ m/pct\.conf/) {
 
-	$conf = PVE::LXC::Config::parse_pct_config("/lxc/0.conf" , $raw);
+	$conf = PVE::LXC::Config::parse_pct_config("/lxc/${vmid}.conf" , $raw);
 
 	delete $conf->{snapshots};
 
@@ -273,7 +276,7 @@ sub restore_configuration_from_proxmox_backup {
     my ($vtype, $name, undef, undef, undef, undef, $format) =
 	PVE::Storage::parse_volname($storage_cfg, $archive);
 
-    my $oldconf = recover_config_from_proxmox_backup($storage_cfg, $archive);
+    my $oldconf = recover_config_from_proxmox_backup($storage_cfg, $archive, $vmid);
 
     sanitize_and_merge_config($conf, $oldconf, $restricted, $unique);
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH container 2/2] restore: add more informational messages
  2020-11-25 14:07 [pve-devel] [PATCH container 1/2] restore: pass target vmid to config recovery Fabian Grünbichler
@ 2020-11-25 14:07 ` Fabian Grünbichler
  2021-01-26 17:53   ` [pve-devel] applied: " Thomas Lamprecht
  2021-01-26 17:52 ` [pve-devel] applied: [PATCH container 1/2] restore: pass target vmid to config recovery Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Fabian Grünbichler @ 2020-11-25 14:07 UTC (permalink / raw)
  To: pve-devel

to provide context for warnings/output created by various sub-operations.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 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 a263104..824da40 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -354,6 +354,7 @@ __PACKAGE__->register_method({
 		    die "can't overwrite running container\n" if PVE::LXC::check_running($vmid);
 		    if ($is_root && $archive ne '-') {
 			my $orig_conf;
+			print "recovering backed-up configuration from '$archive'\n";
 			($orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($storage_cfg, $archive, $vmid);
 			$was_template = delete $orig_conf->{template};
 			# When we're root call 'restore_configuration' with restricted=0,
@@ -366,6 +367,7 @@ __PACKAGE__->register_method({
 		if ($storage_only_mode) {
 		    if ($restore) {
 			if (!defined($orig_mp_param)) {
+			    print "recovering backed-up configuration from '$archive'\n";
 			    (undef, $orig_mp_param) = PVE::LXC::Create::recover_config($storage_cfg, $archive, $vmid);
 			}
 			$mp_param = $orig_mp_param;
@@ -414,9 +416,12 @@ __PACKAGE__->register_method({
 		eval {
 		    my $rootdir = PVE::LXC::mount_all($vmid, $storage_cfg, $conf, 1);
 		    $bwlimit = PVE::Storage::get_bandwidth_limit('restore', [keys %used_storages], $bwlimit);
+		    print "restoring '$archive' now..\n"
+			if $restore && $archive ne '-';
 		    PVE::LXC::Create::restore_archive($storage_cfg, $archive, $rootdir, $conf, $ignore_unpack_errors, $bwlimit);
 
 		    if ($restore) {
+			print "merging backed-up and given configuration..\n";
 			PVE::LXC::Create::restore_configuration($vmid, $storage_cfg, $archive, $rootdir, $conf, !$is_root, $unique, $skip_fw_config_restore);
 			my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir);
 			$lxc_setup->template_fixup($conf);
-- 
2.20.1





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] applied: [PATCH container 1/2] restore: pass target vmid to config recovery
  2020-11-25 14:07 [pve-devel] [PATCH container 1/2] restore: pass target vmid to config recovery Fabian Grünbichler
  2020-11-25 14:07 ` [pve-devel] [PATCH container 2/2] restore: add more informational messages Fabian Grünbichler
@ 2021-01-26 17:52 ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2021-01-26 17:52 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Grünbichler

On 25.11.20 15:07, Fabian Grünbichler wrote:
> so that we get the correct warning prefix when the config contains bogus lines.
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
>  arc/PVE/API2/LXC.pm   |  4 ++--
>  src/PVE/LXC/Create.pm | 19 +++++++++++--------
>  2 files changed, 13 insertions(+), 10 deletions(-)
> 
>

applied, thanks!





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] applied: [PATCH container 2/2] restore: add more informational messages
  2020-11-25 14:07 ` [pve-devel] [PATCH container 2/2] restore: add more informational messages Fabian Grünbichler
@ 2021-01-26 17:53   ` Thomas Lamprecht
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2021-01-26 17:53 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Grünbichler

On 25.11.20 15:07, Fabian Grünbichler wrote:
> to provide context for warnings/output created by various sub-operations.
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
>  src/PVE/API2/LXC.pm | 5 +++++
>  1 file changed, 5 insertions(+)
> 
>

applied, thanks!





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-26 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 14:07 [pve-devel] [PATCH container 1/2] restore: pass target vmid to config recovery Fabian Grünbichler
2020-11-25 14:07 ` [pve-devel] [PATCH container 2/2] restore: add more informational messages Fabian Grünbichler
2021-01-26 17:53   ` [pve-devel] applied: " Thomas Lamprecht
2021-01-26 17:52 ` [pve-devel] applied: [PATCH container 1/2] restore: pass target vmid to config recovery Thomas Lamprecht

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