ia64/xen-unstable

view tools/misc/setdomainmaxmem @ 2422:2274a0386cc9

bitkeeper revision 1.1159.69.5 (4138e882jA1YaR_OfTfNHe_uT4PDIg)

trivial
author iap10@labyrinth.cl.cam.ac.uk
date Fri Sep 03 21:56:18 2004 +0000 (2004-09-03)
parents 6c0df1212e95
children
line source
1 #!/usr/bin/env perl
3 use strict;
4 require "sys/ioctl.ph";
6 sub SIZEOF_HYPERCALL () { 24; }
7 sub STRUCT_PRIVCMD_HYPERCALL () {"L P";}
8 sub IOCTL_PRIVCMD_HYPERCALL ()
9 { &_IOC( &_IOC_NONE, ord('P'), 0, SIZEOF_HYPERCALL );}
10 sub __HYPERVISOR_dom0_op () {7;}
11 sub DOM0_INTERFACE_VERSION () {0xaaaa0010;}
12 sub DOM0_SETDOMAINMAXMEM () {28;}
13 sub STRUCT_DOM0_OP_PREFIX () {"L L";}
14 sub STRUCT_SETDOMAINMAXMEM () {STRUCT_DOM0_OP_PREFIX."L x4 L";}
15 sub XEN_PRIVCMD () {"/proc/xen/privcmd";}
17 sub setdomainmaxmem($$) {
18 my ($domain,$bytes) = @_;
19 my $msg = pack(STRUCT_SETDOMAINMAXMEM,DOM0_SETDOMAINMAXMEM,
20 DOM0_INTERFACE_VERSION, $domain, $bytes);
21 my $cmd = pack(STRUCT_PRIVCMD_HYPERCALL,__HYPERVISOR_dom0_op,$msg);
22 open(XEN,XEN_PRIVCMD) or die "$!\n";
23 ioctl(XEN, IOCTL_PRIVCMD_HYPERCALL, $cmd) or die "ioctl: $!";
24 close XEN;
25 }
27 my ($bytes,$suffix) = $ARGV[1] =~ m/(^\d+)([mMkKgG])/;
28 $bytes<<=10 if $suffix =~ m/[kK]/;
29 $bytes<<=20 if $suffix =~ m/[mM]/;
30 $bytes<<=30 if $suffix =~ m/[gG]/;
32 printf "set domain $ARGV[0] to $bytes\n";
33 setdomainmaxmem($ARGV[0],$bytes);