[pve-devel] [PATCH] Make qm clone working with devices.
Jasmin J.
jasmin at anw.at
Sun Oct 26 11:04:40 CET 2014
Hi!
> Wouldn't this cause issues with multiple systems attempting to control the
> same device simultaneously?
Whenever you use software, you need to think. The same applies here.
It is possible to clone the VM manually by copying the conf file and the
referenced virtual disks. The advantage of doing it from within the PVE system
is, you can do it when the VM is running by the already provided features. I
tested this.
Like I wrote in the forum, the current implementation of the device support
seems to be added very quick and the missing clone feature was not intended, I
guess.
I intended to use cloning a VM with a device to make a copy of the current
state just before I do changes in the VM (e.g: update, install new software).
And yes, it might be a problem to start the cloned VM together with the
original, but this is logical and depends on the file system used on the disk
device.
With my patch cloning is still possible only from the command line, because the
WEB interface currently doesn't allow it for VMs with device disks.
BR,
Jasmin
***************************************************************************
On 2014-10-26 02:13, Daniel Hunsaker wrote:
> Wouldn't this cause issues with multiple systems attempting to control the same
> device simultaneously?
>
> On Oct 25, 2014 12:07 PM, "Jasmin Jessich" <jasmin at anw.at
> <mailto:jasmin at anw.at>> wrote:
>
> Signed-off-by: Jasmin Jessich <jasmin at anw.at <mailto:jasmin at anw.at>>
> ---
> PVE/API2/Qemu.pm | 5 ++++-
> PVE/QemuServer.pm | 8 ++++++++
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index a0fcd28..32ee6de 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -71,6 +71,7 @@ my $check_storage_access_clone = sub {
> my ($ds, $drive) = @_;
>
> my $isCDROM = PVE::QemuServer::drive_is_cdrom($drive);
> + my $isDEVICE = PVE::QemuServer::drive_is_device($drive);
>
> my $volid = $drive->{file};
>
> @@ -86,7 +87,7 @@ my $check_storage_access_clone = sub {
> $sharedvm = 0 if !$scfg->{shared};
>
> }
> - } else {
> + } elsif (!$isDEVICE) {
> my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
> my $scfg = PVE::Storage::storage_config($storecfg, $sid);
> $sharedvm = 0 if !$scfg->{shared};
> @@ -2260,6 +2261,8 @@ __PACKAGE__->register_method({
> die "unable to parse drive options for '$opt'\n" if
> !$drive;
> if (PVE::QemuServer::drive_is_cdrom($drive)) {
> $newconf->{$opt} = $value; # simply copy configuration
> + } elsif (PVE::QemuServer::drive_is_device($drive)) {
> + $newconf->{$opt} = $value; # simply copy configuration
> } else {
> if ($param->{full}) {
> die "Full clone feature is not available"
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 98264d1..49fbffa 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -1272,6 +1272,14 @@ sub drive_is_cdrom {
>
> }
>
> +sub drive_is_device {
> + my ($drive) = @_;
> +
> + my $volid = $drive->{file};
> +
> + return $volid && $volid =~ m/^\/dev\//;
> +}
> +
> sub parse_hostpci {
> my ($value) = @_;
>
> --
> 1.8.3.2
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com <mailto:pve-devel at pve.proxmox.com>
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
More information about the pve-devel
mailing list