diff --git a/packages/qemu-server/patches/pxcloud/001-add-microvm-pxcloud.patch b/packages/qemu-server/patches/pxcloud/001-add-microvm-pxcloud.patch index a2c2308..44cf6fb 100644 --- a/packages/qemu-server/patches/pxcloud/001-add-microvm-pxcloud.patch +++ b/packages/qemu-server/patches/pxcloud/001-add-microvm-pxcloud.patch @@ -6,8 +6,8 @@ index c52f00d2..36e3f65c 100644 'autostart' => 1, 'bios' => 1, 'description' => 1, -+ 'initrd' =>1, -+ 'kernel' =>1, ++ 'initrd' =>1, ++ 'kernel' =>1, 'keyboard' => 1, 'localtime' => 1, 'migrate_downtime' => 1, @@ -24,7 +24,7 @@ index c52f00d2..36e3f65c 100644 { subdir => 'rrddata' }, { subdir => 'monitor' }, { subdir => 'agent' }, -+ { subdir => 'showcmd'}, ++ { subdir => 'showcmd'}, { subdir => 'snapshot' }, { subdir => 'spiceproxy' }, { subdir => 'sendkey' }, @@ -317,7 +317,7 @@ index 687135cf..088aaee1 100644 + + if ($machine_type =~ /microvm/ && $arch ne 'x86_64'){ + die "microvm only support on x86_64!\n"; -+ } ++ } + if ($machine_type =~ /microvm/ && $arch eq 'x86_64'){ + push @$cmd, '-machine','microvm,pit=off,pic=off,rtc=off,x-option-roms=on'; + }else{ @@ -344,8 +344,8 @@ index 687135cf..088aaee1 100644 if !$params->{skiptemplate} && PVE::QemuConfig->is_template($conf); - + if ($conf->{noboot}){ -+ die "VM can't start when noboot flag is true\n"; -+ } ++ die "VM can't start when noboot flag is true\n"; ++ } my $has_suspended_lock = PVE::QemuConfig->has_lock($conf, 'suspended'); my $has_backup_lock = PVE::QemuConfig->has_lock($conf, 'backup'); @@ -371,7 +371,7 @@ index 98141516..6eb23f7c 100644 description => "The ID of a cluster wide mapping. Either this or the default-key 'host'" ." must be set.", + }, -+ ramfb => { ++ ramfb => { + type => 'boolean', + description => "Show mdev device's ramfb", + optional => 1, @@ -396,7 +396,7 @@ index 98141516..6eb23f7c 100644 for my $option (qw(vendor-id device-id sub-vendor-id sub-device-id)) { $devicestr .= ",x-pci-$option=$d->{$option}" if $d->{$option}; } -+ ++ + if ($vga->{type} eq 'mdev'){ + $devicestr .= ",display=on"; + if ($mdevtype eq "i915"){ @@ -408,3 +408,116 @@ index 98141516..6eb23f7c 100644 } +diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm +index 2046a7c5..563b6aba 100644 +--- a/PVE/QemuServer.pm ++++ b/PVE/QemuServer.pm +@@ -8982,6 +8982,11 @@ sub create_ifaces_ipams_ips { + } + } + ++sub generate_vm_uuid { ++ my ($vmid, $index) = @_; ++ return sprintf("%08d-0000-0000-0000-%012d", $index, $vmid); ++} ++ + sub delete_ifaces_ipams_ips { + my ($conf, $vmid) = @_; + +diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm +index a7bd853b..27863d83 100644 +--- a/PVE/API2/Qemu.pm ++++ b/PVE/API2/Qemu.pm +@@ -17,7 +17,7 @@ use PVE::CGroup; + use PVE::Cluster qw (cfs_read_file cfs_write_file);; + use PVE::RRD; + use PVE::SafeSyslog; +-use PVE::Tools qw(extract_param); ++use PVE::Tools qw(extract_param get_host_arch); + use PVE::Exception qw(raise raise_param_exc raise_perm_exc); + use PVE::Storage; + use PVE::JSONSchema qw(get_standard_option); +@@ -676,6 +677,8 @@ my $generaloptions = { + 'onboot' => 1, + 'ostype' => 1, + 'protection' => 1, ++ 'pxclouduuid' => 1, ++ 'pxcloulduser' => 1, + 'reboot' => 1, + 'startdate' => 1, + 'startup' => 1, +@@ -988,6 +991,16 @@ __PACKAGE__->register_method({ + type => 'string', format => 'pve-poolid', + description => "Add the VM to the specified pool.", + }, ++ pxcloulduser => { ++ optional => 1, ++ type => 'string', ++ description => "Set pxcloud-user to access this vm.", ++ }, ++ pxclouduuid =>{ ++ optional => 1, ++ type => 'string', ++ description => "Set pxclouduuid.", ++ }, + bwlimit => { + description => "Override I/O bandwidth limit (in KiB/s).", + optional => 1, +@@ -1227,6 +1240,14 @@ __PACKAGE__->register_method({ + $conf->{smbios1} = PVE::QemuServer::generate_smbios1_uuid(); + } + ++ if (!$conf->{pxclouduuid}) { ++ $conf->{pxclouduuid} = PVE::QemuServer::generate_uuid(); ++ } ++ ++ if (!$conf->{arch}) { ++ $conf->{arch} = get_host_arch(); ++ } ++ + if ((!defined($conf->{vmgenid}) || $conf->{vmgenid} eq '1') && $arch ne 'aarch64') { + $conf->{vmgenid} = PVE::QemuServer::generate_uuid(); + } +@@ -3937,6 +3958,9 @@ __PACKAGE__->register_method({ + $newconf->{vmgenid} = PVE::QemuServer::generate_uuid(); + } + ++ # auto generate a new uuid only if the option was set for template ++ $newconf->{pxclouduuid} = PVE::QemuServer::generate_uuid(); ++ + delete $newconf->{template}; + + if ($param->{name}) { +diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm +index b562f2ee..fe9c8241 100755 +--- a/PVE/CLI/qm.pm ++++ b/PVE/CLI/qm.pm +@@ -1121,11 +1121,13 @@ our $cmddef = { + my $vmlist = shift; + exit 0 if (!scalar(@$vmlist)); + +- printf "%10s %-20s %-10s %-10s %12s %-10s\n", +- qw(VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID); ++ printf "%10s %-20s %-40s %-12s %-10s %-10s %12s %-10s\n", ++ qw(VMID NAME PXCLOUDUUID ARCH STATUS MEM(MB) BOOTDISK(GB) PID); + + foreach my $rec (sort { $a->{vmid} <=> $b->{vmid} } @$vmlist) { +- printf "%10s %-20s %-10s %-10s %12.2f %-10s\n", $rec->{vmid}, $rec->{name}, ++ printf "%10s %-20s %-10s %-10s %12.2f %-10s\n", $rec->{vmid}, $rec->{name}, ++ $rec->{pxclouduuid}, ++ $rec->{arch}, + $rec->{qmpstatus} || $rec->{status}, + ($rec->{maxmem} || 0)/(1024*1024), + ($rec->{maxdisk} || 0)/(1024*1024*1024), +diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm +index ce5012e0..ef8bf035 100644 +--- a/PVE/QemuServer.pm ++++ b/PVE/QemuServer.pm +@@ -3108,6 +3108,7 @@ sub vmstatus { + $d->{cpus} = $conf->{vcpus} if $conf->{vcpus}; + + $d->{name} = $conf->{name} || "VM $vmid"; ++ $d->{pxclouduuid} = $conf->{pxclouduuid} || generate_vm_uuid($vmid,0); + $d->{maxmem} = get_current_memory($conf->{memory})*(1024*1024); + + if ($conf->{balloon}) {