From: Michal Novotny <minovotn@redhat.com>
To: Ian Campbell <Ian.Campbell@eu.citrix.com>
Cc: "'xen-devel@lists.xensource.com'" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] Disallow setting maxmem to higher value than total physical memory size
Date: Wed, 01 Sep 2010 17:34:10 +0200 [thread overview]
Message-ID: <4C7E7272.20509@redhat.com> (raw)
In-Reply-To: <1283354425.12544.9514.camel@zakaz.uk.xensource.com>
[-- Attachment #1: Type: text/plain, Size: 1647 bytes --]
On 09/01/2010 05:20 PM, Ian Campbell wrote:
> On Wed, 2010-09-01 at 15:18 +0100, Michal Novotny wrote:
>
>
>> Oh, ok. It's not limited to dom0 nevertheless I don't see anything to be
>> causing anything bad in domU. Of course, I can limit this to dom0 but
>> for domU you can be having e.g. this:
>> 1)
>> dom0: total memory = 8192
>> domU: memory = 4096, maxmem = 8192 (xm mem-max domU 16384 fails)
>>
> It is useful, legal and valid to set e.g. maxmem = 12288 here, leaving
> memory = 4096. Your patch prevents that.
>
>
That's right. I'm just saying that there's a possibility that there will
be wrong data output from `xm list -l` command.
>> 2)
>> and when you migrate to host B:
>> dom0: total memory = 16384
>> domU: memory = 4096, maxmem = 8192
>>
> If maxmem = 12288 then it would be possible to balloon this guest up to
> 12288 on this system. With your patch it is no longer possible. Note
> that maxmem cannot change once the domU is booted so it needs to have
> been = 12288 at the time the guest was created on Host A.
>
>
That's correct.
>> Or should I just ignore the possibility domU maxmem could be set to
>> higher value than host machine could provide and should I limit my check
>> to dom0 only?
>>
> Yes!
>
> I haven't considered the applicability of this patch to dom0
> particularly deeply but it is wrong to enforce this constraint on domUs.
>
> Ian.
>
>
Ok, I'm attaching the patch now for review. Now it's working fine for
dom0 to limit just dom0.
What do you think about this?
Michal
--
Michal Novotny<minovotn@redhat.com>, RHCE
Virtualization Team (xen userspace), Red Hat
[-- Attachment #2: xen-disallow-setting-max-mem-higher-than-total-phys-mem.patch --]
[-- Type: text/x-patch, Size: 1316 bytes --]
diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
index 4360ce2..aabc30f 100644
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -152,6 +152,12 @@ def recreate(info, priv):
assert not info['dying']
+ # Validate domain maxmem value not to be higher than dom0 physical memory
+ if priv:
+ total_mem = int(xc.physinfo()['total_memory'])
+ if info['maxmem_kb'] > total_mem:
+ info['maxmem_kb'] = total_mem
+
xeninfo = XendConfig.XendConfig(dominfo = info)
xeninfo['is_control_domain'] = priv
xeninfo['is_a_template'] = False
@@ -1490,6 +1496,14 @@ class XendDomainInfo:
"""Set the maximum memory limit of this domain
@param limit: In MiB.
"""
+ # Get total memory and convert to MiB
+ if self.info['is_control_domain']:
+ total_mem = int(xc.physinfo()['total_memory'] / 1024)
+
+ if limit <= 0 or limit > total_mem:
+ raise XendError('Invalid memory size, only positive values '
+ 'up to %s MiB are valid' % total_mem)
+
log.debug("Setting memory maximum of domain %s (%s) to %d MiB.",
self.info['name_label'], str(self.domid), limit)
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2010-09-01 15:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-01 12:31 [PATCH] Disallow setting maxmem to higher value than total physical memory size Michal Novotny
2010-09-01 12:44 ` Ian Campbell
2010-09-01 13:01 ` Michal Novotny
2010-09-01 13:37 ` Ian Campbell
2010-09-01 14:18 ` Michal Novotny
2010-09-01 14:21 ` Michal Novotny
2010-09-01 14:26 ` Jan Beulich
2010-09-01 14:50 ` Michal Novotny
2010-09-01 15:00 ` Jan Beulich
2010-09-01 15:10 ` Michal Novotny
2010-09-01 15:14 ` Jan Beulich
2010-09-01 15:20 ` Ian Campbell
2010-09-01 15:34 ` Michal Novotny [this message]
2010-09-01 16:53 ` Jeremy Fitzhardinge
2010-09-01 17:56 ` Ian Campbell
2010-09-01 18:15 ` Jeremy Fitzhardinge
2010-09-01 18:53 ` Ian Campbell
2010-09-01 21:10 ` Jeremy Fitzhardinge
2010-09-02 5:43 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C7E7272.20509@redhat.com \
--to=minovotn@redhat.com \
--cc=Ian.Campbell@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.