From 95f0028cb470bcd1e583500da85edec4495ce3c5 Mon Sep 17 00:00:00 2001 From: jiangcuo Date: Sat, 18 Jan 2025 15:10:23 +0800 Subject: [PATCH] update --- packages/common.sh | 2 - .../pxcloud/001-add-microvm-pxcloud.patch | 296 +++++++----------- 2 files changed, 115 insertions(+), 183 deletions(-) diff --git a/packages/common.sh b/packages/common.sh index b694260..a6d40a4 100644 --- a/packages/common.sh +++ b/packages/common.sh @@ -6,7 +6,6 @@ copy_dir(){ exec_build_make(){ version=`dpkg-parsechangelog -Sversion` - debchange -v $version'+pxcloud' -D bookworm --force-distribution -U -M "Update $PKGNAME to $version'+pxcloud' " apt update yes |mk-build-deps --install --remove echo "clean " @@ -19,7 +18,6 @@ exec_build_make(){ } exec_build_dpkg(){ - debchange -v "$version"+pxcloud"" -D bookworm --force-distribution -U -M "Update $PKGNAME to "$version"+pxcloud"" " apt update yes |mk-build-deps --install --remove echo "clean " 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 4b42460..42cda0e 100644 --- a/packages/qemu-server/patches/pxcloud/001-add-microvm-pxcloud.patch +++ b/packages/qemu-server/patches/pxcloud/001-add-microvm-pxcloud.patch @@ -1,8 +1,8 @@ diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm -index c52f00d2..36e3f65c 100644 +index 42fbddca..2986b4a0 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm -@@ -666,6 +666,8 @@ my $generaloptions = { +@@ -679,6 +679,8 @@ my $generaloptions = { 'autostart' => 1, 'bios' => 1, 'description' => 1, @@ -11,16 +11,44 @@ index c52f00d2..36e3f65c 100644 'keyboard' => 1, 'localtime' => 1, 'migrate_downtime' => 1, -@@ -1237,7 +1239,7 @@ __PACKAGE__->register_method({ +@@ -688,6 +690,8 @@ my $generaloptions = { + 'ostype' => 1, + 'gicversion' =>1, + 'protection' => 1, ++ 'pxclouduuid' => 1, ++ 'pxcloulduser' => 1, + 'reboot' => 1, + 'startdate' => 1, + 'startup' => 1, +@@ -1000,6 +1004,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, +@@ -1236,6 +1250,10 @@ __PACKAGE__->register_method({ + $conf->{boot} = PVE::QemuServer::print_bootorder($devs); + } - my $machine_conf = PVE::QemuServer::Machine::parse_machine($conf->{machine}); - my $machine = $machine_conf->{type}; -- if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) { -+ if (!$machine || $machine =~ m/^(?:pc|q35|virt|microvm)$/) { - # always pin Windows' machine version on create, they get to easily confused - if (PVE::QemuServer::Helpers::windows_version($conf->{ostype})) { - $machine_conf->{type} = PVE::QemuServer::windows_get_pinned_machine_version($machine); -@@ -1374,6 +1376,7 @@ __PACKAGE__->register_method({ ++ if (!$conf->{pxclouduuid}) { ++ $conf->{pxclouduuid} = PVE::QemuServer::generate_uuid(); ++ } ++ + my $vga = PVE::QemuServer::parse_vga($conf->{vga}); + PVE::QemuServer::assert_clipboard_config($vga); + +@@ -1415,6 +1433,7 @@ __PACKAGE__->register_method({ { subdir => 'rrddata' }, { subdir => 'monitor' }, { subdir => 'agent' }, @@ -28,7 +56,17 @@ index c52f00d2..36e3f65c 100644 { subdir => 'snapshot' }, { subdir => 'spiceproxy' }, { subdir => 'sendkey' }, -@@ -6219,4 +6222,30 @@ __PACKAGE__->register_method({ +@@ -3985,6 +4004,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}) { +@@ -6311,4 +6333,30 @@ __PACKAGE__->register_method({ return { socket => $socket }; }}); @@ -60,29 +98,41 @@ index c52f00d2..36e3f65c 100644 + 1; diff --git a/PVE/API2/Qemu/Machine.pm b/PVE/API2/Qemu/Machine.pm -index db6c3d80..6a1ad84d 100644 +index 19896e3c..3329330a 100644 --- a/PVE/API2/Qemu/Machine.pm +++ b/PVE/API2/Qemu/Machine.pm @@ -38,7 +38,7 @@ __PACKAGE__->register_method({ }, type => { type => 'string', -- enum => ['q35', 'virt'], -+ enum => ['q35', 'virt','i440fx','microvm'], +- enum => ['q35', 'virt', 'i440fx'], ++ enum => ['q35', 'virt', 'i440fx', 'microvm'], description => "The machine type.", }, version => { -@@ -50,7 +50,7 @@ __PACKAGE__->register_method({ - }, - code => sub { - my $machines = eval { -- my $raw = file_get_contents('/usr/share/kvm/machine-versions-aarch64.json'); -+ my $raw = file_get_contents('/usr/share/kvm/machine-versions.json'); - return from_json($raw, { utf8 => 1 }); - }; - die "could not load supported machine versions - $@\n" if $@; +diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm +index 18ab3326..865e94fa 100755 +--- a/PVE/CLI/qm.pm ++++ b/PVE/CLI/qm.pm +@@ -1124,11 +1124,13 @@ our $cmddef = { + my $vmlist = shift; + exit 0 if (!scalar(@$vmlist)); + +- printf "%10s %-20s %-12s %-10s %-10s %12s %-10s\n", +- qw(VMID NAME ARCH 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 %-12s %-10s %-10s %12.2f %-10s\n", $rec->{vmid}, $rec->{name}, $rec->{arch}, ++ printf "%10s %-20s %-40s %-12s %-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 687135cf..088aaee1 100644 +index 63c961a5..2287b9aa 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -247,7 +247,7 @@ my $vga_fmt = { @@ -216,7 +266,7 @@ index 687135cf..088aaee1 100644 }, tdf => { optional => 1, -@@ -1751,11 +1866,18 @@ sub print_netdevice_full { +@@ -1766,11 +1881,18 @@ sub print_netdevice_full { my $device = $net->{model}; if ($net->{model} eq 'virtio') { @@ -236,7 +286,7 @@ index 687135cf..088aaee1 100644 if ($net->{queues} && $net->{queues} > 1 && $net->{model} eq 'virtio'){ # Consider we have N queues, the number of vectors needed is 2 * N + 2, i.e., one per in # and out of each queue plus one config interrupt and control vector queue -@@ -1854,6 +1976,7 @@ my $vga_map = { +@@ -1869,6 +1991,7 @@ my $vga_map = { 'virtio' => 'virtio-vga', 'virtio-gl' => 'virtio-gpu-gl', 'ramfb' => 'ramfb', @@ -244,16 +294,27 @@ index 687135cf..088aaee1 100644 }; sub print_vga_device { -@@ -3401,7 +3524,7 @@ sub get_vm_machine { +@@ -3010,7 +3133,9 @@ sub vmstatus { + $d->{disk} = 0; + $d->{maxdisk} = 0; + } +- ++ ++ $d->{pxclouduuid} = $conf->{pxclouduuid} || generate_vm_uuid($vmid,0); ++ + $d->{cpus} = ($conf->{sockets} || $defaults->{sockets}) + * ($conf->{cores} || $defaults->{cores}); + $d->{cpus} = $cpucount if $d->{cpus} > $cpucount; +@@ -3430,7 +3555,7 @@ sub get_vm_machine { my $machine_conf = PVE::QemuServer::Machine::parse_machine($conf->{machine}); my $machine = $forcemachine || $machine_conf->{type}; - if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) { + if (!$machine || $machine =~ m/^(?:pc|q35|virt|microvm)$/) { - $kvmversion //= kvm_user_version(); + my $kvmversion //= kvm_user_version(); # we must pin Windows VMs without a specific version to 5.1, as 5.2 fixed a bug in ACPI # layout which confuses windows quite a bit and may result in various regressions.. -@@ -3938,6 +4061,19 @@ sub config_to_command { +@@ -3960,6 +4085,19 @@ sub config_to_command { push @$cmd, '-no-reboot' if defined($conf->{reboot}) && $conf->{reboot} == 0; @@ -273,7 +334,7 @@ index 687135cf..088aaee1 100644 if ($vga->{type} && $vga->{type} !~ m/^serial\d+$/ && $vga->{type} ne 'none'){ if ($vga->{type} eq 'ramfb'){ push @$devices, '-device', 'ramfb'; -@@ -4001,7 +4137,11 @@ sub config_to_command { +@@ -4023,7 +4161,11 @@ sub config_to_command { if (!$guest_agent->{type} || $guest_agent->{type} eq 'virtio') { my $pciaddr = print_pci_addr("qga0", $bridges, $arch, $machine_type); @@ -286,7 +347,7 @@ index 687135cf..088aaee1 100644 push @$devices, '-device', 'virtserialport,chardev=qga0,name=org.qemu.guest_agent.0'; } elsif ($guest_agent->{type} eq 'isa') { push @$devices, '-device', "isa-serial,chardev=qga0"; -@@ -4084,6 +4224,11 @@ sub config_to_command { +@@ -4106,6 +4248,11 @@ sub config_to_command { if (!defined($conf->{balloon}) || $conf->{balloon}) { my $pciaddr = print_pci_addr("balloon0", $bridges, $arch, $machine_type); my $ballooncmd = "virtio-balloon-pci,id=balloon0$pciaddr"; @@ -298,7 +359,7 @@ index 687135cf..088aaee1 100644 $ballooncmd .= ",free-page-reporting=on" if min_version($machine_version, 6, 2); push @$devices, '-device', $ballooncmd; } -@@ -4247,7 +4392,9 @@ sub config_to_command { +@@ -4269,7 +4416,9 @@ sub config_to_command { if ($q35) { # add after -readconfig pve-q35.cfg splice @$devices, 2, 0, '-device', $devstr; } else { @@ -309,7 +370,7 @@ index 687135cf..088aaee1 100644 } } } -@@ -4287,7 +4434,15 @@ sub config_to_command { +@@ -4307,7 +4456,15 @@ sub config_to_command { push @$cmd, @$devices; push @$cmd, '-rtc', join(',', @$rtcFlags) if scalar(@$rtcFlags); @@ -326,7 +387,7 @@ index 687135cf..088aaee1 100644 push @$cmd, '-global', join(',', @$globalFlags) if scalar(@$globalFlags); if (my $vmstate = $conf->{vmstate}) { -@@ -4427,6 +4582,11 @@ sub vm_deviceplug { +@@ -4447,6 +4604,11 @@ sub vm_deviceplug { my $devicefull = "$scsihw_type,id=$deviceid$pciaddr"; @@ -338,7 +399,7 @@ index 687135cf..088aaee1 100644 if($deviceid =~ m/^virtioscsi(\d+)$/ && $device->{iothread}) { qemu_iothread_add($vmid, $deviceid, $device); $devicefull .= ",iothread=iothread-$deviceid"; -@@ -5776,7 +5936,9 @@ sub vm_start { +@@ -5796,7 +5958,9 @@ sub vm_start { die "you can't start a vm if it's a template\n" if !$params->{skiptemplate} && PVE::QemuConfig->is_template($conf); @@ -349,8 +410,20 @@ index 687135cf..088aaee1 100644 my $has_suspended_lock = PVE::QemuConfig->has_lock($conf, 'suspended'); my $has_backup_lock = PVE::QemuConfig->has_lock($conf, 'backup'); +@@ -9087,6 +9251,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/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm -index a3917dae..e2656c14 100644 +index a072ac29..b6a16362 100644 --- a/PVE/QemuServer/Machine.pm +++ b/PVE/QemuServer/Machine.pm @@ -18,7 +18,7 @@ my $machine_fmt = { @@ -363,22 +436,22 @@ index a3917dae..e2656c14 100644 format_description => 'machine type', optional => 1, diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm -index 98141516..6eb23f7c 100644 +index 15c18691..cac59455 100644 --- a/PVE/QemuServer/PCI.pm +++ b/PVE/QemuServer/PCI.pm -@@ -46,6 +46,12 @@ EODESCR - format => 'pve-configid', +@@ -47,6 +47,12 @@ EODESCR description => "The ID of a cluster wide mapping. Either this or the default-key 'host'" ." must be set.", -+ }, + }, + ramfb => { + type => 'boolean', + description => "Show mdev device's ramfb", + optional => 1, + default => 0, - }, ++ }, rombar => { type => 'boolean', + description => "Specify whether or not the device's ROM will be visible in the" @@ -853,6 +859,12 @@ sub print_hostpci_devices { my $mf_addr = $multifunction ? ".$j" : ''; $devicestr .= ",id=${id}${mf_addr}${pciaddr}${mf_addr}"; @@ -408,142 +481,3 @@ 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,8 @@ 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->{arch} = $conf->{arch} || get_host_arch(); - $d->{maxmem} = get_current_memory($conf->{memory})*(1024*1024); - - if ($conf->{balloon}) { -diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm -index b38c863f..e5a97d75 100644 ---- a/PVE/API2/Qemu.pm -+++ b/PVE/API2/Qemu.pm -@@ -663,6 +663,7 @@ my $hwtypeoptions = { - - my $generaloptions = { - 'agent' => 1, -+ 'arch' => 1, - 'autostart' => 1, - 'bios' => 1, - 'description' => 1, -diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm -index fe9c8241..a9fdd18e 100755 ---- a/PVE/CLI/qm.pm -+++ b/PVE/CLI/qm.pm -@@ -1125,7 +1125,7 @@ our $cmddef = { - 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 %-40s %-12s %-10s %-10s %12.2f %-10s\n", $rec->{vmid}, $rec->{name}, - $rec->{pxclouduuid}, - $rec->{arch}, - $rec->{qmpstatus} || $rec->{status},