* [pve-devel] [PATCH qemu-server/pve-container/pve-docs 0/1] Add pre/post-clone hooks
@ 2022-09-23 9:55 Stefan Hanreich
2022-09-23 9:55 ` [pve-devel] [PATCH pve-container 1/1] Add CT hooks for pre/post-clone Stefan Hanreich
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Stefan Hanreich @ 2022-09-23 9:55 UTC (permalink / raw)
To: pve-devel
This patch adds pre/post-clone hooks when the when the user clones a CT/VM
from the Web UI / CLI. I have tested this with both VMs/CTs via Web UI and CLI.
Are there any other places where the hook should get triggered that I missed?
Clone is a bit special since it can either target the same node or a different
node. In the second case, we could also add additional events that fire on the
respective target machine (pre/post-clone-target). In this case the other events
should also be called (pre/post-clone-source) I think. Not sure if there is a
use case for this though. For now we only run the hooks on the source machine, I
think this should suffice. What do you think?
pve-container:
Stefan Hanreich (1):
Add CT hooks for pre/post-clone
src/PVE/API2/LXC.pm | 4 ++++
1 file changed, 4 insertions(+)
pve-docs:
Stefan Hanreich (1):
add pre/post-clone events to example hookscript
examples/guest-example-hookscript.pl | 12 ++++++++++++
1 file changed, 12 insertions(+)
qemu-server:
Stefan Hanreich (1):
Add VM hooks for pre/post-clone
PVE/API2/Qemu.pm | 4 ++++
1 file changed, 4 insertions(+)
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH pve-container 1/1] Add CT hooks for pre/post-clone
2022-09-23 9:55 [pve-devel] [PATCH qemu-server/pve-container/pve-docs 0/1] Add pre/post-clone hooks Stefan Hanreich
@ 2022-09-23 9:55 ` Stefan Hanreich
2022-09-23 9:55 ` [pve-devel] [PATCH pve-docs 1/1] add pre/post-clone events to example hookscript Stefan Hanreich
2022-09-23 9:55 ` [pve-devel] [PATCH qemu-server 1/1] Add VM hooks for pre/post-clone Stefan Hanreich
2 siblings, 0 replies; 5+ messages in thread
From: Stefan Hanreich @ 2022-09-23 9:55 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
src/PVE/API2/LXC.pm | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 589f96f..d6ebc08 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1609,6 +1609,8 @@ __PACKAGE__->register_method({
local $SIG{QUIT} =
local $SIG{HUP} = sub { die "interrupted by signal\n"; };
+ PVE::GuestHelpers::exec_hookscript($newconf, $newid, "pre-clone", 1);
+
PVE::Storage::activate_volumes($storecfg, $vollist, $snapname);
my $bwlimit = extract_param($param, 'bwlimit');
@@ -1690,6 +1692,8 @@ __PACKAGE__->register_method({
}
});
+ PVE::GuestHelpers::exec_hookscript($newconf, $newid, "post-clone");
+
return;
};
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH pve-docs 1/1] add pre/post-clone events to example hookscript
2022-09-23 9:55 [pve-devel] [PATCH qemu-server/pve-container/pve-docs 0/1] Add pre/post-clone hooks Stefan Hanreich
2022-09-23 9:55 ` [pve-devel] [PATCH pve-container 1/1] Add CT hooks for pre/post-clone Stefan Hanreich
@ 2022-09-23 9:55 ` Stefan Hanreich
2022-09-23 10:01 ` Stefan Hanreich
2022-09-23 9:55 ` [pve-devel] [PATCH qemu-server 1/1] Add VM hooks for pre/post-clone Stefan Hanreich
2 siblings, 1 reply; 5+ messages in thread
From: Stefan Hanreich @ 2022-09-23 9:55 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
examples/guest-example-hookscript.pl | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/examples/guest-example-hookscript.pl b/examples/guest-example-hookscript.pl
index adeed59..345b5d9 100755
--- a/examples/guest-example-hookscript.pl
+++ b/examples/guest-example-hookscript.pl
@@ -54,6 +54,18 @@ if ($phase eq 'pre-start') {
print "$vmid stopped. Doing cleanup.\n";
+} elsif ($phase eq 'pre-clone') {
+
+ # Phase 'pre-clone' will run on the source machine before cloning a VM/CT
+
+ print "$vmid will be cloned.\n";
+
+} elsif ($phase eq 'post-clone') {
+
+ # Phase 'post-clone' will run on the source machine before cloning a VM/CT
+
+ print "$vmid successfully cloned.\n";
+
} else {
die "got unknown phase '$phase'\n";
}
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pve-devel] [PATCH pve-docs 1/1] add pre/post-clone events to example hookscript
2022-09-23 9:55 ` [pve-devel] [PATCH pve-docs 1/1] add pre/post-clone events to example hookscript Stefan Hanreich
@ 2022-09-23 10:01 ` Stefan Hanreich
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Hanreich @ 2022-09-23 10:01 UTC (permalink / raw)
To: pve-devel
On 9/23/22 11:55, Stefan Hanreich wrote:
> Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
> ---
> examples/guest-example-hookscript.pl | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/examples/guest-example-hookscript.pl b/examples/guest-example-hookscript.pl
> index adeed59..345b5d9 100755
> --- a/examples/guest-example-hookscript.pl
> +++ b/examples/guest-example-hookscript.pl
> @@ -54,6 +54,18 @@ if ($phase eq 'pre-start') {
>
> print "$vmid stopped. Doing cleanup.\n";
>
> +} elsif ($phase eq 'pre-clone') {
> +
> + # Phase 'pre-clone' will run on the source machine before cloning a VM/CT
> +
> + print "$vmid will be cloned.\n";
> +
> +} elsif ($phase eq 'post-clone') {
> +
> + # Phase 'post-clone' will run on the source machine before cloning a VM/CT
> +
copy/paste error. I'll fix in v2 after a review?
> + print "$vmid successfully cloned.\n";
> +
> } else {
> die "got unknown phase '$phase'\n";
> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH qemu-server 1/1] Add VM hooks for pre/post-clone
2022-09-23 9:55 [pve-devel] [PATCH qemu-server/pve-container/pve-docs 0/1] Add pre/post-clone hooks Stefan Hanreich
2022-09-23 9:55 ` [pve-devel] [PATCH pve-container 1/1] Add CT hooks for pre/post-clone Stefan Hanreich
2022-09-23 9:55 ` [pve-devel] [PATCH pve-docs 1/1] add pre/post-clone events to example hookscript Stefan Hanreich
@ 2022-09-23 9:55 ` Stefan Hanreich
2 siblings, 0 replies; 5+ messages in thread
From: Stefan Hanreich @ 2022-09-23 9:55 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
PVE/API2/Qemu.pm | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 3ec31c2..23a7658 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -3417,6 +3417,8 @@ __PACKAGE__->register_method({
my ($conffile, $newconf, $oldconf, $vollist, $drives, $fullclone) = $load_and_check->();
my $storecfg = PVE::Storage::config();
+ PVE::GuestHelpers::exec_hookscript($newconf, $newid, "pre-clone", 1);
+
# auto generate a new uuid
my $smbios1 = PVE::QemuServer::parse_smbios1($newconf->{smbios1} || '');
$smbios1->{uuid} = PVE::QemuServer::generate_uuid();
@@ -3545,6 +3547,8 @@ __PACKAGE__->register_method({
die "clone failed: $err";
}
+ PVE::GuestHelpers::exec_hookscript($newconf, $newid, "post-clone");
+
return;
};
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-23 10:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 9:55 [pve-devel] [PATCH qemu-server/pve-container/pve-docs 0/1] Add pre/post-clone hooks Stefan Hanreich
2022-09-23 9:55 ` [pve-devel] [PATCH pve-container 1/1] Add CT hooks for pre/post-clone Stefan Hanreich
2022-09-23 9:55 ` [pve-devel] [PATCH pve-docs 1/1] add pre/post-clone events to example hookscript Stefan Hanreich
2022-09-23 10:01 ` Stefan Hanreich
2022-09-23 9:55 ` [pve-devel] [PATCH qemu-server 1/1] Add VM hooks for pre/post-clone Stefan Hanreich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox