[pve-devel] [PATCH] clone : generate a new uuid

Alexandre Derumier aderumier at odiso.com
Tue Aug 26 07:07:54 CEST 2014


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 165dc3d..d135bc4 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2279,6 +2279,22 @@ __PACKAGE__->register_method({
 		}
 	    }
 
+            # auto generate a new uuid
+            my ($uuid, $uuid_str);
+            UUID::generate($uuid);
+            UUID::unparse($uuid, $uuid_str);
+            if (!$newconf->{smbios1}) {
+		$newconf->{smbios1} = "uuid=$uuid_str";
+            }else{
+		my @new_smbios = ();
+       		foreach my $smbios_option (PVE::Tools::split_list($newconf->{smbios1})) {
+		    my ($param, $value) = split(/\=/, $smbios_option);
+		    $smbios_option = "uuid=$uuid_str" if $param eq 'uuid';
+		    push @new_smbios, $smbios_option;
+		}
+		$newconf->{smbios1} = join(",", @new_smbios);
+	    } 
+
 	    delete $newconf->{template};
 
 	    if ($param->{name}) {
-- 
1.7.10.4




More information about the pve-devel mailing list