FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora/Linux Management Tools

 
 
LinkBack Thread Tools
 
Old 12-06-2007, 07:33 AM
Tatsuro Enokura
 
Default BZ#251643: Allow to set the cpu pinning for to create installing domain

Hi,

I want to set the cpu pinning for create installing domain by virt-install
on RHEL5.1.

So, I just add the option to virt-install.
We will be allowed to set "cpus" parameter in configuration file
and to set "cpuset" parameter in create installing domain with "cpuset" option
by this patch.

command-line example:
# virt-install --name=domain1 --ram=512 --file=/dev/sdb --cpuset=0,2-4 ...

some notes are follows:
- cpuset can only contain numeric, ',', or '-' characters.
- cpuset's pCPU numbers must be less than pCPUs.
- This is an effective feature for to create installing domain and
configuration file with libvirt revision >= 1.789.
- This is an effective feature for to create installing domain and
configuration file with xen hypervisor.
Other hypervisor(like kvm, qemu...) ignores this option.
- This feature covers cpupin on virt-install of BZ#251643.
It will work about other things(weight, cap, ...) in the future.

Signed-off-by: Tatsuro Enokura <fj7716hz@aa.jp.fujitsu.com>

Thanks,
Tatsuro Enokura

diff -r c98f26991bad virt-install
--- a/virt-install Wed Dec 05 15:34:29 2007 -0800
+++ b/virt-install Thu Dec 06 16:02:31 2007 +0900
@@ -205,6 +205,9 @@ def parse_args():
help=_("Number of vcpus to configure for your guest"))
parser.add_option("", "--check-cpu", action="store_true", dest="check_cpu",
help=_("Check that vcpus do not exceed physical CPUs and warn if they do."))
+ parser.add_option("", "--cpuset", type="string", dest="cpuset",
+ action="callback", callback=cli.check_before_store,
+ help=_("Set which physical CPUs Domain can use."))

# disk options
parser.add_option("-f", "--file", type="string",
@@ -409,6 +412,10 @@ def main():
cli.get_uuid(options.uuid, guest)
cli.get_vcpus(options.vcpus, options.check_cpu, guest, conn)

+ # set up cpuset
+ if type == "xen":
+ cli.get_cpuset(options.cpuset, guest)
+
# set up disks
get_disks(options.diskfile, options.disksize, options.sparse, options.nodisks,
guest, hvm, conn)
diff -r c98f26991bad virtinst/Guest.py
--- a/virtinst/Guest.py Wed Dec 05 15:34:29 2007 -0800
+++ b/virtinst/Guest.py Thu Dec 06 16:02:31 2007 +0900
@@ -497,6 +497,7 @@ class Guest(object):
self._memory = None
self._maxmemory = None
self._vcpus = None
+ self._cpuset = None
self._graphics = { "enabled": False }
self._keymap = None

@@ -598,6 +599,28 @@ class Guest(object):
self._vcpus = val
vcpus = property(get_vcpus, set_vcpus)

+ # set phy-cpus for the guest
+ def get_cpuset(self):
+ return self._cpuset
+ def set_cpuset(self, val):
+ if type(val) is not type("string") or len(val) == 0:
+ raise ValueError, _("cpuset must be string")
+ if re.match("^[0-9,-]*$", val) is None:
+ raise ValueError, _("cpuset can only contain numeric, ',', or '-' characters")
+
+ pcpus = util.get_phy_cpus(self.conn)
+ for c in val.split(','):
+ if c.find('-') != -1:
+ (x, y) = c.split('-')
+ if int(x) > int(y):
+ raise ValueError, _("cpuset contains invalid format.")
+ if int(x) >= pcpus or int(y) >= pcpus:
+ raise ValueError, _("cpuset's pCPU numbers must be less than pCPUs.")
+ else:
+ if int(c) >= pcpus:
+ raise ValueError, _("cpuset's pCPU numbers must be less than pCPUs.")
+ self._cpuset = val
+ cpuset = property(get_cpuset, set_cpuset)

# graphics setup
def get_graphics(self):
@@ -743,6 +766,11 @@ class Guest(object):
if not osblob:
return None

+ if self.cpuset is not None:
+ cpuset = " cpuset='" + self.cpuset + "'"
+ else:
+ cpuset = ""
+
return """<domain type='%(type)s'>
<name>%(name)s</name>
<currentMemory>%(ramkb)s</currentMemory>
@@ -752,7 +780,7 @@ class Guest(object):
<on_poweroff>destroy</on_poweroff>
<on_reboot>%(action)s</on_reboot>
<on_crash>%(action)s</on_crash>
- <vcpu>%(vcpus)d</vcpu>
+ <vcpu%(cpuset)s>%(vcpus)d</vcpu>
<devices>
%(devices)s
</devices>
@@ -760,6 +788,7 @@ class Guest(object):
""" % { "type": self.type,
"name": self.name,
"vcpus": self.vcpus,
+ "cpuset": cpuset,
"uuid": self.uuid,
"ramkb": self.memory * 1024,
"maxramkb": self.maxmemory * 1024,
diff -r c98f26991bad virtinst/cli.py
--- a/virtinst/cli.py Wed Dec 05 15:34:29 2007 -0800
+++ b/virtinst/cli.py Thu Dec 06 16:02:31 2007 +0900
@@ -148,6 +148,10 @@ def get_vcpus(vcpus, check_cpu, guest, c
guest.vcpus = vcpus
except ValueError, e:
print _("ERROR: "), e
+
+def get_cpuset(cpuset, guest):
+ if cpuset:
+ guest.cpuset = cpuset

def get_network(mac, network, guest):
if mac == "RANDOM":
diff -r c98f26991bad virtinst/util.py
--- a/virtinst/util.py Wed Dec 05 15:34:29 2007 -0800
+++ b/virtinst/util.py Thu Dec 06 16:02:31 2007 +0900
@@ -200,3 +200,9 @@ def get_max_vcpus(conn):
#print >> stderr, _("Couldn't determine max vcpus. Using 32.")
max = 32
return max
+
+def get_phy_cpus(conn):
+ """Get number of physical CPUs."""
+ hostinfo = conn.getInfo()
+ pcpus = hostinfo[4] * hostinfo[5] * hostinfo[6] * hostinfo[7]
+ return pcpus
_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 

Thread Tools




All times are GMT. The time now is 10:35 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org