mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
David Becker writes: This patch adds support for high memory to /proc/xen/memory_target, and it restores the mem= linux boot parameter. This is for 2.4.26 only. I haven't looked at 2.6 yet. (remmeber that CONFIG_HIGHMEM is not on by default in the xen0 and xenU configs) I have racks of 2g and 4g machines, hence my interest. The 'mem=' param tells linux the maximum amount of memory it can use. The feature originated for hosts where the normal mem detection mechanisms failed. These days its main use in stock linux is to artificially constrain how much memory linux uses for testing low memory systems. With this patch, mem= now means the max memory linux could ever use. When a domain is created with less than that the mem= value, linux will behave as though that 'missing' memory is 'allocated'. To give the domain more memory, first run setdomainmaxmem in Dom-0 to raise Xen's limit, then write the new total to /proc/xen/memory_target in the domain. When mem= is not explicitly set, it defaults to the boottime size of the domain. dom-0# xm create name=dom-1 memory=100 extra='-b mem=2g' dom-0# setdomainmaxmem 1 2g dom-1# echo 2g > /proc/xen/memory_target
35 lines
1.1 KiB
Perl
35 lines
1.1 KiB
Perl
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
require "sys/ioctl.ph";
|
|
|
|
sub SIZEOF_HYPERCALL () { 24; }
|
|
sub STRUCT_PRIVCMD_HYPERCALL () {"L P";}
|
|
sub IOCTL_PRIVCMD_HYPERCALL ()
|
|
{ &_IOC( &_IOC_NONE, ord('P'), 0, SIZEOF_HYPERCALL );}
|
|
sub __HYPERVISOR_dom0_op () {7;}
|
|
sub DOM0_INTERFACE_VERSION () {0xaaaa0010;}
|
|
sub DOM0_SETDOMAINMAXMEM () {28;}
|
|
sub STRUCT_DOM0_OP_PREFIX () {"L L";}
|
|
sub STRUCT_SETDOMAINMAXMEM () {STRUCT_DOM0_OP_PREFIX."L x4 L";}
|
|
sub XEN_PRIVCMD () {"/proc/xen/privcmd";}
|
|
|
|
sub setdomainmaxmem($$) {
|
|
my ($domain,$bytes) = @_;
|
|
my $msg = pack(STRUCT_SETDOMAINMAXMEM,DOM0_SETDOMAINMAXMEM,
|
|
DOM0_INTERFACE_VERSION, $domain, $bytes);
|
|
my $cmd = pack(STRUCT_PRIVCMD_HYPERCALL,__HYPERVISOR_dom0_op,$msg);
|
|
open(XEN,XEN_PRIVCMD) or die "$!\n";
|
|
ioctl(XEN, IOCTL_PRIVCMD_HYPERCALL, $cmd) or die "ioctl: $!";
|
|
close XEN;
|
|
}
|
|
|
|
my ($bytes,$suffix) = $ARGV[1] =~ m/(^\d+)([mMkKgG])/;
|
|
$bytes<<=10 if $suffix =~ m/[kK]/;
|
|
$bytes<<=20 if $suffix =~ m/[mM]/;
|
|
$bytes<<=30 if $suffix =~ m/[gG]/;
|
|
|
|
printf "set domain $ARGV[0] to $bytes\n";
|
|
setdomainmaxmem($ARGV[0],$bytes);
|
|
|